Linux

check_linux_stats

Description:

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

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


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!
Project Files
Project Photos
Project Notes
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) Add a Review
Understand about the parameteres
by pbhardwaj, July 31, 2020
Hi Team ,

I am new in linux and using nagios , I want to understand what are these parameters works with this scripts .

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

What is the meaning of -w 99,50 and -c 100,50 . What are these values .

Please help me to understand it in memory script .

Regards
Parshant Bhardwaj
Helpful? Yes  No 
Works great
by mouseymars, May 31, 2020
Nice little collection.

Is there a set of pnp4nagios templates for it?
Helpful? Yes  No 
Changes to this plugin
by apsivam, July 31, 2018
I have made some changes to this plugin at https://github.com/apsivam/monitoring_plugins/blob/master/check_linux_stats.pl.
How can I submit PR?

My changes:
*) percentage based check for disk usage will return percentage perfdata instead of KB
*) added an option to exclude file systems types for disk usage check so that we can exclude file systems like tmpfs, devtmpfs, etc.
Helpful? Yes  No 
Great plugin, need help installing it.
by sam20, April 30, 2017
Hi,

Great work.

I am fairly new to linux and nagios. But is there a tutorial/Link to import and run a plugin?

Thanks in advance!
Helpful? Yes  No 
Problems with NRPE
by Nunez Campos, October 31, 2016
Congratulations for the plugin. I like a lot, but it seems to have problems to execute NRPE, as when I run this plugin with NRPE it is unable to read the output. I have seen that other people have the same error. Could you help us to execute this plugin in remote? I have configured it, but it doen't work.
0 of 1 found this review helpful.
Helpful? Yes  No 1
Units MB is not working on Network Usages
by shamimreza, August 31, 2016
The plugins is great.. working with everything really fine but while i am using the unit variable with MB for Network Usages then its showing the default KB value.
Helpful? Yes  No 
Does a whole lot of good
by unassassinable, May 31, 2016
Works great!
Helpful? Yes  No 
Can't reach owner
by mhoogveld, April 30, 2016
I really like this plugin and have written an extension which I'd like to send to you.
However, I can't seem to reach the owner by email at plugmon@free.fr
I get a "550 5.2.1 This mailbox has been blocked due to inactivity" error message.
How can the owner be reached?
Helpful? Yes  No 
Very Good Plugin for Nagios but I can't see this with WEB-GUI
by ifcnet, March 31, 2016
Hi!,This plugin is great i can do a lot of things with only one command,thanks to the developer.

In the shell all works fine,but i can't show it in the WEB-GUI(Of course before that I added the plugin to the nrpe.cfg and reload the nagios service.)

Whats is the problem here?

Thanks a lot for your support.
Helpful? Yes  No 
Erro CPU Version 1.5
by Barreto, January 31, 2016
Check CPU is presenting problem, does anyone know what they have to modify the script?


/usr/lib64/nagios/plugins/check_linux_stats.pl -C -w 90 -c 95
CPU OK : idle 99.50% |idle=99.50%;90;95 user=0.00% system=0.00% iowait=0.50% steal=0.00%check_linux_stats v1.5
Usage: /usr/lib64/nagios/plugins/check_linux_stats.pl -C|-P|-M|-N|-D|-I|-L|-F|-S|-W|-U -p -w -c [-s ] [-u ] [-V] [-h]
-h, --help
print this help message
-C, --cpu=CPU USAGE
-P, --procs
-M, --memory=MEMORY USAGE
-N, --network=NETWORK USAGE
-D, --disk=DISK USAGE
-I, --io=DISK IO USAGE
-L, --load=LOAD AVERAGE
-F, --file=FILE STATS
-S, --socket=SOCKET STATS
-W, --paging=PAGING AND SWAPPING STATS
-X, --ctxt=CPU CONTEXT SWITCH
-U, --uptime
-p, --pattern
eth0,eth1...sda1,sda2.../usr,/tmp
-w, --warning
-c, --critical
-s, --sleep
-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 :
Memory usage : perl check_linux_stats.pl -M -w 90 -c 95
Cpu usage : perl check_linux_stats.pl -C -w 90 -c 95 -s 5
Disk usage : perl check_linux_stats.pl -D -w 95 -c 100 -u % -p /tmp,/usr,/var
Load average : perl check_linux_stats.pl -L -w 10,8,5 -c 20,18,15
Paging statistics : perl check_linux_stats.pl -W -w 10,1000,1 -c 20,2000,20 -s 3
Process statistics : perl check_linux_stats.pl -P -w 100 -c 200
I/O statistics on disk device : perl check_linux_stats.pl -I -w 10 -c 5 -p sda1,sda4,sda5,sda6
Network usage : perl check_linux_stats.pl -N -w 10000 -c 100000000 -p eth0
Processes virtual memory : perl check_linux_stats.pl -T -w 9551820 -c 9551890 -p /var/run/sendmail.pid
Cpu context switch : perl check_linux_stats.pl -X -w 6000 -c 70000 -s 2
Uptime : perl check_linux_stats.pl -U -w 5
Helpful? Yes  No 
Small bug
by fritsspits, January 31, 2016
Hi,

There's a small bug in v1.5 on line 62:

"if" should be "elsif" otherwise the -C (check_cpu) option will always show help.

Here's the diff:

--- /usr/lib/nagios/plugins/check_linux_stats.pl.org 2016-01-12 11:51:20.586228411 +0100
+++ /usr/lib/nagios/plugins/check_linux_stats.pl 2016-01-12 11:49:45.223925210 +0100
@@ -59,7 +59,7 @@
if($o_cpu){
check_cpu();
}
-if($o_context){
+elsif($o_context){
check_context_switch();
}
elsif($o_mem){
Owner's Reply:

I fixed this ugly bug..


1 of 1 found this review helpful.
Helpful? Yes 1 No 0
Little bug on CPU count
by emarginated, January 31, 2016
Hello,
great check.
I've found a little bug using hte CPU count.
It show me , on the perfdata, the entire help screen, just after the steal percentage:

[root@ph742502]/usr/local/nagios/libexec# ./check_linux_stats.pl -C -w 70 -c 100 -s 2
CPU OK : idle 91.85 |idle=91.85%;70;100 user=0.59% system=0.34% iowait=7.12% steal=0.00%check_linux_stats v1.5
Usage: ./check_linux_stats.pl -C|-P|-M|-N|-D|-I|-L|-F|-S|-W|-U -p -w -c [-s ] [-u ] [-V] [-h]
-h, --help
print this help message
-C, --cpu=CPU USAGE
-P, --procs
-M, --memory=MEMORY USAGE

Could be possible to solve?
i was not able to find it on the check_cpu section, it looks ok to me (but i'm not a programmer).

Thank you.

Michele
Owner's Reply:

I fixed this ugly bug..


Helpful? Yes  No 
check_cpu displays help
by jframeau, January 31, 2016
Very good plugin.

Last version 1.5
check_cpu should be followed by a elsif.

--- check_linux_stats.pl.old 2016-01-06 22:06:17.000000000 +0100
+++ check_linux_stats.pl 2016-01-06 22:03:33.582324204 +0100
@@ -59,7 +59,7 @@
if($o_cpu){
check_cpu();
}
-if($o_context){
+elsif($o_context){
check_context_switch();
}
elsif($o_mem){

jfr
Owner's Reply:

I fixed this ugly bug..


1 of 1 found this review helpful.
Helpful? Yes 1 No 0
major faults
by kevin@candidsource.com, September 30, 2015
Nice plugin. I added a check to paging statistics to check for major faults. diff follows.

--- check_linux_stats.pl 2015-09-11 12:22:42.977785368 -0500
+++ check_linux_stats.pl.orig 2015-08-21 09:11:02.000000000 -0500
@@ -533,22 +533,21 @@
if(defined($stat->pgswstats)) {
$status = "OK";
my $page = $stat->pgswstats;
- my ($warn_in,$warn_out,$warn_flt) = split(/,/,$o_warning);
- my ($crit_in,$crit_out,$crit_flt) = split(/,/,$o_critical);
- if((($page->{pgpgin}>=$crit_in)&&($page->{pgpgout}>=$crit_out))||($page->{pgmajfault}>=$crit_flt)) {
+ my ($warn_in,$warn_out) = split(/,/,$o_warning);
+ my ($crit_in,$crit_out) = split(/,/,$o_critical);
+ if(($page->{pgpgin}>=$crit_in)||($page->{pgpgout}>=$crit_out)) {
$status = "CRITICAL";
}
- elsif((($page->{pgpgin}>=$warn_in)&&($page->{pgpgout}>=$warn_out))||($page->{pgmajfault}>=$warn_flt)) {
+ elsif(($page->{pgpgin}>=$warn_in)||($page->{pgpgout}>=$warn_out)) {
$status = "WARNING";
}

my $perfdata = "|"
."pgpgin=$page->{pgpgin};$warn_in;$crit_in;0 "
."pgpgout=$page->{pgpgout};$warn_out;$crit_out;0 "
- ."pgmajfault=$page->{pgmajfault};$warn_flt;$crit_flt;0 "
."pswpin=$page->{pswpin} pswpout=$page->{pswpout}";

- print "Paging $status : in:$page->{pgpgin},out:$page->{pgpgout},flt:$page->{pgmajfault} $perfdata";
+ print "Paging $status : in:$page->{pgpgin},out:$page->{pgpgout} $perfdata";
}
else {
print "No data";
@@ -627,7 +626,7 @@
Cpu usage : perl check_linux_stats.pl -C -w 90 -c 95 -s 5
Disk usage : perl check_linux_stats.pl -D -w 95 -c 100 -u % -p /tmp,/usr,/var
Load average : perl check_linux_stats.pl -L -w 10,8,5 -c 20,18,15
- Paging statistics : perl check_linux_stats.pl -W -w 10,1000,1 -c 20,2000,20 -s 3
+ Paging statistics : perl check_linux_stats.pl -W -w 10,1000 -c 20,2000 -s 3
Process statistics : perl check_linux_stats.pl -P -w 100 -c 200
I/O statistics on disk device : perl check_linux_stats.pl -I -w 10 -c 5 -p sda1,sda4,sda5,sda6
Network usage : perl check_linux_stats.pl -N -w 10000 -c 100000000 -p eth0
Owner's Reply:

Hello,
thanks for your comment,
Ussue fixed on v1.5


1 of 1 found this review helpful.
Helpful? Yes 1 No 0
Correction to the unit.
by john12, June 30, 2015
Hi,
This plugin is indeed superb.
I found a bug that when using unit=MB for disk usage, the perf data writtens only KB.

So to fix, i made changes on line no. 378 from

$perfdata .= " $mountpoint=$usage$o_unit";

To

$perfdata .= " $mountpoint=$tmpusage$o_unit;;;0;$tmptotal";

Addition $tmptotal in perf data will set the max MB in the graph.

Let me know,

regards,
John.
Owner's Reply:

Hello,
thanks for your comment,
Ussue fixed on v1.5


Helpful? Yes  No 
Good plugin !!
by ledistordu, April 30, 2015
I have a perfcounter problem with 1.4.1 :

/usr/lib/nagios/plugins/check_linux_stats.pl -p sda2,sda5 -I -w 100,70 -c 150,100 [16:04:44]
DISK IO OK |sda2_read=0.00;100;150 sda2_write=0.00;70;100|sda5_read=0.00;100;150 sda5_write=0.00;70;100

Need this result :

DISK IO OK |sda2_read=0.00;100;150 sda2_write=0.00;70;100 sda5_read=0.00;100;150 sda5_write=0.00;70;100
Owner's Reply:

Hello,
thanks for your comment,
Ussue fixed on v1.5


Helpful? Yes  No 
Cant contact owner :(
by Box293, February 28, 2015
I recently tried to email the owner of this plugin however I got the following error:

Google tried to deliver your message, but it was rejected by the server for the recipient domain free.fr by mx1.free.fr. [212.27.48.6].

The error that the other server returned was:
550 5.2.1 This mailbox has been blocked due to inactivity
0 of 1 found this review helpful.
Helpful? Yes  No 1
some minor issues
by martinboer, January 31, 2015
I ran into 2 really minor issues;
- Sys:Statistics relies on YAML:Syck, but the plugin doesn't complain if that fails.
- the plugin itself does not mention that the -I option needs 2 -w and -c variables.

and I have a small request as well; on virtual machines using lvm you often have a lot of 'disks' attached but most of them are loopback and virtual devices, if you add an option no-fake-disks-for-me-no-sirree (or a shortcut for that), you could loop through the devices in /sys/block/ and use readlink to remove the virtual devices from the list. This saves a lot of output when you don't want to use -p.
Helpful? Yes  No 
Net statistics
by edrendar, November 30, 2014
Hi,

First of all, I want to congratulate you on your excellent work with this plugin!
I have a question, I don't understand at all how are obtained the net statistics...
If I check TxBytes in /proc/net/dev to review statistics for bond0, I watch a large number in bytes: 7342573046357

Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
bond0:1259548428146 14687025821 0 0 0 0 0 0 7342573046357 15194696711 0 0 0 0 0 0

But, If I check the Nagios web interface, this amount doesn't match with the previous value:
/proc/net/dev = 7342573046357
Nagios Web = 5323572.80B

How the plugin estimate these values on the Nagios web interface?

Thanks in advance.
Helpful? Yes  No 
Timeouts using disk checks
by feisar, September 30, 2014
Hi,

Thanks for the great plugin. If NFS mounts on the system are unresponsive then an unrelated disk check using this plugin times out.

Can this be fixed?
Helpful? Yes  No 
inaccurate value for memory usage
by subhash, September 30, 2014
Hi Experts,

I have issue with this scripts for memory use in percent. I did not checked about other matter but memory usages showing in very less, but other commands for memroy showing accurate value. as below output.

[root@eam1 libexec]# ./check_linux_stats.pl -M -w 99,50 -c 100,50
MEMORY OK : Mem used: 47.27%, Swap used: 3.18% |MemUsed=47.27%;99;100 SwapUsed=3.18%;50;50 MemCached=52.11% SwapCached=0.98% Active=71.91%
[root@eam1 libexec]# sar -r 1 3
Linux 2.6.18-8.el5 (eam1.cmm.icms.in) 09/23/2014

12:15:11 PM kbmemfree kbmemused %memused kbbuffers kbcached kbswpfree kbswpused %swpused kbswpcad
12:15:12 PM 109176 18371676 99.41 550200 9630152 15866008 520284 3.18 160076
12:15:13 PM 118524 18362328 99.36 550200 9630156 15866008 520284 3.18 160076
12:15:14 PM 118648 18362204 99.36 550200 9630156 15866008 520284 3.18 160076
Average: 115449 18365403 99.38 550200 9630155 15866008 520284 3.18 160076
[root@eam1 libexec]# free -m
total used free shared buffers cached
Mem: 18047 17931 116 0 537 9404
-/+ buffers/cache: 7989 10057
Swap: 16002 508 15494
---------------------

perl script showing 47.27% but sar and nmon and top is showing 98 or 99 percent usage.

Kindly help me for this to get accurate output.

Regards,
Subhash (minixpeg@gmail.com)
Owner's Reply:

Hello,
It's not an issue, but the plugin gets the cache out of the used memory and shows the *real* physical memory usage.

47% MemUsed + 52% MemCached = 99%

Regards,


1 of 1 found this review helpful.
Helpful? Yes 1 No 0
Check disk example problem
by krizb, June 30, 2014
Hello,
nice plugins. I found one problem:
Example for checking disk suggest using limits for "disk full":
perl check_linux_stats.pl -D -w 95 -c 100 -u % -p /tmp,/usr,/var
but plugins uses limits for "disk free":
[krizb@kriznb linux]$ df -h /var
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-varF 4.9G 3.2G 1.5G 69% /var
[krizb@kriznb linux]$ /usr/lib64/nagios/plugins/check_linux_stats.pl -D -w 95 -c 100 -u % -p /var
DISK CRITICAL used : /var 30.47% free | /var=3322124KB
[krizb@kriznb linux]$ /usr/lib64/nagios/plugins/check_linux_stats.pl -D -w 5 -c 0 -u % -p /var
DISK OK used : /var 30.47% free | /var=3322124KB
[krizb@kriznb linux]$
2 of 2 found this review helpful.
Helpful? Yes 2 No 0
-bash: value: No such file or directory (Installation problem)
by afif3011, May 31, 2014
Hi,

Came across your useful plugin for monitoring Linux Stats. I have downloaded the check_linux perl package and installed it on my remote server. But I’ve issues to run the following plugin. To be honest I’m a newbie into this nagios monitoring server and how to configure it. Appreciate if you could lead me to the correct direction

As far as my concerned my steps is as below

At host/remote server

1. root@server# cd /root/nagios
2. root@server nagios# wget http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2516&cf_id=24
3. root@server nagios# tar –zxvf Sys-Statistics-Linux-0.66.tar.gz
4. root@server nagios# cd Sys-Statistics-Linux-0.66
5. root@server Sys-Statistics-Linux-0.66# perl Makefile.PL
6. root@server Sys-Statistics-Linux-0.66# make
7. root@server Sys-Statistics-Linux-0.66# make install
8. root@server# vi /usr/local/nagios/etc/nrpe.cfg

and I add the harcoded command argument in the nrpe.cfg

# 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

9. restart xinetd service && restart nrpe service


At monitoring server

1. Install theLinux Stats plugin same as above

2. go to cd /usr/local/nagios/etc/service.cfg and add the following:

define service{
use generic-service
host_name fastrocom.com
service_description Network Usage
check_command check_nrpe!check_net
}
3. go to cd /usr/local/nagios/etc/objects/command.cfg and add the following:

# 'check_net_usage' command definition
define command{
command_name check_net
command_line $USER1$/check_net -I $HOSTADDRESS$ $ARG1$
}

I believe I miss a few steps and due to this I’m unable to generate the report at Nagios monitoring System. If I go to /usr/local/nagios/libexec/ there is no linux stats plugin available at that directory

Your guidance and advice is highly appreciated
Helpful? Yes  No 
Works Great, but Still can't get it graphing
by duke12687, February 28, 2014
I know some people have asked in earlier comments how to generate perf data to go into nagiosgraph, but I can't get it to work.

Nagiosgraph is saying "no data available". Can you tell me how to get this working?
Helpful? Yes  No 
Fix bug of the SWAP is off
by rril, January 31, 2014
290,291c290,295
{swapused}/$mem->{swaptotal})*100);
{swapcached}/$mem->{swaptotal})*100);
---
> my $swapused = 0;
> my $swapcached = 0;
> if($mem->{swaptotal}>0) {
> $swapused = sprintf("%.2f", ($mem->{swapused}/$mem->{swaptotal})*100);
> $swapcached = sprintf("%.2f", ($mem->{swapcached}/$mem->{swaptotal})*100);
> }
294c298
=$mem_crit)||($swapused>=$swap_crit)) {
---
> if(($memused>=$mem_crit)||(($swapused>=$swap_crit) && ($swapused>0))) {
297c301
=$mem_warn)||($swapused>=$swap_warn)) {
---
> elsif (($memused>=$mem_warn)||(($swapused>=$swap_warn) && ($swapused>0))) {


Sorry, I do not write English well.
Owner's Reply:

Hello,
issue fixed,


1 of 1 found this review helpful.
Helpful? Yes 1 No 0
Patches
by migoo, December 31, 2013
Do you still maintain this plugin? If that's the case where can one send patches to you?
Owner's Reply:

Yes I still maitain my plugin !


Helpful? Yes  No 
Small issues
by RedFish, October 31, 2013
Hello,
Great job this check worked great out of the box, I applied ruddockr suggestion to have CPU usage and not Idle time.
I noticed two small issues :

If you do not have any swap you get the divide by zero error noticed by helium_rday, as a quick fix I added a +1 in the division at line 290 and 291.

I always get a empty disk io, the perfdata are there but the output is always :
DISK OK io : |sda1_read=0.00;100;150 sda1_write=0.00;70;100 with nothing after the "io : ". I'm not a Perl expert but I noticed that the $return_str is initiliazed but no data is added to it.
Owner's Reply:

Hello,
thanks for your comment,
I fixed this two issues on v1.4 !


Helpful? Yes  No 
pnp4nagios templates
by cathode, September 30, 2013
Hi! Thanks for this excellent plugin.
Are there any pnp4nagios templates for this plugin?
Helpful? Yes  No 
How to you create the graph you display?
by jobst, July 31, 2013
Hi.
Great plugin.
You display a graph with three data sets for memory. While I can create the data using the plugin I do not know how to create the graph.
Could you elaborate how you created the graph, please?
thank you
Jobst
Helpful? Yes  No 
Great Plugin
by andynowakowski, June 30, 2013
Excellent plugin. VERY useful.

The only problem I'm having is with the check_network_usage check. All the other checks work, but check_network_usage returns "NRPE: Unable to read output". When i run the check on the remote host manually, it gives the correct output, but falls over at some point during the NRPE check when run from the nagios host.

Any ideas?
Helpful? Yes  No 
unable to add this plugins with check_nrpe
by c.shailesh, May 31, 2013
kindly provide ur help to add this plugins to monitor remote host through nrpe
Helpful? Yes  No 
mem usage not correctly calculated
by waterdeep, May 31, 2013
Hi

Please check the calculation of the free memory (physical).

Currently this is the value of memused:

$memused = ($mem->{memused} / $mem->{memtotal}*100);

But you will have to calculate also with the cached memory.
> $memused = sprintf("%.2f", $memused - $memcached);

This is at least the real free memory.

Especially on RedHat based systems almost the whole physical memory will be allocated and only be provided for usage out of the cached memory. Means: once loaded component's required memory stays reserved for the OS for faster re-allocation but it can be freed if the remaining physical memory goes down very fast.

Regards
Jochen
Owner's Reply:

Hello,
I fixed this issue on v1.4,


Helpful? Yes  No 
Superb utility!
by knightsamar, March 31, 2013
This is a very nicely designed and useful plugin. The only improvement I can suggest is being able to pass a program name rather than the PID file name.

And for those who couldn't find graphs, graphs are available through nagiosgraph (http://nagiosgraph.sourceforge.net/) which is a small 5-minute setup.
Owner's Reply:

Hi,
You can already check a process using the -T parameter. Example :
./check_linux_stats.pl -T -w 200000000 -c 300000000 -p /var/run/vmtoolsd.pid

Returns virtual mem & cpu information :
PROCESSES OK |vmtoolsd_vsize=39239680;200000000;300000000 vmtoolsd_nswap=0 vmtoolsd_cnswap=0 vmtoolsd_cpu=1


Helpful? Yes  No 
how to grpah cpu utilization
by rahuliq, March 31, 2013
Hi How can I graph the cpu utilization
Helpful? Yes  No 
Nice work
by csterley, March 31, 2013
Im able to get all the checks finally condensed into one nice neat script. One thing of the future todo list.

Have an issue thought, the uptime check is returning a status of unknown. Doesn't seem to be effected by the -w -c on the command.
Owner's Reply:

I fixed it,
The plugin can report a notify if the boot time is lower than a given warning threshold in minutes.

./check_linux_stats.pl -U -w 12
WARNING : up 0 days, 00:11:23 |uptime=683


Helpful? Yes  No 
just what I needed
by ruddockr, March 31, 2013
Great plugin - and yielding great info for nagiosgraph too!
Just one tweak that makes the graph more sensible to read.
default output is %idle which can be 100% all the time if a quiet server.
I changed this to return to CPU busy time (based on cpu_used variable)

code change snippett at line 120-126 (under check_cpu sub):
120 my $perfdata .= "|"
121 ."user=$cpu->{user}% "
122 ."system=$cpu->{system}% "
123 ."iowait=$cpu->{iowait}% "
124 ."InUse=$cpu_used%;$o_warning;$o_critical";
125
126 print "CPU $status : InUse $cpu_used% $perfdata";


Richard
Helpful? Yes  No 
Enchancement
by eulen, December 31, 2012
Hi
We had an error first when trying to use the plugin. After changing the following lines it worked perfectly:
#use lib "/usr/local/nagios/libexec";
use FindBin;
use lib "$FindBin::Bin";

(replaced the lib definition)

Friendly regards, Till
Helpful? Yes  No 
NRPE: Command 'check_linux_stats.pl' not defined
by beagless, December 31, 2012
I have run the install as described below

#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

and put in the entries as you described
# 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

but i get a NRPE: Command 'check_linux_stats.pl' not defined

am i missing something in the host config file hostname.cfg ?

any help welcome thanks :-)

Paul
Helpful? Yes  No 
Good work!
by dbsanders, November 30, 2012
I love the idea of all the stats coming from one script. Had to modify a bit, to get the cache out of the "used" memory.

Also, Sys::Statistics::Linux reports network traffic in "bytes". However you are appending "KB" to the output, but I don't see the conversion in your script. Shouldn't this be appending "B" instead?
Helpful? Yes  No 
Illegal division by 0
by helium_rday, October 31, 2012
Great plugin!

When running the memory example however i get the following error:

15:34:18 /usr/local/icinga/libexec $ perl check_linux_stats.pl -M -w 90 -c 95
Illegal division by zero at check_linux_stats.pl line 250.

All the other checks, such as CPU, load, process vmem, network, io, etc work perfectly.

Thoughts?
Helpful? Yes  No 
NRPE: Command not defined
by nagiostester, October 31, 2012
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
1 of 1 found this review helpful.
Helpful? Yes 1 No 0
Super nice plugin!
by patricio.dorantes, October 31, 2012
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!
Helpful? Yes  No 
Need to know meaning
by SushilR, August 31, 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


Helpful? Yes  No 
How to use?
by mik, July 31, 2012
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


1 of 1 found this review helpful.
Helpful? Yes 1 No 0
Great plugin! But query re "-H" option
by mthuijs, January 31, 2012
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
1 of 1 found this review helpful.
Helpful? Yes 1 No 0
how to generate the graph?
by hedkandi, December 31, 2011
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 ?


1 of 2 found this review helpful.
Helpful? Yes 1 No 1
Bloonix Plugins
by bloonix, November 30, 2011
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.
0 of 1 found this review helpful.
Helpful? Yes  No 1
..
by wush, August 31, 2011
install the package libsys-statistics-linux-perl, it comes with /usr/share/perl5/Sys/Statistics/Linux.pm

but how can i use the graph?
0 of 1 found this review helpful.
Helpful? Yes  No 1
Not working (yet)
by fogier, July 31, 2011
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/


4 of 4 found this review helpful.
Helpful? Yes 4 No 0
Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.5 (79)
Favorites
19
Views
468,370