blog:check_netio_1.1_debian
| Both sides previous revisionPrevious revision | |||
| blog:check_netio_1.1_debian [2011-05-22 16:42] – brb | blog:check_netio_1.1_debian [2011-05-22 16:42] (current) – removed brb | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | <code bash> | ||
| - | #!/bin/sh | ||
| - | ############################################### | ||
| - | # | ||
| - | # Nagios script to check network I/O status | ||
| - | # | ||
| - | # Copyright 2007, 2008 Ian Yates | ||
| - | # | ||
| - | # See usage for command line switches | ||
| - | # | ||
| - | # NOTE: Because of the method of gathering information, | ||
| - | # | ||
| - | # This plugin is a means of returning stats to nagios for graphing (recommend DERIVE graph in RRD) | ||
| - | # | ||
| - | # Created: 2007-09-06 (i.yates@uea.ac.uk) | ||
| - | # Updated: 2007-09-06 (i.yates@uea.ac.uk) | ||
| - | # Updated: 2008-11-27 (i.yates@uea.ac.uk) - Added GPLv3 licence | ||
| - | # Updated: 2011-05-22 (b.brunner@it-transforms.ch) Changed paths for debian | ||
| - | # | ||
| - | # This program is free software: you can redistribute it and/or modify | ||
| - | # it under the terms of the GNU General Public License as published by | ||
| - | # the Free Software Foundation, either version 3 of the License, or | ||
| - | # (at your option) any later version. | ||
| - | # | ||
| - | # This program is distributed in the hope that it will be useful, | ||
| - | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| - | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| - | # GNU General Public License for more details. | ||
| - | # | ||
| - | # You should have received a copy of the GNU General Public License | ||
| - | # along with this program. | ||
| - | # | ||
| - | ############################################### | ||
| - | . / | ||
| - | #. / | ||
| - | |||
| - | |||
| - | VERSION=" | ||
| - | |||
| - | IFCONFIG=/ | ||
| - | GREP=/ | ||
| - | CUT=/ | ||
| - | |||
| - | FLAG_VERBOSE=FALSE | ||
| - | INTERFACE="" | ||
| - | LEVEL_WARN=" | ||
| - | LEVEL_CRIT=" | ||
| - | RESULT="" | ||
| - | EXIT_STATUS=$STATE_OK | ||
| - | |||
| - | |||
| - | |||
| - | ############################################### | ||
| - | # | ||
| - | ## FUNCTIONS | ||
| - | # | ||
| - | |||
| - | ## Print usage | ||
| - | usage() { | ||
| - | echo " check_netio $VERSION - Nagios network I/O check script" | ||
| - | echo "" | ||
| - | echo " Usage: check_netio {-i} [ -v ] [ -h ]" | ||
| - | echo "" | ||
| - | echo " | ||
| - | echo " | ||
| - | echo " | ||
| - | echo "" | ||
| - | } | ||
| - | |||
| - | ## Process command line options | ||
| - | doopts() { | ||
| - | if ( `test 0 -lt $#` ) | ||
| - | then | ||
| - | while getopts i:vh myarg " | ||
| - | do | ||
| - | case $myarg in | ||
| - | h|\?) | ||
| - | usage | ||
| - | exit;; | ||
| - | i) | ||
| - | INTERFACE=$OPTARG;; | ||
| - | v) | ||
| - | FLAG_VERBOSE=TRUE;; | ||
| - | *) # Default | ||
| - | usage | ||
| - | exit;; | ||
| - | esac | ||
| - | done | ||
| - | else | ||
| - | usage | ||
| - | exit | ||
| - | fi | ||
| - | } | ||
| - | |||
| - | |||
| - | # Write output and return result | ||
| - | theend() { | ||
| - | echo $RESULT | ||
| - | exit $EXIT_STATUS | ||
| - | } | ||
| - | |||
| - | |||
| - | # | ||
| - | ## END FUNCTIONS | ||
| - | # | ||
| - | |||
| - | ############################################# | ||
| - | # | ||
| - | ## MAIN | ||
| - | # | ||
| - | |||
| - | |||
| - | # Handle command line options | ||
| - | doopts $@ | ||
| - | |||
| - | # Do the do | ||
| - | |||
| - | BYTES_RX=`$IFCONFIG $INTERFACE | $GREP ' | ||
| - | BYTES_TX=`$IFCONFIG $INTERFACE | $GREP ' | ||
| - | |||
| - | RESULT=" | ||
| - | |||
| - | # Quit and return information and exit status | ||
| - | theend | ||
| - | |||
| - | </ | ||
blog/check_netio_1.1_debian.1306075324.txt.gz · Last modified: 2011-05-22 16:42 by brb
