aix5310以上都系统自带了nmon,其他低版本需要手动安装

软件包下载地址https://www.ibm.com/developerworks/community/wikis/home?lang=en#/wiki/Power%20Systems/page/nmon

安装脚本如下

import os
from subprocess import Popen, PIPE, STDOUT
import sys
import platform
import shutil def run_cmd(cmd, cwd=None, env=None, run_as=None):
if not sys.platform.startswith('win') and run_as and run_as != 'root':
cmd = 'su - {} -c "{}"'.format(run_as, cmd)
p = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, stdin=PIPE, cwd=cwd, env=env)
stdout, _ = p.communicate()
return p.returncode, stdout.strip() if 'aix' not in platform.platform().lower():
print '只支持aix系统的安装,该机器不是aix系统'
sys.exit(1) cmd = 'oslevel -r'
version_list={'5':5309,'6':6102,'7':7000}
code, res = run_cmd(cmd)
if not code and res:
key=res[0].strip()
value=res.split('-')[1].strip()
if version_list.get(key) and int(key+res[1].strip()+value)>=version_list.get(key):
print '当前版本是',res
else:
print '当前版本是',res,'该操作只支持5309+,6102+,7100+的版本'
sys.exit(1)
else:
print '获取版本失败'
sys.exit(1) cmd = 'ps -ef |grep nmon|grep -v grep'
code, res = run_cmd(cmd)
if res:
print '已有nmon在运行'
sys.exit(1) cmd = 'which nmon'
code, res = run_cmd(cmd)
if code:
print '该系统未安装nmon'
sys.exit(1) if not os.path.exists(data_path):
os.makedirs(data_path) def is_empty(path):
for root, dirs, files in os.walk(path):
if len(files) != 0:
return False
return True cronfile = '/var/spool/cron/crontabs/root'
run_cmd('cp {0} /tmp/crontab_root.`date +%F_%T`'.format(cronfile)) content = '0 0 * * * nmon -fT -m {0} -s {1} -c {2}\n' \
'0 0 * * * find {1} -mtime +{3} -name "*.nmon" -exec rm -rf {{}} \;\n'.format(data_path, save_day, count,gap_time) has_content=False
if not os.path.exists(cronfile):
with open(cronfile, 'w') as f:
f.writelines(['### for nmon install ###\n',content,'### for nmon install ###\n'])
else:
real_content=[]
with open(cronfile, 'r') as f:
raw_content = f.readlines() flag=0
for i in raw_content:
flag = flag % 2
if '### for nmon install ###' in i.strip():
flag += 1
if flag==0:
real_content.append(i) with open(cronfile, 'w') as f:
f.writelines(real_content)
with open(cronfile, 'a') as f:
f.writelines(['### for nmon install ###\n',content,'### for nmon install ###\n']) print '安装并配置成功'

  

aix安装nmon的更多相关文章

  1. AIX安装恢复oracle问题-内存不足

    AIX安装恢复oracle问题-----------------------2013/10/19 oracle 安装后后,进行rman恢复数据库时,启动不了dummy实例,报内存不足   RMAN&g ...

  2. 手把手教你安装nmon

    一.nmon简介 nmon是由IBM 提供.免费监控 AIX 系统与 Linux 系统资源的工具.该工具可帮助在一个屏幕上显示服务器系统资源耗用情况,并动态地对其进行更新.此外,他还可以利用 exce ...

  3. 现场故障案例:AIX安装Oracle10G runInstaller弹出错误一例

    AIX安装Oracle10G runInstallert弹出错误一例 环境: 系统:AIX5300-08 数据库:Oracle 10g(64bit) AIX客户机卸载oracle软件后,又一次安装or ...

  4. HDLM for AIX安装

    HDLM for AIX安装 1)    安装ODM补丁包 补丁包在软件介质光盘的\HDLM_AIX\AIX_ODM\HTC_ODM下面:HTCODM3.tar 解压:#tar -xvf HCODM3 ...

  5. centos7下安装nmon后,无法运行,提示 cannot execute binary file或/lib64/ld64.so.1不存在

    在centos 7.1上安装nmon后,从管网(http://nmon.sourceforge.net/pmwiki.php?n=Site.Download)下载tar包解压后,两台机器一台提示 ca ...

  6. AIX安装单实例11gR2 GRID+DB

    AIX安装单实例11gR2 GRID+DB   一.1  BLOG文档结构图       一.2  前言部分   一.2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以 ...

  7. CentOS6.4 安装nmon

    安装 mkdir /usr/local/nmon cd /usr/local/nmon wget http://sourceforge.net/projects/nmon/files/nmon_lin ...

  8. 分享一下 aix安装python提示C编译器问题的办法

    今天在AIX上面安装Python-2.7.2时失败,报下面的错误 checking for --enable-universalsdk... no checking for --with-univer ...

  9. aix 安装redis

    下载最新rpm安装包 http://www.perzl.org/aix/index.php?n=Main.Redis # uname -aAIX rhjf 1 6 00C5CC964C00# pwd/ ...

随机推荐

  1. 【XShell】xshell评估过期解决办法

    1.登录网景官网的下载页面: 官网:https://www.netsarang.com/download/down_form.html?code=522 2.填写基本信息 licensetype 必须 ...

  2. Spring Boot笔记一 输出hello

    开始学习Spring Boot了,本篇文章你可以学到 1.Spring Boot的基本配置,输出一句hello 许嵩 2.Spring boot打包成jar包 一.Spring boot的基本配置 这 ...

  3. ssh-keygen Linux 免密登录

    一.选择算法和密钥大小 rsa - 基于分解大数的难度的旧算法.RSA建议密钥大小至少为2048位,4096位更好.RSA正在变老,并且在保理方面取得了重大进展.可能建议选择不同的算法.在可预见的将来 ...

  4. linux环境下遇到的所有问题

    启动redis # 进去到src目录下,指定配置文件启动 ./redis-server ../redis.conf 设置外网访问 更改redis.conf 文件 bind 127.0.0.1 prot ...

  5. springMVC的全局拦截器

    先说说为什么要使用springMVC的全局拦截器,比如 当我们在访问接口的时候,我们一般都会先判断这个用户是否登陆,我们就要在每个接口的前面都要判断一下,想想是不是很蛋疼,那工作量... 这时候,我们 ...

  6. java生产环境增量发版陷阱【原】

    前言 在生产环境,我们为了降低发版风险,一般都只做增量发布,不做全量发布. 除非项目只有一到两人开发,对时间线和代码脉络结构一清二楚,才可全量发布. 然而增量发布也是有一定隐藏陷阱在里面的,以下就是笔 ...

  7. eclipse配置文件乱码

    修改文件打开工具 安装文件编辑器插件 然后搜索

  8. 他山之石--机器学习 step by step

    练习使用的数据 diabetes.csv 备用百度网盘地址 输入变量与输出变量均为连续变量的预测问题是回归问题: 输出变量为有限个离散变量的预测问题成为分类问题: 其实回归问题和分类问题的本质一样,都 ...

  9. 搭建idea下的vue工程

    需要先安装好nodejs和npm 输入下面的命令查看是否成功安装 node -v npm -v 一.开始 工作目录:IdeaProjects使用idea新建Static Web项目:demo 在dem ...

  10. JS数据结构库

    lodash https://lodash.com/docs#now https://lodash.com/ A modern JavaScript utility library deliverin ...