9 if test -x /usr
/bin
/printf; then
16 echo "$1 v$2 (nagios-plugins 1.4.16)"
17 $ECHO "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugins under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n" |
sed -e 's/\n/ /g'
21 $ECHO "Send email to nagios-users@lists.sourceforge.net if you have questions\nregarding use of this software. To submit patches or suggest improvements,\nsend email to nagiosplug-devel@lists.sourceforge.net.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n" |
sed -e 's/\n/ /g'
25 # check_range takes a value and a range string, returning successfully if an
26 # alert should be raised based on the range.
29 local v range
yes no err decimal start end
cmp match
33 # whether to raise an alert or not
38 # regex to match a decimal number
39 decimal
="-?([0-9]+\.?[0-9]*|[0-9]*\.[0-9]+)"
41 # compare numbers (including decimals), returning true/false
42 cmp() { awk "BEGIN{ if ($1) exit(0); exit(1)}"; }
44 # returns successfully if the string in the first argument matches the
46 match
() { echo "$1" |
grep -E -q -- "$2"; }
48 # make sure value is valid
49 if ! match
"$v" "^$decimal$"; then
50 echo "${0##*/}: check_range: invalid value" >&2
55 # make sure range is valid
56 if ! match
"$range" "^@?(~|$decimal)(:($decimal)?)?$"; then
57 echo "${0##*/}: check_range: invalid range" >&2
62 # check for leading @ char, which negates the range
63 if match
$range '^@'; then
69 # parse the range string
70 if ! match
"$range" ':'; then
78 # do the comparison, taking positive ("") and negative infinity ("~")
80 if [ "$start" != "~" ] && [ "$end" != "" ]; then
81 if cmp "$start <= $v" && cmp "$v <= $end"; then
88 elif [ "$start" != "~" ] && [ "$end" = "" ]; then
89 if cmp "$start <= $v"; then
96 elif [ "$start" = "~" ] && [ "$end" != "" ]; then
97 if cmp "$v <= $end"; then