Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_linux_stats Featured

Rating
79 votes
Favoured:
19
Current Version
1.5
Last Release Date
2015-11-27
Compatible With
  • Nagios 2.x
  • Nagios 3.x
  • Nagios 4.x
  • Nagios XI
Owner
License
GPL
Hits
468930
Files:
FileDescription
check_linux_stats.plcheck_linux_stats
nrpe.cfg.samplenrpe.cfg.sample
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
check_linux_stats
Plugin to check linux system performance (cpu, mem, load, disk usage, disk io, network usage, open files and processes).
A perl plugin using Sys::Statistics::Linux


Thanks to Jonny Schulz, the author of Sys::Statistics::Linux, for his great work (http://search.cpan.org/~bloonix/) !

v1.2 Changelog :
- Add Paging statistics
- Add swapused and active memory on perfparse statistics
- Remove unused -H option (mthuijs)
v1.3 Changelog :
- Add uptime check, warning threshold in minutes (csterley)
- Replace /usr/local/nagios/libexec with FindBin (eulen)
- Fix reports network traffic in bytes (dbsanders)
v1.4 Changelog :
- Illegal division by zero (helium_rday, RedFish)
- Get the cache out of the used memory (waterdeep, dbsanders)
- Removed unused $return_str on check io disk (RedFish)
- Add steal cpu statistics
v1.5 Changelog :
- Add paging statistics to check for major faults (kevin@candidsource.com)
- bug, when using unit=MB for disk usage, the perf data writtens only KB (john12)
- Bug, multiple pipe on IO perfcournter (ledistordu)
- Add CPU context switch statistics
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
-X, --ctxt=CPU CONTEXT SWITCH
check CPU context switch
-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 10,1000,1 -c 20,2000,20 -s 3
Paging OK : in:0.00,out:0.00,flt:0.00 |pgpgin=0.00;10;20;0 pgpgout=0.00;1000;2000;0 pgmajfault=0.00;1;20;0 pswpin=0.00 pswpout=0.00

* Cpu context switch :
./check_linux_stats.pl -X -w 6000 -c 70000 -s 2
CONTEXT SWITCH OK : context 80|ctxt=80

* Uptime :
./check_linux_stats.pl -U -w 9
WARNING : up 0 days, 00:08:16 |uptime=496.05

Reviews (49)
bynagiostester, October 14, 2012
1 of 1 people found this review helpful
I have this error NRPE: Command 'check_cpu_usage' not defined. It is the same for all other commands.
This command works on my remote server which i want to monitor . /usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
However running /usr/local/nagios/libexec/check_nrpe -H localhost -c /usr/local/nagios/libexec/check_linux_stats.pl -M
does not work. it says that the plugin requires that i have NRPE daemon running on the remote host. My remote host does have NRPE daemon running. Furthermore, adding the command into nrpe.cfg and adding it into the service gives me NRPE: Command "check_memory_usage"not defined.
sorry for bad english
Hey! I just coded a 3 bash scripts ignoring this great great plugin!

I got some comments that may interest you or the community:

RedHat installation without a direct CPAN access:
##################################################
#Get and scp the files:
wget http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/Test-Simple-0.98.tar.gz
wget http://search.cpan.org/CPAN/authors/id/B/BL/BLOONIX/Sys-Statistics-Linux-0.66.tar.gz


# On the host get makemaker:
yum install perl-ExtUtils-MakeMaker.ppc64 -y
# Install the required modules:
tar xzf Test-Simple-0.98.tar.gz
cd Test-Simple-0.98
perl Makefile.PL
make
make test
make install
cd ..
tar xzf Sys-Statistics-Linux-0.66.tar.gz
cd Sys-Statistics-Linux-0.66
perl Makefile.PL
make
make test
make install
# You got it!
##################################################

Second, memory usage is reporting used as used+cached, so it could be misleading, I'll modify for my environment IDK if you would like to patch your code.

THANK YOU for sharing your amazing piece of work!
bySushilR, August 8, 2012
Hi,

Please let me know what is means..

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

Please reply to me on sushil.rangari@gmail.com
Owner's reply

Hi,

This format is the same as the default format that is used by the command 'uptime', 'w', or 'cat /proc/loadavg'

./check_linux_stats.pl -L -w wload1,wload5,wload15 -c cload,cload5,cload15

bymik, July 29, 2012
1 of 1 people found this review helpful
Very nice plugin!

But how to use for remote hosts and syntax in
commands.cfg...
Thanks a lot!
Owner's reply

Hi,

Did you try nrpe (or nsca) :

# command.cfg on nagios server
# $ARG1$ = check_cpu_usage,check_mem_usage,etc..

define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

# nrpe.cfg on the remote server
command[check_cpu_usage]=/usr/local/nagios/libexec/check_linux_stats.pl -C -w 90 -c 100 -s 5

command[check_load_average]=/usr/local/nagios/libexec/check_linux_stats.pl -L -w 10,8,5 -c 20,18,15

command[check_memory_usage]=/usr/local/nagios/libexec/check_linux_stats.pl -M -w 99,50 -c 100,50

command[check_disk_usage]=/usr/local/nagios/libexec/check_linux_stats.pl -D -w 10 -c 5 -p /,/usr,/tmp,/var

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

command[check_network_usage]=/usr/local/nagios/libexec/check_linux_stats.pl -N -w 30000 -c 45000 -p eth0

command[check_open_files]=/usr/local/nagios/libexec/check_linux_stats.pl -F -w 10000,150000 -c 15000,250000

command[check_socket_usage]=/usr/local/nagios/libexec/check_linux_stats.pl -S -w 1000 -c 2000

command[check_number_procs]=/usr/local/nagios/libexec/check_linux_stats.pl -P -w 1000 -c 2000

bymthuijs, January 22, 2012
1 of 1 people found this review helpful
Hi,

The Usage message for the script suggests there is a "-H " option, but it doesnt appear to be actually implemented. Any chance you have a version in the pipeline that will have that working? At the moment I would need too use NRPE to utilise this plugin. No biggie I suppose, but a "-H" option would mean I dont need to configure NRPE on all linux hosts.

Marc
byhedkandi, December 19, 2011
1 of 2 people found this review helpful
Well, i have the same query as the guy above..how do i generate the graph? it works fine so far with command configs but the graph part i have no idea how to go by it! please assist!
Owner's reply

Hi, you mean the plugin returns perfdata but you cannot getting graph in nagios ?

bybloonix, November 17, 2011
0 of 1 people found this review helpful
Hi, this is a really nice plugin based on my module Sys::Statistics::Linux. You should also view the original bloonix plugins on http://download.bloonix.net/sources. Note that the statistic output is in YAML format.
bywush, August 1, 2011
0 of 1 people found this review helpful
install the package libsys-statistics-linux-perl, it comes with /usr/share/perl5/Sys/Statistics/Linux.pm

but how can i use the graph?
byfogier, July 8, 2011
4 of 4 people found this review helpful
When i do a local check with the example
./check_linux_stats.pl -C -w 90 -c 100 -s 5
I get a error (see underneath).
It seems he misses a perl module. Is this right?
I could find a perl-Sys-Statistics-Linux rpm (I'm on SLES 10 SP2). Do I have to install this?

Can't locate Sys/Statistics/Linux.pm in @INC (@INC contains: /usr/local/nagios/libexec /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at ./check_linux_stats.pl line 31.
BEGIN failed--compilation aborted at ./check_linux_stats.pl line 31.
Owner's reply

Right, you must install Sys-Statistics-Linux perl package.
See on CPAN :
http://search.cpan.org/~bloonix/Sys-Statistics-Linux/

Page 3 of 3