加载中…
个人资料
李军
李军
  • 博客等级:
  • 博客积分:0
  • 博客访问:126,441
  • 关注人气:12
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
相关博文
推荐博文
谁看过这篇博文
加载中…
正文 字体大小:

nagios插件脚本check_linux_stats

(2013-01-22 17:51:48)
标签:

杂谈

分类: Cacti_Nagios_Zabbix

from:http://www.gaizaoren.org/archives/536  如有版权请告知,谢谢!

check_linux_stats插件用于监控linux系统性能(cpu, mem, load, disk usage, disk io, network usage, open files and processes).

需要安装Sys::Statistics::Linux(是perl插件)
nagios插件地址:http://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_linux_stats/details

下载check_linux_stats.pl插件,放置nagios的插件目录,给予执行权限。
perl插件安装:
wget -c http://search.cpan.org/CPAN/authors/id/B/BL/BLOONIX/Sys-Statistics-Linux-0.66.tar.gz

 

tar zxf Sys-Statistics-Linux-0.66.tar.gz

perl Makefile
yum install perl-UNIVERSAL-require.noarch

make && make install

定义nagios命令

define command{

command_name   linux_cpu_stats

command_line   $USER1$/check_linux_stats.pl -C -w 100 -s 5

}

define command{

command_name   linux_load_stats

command_line   $USER1$/check_linux_stats.pl -L -w 10,8,5 -c 20,18,15

}

define command{

command_name   linux_mem_stats

command_line   $USER1$/check_linux_stats.pl -M -w 99,50 -c 100,50

}

define command{

command_name   linux_disk_stats

command_line   $USER1$/check_linux_stats.pl -D -w 10 -c 5 -p / -u GB

}

define command{

command_name   linux_disk_IO_stats

command_line   $USER1$/check_linux_stats.pl -I -w 100,70 -c 150,100 -p sda1

}

define command{

command_name   linux_network_stats

command_line   $USER1$/check_linux_stats.pl -N -w 30000 -c 45000 -p eth0

}

define command{

command_name   linux_openfiles_stats

command_line   $USER1$/check_linux_stats.pl -F -w 10000,150000 -c 15000,250000

}

define command{

command_name   linux_sockets_stats

command_line   $USER1$/check_linux_stats.pl -S -w 1000 -c 2000

}

define command{

command_name   linux_process_stats

command_line   $USER1$/check_linux_stats.pl -P -w 2000 -c 3000

}

定义nagios主机服务

define service{

use                             local-service

host_name                       local

service_description             linux disk stats

check_command                   linux_disk_stats

}

define service{

use                             local-service

host_name                       local

service_description             linux Processes stats

check_command                   linux_process_stats

}

define service{

use                             local-service

host_name                       local

service_description             linux Load stats

check_command                   linux_load_stats

}

define service{

use                             local-service

host_name                       local

service_description             linux mem stats

check_command                   linux_mem_stats

notifications_enabled           1

}

define service{

use                             local-service

host_name                       local

service_description             linux cpu stats

check_command                   linux_cpu_stats

notifications_enabled           1

}

define service{

use                             local-service

host_name                       local

service_description             linux socket stats

check_command                   linux_sockets_stats

notifications_enabled           1

}

define service{

use                             local-service

host_name                       local

service_description             linux disk_io stats

check_command                   linux_disk_IO_stats

notifications_enabled           1

}

define service{

use                             local-service

host_name                       local

service_description             linux network stats

check_command                   linux_network_stats

notifications_enabled           1

}

define service{

use                             local-service

host_name                       local

service_description             linux openfiles stats

check_command                   linux_openfiles_stats

notifications_enabled           1

}

[root@localhost objects]# ../../libexec/check_linux_stats.pl -h

check_linux_stats v1.1

Usage: ../../libexec/check_linux_stats.pl -H <host> [-C|-P|-M|-N|-D|-I|-L|-F|-S] [-P  ] -w -c [-s] [-h] [-V]

-h, --help

print this help message

-C, --cpu

check cpu usage

-P, --proc

check the processes number

-M, --memory

check memory usage (memory used, swap used and memory cached)

-N, --network=NETWORK USAGE

check network usage in resq or bytes (default bytes)

-D, --disk=DISK USAGE

check disk usage

-I, --io=DISK IO USAGE

check disk I/O (r/w on /dev/sd*)

-L, --load=LOAD AVERAGE

check load average

-F, --file=FILE STATS

check open files (file alloc, inode alloc)

-S, --socket=SOCKET STATS

socket usage (tcp, udp, raw)

-p, --pattern

eth0,eth1...sda1,sda2.../usr,/tmp

-w, --warning

warning thresold

-c, --critical

critical thresold

-s, --sleep

default 1 sec.

-u, --unit

%, KB, MB or GB left on disk usage, default : MB

REQS OR BYTES on disk io statistics, default : REQS

-V, --version

version number

ex :

* Cpu usage     :

./check_linux_stats.pl -C -w 90 -c 100 -s 5

CPU OK : idle 99.80% | USER1=0.00% system=0.20% iowait=0.00% idle=99.80%;90;100

* Load average  :

./check_linux_stats.pl -L -w 10,8,5 -c 20,18,15

LOAD AVERAGE OK : 0.20,0.07,0.16 | load1=0.20;10;20;0 load5=0.07;8;18;0 load15=0.16;5;15;0

* Memory usage  :

./check_linux_stats.pl -M -w 99,50 -c 100,50

MEMORY OK : used 94.52% |MemUsed=94.52%;99;100 SwapUsed=0.01;50;50 MemCached=39.66

* Disk usage    :

./check_linux_stats.pl -D -w 10 -c 5 -p /,/usr,/tmp,/var

DISK WARNING used :  / 3331.80MB on 3875.09MB (8.86% free) /usr 10084.27MB on 14528.41MB (25.43% free)| /=3331.80MB /usr=10084.27MB

* Disk I/O :

./check_linux_stats.pl -I -w 100,70 -c 150,100 -p sda1,sda2,sda4

DISK I/O OK | sda2_read=0.00;100;150 sda2_write=0.00;70;100 sda4_read=0.00;100;150 sda4_write=0.00;70;100 sda1_read=0.00;100;150 sda1_write=0.00;70;100

* Network usage :

./check_linux_stats.pl -N -w 30000 -c 45000 -p eth0

NET USAGE OK eth0:8021.78KB  | eth0_txbyt=3461.39KB eth0_txerrs=0.00KB eth0_rxbyt=4560.40KB eth0_rxerrs=0.00KB

* Open files    :

./check_linux_stats.pl -F -w 10000,150000 -c 15000,250000

OPEN FILES OK allocated: 1728 (inodes: 70390) | fhalloc=1728;10000;15000;411810 inalloc=70390;150000;250000;100250 dentries=50754

* Socket usage  :

./check_linux_stats.pl -S -w 1000 -c 2000

SOCKET USAGE  OK : used 257 |used=257;1000;2000 tcp=18 udp=5 raw=0

* Number of procs       :

./check_linux_stats.pl -P -w 1000 -c 2000

PROCS OK : count 272 |count=272;1000;2000 runqueue=2 blocked=0 running=2 new=0.98

* Process mem & cpu     :

./check_linux_stats.pl -T -w 9551820 -c 9551890 -p /var/run/jonas.pid

PROCESSES OK  | java_vsize=1804918784;2000000000;3000000000 java_nswap=0 java_cnswap=0 java_cpu=0

/usr/local/nagios/libexec/check_linux_stats.pl -C -w 90 -c 100 -s 5

/usr/local/nagios/libexec/check_linux_stats.pl -L -w 10,8,5 -c 20,18,15

/usr/local/nagios/libexec/check_linux_stats.pl -M -w 99,50 -c 100,50

/usr/local/nagios/libexec/check_linux_stats.pl -D -w 10 -c 5 -p /,/usr,/tmp,/var

/usr/local/nagios/libexec/check_linux_stats.pl -I -w 100,70 -c 150,100 -p sda1,sda2,sda4

/usr/local/nagios/libexec/check_linux_stats.pl -N -w 30000 -c 45000 -p eth0

/usr/local/nagios/libexec/check_linux_stats.pl -F -w 10000,150000 -c 15000,250000

/usr/local/nagios/libexec/check_linux_stats.pl -S -w 1000 -c 2000

/usr/local/nagios/libexec/check_linux_stats.pl -P -w 1000 -c 2000

/usr/local/nagios/libexec/check_linux_stats.pl -T -w 9551820 -c 9551890 -p /var/run/jonas.pid

0

阅读 评论 收藏 禁止转载 喜欢 打印举报/Report
  • 评论加载中,请稍候...
发评论

    发评论

    以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

      

    新浪BLOG意见反馈留言板 电话:4000520066 提示音后按1键(按当地市话标准计费) 欢迎批评指正

    新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 会员注册 | 产品答疑

    新浪公司 版权所有