From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Nov 6 21:00:17 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 95066106564A for ; Sat, 6 Nov 2010 21:00:17 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 495A68FC1A for ; Sat, 6 Nov 2010 21:00:17 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oA6L0HJf042534 for ; Sat, 6 Nov 2010 21:00:17 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oA6L0Hi1042514; Sat, 6 Nov 2010 21:00:17 GMT (envelope-from gnats) Resent-Date: Sat, 6 Nov 2010 21:00:17 GMT Resent-Message-Id: <201011062100.oA6L0Hi1042514@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Marián Jamrich Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA085106566C for ; Sat, 6 Nov 2010 20:54:58 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id D8A658FC08 for ; Sat, 6 Nov 2010 20:54:58 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id oA6KswTD067353 for ; Sat, 6 Nov 2010 20:54:58 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id oA6KswSC067340; Sat, 6 Nov 2010 20:54:58 GMT (envelope-from nobody) Message-Id: <201011062054.oA6KswSC067340@www.freebsd.org> Date: Sat, 6 Nov 2010 20:54:58 GMT From: Marián Jamrich To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/151995: nagios check cpu usage X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 21:00:17 -0000 >Number: 151995 >Category: ports >Synopsis: nagios check cpu usage >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Nov 06 21:00:16 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Marián Jamrich >Release: 8.1 >Organization: >Environment: FreeBSD trinity.vx.sk 8.1-STABLE FreeBSD 8.1-STABLE #1 r212791: Wed Nov 3 11:37:30 CET 2010 root@trinity.vx.sk:/usr/obj/usr/src/sys/MYKERNEL amd64 >Description: Nagios Plugin to check your actually CPU utilization. - Marián Jamrich jamrich.majo@gmail.com >How-To-Repeat: >Fix: Patch attached with submission follows: # 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 >Release-Note: >Audit-Trail: >Unformatted: