Nagios监控linux_stat

check_linux-stats.pl监控linux的CPU,DISK,MEMORY,LOAD,NETWORK,IO,PROC,FILE,SOCKET,UPTIME

需要安装perl模块Sys::Statistics::Linux

perl –MCPAN –e shell进入安装即可

http://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_linux_stats/details

define nrpe.cfg

# Check disk usage on /, /home, /var
command[check_disk]=/usr/local/nagios/libexec/check_linux_stats.pl -D -w 10 -c 5 -p /,/home,/var -u %
# Check load average
command[check_load]=/usr/local/nagios/libexec/check_linux_stats.pl -L -w 10,8,5 -c 20,18,15
# Check memory & swap usage
command[check_mem]=/usr/local/nagios/libexec/check_linux_stats.pl -M -w 100,25 -c 100,50
# Check cpu usage
command[check_cpu]=/usr/local/nagios/libexec/check_linux_stats.pl -C -w 99 -c 100 -s 5
# Check open files
command[check_open_file]=/usr/local/nagios/libexec/check_linux_stats.pl -F -w 10000,250000 -c 15000,350000
# Check io disk on device sda1, sda3 and sda4
command[check_io]=/usr/local/nagios/libexec/check_linux_stats.pl -I -w 2000,600 -c 3000,800 -p sda1,sda3,sda4 -s 5
# Check processes
command[check_procs]=/usr/local/nagios/libexec/check_linux_stats.pl -P -w 1000 -c 2000
# Check network usage on eth0
command[check_net]=/usr/local/nagios/libexec/check_linux_stats.pl -N -w 1000000 -c 1500000 -p eth0 -s 5
# Check socket usage
command[check_socket]=/usr/local/nagios/libexec/check_linux_stats.pl -S -w 500 -c 1000
# Check uptime
command[check_uptime]=/usr/local/nagios/libexec/check_linux_stats.pl -U -w 5

Usage :
-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)
-W, –paging=PAGING AND SWAPPING STATS
-U, –uptime
-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% | user=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 : Mem used=92.57%, Swap used=0.01% |MemUsed=92.57%;95;99 SwapUsed=0.01;50;50 MemCached=12.62 SwapCached=0.00 Active=12.61
* 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 2000000000 -c 3000000000 -p /var/run/jonas.pid
PROCESSES OK | java_vsize=1804918784;2000000000;3000000000 java_nswap=0 java_cnswap=0 java_cpu=0
* Paging statistics :
./check_linux_stats.pl -W -w 50000,1000 -c 60000,2000 -s 3
Paging OK : In:11553.33, Out:452.00 | pgpgin=11553.33;50000;60000;0 pgpgout=452.00;1000;2000;0 pswpin=0.00 pswpout=0.00
* Uptime :
./check_linux_stats.pl -U -w 9
WARNING : up 0 days, 00:08:16 |uptime=496.05

此条目发表在Nagios分类目录。将固定链接加入收藏夹。