Search Exchange
Search All Sites
Login
check_cpu_stats.sh
Compatible With
- Nagios 2.x
- Nagios 3.x
Owner
Hits
34852
Files:
| File | Description |
|---|---|
| check_cpu_stats.ncfg | check_cpu_stats.ncfg v2.3 (NagiosGrapher Template) |
| check_cpu_stats.sh | check_cpu_stats.sh |
Nagios plugin (script) to check cpu utilization statistics. This script has been designed and written on Unix plateform (Linux, Aix, Solaris), requiring iostat as external program. The location of these can easily be changed by editing the variables $IOSTAT at the top of the script. The script is used to query 6 of the key cpu statistics (user,system,iowait,idle,nice and steal if possible) at the same time. Note though that there is now set of warning and critical values for user,system and iowait percent.
Usage : ./check_cpu_stats.sh -w -c ( -i -n )
# Exemple: ./check_cpu_stats.sh
# ./check_cpu_stats.sh -w 70,40,30 -c 90,50,40
# ./check_cpu_stats.sh -w 90,40,30 -c 90,50,40 -i 3 -n 5
CPU STATISTICS WARNING : user=0.00% system=20.77% iowait=32.37% idle=46.86% nice=0.00% steal=0.00% | CpuUser=0.00;CpuSystem=20.77;CpuIowait=32.37;CpuIdle=46.86;CpuNice=0.00;CpuSteal=0.00;40,20,30;50,30,45
You can use too provided nagiosgrapher template for this plugin.
# ========================================================================================
#
# HISTORY :
# Release | Date | Authors | Description
# --------------+---------------+----------------------+-----------------------------------
# 2.0 | 16.02.08 | Steve Bosek | Solaris support and new parameters
# | | | New Parameters : - iostat seconds intervals
# | | | - iostat report number
# 2.1 | 08.06.08 | Steve Bosek | Bug perfdata and convert comma in point for Linux result
# 2.1.1 | 05.12.08 | Steve Bosek | Fixed improperly terminated string that was left open at line 130
# 2.1.2 | 06.12.08 | Bas van der Doorn | Fixed linux steal reported as idle, comparisons
# 2.2 | 06.12.08 | Bas van der Doorn | Capable systems will output nice and steal data
# 2.2.1 | 06.12.08 | Steve Bosek | Add for uniform Unix output nice and steal data on all perfdata
# 2.3 | 11.12.08 | Steve Bosek | Add Threshold for user and system output with format -w user,system,iowait -c user,system,iowait
# Add Default parameters value for threshold if not define
# Add check for ${TAB_WARNING_THRESHOLD@} and ${TAB_CRITICAL_THRESHOLD@}
# Add verify for Critical CPU Threshold lower as Warning CPU threshold
# 2.3.1 | 16.12.08 | Steve Bosek | Potability AIX,SOLARIS,LINUX for table initialisation (TAB_WARNING_THRESHOLD and TAB_CRITICAL_THRESHOLD)
# 2.3.2 | 22.12.08 | Steve Bosek | Strict Guideline Nagios for perfdata
# 2.3.3 | 08.02.08 | Philipp Lemke | Add HP-UX support (tested on HP-UX B.11.23 U ia64) - steve bosek : uniform perfdata
# 2.3.4 | 29.03.08 | Steve Bosek | Bug line 176 : USER_CRITICAL_THRESHOLD=`echo ${TAB_CRITICAL_THRESHOLD0}`
# 2.3.5 | 05.05.09 | Steve Bosek | Bug fix in NAGIOS_DATA for HP-UX
# 2.3.6 | 05.08.11 | Steve Bosek | Bug fix in NAGIOS_DATA : replace comma with semicolon in perfdata - compatibility with pnp
Usage : ./check_cpu_stats.sh -w -c ( -i -n )
# Exemple: ./check_cpu_stats.sh
# ./check_cpu_stats.sh -w 70,40,30 -c 90,50,40
# ./check_cpu_stats.sh -w 90,40,30 -c 90,50,40 -i 3 -n 5
CPU STATISTICS WARNING : user=0.00% system=20.77% iowait=32.37% idle=46.86% nice=0.00% steal=0.00% | CpuUser=0.00;CpuSystem=20.77;CpuIowait=32.37;CpuIdle=46.86;CpuNice=0.00;CpuSteal=0.00;40,20,30;50,30,45
You can use too provided nagiosgrapher template for this plugin.
# ========================================================================================
#
# HISTORY :
# Release | Date | Authors | Description
# --------------+---------------+----------------------+-----------------------------------
# 2.0 | 16.02.08 | Steve Bosek | Solaris support and new parameters
# | | | New Parameters : - iostat seconds intervals
# | | | - iostat report number
# 2.1 | 08.06.08 | Steve Bosek | Bug perfdata and convert comma in point for Linux result
# 2.1.1 | 05.12.08 | Steve Bosek | Fixed improperly terminated string that was left open at line 130
# 2.1.2 | 06.12.08 | Bas van der Doorn | Fixed linux steal reported as idle, comparisons
# 2.2 | 06.12.08 | Bas van der Doorn | Capable systems will output nice and steal data
# 2.2.1 | 06.12.08 | Steve Bosek | Add for uniform Unix output nice and steal data on all perfdata
# 2.3 | 11.12.08 | Steve Bosek | Add Threshold for user and system output with format -w user,system,iowait -c user,system,iowait
# Add Default parameters value for threshold if not define
# Add check for ${TAB_WARNING_THRESHOLD@} and ${TAB_CRITICAL_THRESHOLD@}
# Add verify for Critical CPU Threshold lower as Warning CPU threshold
# 2.3.1 | 16.12.08 | Steve Bosek | Potability AIX,SOLARIS,LINUX for table initialisation (TAB_WARNING_THRESHOLD and TAB_CRITICAL_THRESHOLD)
# 2.3.2 | 22.12.08 | Steve Bosek | Strict Guideline Nagios for perfdata
# 2.3.3 | 08.02.08 | Philipp Lemke | Add HP-UX support (tested on HP-UX B.11.23 U ia64) - steve bosek : uniform perfdata
# 2.3.4 | 29.03.08 | Steve Bosek | Bug line 176 : USER_CRITICAL_THRESHOLD=`echo ${TAB_CRITICAL_THRESHOLD0}`
# 2.3.5 | 05.05.09 | Steve Bosek | Bug fix in NAGIOS_DATA for HP-UX
# 2.3.6 | 05.08.11 | Steve Bosek | Bug fix in NAGIOS_DATA : replace comma with semicolon in perfdata - compatibility with pnp
Reviews (3)
works locally in nagios and through command line but doesn't work through nrpe (gives can't read output) and doesn't graph with pnp4nagios.
Owner's reply
Bug corrected in perfdata for pnp in 2.3.6. Can you retry with this new release please.
byamybrown@gamestop.com, October 13, 2011
byMajed1, August 22, 2011
i install ksh in gentoo and now it produces output from command line:
nagios@srvmonm /usr/lib/nagios/plugins $ ./check_cpu_stats2.3.6.sh
CPU STATISTICS CRITICAL : user=176% system=7.1%, iowait=0%, idle=2%, nice=21%, steal=0% | CpuUser=176%;70;90;0; CpuSystem=7.1%;40;60;0; CpuIowait=0%;30;40;0; CpuIdle=2%;0;0;0; CpuNice=21%;0;0;0; CpuSteal=0%;0;0;0;
it also works in nagios. Moreover, now it checks other linux systems through nrpe and draws graphs in nagios.
i can't imagine anything else to tune up :)
nagios@srvmonm /usr/lib/nagios/plugins $ ./check_cpu_stats2.3.6.sh
CPU STATISTICS CRITICAL : user=176% system=7.1%, iowait=0%, idle=2%, nice=21%, steal=0% | CpuUser=176%;70;90;0; CpuSystem=7.1%;40;60;0; CpuIowait=0%;30;40;0; CpuIdle=2%;0;0;0; CpuNice=21%;0;0;0; CpuSteal=0%;0;0;0;
it also works in nagios. Moreover, now it checks other linux systems through nrpe and draws graphs in nagios.
i can't imagine anything else to tune up :)


New Listings


