• nmon本地监控


    Nmon本地监控

    nmon for Linux
    Nmon, 是 Nigel's Monitor 的缩写,是一个使用很普遍的开源工具,用以监控 Linux 系统的性能。
    例如:处理器的使用率、内存使用率、队列、磁盘I/O统计、网络I/O统计、内存页处理和进程信息。

    源码安装
    一.安装编译依赖库
    yum -y install gcc gcc-c++ ncurses-devel

    二.下载 lmon.c) & makefile

    三.硬链接lmon.c
    ln lmon15h.c lmon.c

    四.根据模板makefile针对发行版修改
    如:CentOS6.5 x64
    cp makefile{,.bak}
    cat >makefile <<HERE
    # NOTE: link the curent working copy of the code to lmon.c for compiling
    CFLAGS=-g -O3 -D JFS -D GETUSER -Wall -D LARGEMEM -lm
    # CFLAGS=-g -O2 -D JFS -D GEER -Wall -D POWER
    #CFLAGS=-g -D JFS -D GETUSER 
    LDFLAGS=-lncurses -g
    FILE=lmon.c
    nmon_x86_64_rhel65: $(FILE)
    gcc -o nmon_x86_64_rhel65 $(FILE) $(CFLAGS) $(LDFLAGS) -D X86 -D KERNEL_2_6_18
    HERE

    五.编译
    make
    执行完成后会生成二进制文件nmon_x86_64_rhel65


    二进制包
    下载对应平台最新的二进制包集合,解压后执行对应发行版的二进制文件即可(请确保有可执行权限)
    nmon本地监控

    语法
    nmon本地监控
    Hint: nmon_x86_64_rhel65 [-h] [-s ] [-c ] [-f -d -t -r ] [-x]

            -h            FULL help information
            Interactive-Mode:
            read startup banner and type: "h" once it is running
            For Data-Collect-Mode (-f)
            -f            spreadsheet output format [note: default -s300 -c288]
            optional
            -s  between refreshing the screen [default 2]
            -c   of refreshes [default millions]
            -d    to increase the number of disks [default 256]
            -t            spreadsheet includes top processes
            -x            capacity planning (15 min for 1 day = -fdt -s 900 -c 96)
    nmon本地监控
    CPU、内存、磁盘和网络的消耗情况

    生成nmon报告
    1.采集数据
    ./nmon_x86_64_rhel65 -s10 -c60 -f -m /root/
    -s10 每 10 秒采集一次数据。
    -c60 采集 60 次,即为采集十分钟的数据。
    -f 生成的数据文件名中包含文件创建的时间。
    -m 生成的数据文件的存放目录。
    这样就会生成一个 nmon 文件,并每十秒更新一次,直到十分钟后。
    生成的文件名如: db2_151015_1032.nmon ,db2是这台主机的主机名。

    2.生成报表
    工具一:nmon analyser
    zip文件解压后有一个带宏的excel和说明文档, 运行excel需要office 2007及以上版本且要启用宏,如果宏不能运行,需要做以下操作:
    工具 -> 宏 -> 安全性 -> 中,然后再打开文件并允许运行宏。
    nmon本地监控

    nmon本地监控

    将之前生成的 nmon 数据文件传到 Windows 机器上,用 Excel 打开分析工具 nmon analyser v33C.xls 。
    点击 Excel 文件中的 "Analyze nmon data" 按钮,选择 nmon 数据文件,这样就会生成一个分析后的结果文件: db2_151015_1032.nmon.xlsx ,用 Excel 打开生成的文件就可以看到结果了。
    nmon本地监控
    ln nmon2rrd_21.c nmon2rrd.c
    gcc nmon2rrd.c -o nmon2rrd
    语法
    nmon2rrd -f nmonfile [-d directory] [-x] [-n files] [-g] [-w width] [-h height]         Version:20a
     -f nmonfile    the regular CSV nmon output file
     -d directory   dirname for the output
     -w width       graph width  (default 800, max 1500)
     -h height      graph height (default 300)
     -x             execute the output files
     -n files       make the rrdtool database larger for this number of nmon files (effects the rrd_create file)
     -g             change the rrd_graph file to make it easier to change "--start 0000001111 --end 0000002222"
                    extract the actual start & end seconds: rrdtool first net.rrd ;  rrdtool last net.rrd
     -b             change rrd_graph script dates to YYYY/MM/DD
    Example:
     nmon2rrd -f m1_030811_1534.nmon -d /webpages/docs/m1/030811 -x 
      - or - 
     nmon2rrd -f my.nmon -d /home/nag/tmp42
     Manually complete with:
     cd /home/nag/tmp42
     rm -f *.rrd
     rm -f *.gif
     rrdtool - < rrd_create
     rrdtool - < rrd_update >rrd_update.log
     rrdtool - < rrd_top >rrd_top.log
     rrdtool - < rrd_graph
     then copy the *.gif and index.html files to your web server
    需要安装rrdtool
    yum -y install rrdtool
    生成rrdtool报表命令到web服务器的指定目录
    ./nmon2rrd -f db2_151015_1032.nmon -d /usr/local/nginx/html/ -x
    nmon本地监控

    nmon本地监控

    nmon本地监控


    3.自动按天采集数据
    在 crontab 中增加一条记录:
    0 0 * * * root /root/nmon_x86_64_rhel65 -s300 -c288 -f -m /root/ > /dev/null 2>&1
    300*288=86400 秒,正好是一天的数据。

    有兴趣的朋友还可以通过脚本定期更新
  • 相关阅读:
    训练20191009 2018-2019 ACM-ICPC, Asia East Continent Finals
    [学习笔记] 有上下界网络流
    [HDU4609] 3-idiots
    [HDU1402] A * B Problem Plus
    [HNOI2017] 礼物
    训练20191007 2017-2018 ACM-ICPC Latin American Regional Programming Contest
    [ZJOI2014] 力
    训练20191005 2017-2018 ACM-ICPC Asia East Continent League Final
    [一本通学习笔记] 树链剖分
    [一本通学习笔记] 快速幂
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814338.html
Copyright © 2020-2023  润新知