aix安装nmon

Posted slqt

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了aix安装nmon相关的知识,希望对你有一定的参考价值。

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()

version=platform.version().split(‘.‘)[0]
if ‘aix‘ not in platform.platform().lower() or version not in (‘4‘,‘5‘):
    print ‘目前只支持aix4和aix5系统的安装,该机器不在支持的系统范围内‘
    sys.exit(1)

if not os.path.exists(data_path):
    os.makedirs(data_path)

if not os.path.exists(pkg_path):
    os.makedirs(pkg_path)


def is_empty(path):
    files=os.listdir(path)
    for filee in files:
        f=str(path+filee)
        if os.path.isdir(f):
            if os.listdir(f):
                return False
    return True

if not os.path.exists(install_base):
    os.makedirs(install_base)
elif not is_empty(install_base):
    print ‘{}目录下已有文件,请确认!‘.format(install_base)
    sys.exit(1)

for i in pkg_file:
    code, res = run_cmd(‘tar -zxvf {} -C {}‘.format(i, pkg_path))
    if code:
        print ‘解压异常‘
        print res
        sys.exit(1)

arch=platform.uname()[2]
if version==‘4‘:
    file_name = ‘nmon_{}{}‘.format(version arch)
else:


install_path_tmp = os.path.join(pkg_path, file_name)
install_path = os.path.join(install_base, file_name)
shutil.move(install_path_tmp, install_path)
code, res = run_cmd(‘chown root:root {}‘.format(install_path))
if not code:
    print ‘已安装至{}‘.format(install_path)
else:
    print res
    sys.exit(1)

cronfile = ‘/var/spool/cron/root‘
n = set([‘0 0 * * * {} -fT -m {} -s {} -c {}‘.format(install_path, data_path, save_day, count),
     ‘0 0 * * * find {0} -mtime +{1} -name "*.nmon" -exec rm -rf {{}} ;‘.format(data_path,
                                                                                   gap_time)])

with open(cronfile, ‘r‘) as f:
    content = f.readlines()
content=set([i.strip() for i in content])
n=n-content

if n:
    n=[ i+‘
‘ for i in n ]
    with open(cronfile, ‘a‘) as f:
        f.writelines(n)

print ‘安装并配置成功‘

  

以上是关于aix安装nmon的主要内容,如果未能解决你的问题,请参考以下文章

一款免费监控aix与Linux的软件--nmon

安装nmon监控步骤---学习笔记

linux性能监控工具-nmon安装使用详细教程

linux性能监控工具-nmon安装使用详细教程

nmon部署安装 cacti图表自动导出

性能测试监控工具nmon安装及使用方法