FreeBSD Bugzilla – Attachment 110799 Details for
Bug 151995
net-mgmt/nagios-plugins: new plugin to check CPU usage
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
file.shar
file.shar (text/plain), 3.15 KB, created by
Marián Jamrich
on 2010-11-06 21:00:16 UTC
(
hide
)
Description:
file.shar
Filename:
MIME Type:
Creator:
Marián Jamrich
Created:
2010-11-06 21:00:16 UTC
Size:
3.15 KB
patch
obsolete
># This is a shell archive. Save it in a file, remove anything before ># this line, and then unpack it by entering "sh file". Note, it may ># create directories; files and directories will be owned by you and ># have default permissions. ># ># This archive contains: ># ># /tmp/home/jamrich/port/work/check_cpu_usage ># >echo x - /tmp/home/jamrich/port/work/check_cpu_usage >sed 's/^X//' >/tmp/home/jamrich/port/work/check_cpu_usage << '87363c859dcd04abe63b096e8c513458' >X#!/bin/sh >X# >X# Plugin return codes >X# >X# OK = 0 >X# The plugin was able to check the service and it appeared to be functioning properly >X# >X# Warning = 1 >X# The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly >X# >X# Critical = 2 >X# The plugin detected that either the service was not running or it was above some "critical" threshold >X# >X# Unknown = 3 >X# Invalid command line arguments were supplied to the plugin or low-level failures internal to the plugin (such as unable to fork, or open a tcp socket) that prevent it from performing the specified operation. Higher-level errors (such as name resolution errors, socket timeouts, etc) are outside of the control of plugins and should generally NOT be reported as UNKNOWN states. >X >XST_OK=0 >XST_WR=1 >XST_CR=2 >XST_UN=3 >X >X# Plugin name >XPROGNAME=`basename $0` >X >X# Version >XVERSION="Version 1.0," >X >X# Author >XAUTHOR="" >X >X# TOP command >Xtop=`which top` >Xbc=`which bc` >X >Xprint_version() { >X echo "$VERSION $AUTHOR" >X} >X >Xprint_help() { >X print_version $PROGNAME $VERSION >X echo "" >X echo "$PROGNAME is a Nagios plugin to check CPU utilization." >X echo "" >X echo "Options:" >X echo "" >X echo "--warning | -w" >X echo "--critical | -c" >X echo "--help | --usage" >X echo "" >X echo "Usage:" >X echo "" >X echo "./check_cpu_usage -w 80 -c 100" >X exit $ST_UN >X} >X >Xcase "$1" in >X --help|-h|--usage|-u) >X print_help >X exit $ST_UN >X ;; >X --warning|-w) >X host=$2 >X ;; >X --critical|-c) >X host=$2 >X ;; >X *) >X echo "Unknown argument: $1" >X echo "For more information please try -h or --help!" >X exit $ST_UN >X ;; >Xesac >Xshift >X >Xif [ `uname` != "FreeBSD" ]; then >X echo "This plugin is only for FreeBSD." >Xfi >X >Xif [ -z $1 ] || [ -z $3 ]; then >X print_help >X exit $ST_UN >Xfi >X >Xif [ "$1" -ge "$3" ]; then >X echo "Warning value must be greater than critical value!" >X exit $ST_UN >Xfi >X >Xcpu_idle=$($top -n -d 2 | /usr/bin/grep idle | /usr/bin/awk '{print $10}' | /usr/bin/sed 's/%//') >Xcpu_usage=`echo 100-$cpu_idle| $bc | sed 's/^\./0./'` >X >X >Xif [ $(echo "$cpu_usage>$1"|$bc) -gt 0 ] && [ $(echo "$cpu_usage<$3"|$bc) -gt 0 ]; then >X echo "WARNING - CPU usage is $cpu_usage% for server `hostname`. | http_state=$cpu_usage" >X exit 1 >Xelif [ $(echo "$cpu_usage>$3"|$bc) -gt 0 ]; then >X echo "CRITICAL - CPU usage is $cpu_usage% for server `hostname`. | http_state=$cpu_usage" >X exit 2 >Xelse >X echo "OK - CPU usage is $cpu_usage% for server `hostname`. | http_state=$cpu_usage" >X exit 0 >Xfi >87363c859dcd04abe63b096e8c513458 >exit
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 151995
: 110799