diff options
author | miwi <miwi@FreeBSD.org> | 2011-01-31 19:34:31 +0800 |
---|---|---|
committer | miwi <miwi@FreeBSD.org> | 2011-01-31 19:34:31 +0800 |
commit | 6ce93b03e569ed4c0239bc1017711ad4136dff5b (patch) | |
tree | b59188034bbac3ecd43cd0f11933b26e3e4f88cb /net-mgmt | |
parent | e7f5d50a6457da6c4eca9e3a7447880ef9812c0c (diff) | |
download | freebsd-ports-gnome-6ce93b03e569ed4c0239bc1017711ad4136dff5b.tar.gz freebsd-ports-gnome-6ce93b03e569ed4c0239bc1017711ad4136dff5b.tar.zst freebsd-ports-gnome-6ce93b03e569ed4c0239bc1017711ad4136dff5b.zip |
- Update to 1.1
PR: 154382
Submitted by: Marian Jamrich <jamrich.majo@gmail.com> (maintainer)
Feature safe: yes
Diffstat (limited to 'net-mgmt')
-rw-r--r-- | net-mgmt/nagios-check_hdd_health/Makefile | 4 | ||||
-rw-r--r-- | net-mgmt/nagios-check_hdd_health/pkg-descr | 6 | ||||
-rw-r--r-- | net-mgmt/nagios-check_hdd_health/src/check_hdd_health | 60 |
3 files changed, 39 insertions, 31 deletions
diff --git a/net-mgmt/nagios-check_hdd_health/Makefile b/net-mgmt/nagios-check_hdd_health/Makefile index 8ec3e305ea10..b4272c670407 100644 --- a/net-mgmt/nagios-check_hdd_health/Makefile +++ b/net-mgmt/nagios-check_hdd_health/Makefile @@ -6,7 +6,7 @@ # PORTNAME= nagios-check_hdd_health -PORTVERSION= 1.0.1 +PORTVERSION= 1.1 CATEGORIES= net-mgmt MASTER_SITES= # No distfile DISTFILES= # No distfile @@ -14,7 +14,7 @@ DISTFILES= # No distfile MAINTAINER= jamrich.majo@gmail.com COMMENT= Nagios plug-in to check HDD health from S.M.A.R.T -RUN_DEPENDS= smartmontools>=0:${PORTSDIR}/sysutils/smartmontools +RUN_DEPENDS= smartmontools>=0:${PORTSDIR}/sysutils/smartmontools NO_BUILD= yes diff --git a/net-mgmt/nagios-check_hdd_health/pkg-descr b/net-mgmt/nagios-check_hdd_health/pkg-descr index 45a144ce23b7..dca7561e86e7 100644 --- a/net-mgmt/nagios-check_hdd_health/pkg-descr +++ b/net-mgmt/nagios-check_hdd_health/pkg-descr @@ -1,5 +1,7 @@ -check_hdd_health is a Nagios plug-in written in shell to check HDD health. -This script check HDD from S.M.A.R.T this values: +Check_hdd_health is a Nagios plug-in written in shell to check HDD health. + +This script check HDD from this S.M.A.R.T values: + - Spin Retry Count - Reallocated Sector Ct - Reallocated Event Count diff --git a/net-mgmt/nagios-check_hdd_health/src/check_hdd_health b/net-mgmt/nagios-check_hdd_health/src/check_hdd_health index 9723e071d6f9..de20fb9359ae 100644 --- a/net-mgmt/nagios-check_hdd_health/src/check_hdd_health +++ b/net-mgmt/nagios-check_hdd_health/src/check_hdd_health @@ -16,7 +16,7 @@ SMT=Smartmontools PROGNAME=`basename $0` # Version -VERSION="Version 1.0.1" +VERSION="Version 1.1" # Author AUTHOR="Marian Jamrich" @@ -26,9 +26,9 @@ TMPFILE=/tmp/smart.nagios.$$ # Clean up when done or when aborting trap "rm -f ${TMPFILE}" 0 1 2 3 15 -#print_version() { -# echo "$PROGNAME $VERSION $1" -#} +print_version() { + echo "Nagios-$PROGNAME ($VERSION)" +} mini_help() { echo "Usage $0 --device $device --without [src rsc rec cps ou]" @@ -36,9 +36,9 @@ mini_help() { print_help() { clear; - echo "*********************************************************************************" - echo "* $PROGNAME $VERSION $1""($AUTHOR) <jamrich.majo@gmail.com> (2011) *" - echo "*********************************************************************************" + echo "**************************************************************************************" + echo "* $PROGNAME $VERSION $1""($AUTHOR) <jamrich.majo@gmail.com> (2011) *" + echo "**************************************************************************************" echo "This is Nagios plugin to check HDD health from S.M.A.R.T. by Smartmontools." echo ' The S.M.A.R.T. attributes are specific properties (parameters) of various parts of a disk. @@ -80,7 +80,7 @@ This is test provided by Smartmontools. If total disk state is "health", Smartmo echo "Critical - if some value is greater than \"0\" except \"Spin Retry Count (>=10)\" and \"Reallocated Event Count (>=10)\"." echo -e "\n---------------------------------------------------------------------" echo "Usage:" - echo "$0 --device /dev/ad0 [ --without [src rsc rec cps ou]]" + echo "$0 --device ad0 [ --without [src rsc rec cps ou]]" echo "---------------------------------------------------------------------" exit $ST_UN } @@ -93,12 +93,12 @@ case "$1" in -d | --device) device=$2 ;; - -V) + -v) print_version - exit + exit $ST_UN ;; *) - echo "Unknown argument: $1" + echo "Unknown argument: $1" echo "For more information please try -h or --help!" exit $ST_UN ;; @@ -108,26 +108,30 @@ shift test -z $device && echo -e "\nYou forgot to define device! Please try \"-h or --help\" to help." && exit $ST_UN test `uname` != "FreeBSD" && echo "This plugin is only for FreeBSD." && exit $ST_UN +format_device=`echo $device | grep -w 'dev'` +if [ -z $format_device ]; then + device=/dev/`echo $device` +fi + if [ ! -e $device ]; then - echo - echo "Unknown device \"$device\"!" - exit $ST_UN + echo "Unknown device \"$device\"!" + exit $ST_UN fi if [ -z $smartctl ]; then - echo -e "\nYou don't have installed $SMT. Please install it at http://smartmontools.sourceforge.net or pkg_add -r \"smartmontools\"..." - exit $ST_UN + echo -e "\nYou don't have installed $SMT. Please install it from 'http://smartmontools.sourceforge.net' or pkg_add -r \"smartmontools\"..." + exit $ST_UN fi $smartctl -a $device > ${TMPFILE} SMART_SUPPORT=`awk '/SMART support is/ {print $4}' ${TMPFILE} | tail -n 1` if [ "${SMART_SUPPORT}" = "Unavailable" ]; then - echo -e "\nS.M.A.R.T support is Unavailable for $device !!! You should enable it \"smartctl -s on $device\"." - exit $ST_UN + echo -e "\nS.M.A.R.T support is unavailable for $device !!! You should enable it \"smartctl -s on $device\"." + exit $ST_UN elif [ "${SMART_SUPPORT}" != "Enabled" ]; then - echo -e "\nMaybe you don't have enabled S.M.A.R.T support in $SMT! Please type \"smartctl -s on $device\" that you have it turned on. Or device does not support S.M.A.R.T function." - exit $ST_UN + echo -e "\nMaybe you don't have enabled S.M.A.R.T support in $SMT! Please type \"smartctl -s on $device\" that you have it turned on, or device does not support S.M.A.R.T function." + exit $ST_UN fi ## start S.M.A.R.T test and set variables @@ -138,7 +142,7 @@ cps=`awk '/Current_Pending_Sector/ {print $10}' ${TMPFILE} ` ou=`awk '/Offline_Uncorrectable/ {print $10}' ${TMPFILE} ` pass=`awk -F\: '/test result/ { if ( $2 == " PASSED") print "PASSED"; else print "FAILED" }' ${TMPFILE} ` -## if one or more S.M.A.R.T function is not supported by your HDD, then you define --without variable and then value is set to "0" +## if one or more S.M.A.R.T function is not supported by your HDD, then you define --without variable and then value is set automatically to "0" args=`getopt w:without: $*` for arg; do case "$arg" in @@ -150,16 +154,18 @@ for arg; do esac done -# test if your HDD support all parameters: -[ -z "$src" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support Spin_Retry_Count. Please try \"--without src\"." && mini_help && exit $ST_UN -[ -z "$rsc" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support Reallocated_Sector_Ct. Please try \"--without rsc\"." && mini_help && exit $ST_UN -[ -z "$rec" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support Reallocated_Event_Count. Please try --without rec." && mini_help && exit $ST_UN -[ -z "$cps" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support Current_Pending_Sector. Please try --without cps." && mini_help && exit $ST_UN -[ -z "$ou" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support Offline_Uncorrectable. Please try \"--without ou\"." && mini_help && exit $ST_UN +# test if your HDD support all this parameters: +[ -z "$src" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support "Spin Retry Count". Please try \"--without src\"." && mini_help && exit $ST_UN +[ -z "$rsc" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support "Reallocated Sector Ct". Please try \"--without rsc\"." && mini_help && exit $ST_UN +[ -z "$rec" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support "Reallocated Event Count". Please try --without rec." && mini_help && exit $ST_UN +[ -z "$cps" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support "Current Pending Sector". Please try --without cps." && mini_help && exit $ST_UN +[ -z "$ou" ] && echo -e "***********\n** ERROR **\n***********\n${device} don't support "Offline Uncorrectable". Please try \"--without ou\"." && mini_help && exit $ST_UN perfdata="smart=src=$src; rsc=$rsc; rec=$rec; cps=$cps; ou=$ou; pass=$pass" +############################################################ ##### finally run test, print result and set exit code ##### +############################################################ if [ $src -eq 0 ] && [ $rsc -eq 0 ] && [ $rec -eq 0 ] && [ $cps -eq 0 ] && [ $ou -eq 0 ] && [ "$pass" = "PASSED" ]; then echo "OK - HDD S.M.A.R.T health: src=$src, rsc=$rsc, rec=$rec, cps=$cps, ou=$ou, HEALTH_STATUS=$pass for $device. |${perfdata}" exit $ST_OK |