From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. diff --git a/bin/build-docs b/bin/build-docs new file mode 100755 index 0000000..f3e29c5 --- /dev/null +++ b/bin/build-docs @@ -0,0 +1,84 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' + +prefix='/home/plugins' +repository="$prefix/repositories/nagios-plugins.git" +branch='master' +guidelines="$prefix/web/work/guidelines.html" +man_dir="$prefix/web/work/man" +myself=${0##*/} + +build_plugins() +{ + src_dir=$1 + dst_dir=$2 + + cd "$src_dir" + tools/setup + ./configure --prefix="$dst_dir" + make install + make install-root + cd "$OLDPWD" +} + +build_manpages() +{ + dst_dir=$1 + man_dir=$2 + + find "$man_dir" -name 'check_*.md' -exec rm -f '{}' '+' + find "$dst_dir/libexec" -name 'check_*' | while read plugin_path + do + plugin_name=${plugin_path##*/} + man_file="$man_dir/${plugin_name}.md" + + { + echo "title: $plugin_name" + echo 'parent: Manpages' + echo '---' + echo "# The $plugin_name Plugin" + echo + $plugin_path --help | sed 's/./ &/' + } >"$man_file" + done +} + +if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ] +then + echo "Usage: $myself" + exit 0 +fi + +temp_dir=$(mktemp -d "/tmp/$myself.XXXXXX") +log_file="$temp_dir/log" +exec >"$log_file" 3>&2 2>&1 +trap 'tail -n 25 "$log_file" >&3; rm -rf "$temp_dir"' EXIT +set -x + +src_dir="$temp_dir/src" +dst_dir="$temp_dir/dst" + +git --git-dir="$repository" rev-parse --git-dir >'/dev/null' +git --git-dir="$repository" archive --prefix="$src_dir/" "$branch" | tar -x -P -f - +build_plugins "$src_dir" "$dst_dir" +build_manpages "$dst_dir" "$man_dir" +cp -p "$src_dir/doc/developer-guidelines.html" "$guidelines" + +trap - EXIT +rm -rf "$temp_dir" diff --git a/bin/build-snapshot b/bin/build-snapshot new file mode 100755 index 0000000..18777a5 --- /dev/null +++ b/bin/build-snapshot @@ -0,0 +1,83 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' + +prefix='/home/plugins' +keep_days=2 +snapshot_dir="$prefix/web/download/snapshot" +repository="$prefix/repositories/nagios-plugins.git" +branches=${*:-'maint master pu'} +myself=${0##*/} + +make_dist() +{ + version=$1 + + tools/setup + ./configure + make dist VERSION="$version" +} + +create_snapshot() +{ + branch=$1 + snapshot_dir=$2 + + git checkout --quiet "$branch" + version=$(git describe --abbrev=4 'HEAD' | sed 's/release-//') + tarball="nagios-plugins-$version.tar.gz" + symlink="nagios-plugins-$branch.tar.gz" + make_dist "$version" + cp "$tarball" "$snapshot_dir" + git reset --quiet --hard + git clean --quiet --force -d -x + + cd "$snapshot_dir" + test -e "$tarball.sha1" || shasum -a 1 -b "$tarball" >"$tarball.sha1" + ln -s -f "$tarball" "$symlink" + ln -s -f "$tarball.sha1" "$symlink.sha1" + cd "$OLDPWD" +} + +if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ] +then + echo "Usage: $myself [branch ...]" + exit 0 +fi + +temp_dir=$(mktemp -d "/tmp/$myself.XXXXXX") +log_file="$temp_dir/log" +exec >"$log_file" 3>&2 2>&1 +trap 'tail -n 25 "$log_file" >&3; rm -rf "$temp_dir"' EXIT +set -x + +src_dir="$temp_dir/src" +git clone --quiet --shared "$repository" "$src_dir" +cd "$src_dir" + +for branch in $branches +do + git show-ref --verify "refs/heads/$branch" \ + && create_snapshot "$branch" "$snapshot_dir" +done + +cd "$OLDPWD" +find "$snapshot_dir" -type f -mtime "+$((keep_days - 1))" -exec rm -f '{}' '+' +find "$snapshot_dir" -type l '!' -exec test -e '{}' ';' -exec rm -f '{}' '+' +trap - EXIT +rm -rf "$temp_dir" diff --git a/bin/build-web-site b/bin/build-web-site new file mode 100755 index 0000000..95ac355 --- /dev/null +++ b/bin/build-web-site @@ -0,0 +1,46 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +prefix='/home/plugins' +poole_dir="$prefix/web/generator" +site_source_dir="$prefix/exported/site/web/content" +site_target_dir="$poole_dir/input" +man_source_dir="$prefix/web/work/man" +man_target_dir="$site_target_dir/doc/man" +guidelines_source="$prefix/web/work/guidelines.html" +guidelines_target="$site_target_dir/doc/guidelines.html" + +export PATH="$prefix/src/poole:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin" + +# +# Collect the pieces of the site. +# +rsync -aH --delete "$site_source_dir/" "$site_target_dir" +rsync -aH "$man_source_dir/" "$man_target_dir" +cp -p "$guidelines_source" "$guidelines_target" + +cd "$poole_dir" + +# +# See http://pythonhosted.org/Markdown/extensions/ for documentation on the +# extensions. +# +exec poole.py --build \ + --md-ext='extra' \ + --md-ext='headerid' \ + --md-ext='toc' \ + --md-ext='wikilinks' diff --git a/bin/create-checksum b/bin/create-checksum new file mode 100755 index 0000000..7d6ac1f --- /dev/null +++ b/bin/create-checksum @@ -0,0 +1,36 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -u + +export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' + +create_checksum() +{ + tarball=$1 + + shasum -a 1 -b "$tarball" >"$tarball.sha1" + touch --date="$(stat --format='%y' "$tarball")" "$tarball.sha1" +} + +if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ] +then + echo "Usage: $myself [branch ...]" + exit 0 +fi + +for tarball in "$@" +do + create_checksum "$tarball" +done diff --git a/bin/git-export b/bin/git-export new file mode 100755 index 0000000..fc76081 --- /dev/null +++ b/bin/git-export @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' + +export_prefix='/home/plugins/exported' +export_branch='master' +myself=${0##*/} + +if [ $# -lt 1 ] +then + echo >&2 "Usage: $myself ..." + exit 2 +fi + +for repository in "$@" +do + export_dir="$export_prefix/${repository##*/}" + export_dir=${export_dir%.git} + + cd "$repository" + rm -r -f "$export_dir" + mkdir -p "$export_dir" + git archive "$export_branch" | tar -x -C "$export_dir" -f - + cd "$OLDPWD" +done diff --git a/bin/git-mirror b/bin/git-mirror new file mode 100755 index 0000000..af54a14 --- /dev/null +++ b/bin/git-mirror @@ -0,0 +1,84 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' + +temp_prefix='/run/shm' +fourty_zeros=$(printf '%.40u' 0) +myself=${0##*/} + +check_refs() +{ + turn=$1 + temp_dir=$2 + + git show-ref | while read object ref + do + ref_dir="$temp_dir/${ref%/*}" + ref_file="$temp_dir/$ref" + + if [ $turn -eq 2 -a -f "$ref_file" ] \ + && grep "^1 $object$" "$ref_file" >'/dev/null' + then # The ref has not been modified. + rm -f "$ref_file" + else + mkdir -p "$ref_dir" + echo "$turn $object" >>"$ref_file" + fi + done +} + +if [ $# -lt 1 ] +then + echo >&2 "Usage: $myself ..." + exit 2 +fi + +temp_dir=$(mktemp -d "$temp_prefix/$myself.XXXXXX") +temp_file=$(mktemp "$temp_prefix/$myself.XXXXXX") +trap 'rm -rf "$temp_dir" "$temp_file"' EXIT + +for repository in "$@" +do + hook="$repository/hooks/post-receive" + cd "$repository" + + check_refs 1 "$temp_dir" + if ! git remote update --prune >"$temp_file" 2>&1 + then + cat >&2 "$temp_file" + exit 1 + fi + git fetch --quiet --tags + check_refs 2 "$temp_dir" + + if [ -x "$hook" ] + then + find "$temp_dir" -type 'f' -print | while read ref_file + do + ref=${ref_file#$temp_dir/} + old=$(awk '$1 == "1" { print $2; exit }' "$ref_file") + new=$(awk '$1 == "2" { print $2; exit }' "$ref_file") + old=${old:-$fourty_zeros} + new=${new:-$fourty_zeros} + + echo "$old" "$new" "$ref" + done >"$temp_file" + test -s "$temp_file" && "$hook" <"$temp_file" + fi + cd "$OLDPWD" +done diff --git a/etc/crontab b/etc/crontab new file mode 100644 index 0000000..86bba49 --- /dev/null +++ b/etc/crontab @@ -0,0 +1,7 @@ +# vim:set filetype=crontab: +# +# $HOME/etc/crontab +# +MAILTO=admin@monitoring-plugins.org +# +*/10 * * * * $HOME/bin/git-mirror $HOME/repositories/nagios-*.git diff --git a/etc/forward b/etc/forward new file mode 100644 index 0000000..ece2155 --- /dev/null +++ b/etc/forward @@ -0,0 +1 @@ +admin@monitoring-plugins.org diff --git a/etc/nginx/site.conf b/etc/nginx/site.conf new file mode 100644 index 0000000..8d56aeb --- /dev/null +++ b/etc/nginx/site.conf @@ -0,0 +1,76 @@ +# +# Nginx server configuration for the Nagios Plugins. +# +# See: +# /usr/share/doc/nginx-doc/examples +# +# http://wiki.nginx.org/Pitfalls +# http://wiki.nginx.org/QuickStart +# http://wiki.nginx.org/Configuration +# + +# +# Server definition for . +# +server { + listen 443 ssl; + server_name www.nagios-plugins.org; + root /home/plugins/web/site; + + # + # Downloads and attachments. + # + location ^~ /attachments/ { + root /home/plugins/web; + } + location ^~ /download/ { + root /home/plugins/web; + fancyindex on; + fancyindex_exact_size off; + fancyindex_css_href /media/plugins.css; + } + + # + # Mailman and cgit. + # + location ^~ /cgit { + root /home/git/opt/cgit/web; + } + location ^~ /list/icons/ { + alias /home/mailman/server/icons/; + } + location ~ ^/list/?$ { + return 301 /list/listinfo; + } + location ~ ^/(?:list/|repositories) { + root /home/plugins/web/cgi-bin; + fastcgi_split_path_info ^(/list/[^/]+|/repositories)(.*)$; + fastcgi_pass unix:/var/run/fcgiwrap.socket; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + include /etc/nginx/fastcgi_params; + gzip off; # Scripts have to complete before getting gzipped. + } + + # + # Redirects etc. + # + location = /favicon.ico { + root /home/plugins/web/site/media; + } + location ^~ /snapshot { + return 301 /download$request_uri; + } + location ~ ^/(?:man|guidelines$) { + return 301 /doc$request_uri.html; + } +} + +# +# Redirect HTTP and all other domains to . +# +server { + listen 80 default_server; + listen 443 default_server ssl; + return 301 https://www.nagios-plugins.org$request_uri; +} diff --git a/etc/nginx/ssl.conf b/etc/nginx/ssl.conf new file mode 100644 index 0000000..04f029a --- /dev/null +++ b/etc/nginx/ssl.conf @@ -0,0 +1,6 @@ +# +# Nginx SSL configuration for the Nagios Plugins. +# +ssl_certificate /home/plugins/etc/ssl/nagios-plugins.crt; +ssl_certificate_key /home/plugins/etc/ssl/nagios-plugins.key; +ssl_session_cache shared:SSL:10m; diff --git a/etc/ssl/README b/etc/ssl/README new file mode 100644 index 0000000..c41dc3d --- /dev/null +++ b/etc/ssl/README @@ -0,0 +1,11 @@ +Notes +----- + +- The certificate key file must be readable by the "plugins" group, as Nginx is + run by the "www-adm" user and "www-adm" is in the "plugins" group. + +- The file nagios-plugins.crt includes our certificate, followed by the StartSSL + intermediate¹ certificate, followed by the root² certificate. + +¹ https://www.startssl.com/certs/sub.class1.server.ca.pem +² https://www.startssl.com/certs/ca.pem diff --git a/etc/ssl/nagios-plugins.crt b/etc/ssl/nagios-plugins.crt new file mode 100644 index 0000000..2927083 --- /dev/null +++ b/etc/ssl/nagios-plugins.crt @@ -0,0 +1,122 @@ +-----BEGIN CERTIFICATE----- +MIIHcjCCBlqgAwIBAgIDDBmJMA0GCSqGSIb3DQEBBQUAMIGMMQswCQYDVQQGEwJJ +TDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0 +YWwgQ2VydGlmaWNhdGUgU2lnbmluZzE4MDYGA1UEAxMvU3RhcnRDb20gQ2xhc3Mg +MSBQcmltYXJ5IEludGVybWVkaWF0ZSBTZXJ2ZXIgQ0EwHhcNMTMwOTIzMTgwNjI2 +WhcNMTQwOTI0MTA0MDM1WjB3MRkwFwYDVQQNExA5VUNFV1F4OUM0NTdlNE40MQsw +CQYDVQQGEwJERTEfMB0GA1UEAxMWd3d3Lm5hZ2lvcy1wbHVnaW5zLm9yZzEsMCoG +CSqGSIb3DQEJARYdcG9zdG1hc3RlckBuYWdpb3MtcGx1Z2lucy5vcmcwggIiMA0G +CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDbhm/me2Gy+/mq229mcuxs9TM71h9+ +wpqBcBD79LLU8nTgeNOZlphUmwqFJZKr4TrGCe4Vdh+t3PjcPkjW8wa5B1TCbnNh +70tF4sPKMX+k8rmQUwuscGDofienFGxJF+p2y01NkRgEZQ0ijCJh7POBYcHcWpPs +KRfUOkhRcnelVgwo+xo5OHEN7X4RFbsulhIuC1BnzPH2ycHniBuAd9XCgM/qeYsB +N1WTIW1KUFMeQp/AvR0yKFnYlomBNpEVoKWAgDl4p6qHUsoTTqoFbIPAoXTAMk+Y ++CpfiAGDTBsB8NOZeMc9J10pQPl5euY7Hp3tNP3dLpOieiYVB3P06yq7D87Aints +3Cms43In32H9ON0MqQyS21NT2SoAuM4dZz3dnLP/Nvst7yIrYX4mqRVvz7XjBWC1 +QQtMdOsYFAoayrxqUxcSsMKOXQzJGzNSq2DQZf/vq3BAIRks6UtMHDDdRyMn3pZq +KJG9AEcDNJpRojW3ziiuI9/L4q7NfbejdslqeL0xO/zCf8Xx4dv2lxUDriKR1xEf +xMgv/9ZDgiE03gh6ZEgOZSDS9r7vXmdFiaaxiX8LVTB+YJoSFLQG5cnz6QSwhCG+ +l4SANikOswuHTyFuhCHIr/OP8iz41KfiMPUmjifBYn7e1nb4+NObkkTeua8yqRac +DGJcWmDik2N0MwIDAQABo4IC7zCCAuswCQYDVR0TBAIwADALBgNVHQ8EBAMCA6gw +EwYDVR0lBAwwCgYIKwYBBQUHAwEwHQYDVR0OBBYEFJELwbDKT37MBvvNDH5pdV9W +y8jKMB8GA1UdIwQYMBaAFOtCNNCYsKuf9BtrCPfMZC7vDixFMDUGA1UdEQQuMCyC +Fnd3dy5uYWdpb3MtcGx1Z2lucy5vcmeCEm5hZ2lvcy1wbHVnaW5zLm9yZzCCAVYG +A1UdIASCAU0wggFJMAgGBmeBDAECATCCATsGCysGAQQBgbU3AQIDMIIBKjAuBggr +BgEFBQcCARYiaHR0cDovL3d3dy5zdGFydHNzbC5jb20vcG9saWN5LnBkZjCB9wYI +KwYBBQUHAgIwgeowJxYgU3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkw +AwIBARqBvlRoaXMgY2VydGlmaWNhdGUgd2FzIGlzc3VlZCBhY2NvcmRpbmcgdG8g +dGhlIENsYXNzIDEgVmFsaWRhdGlvbiByZXF1aXJlbWVudHMgb2YgdGhlIFN0YXJ0 +Q29tIENBIHBvbGljeSwgcmVsaWFuY2Ugb25seSBmb3IgdGhlIGludGVuZGVkIHB1 +cnBvc2UgaW4gY29tcGxpYW5jZSBvZiB0aGUgcmVseWluZyBwYXJ0eSBvYmxpZ2F0 +aW9ucy4wNQYDVR0fBC4wLDAqoCigJoYkaHR0cDovL2NybC5zdGFydHNzbC5jb20v +Y3J0MS1jcmwuY3JsMIGOBggrBgEFBQcBAQSBgTB/MDkGCCsGAQUFBzABhi1odHRw +Oi8vb2NzcC5zdGFydHNzbC5jb20vc3ViL2NsYXNzMS9zZXJ2ZXIvY2EwQgYIKwYB +BQUHMAKGNmh0dHA6Ly9haWEuc3RhcnRzc2wuY29tL2NlcnRzL3N1Yi5jbGFzczEu +c2VydmVyLmNhLmNydDAjBgNVHRIEHDAahhhodHRwOi8vd3d3LnN0YXJ0c3NsLmNv +bS8wDQYJKoZIhvcNAQEFBQADggEBAEJHh3WK/lrdGJCMckYogjsNWcmk8QXkEvaD +iaWkA8RQ7mf/sxCgl3LcV39pvyKM++0K2Apq4VsyUM8ZRXylYvdv88A5IO8wjVa9 +rG9Ipe+9hBiWnPNtRqT+SO8QeM+GED4MsnTznyuzwBIiaR72x/rCEadECJfMtrxj +y9GZiOx3mwf6tAeZI4kZzC4lSv2d0/4KgPOmWv++i9EYax6cF/f5Fc00JiXxFtYU +U99vVsJxFQpy4aw2foCoAKcs3vQXCROSmpJtJg/3gGbL89j1cHwAv1LAVEmcX2tD +goE5JcyCzy7cFijtmgrIvXgpePax8d1SCo6tWrkJI0AYcDo0sYs= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIGNDCCBBygAwIBAgIBGDANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJJTDEW +MBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwg +Q2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwHhcNMDcxMDI0MjA1NDE3WhcNMTcxMDI0MjA1NDE3WjCB +jDELMAkGA1UEBhMCSUwxFjAUBgNVBAoTDVN0YXJ0Q29tIEx0ZC4xKzApBgNVBAsT +IlNlY3VyZSBEaWdpdGFsIENlcnRpZmljYXRlIFNpZ25pbmcxODA2BgNVBAMTL1N0 +YXJ0Q29tIENsYXNzIDEgUHJpbWFyeSBJbnRlcm1lZGlhdGUgU2VydmVyIENBMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtonGrO8JUngHrJJj0PREGBiE +gFYfka7hh/oyULTTRwbw5gdfcA4Q9x3AzhA2NIVaD5Ksg8asWFI/ujjo/OenJOJA +pgh2wJJuniptTT9uYSAK21ne0n1jsz5G/vohURjXzTCm7QduO3CHtPn66+6CPAVv +kvek3AowHpNz/gfK11+AnSJYUq4G2ouHI2mw5CrY6oPSvfNx23BaKA+vWjhwRRI/ +ME3NO68X5Q/LoKldSKqxYVDLNM08XMML6BDAjJvwAwNi/rJsPnIO7hxDKslIDlc5 +xDEhyBDBLIf+VJVSH1I8MRKbf+fAoKVZ1eKPPvDVqOHXcDGpxLPPr21TLwb0pwID +AQABo4IBrTCCAakwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYD +VR0OBBYEFOtCNNCYsKuf9BtrCPfMZC7vDixFMB8GA1UdIwQYMBaAFE4L7xqkQFul +F2mHMMo0aEPQQa7yMGYGCCsGAQUFBwEBBFowWDAnBggrBgEFBQcwAYYbaHR0cDov +L29jc3Auc3RhcnRzc2wuY29tL2NhMC0GCCsGAQUFBzAChiFodHRwOi8vd3d3LnN0 +YXJ0c3NsLmNvbS9zZnNjYS5jcnQwWwYDVR0fBFQwUjAnoCWgI4YhaHR0cDovL3d3 +dy5zdGFydHNzbC5jb20vc2ZzY2EuY3JsMCegJaAjhiFodHRwOi8vY3JsLnN0YXJ0 +c3NsLmNvbS9zZnNjYS5jcmwwgYAGA1UdIAR5MHcwdQYLKwYBBAGBtTcBAgEwZjAu +BggrBgEFBQcCARYiaHR0cDovL3d3dy5zdGFydHNzbC5jb20vcG9saWN5LnBkZjA0 +BggrBgEFBQcCARYoaHR0cDovL3d3dy5zdGFydHNzbC5jb20vaW50ZXJtZWRpYXRl +LnBkZjANBgkqhkiG9w0BAQUFAAOCAgEAIQlJPqWIbuALi0jaMU2P91ZXouHTYlfp +tVbzhUV1O+VQHwSL5qBaPucAroXQ+/8gA2TLrQLhxpFy+KNN1t7ozD+hiqLjfDen +xk+PNdb01m4Ge90h2c9W/8swIkn+iQTzheWq8ecf6HWQTd35RvdCNPdFWAwRDYSw +xtpdPvkBnufh2lWVvnQce/xNFE+sflVHfXv0pQ1JHpXo9xLBzP92piVH0PN1Nb6X +t1gW66pceG/sUzCv6gRNzKkC4/C2BBL2MLERPZBOVmTX3DxDX3M570uvh+v2/miI +RHLq0gfGabDBoYvvF0nXYbFFSF87ICHpW7LM9NfpMfULFWE7epTj69m8f5SuauNi +YpaoZHy4h/OZMn6SolK+u/hlz8nyMPyLwcKmltdfieFcNID1j0cHL7SRv7Gifl9L +WtBbnySGBVFaaQNlQ0lxxeBvlDRr9hvYqbBMflPrj0jfyjO1SPo2ShpTpjMM0InN +SRXNiTE8kMBy12VLUjWKRhFEuT2OKGWmPnmeXAhEKa2wNREuIU640ucQPl2Eg7PD +wuTSxv0JS3QJ3fGz0xk+gA2iCxnwOOfFwq/iI9th4p1cbiCJSS4jarJiwUW0n6+L +p/EiO/h94pDQehn7Skzj0n1fSoMD7SfWI55rjbRZotnvbIIp3XUZPD9MEI3vu3Un +0q6Dp6jOW6c= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIHyTCCBbGgAwIBAgIBATANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJJTDEW +MBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwg +Q2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwHhcNMDYwOTE3MTk0NjM2WhcNMzYwOTE3MTk0NjM2WjB9 +MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMi +U2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3Rh +cnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA +A4ICDwAwggIKAoICAQDBiNsJvGxGfHiflXu1M5DycmLWwTYgIiRezul38kMKogZk +pMyONvg45iPwbm2xPN1yo4UcodM9tDMr0y+v/uqwQVlntsQGfQqedIXWeUyAN3rf +OQVSWff0G0ZDpNKFhdLDcfN1YjS6LIp/Ho/u7TTQEceWzVI9ujPW3U3eCztKS5/C +Ji/6tRYccjV3yjxd5srhJosaNnZcAdt0FCX+7bWgiA/deMotHweXMAEtcnn6RtYT +Kqi5pquDSR3l8u/d5AGOGAqPY1MWhWKpDhk6zLVmpsJrdAfkK+F2PrRt2PZE4XNi +HzvEvqBTViVsUQn3qqvKv3b9bZvzndu/PWa8DFaqr5hIlTpL36dYUNk4dalb6kMM +Av+Z6+hsTXBbKWWc3apdzK8BMewM69KN6Oqce+Zu9ydmDBpI125C4z/eIT574Q1w ++2OqqGwaVLRcJXrJosmLFqa7LH4XXgVNWG4SHQHuEhANxjJ/GP/89PrNbpHoNkm+ +Gkhpi8KWTRoSsmkXwQqQ1vp5Iki/untp+HDH+no32NgN0nZPV/+Qt+OR0t3vwmC3 +Zzrd/qqc8NSLf3Iizsafl7b4r4qgEKjZ+xjGtrVcUjyJthkqcwEKDwOzEmDyei+B +26Nu/yYwl/WL3YlXtq09s68rxbd2AvCl1iuahhQqcvbjM4xdCUsT37uMdBNSSwID +AQABo4ICUjCCAk4wDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAa4wHQYDVR0OBBYE +FE4L7xqkQFulF2mHMMo0aEPQQa7yMGQGA1UdHwRdMFswLKAqoCiGJmh0dHA6Ly9j +ZXJ0LnN0YXJ0Y29tLm9yZy9zZnNjYS1jcmwuY3JsMCugKaAnhiVodHRwOi8vY3Js +LnN0YXJ0Y29tLm9yZy9zZnNjYS1jcmwuY3JsMIIBXQYDVR0gBIIBVDCCAVAwggFM +BgsrBgEEAYG1NwEBATCCATswLwYIKwYBBQUHAgEWI2h0dHA6Ly9jZXJ0LnN0YXJ0 +Y29tLm9yZy9wb2xpY3kucGRmMDUGCCsGAQUFBwIBFilodHRwOi8vY2VydC5zdGFy +dGNvbS5vcmcvaW50ZXJtZWRpYXRlLnBkZjCB0AYIKwYBBQUHAgIwgcMwJxYgU3Rh +cnQgQ29tbWVyY2lhbCAoU3RhcnRDb20pIEx0ZC4wAwIBARqBl0xpbWl0ZWQgTGlh +YmlsaXR5LCByZWFkIHRoZSBzZWN0aW9uICpMZWdhbCBMaW1pdGF0aW9ucyogb2Yg +dGhlIFN0YXJ0Q29tIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFBvbGljeSBhdmFp +bGFibGUgYXQgaHR0cDovL2NlcnQuc3RhcnRjb20ub3JnL3BvbGljeS5wZGYwEQYJ +YIZIAYb4QgEBBAQDAgAHMDgGCWCGSAGG+EIBDQQrFilTdGFydENvbSBGcmVlIFNT +TCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOCAgEAFmyZ +9GYMNPXQhV59CuzaEE44HF7fpiUFS5Eyweg78T3dRAlbB0mKKctmArexmvclmAk8 +jhvh3TaHK0u7aNM5Zj2gJsfyOZEdUauCe37Vzlrk4gNXcGmXCPleWKYK34wGmkUW +FjgKXlf2Ysd6AgXmvB618p70qSmD+LIU424oh0TDkBreOKk8rENNZEXO3SipXPJz +ewT4F+irsfMuXGRuczE6Eri8sxHkfY+BUZo7jYn0TZNmezwD7dOaHZrzZVD1oNB1 +ny+v8OqCQ5j4aZyJecRDjkZy42Q2Eq/3JR44iZB3fsNrarnDy0RLrHiQi+fHLB5L +EUTINFInzQpdn4XBidUaePKVEFMy3YCEZnXZtWgo+2EuvoSoOMCZEoalHmdkrQYu +L6lwhceWD3yJZfWOQ1QOq92lgDmUYMA0yZZwLKMS9R9Ie70cfmu3nZD0Ijuu+Pwq +yvqCUqDvr0tVk+vBtfAii6w0TiYiBKGHLHVKt+V9E9e4DGTANtLJL4YSjCMJwRuC +O3NJo2pXh5Tl1njFmUNj403gdy3hZZlyaQQaRwnmDwFWJPsfvw55qVguucQJAX6V +um0ABj6y6koQOdjQK/W/7HW/lwLFCRsI3FU34oH7N4RDYiDK51ZLZer+bMEkkySh +NOsF/5oirpt9P/FlUQqmMGqz9IgcgA38corog14= +-----END CERTIFICATE----- diff --git a/etc/ssl/nagios-plugins.csr b/etc/ssl/nagios-plugins.csr new file mode 100644 index 0000000..40c2f1e --- /dev/null +++ b/etc/ssl/nagios-plugins.csr @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIE5DCCAswCAQAwgZ4xCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzAN +BgNVBAcMBkJlcmxpbjEfMB0GA1UECgwWTmFnaW9zIFBsdWdpbnMgUHJvamVjdDEf +MB0GA1UEAwwWd3d3Lm5hZ2lvcy1wbHVnaW5zLm9yZzErMCkGCSqGSIb3DQEJARYc +d2VibWFzdGVyQG5hZ2lvcy1wbHVnaW5zLm9yZzCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBANuGb+Z7YbL7+arbb2Zy7Gz1MzvWH37CmoFwEPv0stTydOB4 +05mWmFSbCoUlkqvhOsYJ7hV2H63c+Nw+SNbzBrkHVMJuc2HvS0Xiw8oxf6TyuZBT +C6xwYOh+J6cUbEkX6nbLTU2RGARlDSKMImHs84Fhwdxak+wpF9Q6SFFyd6VWDCj7 +Gjk4cQ3tfhEVuy6WEi4LUGfM8fbJweeIG4B31cKAz+p5iwE3VZMhbUpQUx5Cn8C9 +HTIoWdiWiYE2kRWgpYCAOXinqodSyhNOqgVsg8ChdMAyT5j4Kl+IAYNMGwHw05l4 +xz0nXSlA+Xl65jsene00/d0uk6J6JhUHc/TrKrsPzsCKe2zcKazjciffYf043Qyp +DJLbU1PZKgC4zh1nPd2cs/82+y3vIithfiapFW/PteMFYLVBC0x06xgUChrKvGpT +FxKwwo5dDMkbM1KrYNBl/++rcEAhGSzpS0wcMN1HIyfelmookb0ARwM0mlGiNbfO +KK4j38virs19t6N2yWp4vTE7/MJ/xfHh2/aXFQOuIpHXER/EyC//1kOCITTeCHpk +SA5lINL2vu9eZ0WJprGJfwtVMH5gmhIUtAblyfPpBLCEIb6XhIA2KQ6zC4dPIW6E +Iciv84/yLPjUp+Iw9SaOJ8Fift7Wdvj405uSRN65rzKpFpwMYlxaYOKTY3QzAgMB +AAGgADANBgkqhkiG9w0BAQUFAAOCAgEAkWq/1lqCjfY2o6kJpk5SLZ2mSAc9Hx5M +Y2QdxV21RaUGkAhSnjXCkptyeNQhvIBACvh7ASKAshg5yebHmhGiJPNqjsQZlCk4 +bqcHojHg8xKQWDlOV1J/GMf23RLJmySc5G1eoXO+Q8RqGyCnXxiTpjfVPNg4BMmO +aqAROSl7MfXthsG2daGqiqR5JRat++yaRbxhyu37TTukzomR0Fjnn9gUosRYK9qx +bm1fCIoQMb0sjPFezSRF7rGh3I9Bh7pUA5/2RE3AT9J/dhYVe1lDvGZwN/IBQVpc +RkhZLzt8yXJqpxwRKR9qaQwdNt5zE7bPsqCoJmjXeT+/06lR+HVKswz6TKQrDHRN +wcocpJFGEDO5TB33bFCRAtq4IrVyh0v9bHMu7N6iZdGovPaL7b0P5WQp9M1M+zEc +HyaeYDI7WCr5zRZPxkVAEk3GfFUrc3iP90k8UJXblP9jEcVdVjc6LKkIgas/GPES +JaR8YEW0VEq+RWKdvGnijFwHXM4TcmPOkp2u6lyTUe3wwYPrqexu/dzO/wwDCy4v +BSr6Mk9vtxaTi800p7TVayMLshgn7s1xQgv4Z7wcjI+zrIiYLCRTyqVHDE7V68yp +Y+Vh+Ic0tqaXLXZS0QjA+cFTvLza58CVuGpUXEIozBnb/QcQel0jvMMkj8e6Qx9l +CBO22rc02os= +-----END CERTIFICATE REQUEST----- diff --git a/libexec/git-notify b/libexec/git-notify new file mode 100755 index 0000000..8514296 --- /dev/null +++ b/libexec/git-notify @@ -0,0 +1,676 @@ +#!/usr/bin/perl -w +# +# Tool to send git commit notifications +# +# Copyright 2005 Alexandre Julliard +# Copyright 2009 Nagios Plugins Development Team +# +# 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 2 of +# the License, or (at your option) any later version. +# +# +# This script is meant to be called from .git/hooks/post-receive. +# +# Usage: git-notify [options] [--] old-sha1 new-sha1 refname +# +# -A Omit the author name from the mail subject +# -C Show committer in the body if different from the author +# -c name Send CIA notifications under specified project name +# -m addr Send mail notifications to specified address +# -n max Set max number of individual mails to send +# -r name Set the git repository name +# -S Enable compatibility with SourceForge's gitweb URLs +# -s bytes Set the maximum diff size in bytes (-1 for no limit) +# -T Prefix the mail subject with a [repository name] tag +# -t file Prevent duplicate notifications by saving state to this file +# -U mask Set the umask for creating the state file +# -u url Set the URL to the gitweb browser +# -i branch If at least one -i is given, report only for specified branches +# -x branch Exclude changes to the specified branch from reports +# -X Exclude merge commits +# -z Try to abbreviate the SHA1 name within gitweb URLs (unsafe) +# + +use strict; +use Fcntl ':flock'; +use Encode qw(encode decode); +use Cwd 'realpath'; + +sub git_config($); +sub get_repos_name(); + +# some parameters you may want to change + +# sendmail's pathname +my $sendmail = "/usr/sbin/sendmail"; + +# CIA notification address +my $cia_address = "cia\@cia.vc"; + +# debug mode +my $debug = 0; + +# configuration parameters + +# omit the author from the mail subject (can be set with the -A option) +my $omit_author = git_config( "notify.omitauthor" ); + +# prefix the mail subject with a [repository name] tag (can be set with the -T option) +my $emit_repo = git_config( "notify.emitrepository" ); + +# show the committer if different from the author (can be set with the -C option) +my $show_committer = git_config( "notify.showcommitter" ); + +# base URL of the gitweb repository browser (can be set with the -u option) +my $gitweb_url = git_config( "notify.baseurl" ); + +# abbreviate the SHA1 name within gitweb URLs (can be set with the -z option) +my $abbreviate_url = git_config( "notify.shorturls" ); + +# don't report merge commits (can be set with the -X option) +my $ignore_merges = git_config( "notify.ignoremerges" ); + +# enable compatibility with SourceForge's gitweb (can be set with the -S option) +my $sourceforge = git_config( "notify.sourceforge" ); + +# default repository name (can be changed with the -r option) +my $repos_name = git_config( "notify.repository" ) || get_repos_name(); + +# max size of diffs in bytes (can be changed with the -s option) +my $max_diff_size = git_config( "notify.maxdiff" ) || 10000; + +# address for mail notices (can be set with -m option) +my $commitlist_address = git_config( "notify.mail" ); + +# project name for CIA notices (can be set with -c option) +my $cia_project_name = git_config( "notify.cia" ); + +# max number of individual notices before falling back to a single global notice (can be set with -n option) +my $max_individual_notices = git_config( "notify.maxnotices" ) || 100; + +# branches to include +my @include_list = split /\s+/, git_config( "notify.include" ) || ""; + +# branches to exclude +my @exclude_list = split /\s+/, git_config( "notify.exclude" ) || ""; + +# the state file we use (can be set with the -t option) +my $state_file = git_config( "notify.statefile" ); + +# umask for creating the state file (can be set with -U option) +my $mode_mask = git_config( "notify.umask" ) || 002; + +sub usage() +{ + print "Usage: $0 [options] [--] old-sha1 new-sha1 refname\n"; + print " -A Omit the author name from the mail subject\n"; + print " -C Show committer in the body if different from the author\n"; + print " -c name Send CIA notifications under specified project name\n"; + print " -m addr Send mail notifications to specified address\n"; + print " -n max Set max number of individual mails to send\n"; + print " -r name Set the git repository name\n"; + print " -S Enable compatibility with SourceForge's gitweb URLs\n"; + print " -s bytes Set the maximum diff size in bytes (-1 for no limit)\n"; + print " -T Prefix the mail subject with a [repository name] tag\n"; + print " -t file Prevent duplicate notifications by saving state to this file\n"; + print " -U mask Set the umask for creating the state file\n"; + print " -u url Set the URL to the gitweb browser\n"; + print " -i branch If at least one -i is given, report only for specified branches\n"; + print " -x branch Exclude changes to the specified branch from reports\n"; + print " -X Exclude merge commits\n"; + print " -z Try to abbreviate the SHA1 name within gitweb URLs (unsafe)\n"; + exit 1; +} + +sub xml_escape($) +{ + my $str = shift; + $str =~ s/&/&/g; + $str =~ s//>/g; + my @chars = unpack "U*", $str; + $str = join "", map { ($_ > 127) ? sprintf "&#%u;", $_ : chr($_); } @chars; + return $str; +} + +# execute git-rev-list(1) with the given parameters and return the output +sub git_rev_list(@) +{ + my @args = @_; + my $revlist = []; + my $pid = open REVLIST, "-|"; + + die "Cannot open pipe: $!" if not defined $pid; + if (!$pid) + { + exec "git", "rev-list", "--reverse", @args or die "Cannot execute rev-list: $!"; + } + while () + { + chomp; + unless (grep {$_ eq "--pretty"} @args) + { + die "Invalid commit: $_" if not /^[0-9a-f]{40}$/; + } + push @$revlist, $_; + } + close REVLIST or die $! ? "Cannot execute rev-list: $!" : "rev-list exited with status: $?"; + return $revlist; +} + +# append the given commit hashes to the state file +sub save_commits($) +{ + my $commits = shift; + + open STATE, ">>", $state_file or die "Cannot open $state_file: $!"; + flock STATE, LOCK_EX or die "Cannot lock $state_file"; + print STATE "$_\n" for @$commits; + flock STATE, LOCK_UN or die "Cannot unlock $state_file"; + close STATE or die "Cannot close $state_file: $!"; +} + +# for the given range, return the new hashes (and append them to the state file) +sub get_new_commits($$) +{ + my ($old_sha1, $new_sha1) = @_; + my ($seen, @args); + my $newrevs = []; + + @args = ( "^$old_sha1" ) unless $old_sha1 eq '0' x 40; + push @args, $new_sha1, @exclude_list; + unshift @args, "--no-merges" if $ignore_merges; + + my $revlist = git_rev_list(@args); + + if (not defined $state_file or not -e $state_file) + { + save_commits(git_rev_list("--all", "--full-history")) if defined $state_file; + return $revlist; + } + + open STATE, $state_file or die "Cannot open $state_file: $!"; + flock STATE, LOCK_SH or die "Cannot lock $state_file"; + while () + { + chomp; + die "Invalid commit: $_" if not /^[0-9a-f]{40}$/; + $seen->{$_} = 1; + } + flock STATE, LOCK_UN or die "Cannot unlock $state_file"; + close STATE or die "Cannot close $state_file: $!"; + + # FIXME: if another git-notify process reads the $state_file at *this* + # point, that process might generate duplicates of our notifications. + + save_commits($revlist); + + foreach my $commit (@$revlist) + { + push @$newrevs, $commit unless $seen->{$commit}; + } + return $newrevs; +} + +# truncate the given string if it exceeds the specified number of characters +sub truncate_str($$) +{ + my ($str, $max) = @_; + + if (length($str) > $max) + { + $str = substr($str, 0, $max); + $str =~ s/\s+\S+$//; + $str .= " ..."; + } + return $str; +} + +# right-justify the left column of "left: right" elements, omit undefined elements +sub format_table(@) +{ + my @lines = @_; + my @table; + my $max = 0; + + foreach my $line (@lines) + { + next if not defined $line; + my $pos = index($line, ":"); + + $max = $pos if $pos > $max; + } + + foreach my $line (@lines) + { + next if not defined $line; + my ($left, $right) = split(/: */, $line, 2); + + push @table, (defined $left and defined $right) + ? sprintf("%*s: %s", $max + 1, $left, $right) + : $line; + } + return @table; +} + +# format an integer date + timezone as string +# algorithm taken from git's date.c +sub format_date($$) +{ + my ($time,$tz) = @_; + + if ($tz < 0) + { + my $minutes = (-$tz / 100) * 60 + (-$tz % 100); + $time -= $minutes * 60; + } + else + { + my $minutes = ($tz / 100) * 60 + ($tz % 100); + $time += $minutes * 60; + } + return gmtime($time) . sprintf " %+05d", $tz; +} + +# fetch a parameter from the git config file +sub git_config($) +{ + my ($param) = @_; + + open CONFIG, "-|" or exec "git", "config", $param; + my $ret = ; + chomp $ret if $ret; + close CONFIG or $ret = undef; + return $ret; +} + +# parse command line options +sub parse_options() +{ + while (@ARGV && $ARGV[0] =~ /^-/) + { + my $arg = shift @ARGV; + + if ($arg eq '--') { last; } + elsif ($arg eq '-A') { $omit_author = 1; } + elsif ($arg eq '-C') { $show_committer = 1; } + elsif ($arg eq '-c') { $cia_project_name = shift @ARGV; } + elsif ($arg eq '-m') { $commitlist_address = shift @ARGV; } + elsif ($arg eq '-n') { $max_individual_notices = shift @ARGV; } + elsif ($arg eq '-r') { $repos_name = shift @ARGV; } + elsif ($arg eq '-S') { $sourceforge = 1; } + elsif ($arg eq '-s') { $max_diff_size = shift @ARGV; } + elsif ($arg eq '-T') { $emit_repo = 1; } + elsif ($arg eq '-t') { $state_file = shift @ARGV; } + elsif ($arg eq '-U') { $mode_mask = shift @ARGV; } + elsif ($arg eq '-u') { $gitweb_url = shift @ARGV; } + elsif ($arg eq '-i') { push @include_list, shift @ARGV; } + elsif ($arg eq '-X') { $ignore_merges = 1; } + elsif ($arg eq '-x') { push @exclude_list, shift @ARGV; } + elsif ($arg eq '-z') { $abbreviate_url = 1; } + elsif ($arg eq '-d') { $debug++; } + else { usage(); } + } + if (@ARGV && $#ARGV != 2) { usage(); } + @exclude_list = map { "^$_"; } @exclude_list; +} + +# send an email notification +sub mail_notification($$$@) +{ + my ($name, $subject, $content_type, @text) = @_; + + $subject = "[$repos_name] $subject" if ($emit_repo and $name ne $cia_address); + $subject = encode("MIME-Q",$subject); + + my @header = ("To: $name", "Subject: $subject", "Content-Type: $content_type"); + + if ($debug) + { + binmode STDOUT, ":utf8"; + print "---------------------\n"; + print join("\n", @header), "\n\n", join("\n", @text), "\n"; + } + else + { + my $pid = open MAIL, "|-"; + return unless defined $pid; + if (!$pid) + { + exec $sendmail, "-t", "-oi", "-oem" or die "Cannot exec $sendmail"; + } + binmode MAIL, ":utf8"; + print MAIL join("\n", @header), "\n\n", join("\n", @text), "\n"; + close MAIL or warn $! ? "Cannot execute $sendmail: $!" : "$sendmail exited with status: $?"; + } +} + +# get the default repository name +sub get_repos_name() +{ + my $dir = `git rev-parse --git-dir`; + chomp $dir; + my $repos = realpath($dir); + $repos =~ s/(.*?)((\.git\/)?\.git)$/$1/; + $repos =~ s/(.*)\/([^\/]+)\/?$/$2/; + return $repos; +} + +# return the type of the given object +sub get_object_type($) +{ + my $obj = shift; + + open TYPE, "-|" or exec "git", "cat-file", "-t", $obj or die "cannot run git-cat-file"; + my $type = ; + chomp $type; + close TYPE or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?"; + return $type; +} + +# extract the information from a commit or tag object and return a hash containing the various fields +sub get_object_info($) +{ + my $obj = shift; + my %info = (); + my @log = (); + my $do_log = 0; + + $info{"encoding"} = "utf-8"; + + my $type = get_object_type($obj); + + open OBJ, "-|" or exec "git", "cat-file", $type, $obj or die "cannot run git-cat-file"; + while () + { + chomp; + if ($do_log) + { + last if /^-----BEGIN PGP SIGNATURE-----/; + push @log, $_; + } + elsif (/^(author|committer|tagger) ((.*) (<.*>)) (\d+) ([+-]\d+)$/) + { + $info{$1} = $2; + $info{$1 . "_name"} = $3; + $info{$1 . "_email"} = $4; + $info{$1 . "_date"} = $5; + $info{$1 . "_tz"} = $6; + } + elsif (/^tag (.+)/) + { + $info{"tag"} = $1; + } + elsif (/^encoding (.+)/) + { + $info{"encoding"} = $1; + } + elsif (/^$/) { $do_log = 1; } + } + close OBJ or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?"; + + $info{"type"} = $type; + $info{"log"} = \@log; + return %info; +} + +# send a ref change notice to a mailing list +sub send_ref_notice($$@) +{ + my ($ref, $action, @notice) = @_; + my ($reftype, $refname) = ($ref =~ /^refs\/(head|tag)s\/(.+)/); + + $reftype =~ s/^head$/branch/; + + @notice = (format_table( + "Module: $repos_name", + ($reftype eq "tag" ? "Tag:" : "Branch:") . $refname, + @notice, + ($action ne "removed" and $gitweb_url) + ? "URL: ${gitweb_url}a=shortlog;h=$ref" : undef), + "", + "The $refname $reftype has been $action."); + + mail_notification($commitlist_address, "$refname $reftype $action", + "text/plain; charset=us-ascii", @notice); +} + +# send a commit notice to a mailing list +sub send_commit_notice($$) +{ + my ($ref,$obj) = @_; + my %info = get_object_info($obj); + my @notice = (); + my ($url,$subject,$obj_string); + + if ($gitweb_url) + { + if ($abbreviate_url) + { + open REVPARSE, "-|" or exec "git", "rev-parse", "--short", $obj or die "cannot exec git-rev-parse"; + $obj_string = ; + chomp $obj_string if defined $obj_string; + close REVPARSE or die $! ? "Cannot execute rev-parse: $!" : "rev-parse exited with status: $?"; + } + $obj_string = $obj if not defined $obj_string; + $url = "${gitweb_url}a=$info{type};h=$obj_string"; + } + + if ($info{"type"} eq "tag") + { + push @notice, format_table( + "Module: $repos_name", + "Tag: $ref", + "SHA1: $obj", + "Tagger:" . $info{"tagger"}, + "Date:" . format_date($info{"tagger_date"},$info{"tagger_tz"}), + $url ? "URL: $url" : undef), + "", + join "\n", @{$info{"log"}}; + + $subject = "Tag " . $info{"tag"} . ": "; + $subject .= $info{"tagger_name"} . ": " unless $omit_author; + } + else + { + push @notice, format_table( + "Module: $repos_name", + "Branch: $ref", + "Commit: $obj", + "Author:" . $info{"author"}, + $show_committer && $info{"committer"} ne $info{"author"} ? "Committer:" . $info{"committer"} : undef, + "Date:" . format_date($info{"author_date"},$info{"author_tz"}), + $url ? "URL: $url" : undef), + "", + @{$info{"log"}}, + "", + "---", + ""; + + open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree"; + push @notice, join("", ); + close STAT or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?"; + + open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree"; + my $diff = join("", ); + close DIFF or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?"; + + if (($max_diff_size == -1) || (length($diff) < $max_diff_size)) + { + push @notice, $diff; + } + else + { + push @notice, "Diff: ${gitweb_url}a=commitdiff;h=$obj_string" if $gitweb_url; + } + $subject = $info{"author_name"} . ": " unless $omit_author; + } + + $subject .= truncate_str(${$info{"log"}}[0],50); + $_ = decode($info{"encoding"}, $_) for @notice; + mail_notification($commitlist_address, $subject, "text/plain; charset=UTF-8", @notice); +} + +# send a commit notice to the CIA server +sub send_cia_notice($$) +{ + my ($ref,$commit) = @_; + my %info = get_object_info($commit); + my @cia_text = (); + + return if $info{"type"} ne "commit"; + + push @cia_text, + "", + " ", + " git-notify script for CIA", + " ", + " ", + " " . xml_escape($cia_project_name) . "", + " " . xml_escape($repos_name) . "", + " " . xml_escape($ref). "", + " ", + " ", + " ", + " " . substr($commit,0,10) . "", + " " . xml_escape($info{"author"}) . "", + " " . xml_escape(join "\n", @{$info{"log"}}) . "", + " "; + + open COMMIT, "-|" or exec "git", "diff-tree", "--name-status", "-r", "-M", $commit or die "cannot run git-diff-tree"; + while () + { + chomp; + if (/^([AMD])\t(.*)$/) + { + my ($action, $file) = ($1, $2); + my %actions = ( "A" => "add", "M" => "modify", "D" => "remove" ); + next unless defined $actions{$action}; + push @cia_text, " " . xml_escape($file) . ""; + } + elsif (/^R\d+\t(.*)\t(.*)$/) + { + my ($old, $new) = ($1, $2); + push @cia_text, " " . xml_escape($old) . ""; + } + } + close COMMIT or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?"; + + push @cia_text, + " ", + $gitweb_url ? " " . xml_escape("${gitweb_url}a=commit;h=$commit") . "" : "", + " ", + " ", + " " . $info{"author_date"} . "", + ""; + + mail_notification($cia_address, "DeliverXML", "text/xml", @cia_text); +} + +# send a global commit notice when there are too many commits for individual mails +sub send_global_notice($$$) +{ + my ($ref, $old_sha1, $new_sha1) = @_; + my $notice = git_rev_list("--pretty", "^$old_sha1", "$new_sha1", @exclude_list); + + foreach my $rev (@$notice) + { + $rev =~ s/^commit /URL: ${gitweb_url}a=commit;h=/ if $gitweb_url; + } + + mail_notification($commitlist_address, "New commits on branch $ref", "text/plain; charset=UTF-8", @$notice); +} + +# send all the notices +sub send_all_notices($$$) +{ + my ($old_sha1, $new_sha1, $ref) = @_; + my ($reftype, $refname, $tagtype, $action, @notice); + + return if ($ref =~ /^refs\/remotes\// + or (@include_list && !grep {$_ eq $ref} @include_list)); + die "The name \"$ref\" doesn't sound like a local branch or tag" + if not (($reftype, $refname) = ($ref =~ /^refs\/(head|tag)s\/(.+)/)); + + if ($reftype eq "tag") + { + $tagtype = get_object_type($ref) eq "tag" ? "annotated" : "lightweight"; + } + + if ($new_sha1 eq '0' x 40) + { + $action = "removed"; + @notice = ( "Old SHA1: $old_sha1" ); + } + elsif ($old_sha1 eq '0' x 40) + { + if ($reftype eq "tag" and $tagtype eq "annotated") + { + send_commit_notice( $refname, $new_sha1 ) if $commitlist_address; + return; + } + $action = "created"; + @notice = ( "SHA1: $new_sha1" ); + } + elsif ($reftype eq "tag") + { + $action = "updated"; + @notice = ( "Old SHA1: $old_sha1", "New SHA1: $new_sha1" ); + } + elsif (not grep( $_ eq $old_sha1, @{ git_rev_list( $new_sha1, "--full-history" ) } )) + { + $action = "rewritten"; + @notice = ( "Old SHA1: $old_sha1", "New SHA1: $new_sha1" ); + } + + send_ref_notice( $ref, $action, @notice ) if ($commitlist_address and $action); + + unless ($reftype eq "tag" or $new_sha1 eq '0' x 40) + { + my $commits = get_new_commits ( $old_sha1, $new_sha1 ); + + if (@$commits > $max_individual_notices) + { + send_global_notice( $refname, $old_sha1, $new_sha1 ) if $commitlist_address; + } + elsif (@$commits > 0) + { + foreach my $commit (@$commits) + { + send_commit_notice( $refname, $commit ) if $commitlist_address; + send_cia_notice( $refname, $commit ) if $cia_project_name; + } + } + elsif ($commitlist_address) + { + @notice = ( "Old SHA1: $old_sha1", "New SHA1: $new_sha1" ); + send_ref_notice( $ref, "modified", @notice ); + } + } +} + +parse_options(); + +umask( $mode_mask ); + +# append repository path to URL +if ($gitweb_url) { + $gitweb_url .= $sourceforge ? "/$repos_name;" : "/$repos_name.git/?"; +} + +if (@ARGV) +{ + send_all_notices( $ARGV[0], $ARGV[1], $ARGV[2] ); +} +else # read them from stdin +{ + while (<>) + { + chomp; + if (/^([0-9a-f]{40}) ([0-9a-f]{40}) (.*)$/) { send_all_notices( $1, $2, $3 ); } + } +} + +exit 0; diff --git a/libexec/plugins-hook b/libexec/plugins-hook new file mode 100755 index 0000000..c2cce60 --- /dev/null +++ b/libexec/plugins-hook @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -u + +export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' + +hook_name=${0##*/} +hook_directory="/home/plugins/libexec/$hook_name.d" + +if [ -d "$hook_directory" ] +then + stdin_file=$(mktemp "/tmp/.$hook_name.XXXXXX") + trap 'rm -f "$stdin_file"' EXIT + test "${hook_name##*-}" = 'receive' && cat > "$stdin_file" + + for file in $(find -L "$hook_directory/." ! -name '.' -prune \ + -type 'f' -perm -'+x' | sort) + do + "$file" "$@" < "$stdin_file" + status=$? + test "$status" -ne 0 && return_value=$status + done +fi + +exit ${return_value:-0} diff --git a/libexec/post-receive.d/01-git-export b/libexec/post-receive.d/01-git-export new file mode 100755 index 0000000..e16574c --- /dev/null +++ b/libexec/post-receive.d/01-git-export @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +prefix='/home/plugins' + +exec "$prefix/bin/git-export" "$PWD" diff --git a/libexec/post-receive.d/01-mail-notify b/libexec/post-receive.d/01-mail-notify new file mode 100755 index 0000000..d5e8b84 --- /dev/null +++ b/libexec/post-receive.d/01-mail-notify @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +test "${PWD##*/}" = 'site.git' && exit 0 # Don't report site.git updates. + +prefix=$PWD # $GIT_DIR +recipient='nagiosplug-checkins@lists.sourceforge.net' +maxcommits=25 +maxdiffsize=$((300 * 1024)) +gitweburl="FIXME" +gitnotify='/home/plugins/libexec/git-notify' +statedir="$prefix/info" +statefile="$statedir/git-notify.dat" + +test -n "$recipient" || exit 0 + +exec "$gitnotify" \ + -m "$recipient" \ + -n "$maxcommits" \ + -s "$maxdiffsize" \ + -t "$statefile" \ + -A \ + -C \ + -T \ + -z diff --git a/libexec/post-receive.d/02-build-snapshots b/libexec/post-receive.d/02-build-snapshots new file mode 100755 index 0000000..ed8ef77 --- /dev/null +++ b/libexec/post-receive.d/02-build-snapshots @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +prefix='/home/plugins' +repository=${PWD##*/} +snapshot_repository='nagios-plugins.git' +snapshot_branches='maint master pu' + +if [ "$repository" = "$snapshot_repository" ] +then + while read old new ref + do + ref=${ref#refs/heads/} + + for head in $snapshot_branches + do + test "$ref" = "$head" \ + && exec "$prefix/bin/build-snapshot" "$ref" + done + done +fi diff --git a/libexec/post-receive.d/03-build-docs b/libexec/post-receive.d/03-build-docs new file mode 100755 index 0000000..1fd7819 --- /dev/null +++ b/libexec/post-receive.d/03-build-docs @@ -0,0 +1,30 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +prefix='/home/plugins' +repository=${PWD##*/} +doc_repository='nagios-plugins.git' +doc_branch='master' + +if [ "$repository" = "$doc_repository" ] +then + while read old new ref + do + test "${ref#refs/heads/}" = "$doc_branch" \ + && exec "$prefix/bin/build-docs" + done +fi diff --git a/libexec/post-receive.d/04-build-web-site b/libexec/post-receive.d/04-build-web-site new file mode 100755 index 0000000..68a439c --- /dev/null +++ b/libexec/post-receive.d/04-build-web-site @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +prefix='/home/plugins' +repository=${PWD##*/} +web_repositories='nagios-plugins.git site.git' +web_branch='master' + +for web_repository in $web_repositories +do + if [ "$repository" = "$web_repository" ] + then + while read old new ref + do + test "${ref#refs/heads/}" = "$web_branch" \ + && exec "$prefix/bin/build-web-site" >'/dev/null' + done + fi +done diff --git a/web/attachments/101025-check_ntp.patch b/web/attachments/101025-check_ntp.patch new file mode 100644 index 0000000..373d521 --- /dev/null +++ b/web/attachments/101025-check_ntp.patch @@ -0,0 +1,40 @@ +Index: check_ntp.pl +=================================================================== +RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-scripts/check_ntp.pl,v +retrieving revision 1.19 +diff -u -w -r1.19 check_ntp.pl +--- check_ntp.pl 14 Oct 2003 02:40:31 -0000 1.19 ++++ check_ntp.pl 10 Sep 2004 15:01:45 -0000 +@@ -358,13 +358,13 @@ + } elsif( !$have_ntpq ) { # no errors from ntpdate and no ntpq or ntpq timed out + if (abs($offset) > $ocrit) { + $state = $ERRORS{'CRITICAL'}; +- $answer = "Offset $offset msec > +/- $ocrit sec\n"; ++ $answer = "Offset $offset sec > +/- $ocrit sec\n"; + } elsif (abs($offset) > $owarn) { + $state = $ERRORS{'WARNING'}; +- $answer = "Offset $offset msec > +/- $owarn sec\n"; ++ $answer = "Offset $offset sec > +/- $owarn sec\n"; + } elsif (( abs($offset) > $owarn) && $def_jitter ) { + $state = $ERRORS{'WARNING'}; +- $answer = "Offset $offset msec > +/- $owarn sec, ntpq timed out\n"; ++ $answer = "Offset $offset sec > +/- $owarn sec, ntpq timed out\n"; + } elsif ( $def_jitter ) { + $state = $ERRORS{'WARNING'}; + $answer = "Offset $offset secs, ntpq timed out\n"; +@@ -378,13 +378,13 @@ + } else { # no errors from ntpdate or ntpq + if (abs($offset) > $ocrit) { + $state = $ERRORS{'CRITICAL'}; +- $answer = "Offset $offset msec > +/- $ocrit sec, jitter $jitter msec\n"; ++ $answer = "Offset $offset sec > +/- $ocrit sec, jitter $jitter msec\n"; + } elsif (abs($jitter) > $jcrit ) { + $state = $ERRORS{'CRITICAL'}; + $answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset sec \n"; + } elsif (abs($offset) > $owarn) { + $state = $ERRORS{'WARNING'}; +- $answer = "Offset $offset msec > +/- $owarn sec, jitter $jitter msec\n"; ++ $answer = "Offset $offset sec > +/- $owarn sec, jitter $jitter msec\n"; + } elsif (abs($jitter) > $jwarn ) { + $state = $ERRORS{'WARNING'}; + $answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset sec \n"; diff --git a/web/attachments/101069-check_swap.diff.txt b/web/attachments/101069-check_swap.diff.txt new file mode 100644 index 0000000..24cfdad --- /dev/null +++ b/web/attachments/101069-check_swap.diff.txt @@ -0,0 +1,18 @@ +49c49 +< char tmp_status[MAX_INPUT_BUFFER]; +--- +> +197c197 +< printf (_("total=%llu, free=%llu\n"), dsktotal, +dskfree); +--- +> printf (_("total=%d, free=%d\n"), dsktotal, dskf +ree); +314,315c314,315 +< sprintf (tmp_status, _(" %d%% free (%llu MB out of %llu MB)"), +< (100 - percent_used), free_swap, + total_swap); +--- +> asprintf (&tmp_status, _(" %d%% free (%llu MB out of %llu MB)"), +> (100 - percent_used), free_swap, + total_swap); diff --git a/web/attachments/101436-check_oracle b/web/attachments/101436-check_oracle new file mode 100644 index 0000000..16fb473 --- /dev/null +++ b/web/attachments/101436-check_oracle @@ -0,0 +1,284 @@ +#! /bin/bash +# +# latigid010@yahoo.com +# 01/06/2000 +# +# This Nagios plugin was created to check Oracle status +# + +PROGNAME=`basename $0` +PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` +REVISION=`echo '$Revision: 1.12 $' | sed -e 's/[^0-9.]//g'` + +. $PROGPATH/utils.sh + + +print_usage() { + echo "Usage:" + echo " $PROGNAME --tns " + echo " $PROGNAME --db " + echo " $PROGNAME --login " + echo " $PROGNAME --cache " + echo " $PROGNAME --tablespace " + echo " $PROGNAME --oranames " + echo " $PROGNAME --help" + echo " $PROGNAME --version" +} + +print_help() { + print_revision $PROGNAME $REVISION + echo "" + print_usage + echo "" + echo "Check Oracle status" + echo "" + echo "--tns SID/IP Address" + echo " Check remote TNS server" + echo "--db SID" + echo " Check local database (search /bin/ps for PMON process) and check" + echo " filesystem for sgadefORACLE_SID.dbf" + echo "--login SID" + echo " Attempt a dummy login and alert if not ORA-01017: invalid username/password" + echo "--cache" + echo " Check local database for library and buffer cache hit ratios" + echo " ---> Requires Oracle user/password and SID specified." + echo " ---> Requires select on v_$sysstat and v_$librarycache" + echo "--tablespace" + echo " Check local database for tablespace capacity in ORACLE_SID" + echo " ---> Requires Oracle user/password specified." + echo " ---> Requires select on dba_data_files and dba_free_space" + echo "--oranames Hostname" + echo " Check remote Oracle Names server" + echo "--help" + echo " Print this help screen" + echo "--version" + echo " Print version and license information" + echo "" + echo "If the plugin doesn't work, check that the ORACLE_HOME environment" + echo "variable is set, that ORACLE_HOME/bin is in your PATH, and the" + echo "tnsnames.ora file is locatable and is properly configured." + echo "" + echo "When checking local database status your ORACLE_SID is case sensitive." + echo "" + echo "If you want to use a default Oracle home, add in your oratab file:" + echo "*:/opt/app/oracle/product/7.3.4:N" + echo "" + support +} + +case "$1" in +1) + cmd='--tns' + ;; +2) + cmd='--db' + ;; +*) + cmd="$1" + ;; +esac + +# Information options +case "$cmd" in +--help) + print_help + exit $STATE_OK + ;; +-h) + print_help + exit $STATE_OK + ;; +--version) + print_revision $PLUGIN $REVISION + exit $STATE_OK + ;; +-V) + print_revision $PLUGIN $REVISION + exit $STATE_OK + ;; +esac + +# Hunt down a reasonable ORACLE_HOME +if [ -z "$ORACLE_HOME" ] ; then + # Adjust to taste + for oratab in /var/opt/oracle/oratab /etc/oratab + do + [ ! -f $oratab ] && continue + ORACLE_HOME=`IFS=: + while read SID ORACLE_HOME junk; + do + if [ "$SID" = "$2" -o "$SID" = "*" ] ; then + echo $ORACLE_HOME; + exit; + fi; + done < $oratab` + [ -n "$ORACLE_HOME" ] && break + done +fi +# Last resort +[ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle + +if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then + echo "Cannot determine ORACLE_HOME for sid $2" + exit $STATE_UNKNOWN +fi +PATH=$PATH:$ORACLE_HOME/bin +LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib +export ORACLE_HOME PATH LD_LIBRARY_PATH + +case "$cmd" in +--tns) + tnschk=` tnsping $2` + tnschk2=` echo $tnschk | grep -c OK` + if [ ${tnschk2} -eq 1 ] ; then + tnschk3=` echo $tnschk | sed -e 's/.*(//' -e 's/).*//'` + echo "OK - reply time ${tnschk3} from $2" + exit $STATE_OK + else + echo "No TNS Listener on $2" + exit $STATE_CRITICAL + fi + ;; +--oranames) + namesctl status $2 | awk ' + /Server has been running for:/ { + msg = "OK: Up" + for (i = 6; i <= NF; i++) { + msg = msg " " $i + } + status = '$STATE_OK' + } + /error/ { + msg = "CRITICAL: " $0 + status = '$STATE_CRITICAL' + } + END { + print msg + exit status + }' + ;; +--db) + pmonchk=`ps -ef | grep -v grep | grep ${2} | grep -c pmon` + if [ ${pmonchk} -ge 1 ] ; then + echo "${2} OK - ${pmonchk} PMON process(es) running" + exit $STATE_OK + #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then + #if [ ${pmonchk} -eq 1 ] ; then + #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` + #echo "${2} OK - running since ${utime}" + #exit $STATE_OK + #fi + else + echo "${2} Database is DOWN" + exit $STATE_CRITICAL + fi + ;; +--login) + loginchk=`sqlplus dummy/user@$2 < /dev/null` + loginchk2=` echo $loginchk | grep -c ORA-01017` + if [ ${loginchk2} -eq 1 ] ; then + echo "OK - dummy login connected" + exit $STATE_OK + else + loginchk3=` echo "$loginchk" | grep "ORA-" | head -1` + echo "CRITICAL - $loginchk3" + exit $STATE_CRITICAL + fi + ;; +--cache) + if [ ${5} -gt ${6} ] ; then + echo "UNKNOWN - Warning level is less then Crit" + exit $STATE_UNKNOWN + fi + result=`sqlplus -s ${3}/${4}@${2} << EOF +set pagesize 0 +set numf '9999999.99' +select (1-(pr.value/(dbg.value+cg.value)))*100 +from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg +where pr.name='physical reads' +and dbg.name='db block gets' +and cg.name='consistent gets'; +EOF` + + if [ -n "`echo $result | grep ORA-`" ] ; then + error=` echo "$result" | grep "ORA-" | head -1` + echo "CRITICAL - $error" + exit $STATE_CRITICAL + fi + + buf_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` + buf_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` + result=`sqlplus -s ${3}/${4}@${2} << EOF +set pagesize 0 +set numf '9999999.99' +select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 +from v\\$librarycache lc; +EOF` + + if [ -n "`echo $result | grep ORA-`" ] ; then + error=` echo "$result" | grep "ORA-" | head -1` + echo "CRITICAL - $error" + exit $STATE_CRITICAL + fi + + lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` + lib_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` + + if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then + echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" + exit $STATE_CRITICAL + fi + if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then + echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" + exit $STATE_WARNING + fi + echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" + + exit $STATE_OK + ;; +--tablespace) + if [ ${6} -lt ${7} ] ; then + echo "UNKNOWN - Warning level is more then Crit" + exit $STATE_UNKNOWN + fi + result=`sqlplus -s ${3}/${4}@${2} << EOF +set pagesize 0 +set numf '9999999.99' +select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc +from ( +select tablespace_name,sum(bytes)/1024/1024 total +from dba_data_files group by tablespace_name) A, +( select tablespace_name,sum(bytes)/1024/1024 free +from dba_free_space group by tablespace_name) B +where a.tablespace_name=b.tablespace_name and a.tablespace_name='${5}'; +EOF` + + if [ -n "`echo $result | grep ORA-`" ] ; then + error=` echo "$result" | grep "ORA-" | head -1` + echo "CRITICAL - $error" + exit $STATE_CRITICAL + fi + + ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'` + ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'` + ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'` + ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'` + if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then + echo "No data returned by Oracle - tablespace $5 not found?" + exit $STATE_UNKNOWN + fi + if [ "$ts_pct" -ge ${6} ] ; then + echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" + exit $STATE_CRITICAL + fi + if [ "$ts_pct" -ge ${7} ] ; then + echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" + exit $STATE_WARNING + fi + echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" + exit $STATE_OK + ;; +*) + print_usage + exit $STATE_UNKNOWN +esac diff --git a/web/attachments/101482-nagios-plugins-1.3.1-check_ldap.patchTLS b/web/attachments/101482-nagios-plugins-1.3.1-check_ldap.patchTLS new file mode 100644 index 0000000..66046e3 --- /dev/null +++ b/web/attachments/101482-nagios-plugins-1.3.1-check_ldap.patchTLS @@ -0,0 +1,195 @@ +diff -r -p nagios-plugins-1.3.1/configure.in nagios-plugins-1.3.1-patchTLS/configure.in +*** nagios-plugins-1.3.1/configure.in Fri Jul 11 08:12:23 2003 +--- nagios-plugins-1.3.1-patchTLS/configure.in Tue Sep 14 15:07:12 2004 +*************** if test "$ac_cv_lib_ldap_main" = "yes"; +*** 165,170 **** +--- 165,171 ---- + AC_SUBST(LDAPLIBS) + AC_SUBST(LDAPINCLUDE) + EXTRAS="$EXTRAS check_ldap" ++ AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s) + else + AC_MSG_WARN([Skipping LDAP plugin]) + AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).]) +diff -r -p nagios-plugins-1.3.1/plugins/Makefile.am nagios-plugins-1.3.1-patchTLS/plugins/Makefile.am +*** nagios-plugins-1.3.1/plugins/Makefile.am Fri Jul 11 08:11:06 2003 +--- nagios-plugins-1.3.1-patchTLS/plugins/Makefile.am Sat Sep 11 01:59:42 2004 +*************** $(check_tcp_programs): check_tcp +*** 132,138 **** + + install-exec-hook: + cd $(DESTDIR)$(libexecdir) && \ +! for i in $(check_tcp_programs) ; do rm -f $$i; ln -s -f check_tcp $$i ; done + + clean-local: + rm -f $(check_tcp_programs) +--- 132,139 ---- + + install-exec-hook: + cd $(DESTDIR)$(libexecdir) && \ +! for i in $(check_tcp_programs) ; do rm -f $$i; ln -s -f check_tcp $$i ; done ;\ +! rm -f check_ldaps ; ln -s -f check_ldap check_ldaps + + clean-local: + rm -f $(check_tcp_programs) +diff -r -p nagios-plugins-1.3.1/plugins/check_ldap.c nagios-plugins-1.3.1-patchTLS/plugins/check_ldap.c +*** nagios-plugins-1.3.1/plugins/check_ldap.c Wed Jan 29 07:16:15 2003 +--- nagios-plugins-1.3.1-patchTLS/plugins/check_ldap.c Tue Sep 14 15:16:05 2004 +*************** +*** 20,26 **** + * + *****************************************************************************/ + +! const char *progname = "check_ldap"; + const char *revision = "$Revision: 1.4 $"; + + #include "config.h" +--- 20,26 ---- + * + *****************************************************************************/ + +! char *progname = "check_ldap"; + const char *revision = "$Revision: 1.4 $"; + + #include "config.h" +*************** char *ld_binddn = NULL; +*** 50,55 **** +--- 50,56 ---- + unsigned int ld_port = DEFAULT_PORT; + int warn_time = UNDEFINED; + int crit_time = UNDEFINED; ++ char *SERVICE = "LDAP"; + + int + main (int argc, char *argv[]) +*************** main (int argc, char *argv[]) +*** 60,65 **** +--- 61,73 ---- + + int t_diff; + time_t time0, time1; ++ int tls; ++ ++ int version=3; ++ ++ if (strstr(argv[0],"check_ldaps")) { ++ asprintf (&progname, "check_ldaps"); ++ } + + if (process_arguments (argc, argv) == ERROR) + usage ("check_ldap: could not parse arguments\n"); +*************** main (int argc, char *argv[]) +*** 74,84 **** + time (&time0); + + /* initialize ldap */ + if (!(ld = ldap_open (ld_host, ld_port))) { +- /*ldap_perror(ld, "ldap_open"); */ + printf ("Could not connect to the server at port %i\n", ld_port); + return STATE_CRITICAL; + } + + /* bind to the ldap server */ + if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != +--- 82,145 ---- + time (&time0); + + /* initialize ldap */ ++ #ifdef HAVE_LDAP_INIT ++ if (!(ld = ldap_init (ld_host, ld_port))) { ++ printf ("Could not connect to the server at port %i\n", ld_port); ++ return STATE_CRITICAL; ++ } ++ #else + if (!(ld = ldap_open (ld_host, ld_port))) { + printf ("Could not connect to the server at port %i\n", ld_port); + return STATE_CRITICAL; + } ++ #endif /* HAVE_LDAP_INIT */ ++ ++ #if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_PROTOCOL_VERSION) ++ ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version); ++ #endif /* LDAP_OPT_PROTOCOL_VERSION */ ++ ++ if (strstr(argv[0],"check_ldaps")) { ++ /* with TLS */ ++ if ( ld_port == LDAPS_PORT ) { ++ asprintf (&SERVICE, "LDAPS"); ++ #if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_X_TLS) ++ /* ldaps: set option tls */ ++ tls = LDAP_OPT_X_TLS_HARD; ++ if (ldap_set_option (ld, LDAP_OPT_X_TLS, &tls) != LDAP_SUCCESS) ++ { ++ /*ldap_perror(ld, "ldaps_option"); */ ++ printf ("Could not init TLS at port %i!\n", ld_port); ++ return STATE_CRITICAL; ++ } ++ #else ++ printf ("TLS not supported by the libraries!\n", ld_port); ++ return STATE_CRITICAL; ++ #endif /* LDAP_OPT_X_TLS */ ++ } else { ++ asprintf (&SERVICE, "LDAP-TLS"); ++ #if defined(HAVE_LDAP_SET_OPTION) && defined(HAVE_LDAP_START_TLS_S) ++ /* ldap with startTLS: set option version */ ++ if (ldap_get_option(ld,LDAP_OPT_PROTOCOL_VERSION, &version) == LDAP_OPT_SUCCESS ) ++ { ++ if (version < LDAP_VERSION3) ++ { ++ version = LDAP_VERSION3; ++ ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version); ++ } ++ } ++ /* call start_tls */ ++ if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) ++ { ++ /*ldap_perror(ld, "ldap_start_tls"); */ ++ printf ("Could not init startTLS at port %i!\n", ld_port); ++ return STATE_CRITICAL; ++ } ++ #else ++ printf ("startTLS not supported by the library, needs LDAPv3!\n"); ++ return STATE_CRITICAL; ++ #endif /* HAVE_LDAP_START_TLS_S */ ++ } ++ } + + /* bind to the ldap server */ + if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != +*************** main (int argc, char *argv[]) +*** 109,125 **** + t_diff = time1 - time0; + + if (crit_time!=UNDEFINED && t_diff>=crit_time) { +! printf ("LDAP critical - %i seconds response time\n", t_diff); + return STATE_CRITICAL; + } + + if (warn_time!=UNDEFINED && t_diff>=warn_time) { +! printf ("LDAP warning - %i seconds response time\n", t_diff); + return STATE_WARNING; + } + + /* print out the result */ +! printf ("LDAP ok - %i seconds response time\n", t_diff); + + return STATE_OK; + } +--- 170,186 ---- + t_diff = time1 - time0; + + if (crit_time!=UNDEFINED && t_diff>=crit_time) { +! printf ("%s critical - %i seconds response time\n", SERVICE, t_diff); + return STATE_CRITICAL; + } + + if (warn_time!=UNDEFINED && t_diff>=warn_time) { +! printf ("%s warning - %i seconds response time\n", SERVICE, t_diff); + return STATE_WARNING; + } + + /* print out the result */ +! printf ("%s ok - %i seconds response time\n", SERVICE, t_diff); + + return STATE_OK; + } diff --git a/web/attachments/101495-nagios-plugins-1.3.1-check_ldap.patchTLS b/web/attachments/101495-nagios-plugins-1.3.1-check_ldap.patchTLS new file mode 100644 index 0000000..66046e3 --- /dev/null +++ b/web/attachments/101495-nagios-plugins-1.3.1-check_ldap.patchTLS @@ -0,0 +1,195 @@ +diff -r -p nagios-plugins-1.3.1/configure.in nagios-plugins-1.3.1-patchTLS/configure.in +*** nagios-plugins-1.3.1/configure.in Fri Jul 11 08:12:23 2003 +--- nagios-plugins-1.3.1-patchTLS/configure.in Tue Sep 14 15:07:12 2004 +*************** if test "$ac_cv_lib_ldap_main" = "yes"; +*** 165,170 **** +--- 165,171 ---- + AC_SUBST(LDAPLIBS) + AC_SUBST(LDAPINCLUDE) + EXTRAS="$EXTRAS check_ldap" ++ AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s) + else + AC_MSG_WARN([Skipping LDAP plugin]) + AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).]) +diff -r -p nagios-plugins-1.3.1/plugins/Makefile.am nagios-plugins-1.3.1-patchTLS/plugins/Makefile.am +*** nagios-plugins-1.3.1/plugins/Makefile.am Fri Jul 11 08:11:06 2003 +--- nagios-plugins-1.3.1-patchTLS/plugins/Makefile.am Sat Sep 11 01:59:42 2004 +*************** $(check_tcp_programs): check_tcp +*** 132,138 **** + + install-exec-hook: + cd $(DESTDIR)$(libexecdir) && \ +! for i in $(check_tcp_programs) ; do rm -f $$i; ln -s -f check_tcp $$i ; done + + clean-local: + rm -f $(check_tcp_programs) +--- 132,139 ---- + + install-exec-hook: + cd $(DESTDIR)$(libexecdir) && \ +! for i in $(check_tcp_programs) ; do rm -f $$i; ln -s -f check_tcp $$i ; done ;\ +! rm -f check_ldaps ; ln -s -f check_ldap check_ldaps + + clean-local: + rm -f $(check_tcp_programs) +diff -r -p nagios-plugins-1.3.1/plugins/check_ldap.c nagios-plugins-1.3.1-patchTLS/plugins/check_ldap.c +*** nagios-plugins-1.3.1/plugins/check_ldap.c Wed Jan 29 07:16:15 2003 +--- nagios-plugins-1.3.1-patchTLS/plugins/check_ldap.c Tue Sep 14 15:16:05 2004 +*************** +*** 20,26 **** + * + *****************************************************************************/ + +! const char *progname = "check_ldap"; + const char *revision = "$Revision: 1.4 $"; + + #include "config.h" +--- 20,26 ---- + * + *****************************************************************************/ + +! char *progname = "check_ldap"; + const char *revision = "$Revision: 1.4 $"; + + #include "config.h" +*************** char *ld_binddn = NULL; +*** 50,55 **** +--- 50,56 ---- + unsigned int ld_port = DEFAULT_PORT; + int warn_time = UNDEFINED; + int crit_time = UNDEFINED; ++ char *SERVICE = "LDAP"; + + int + main (int argc, char *argv[]) +*************** main (int argc, char *argv[]) +*** 60,65 **** +--- 61,73 ---- + + int t_diff; + time_t time0, time1; ++ int tls; ++ ++ int version=3; ++ ++ if (strstr(argv[0],"check_ldaps")) { ++ asprintf (&progname, "check_ldaps"); ++ } + + if (process_arguments (argc, argv) == ERROR) + usage ("check_ldap: could not parse arguments\n"); +*************** main (int argc, char *argv[]) +*** 74,84 **** + time (&time0); + + /* initialize ldap */ + if (!(ld = ldap_open (ld_host, ld_port))) { +- /*ldap_perror(ld, "ldap_open"); */ + printf ("Could not connect to the server at port %i\n", ld_port); + return STATE_CRITICAL; + } + + /* bind to the ldap server */ + if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != +--- 82,145 ---- + time (&time0); + + /* initialize ldap */ ++ #ifdef HAVE_LDAP_INIT ++ if (!(ld = ldap_init (ld_host, ld_port))) { ++ printf ("Could not connect to the server at port %i\n", ld_port); ++ return STATE_CRITICAL; ++ } ++ #else + if (!(ld = ldap_open (ld_host, ld_port))) { + printf ("Could not connect to the server at port %i\n", ld_port); + return STATE_CRITICAL; + } ++ #endif /* HAVE_LDAP_INIT */ ++ ++ #if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_PROTOCOL_VERSION) ++ ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version); ++ #endif /* LDAP_OPT_PROTOCOL_VERSION */ ++ ++ if (strstr(argv[0],"check_ldaps")) { ++ /* with TLS */ ++ if ( ld_port == LDAPS_PORT ) { ++ asprintf (&SERVICE, "LDAPS"); ++ #if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_X_TLS) ++ /* ldaps: set option tls */ ++ tls = LDAP_OPT_X_TLS_HARD; ++ if (ldap_set_option (ld, LDAP_OPT_X_TLS, &tls) != LDAP_SUCCESS) ++ { ++ /*ldap_perror(ld, "ldaps_option"); */ ++ printf ("Could not init TLS at port %i!\n", ld_port); ++ return STATE_CRITICAL; ++ } ++ #else ++ printf ("TLS not supported by the libraries!\n", ld_port); ++ return STATE_CRITICAL; ++ #endif /* LDAP_OPT_X_TLS */ ++ } else { ++ asprintf (&SERVICE, "LDAP-TLS"); ++ #if defined(HAVE_LDAP_SET_OPTION) && defined(HAVE_LDAP_START_TLS_S) ++ /* ldap with startTLS: set option version */ ++ if (ldap_get_option(ld,LDAP_OPT_PROTOCOL_VERSION, &version) == LDAP_OPT_SUCCESS ) ++ { ++ if (version < LDAP_VERSION3) ++ { ++ version = LDAP_VERSION3; ++ ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version); ++ } ++ } ++ /* call start_tls */ ++ if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) ++ { ++ /*ldap_perror(ld, "ldap_start_tls"); */ ++ printf ("Could not init startTLS at port %i!\n", ld_port); ++ return STATE_CRITICAL; ++ } ++ #else ++ printf ("startTLS not supported by the library, needs LDAPv3!\n"); ++ return STATE_CRITICAL; ++ #endif /* HAVE_LDAP_START_TLS_S */ ++ } ++ } + + /* bind to the ldap server */ + if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != +*************** main (int argc, char *argv[]) +*** 109,125 **** + t_diff = time1 - time0; + + if (crit_time!=UNDEFINED && t_diff>=crit_time) { +! printf ("LDAP critical - %i seconds response time\n", t_diff); + return STATE_CRITICAL; + } + + if (warn_time!=UNDEFINED && t_diff>=warn_time) { +! printf ("LDAP warning - %i seconds response time\n", t_diff); + return STATE_WARNING; + } + + /* print out the result */ +! printf ("LDAP ok - %i seconds response time\n", t_diff); + + return STATE_OK; + } +--- 170,186 ---- + t_diff = time1 - time0; + + if (crit_time!=UNDEFINED && t_diff>=crit_time) { +! printf ("%s critical - %i seconds response time\n", SERVICE, t_diff); + return STATE_CRITICAL; + } + + if (warn_time!=UNDEFINED && t_diff>=warn_time) { +! printf ("%s warning - %i seconds response time\n", SERVICE, t_diff); + return STATE_WARNING; + } + + /* print out the result */ +! printf ("%s ok - %i seconds response time\n", SERVICE, t_diff); + + return STATE_OK; + } diff --git a/web/attachments/102274-check_upsv2.c b/web/attachments/102274-check_upsv2.c new file mode 100644 index 0000000..f238c7d --- /dev/null +++ b/web/attachments/102274-check_upsv2.c @@ -0,0 +1,593 @@ +/****************************************************************************** + + 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 2 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. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + ******************************************************************************/ + +const char *progname = "check_ups"; +const char *revision = "$Revision: 1.13 $"; +const char *copyright = "2000-2002"; +const char *email = "nagiosplug-devel@lists.sourceforge.net"; + +#include +#include "common.h" +#include "netutils.h" +#include "utils.h" + +enum { + PORT = 3493 +}; + +#define CHECK_NONE 0 + +#define UPS_NONE 0 /* no supported options */ +#define UPS_UTILITY 1 /* supports utility line voltage */ +#define UPS_BATTPCT 2 /* supports percent battery remaining */ +#define UPS_STATUS 4 /* supports UPS status */ +#define UPS_TEMP 8 /* supports UPS temperature */ +#define UPS_LOADPCT 16 /* supports load percent */ + +#define UPSSTATUS_NONE 0 +#define UPSSTATUS_OFF 1 +#define UPSSTATUS_OL 2 +#define UPSSTATUS_OB 4 +#define UPSSTATUS_LB 8 +#define UPSSTATUS_CAL 16 +#define UPSSTATUS_RB 32 /*Replace Battery */ +#define UPSSTATUS_UNKOWN 64 + +enum { NOSUCHVAR = ERROR-1 }; + +int server_port = PORT; +char *server_address; +char *ups_name = NULL; +double warning_value = 0.0; +double critical_value = 0.0; +int check_warn = FALSE; +int check_crit = FALSE; +int check_variable = UPS_NONE; +int supported_options = UPS_NONE; +int status = UPSSTATUS_NONE; + +double ups_utility_voltage = 0.0; +double ups_battery_percent = 0.0; +double ups_load_percent = 0.0; +double ups_temperature = 0.0; +char *ups_status; + +int determine_status (void); +int get_ups_variable (const char *, char *, size_t); + +int process_arguments (int, char **); +int validate_arguments (void); +void print_help (void); +void print_usage (void); + + int +main (int argc, char **argv) +{ + int result = STATE_OK; + char *message; + char *data; + char temp_buffer[MAX_INPUT_BUFFER]; + double ups_utility_deviation = 0.0; + int res; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + ups_status = strdup ("N/A"); + data = strdup (""); + message = strdup (""); + + if (process_arguments (argc, argv) != OK) + usage ("Invalid command arguments supplied\n"); + + /* initialize alarm signal handling */ + signal (SIGALRM, socket_timeout_alarm_handler); + + /* set socket timeout */ + alarm (socket_timeout); + + /* get the ups status if possible */ + if (determine_status () != OK) + return STATE_CRITICAL; + if (supported_options & UPS_STATUS) { + + ups_status = strdup (""); + result = STATE_OK; + + if (status & UPSSTATUS_OFF) { + asprintf (&ups_status, "Off"); + result = STATE_CRITICAL; + } + else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) == + (UPSSTATUS_OB | UPSSTATUS_LB)) { + asprintf (&ups_status, "On Battery, Low Battery"); + result = STATE_CRITICAL; + } + else { + if (status & UPSSTATUS_OL) { + asprintf (&ups_status, "%s%s", ups_status, "Online"); + } + if (status & UPSSTATUS_OB) { + asprintf (&ups_status, "%s%s", ups_status, "On Battery"); + result = STATE_WARNING; + } + if (status & UPSSTATUS_LB) { + asprintf (&ups_status, "%s%s", ups_status, ", Low Battery"); + result = STATE_WARNING; + } + if (status & UPSSTATUS_CAL) { + asprintf (&ups_status, "%s%s", ups_status, ", Calibrating"); + } + if (status & UPSSTATUS_RB) { + asprintf (&ups_status, "%s%s", ups_status, ", Replace Battery"); + result = STATE_WARNING; + } + if (status & UPSSTATUS_UNKOWN) { + asprintf (&ups_status, "%s%s", ups_status, ", Unknown"); + } + } + asprintf (&message, "%sStatus=%s ", message, ups_status); + } + + /* get the ups utility voltage if possible */ + res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer)); + if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY; + else if (res != OK) + return STATE_CRITICAL; + else { + supported_options |= UPS_UTILITY; + + ups_utility_voltage = atof (temp_buffer); + asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage); + + if (ups_utility_voltage > 120.0) + ups_utility_deviation = 120.0 - ups_utility_voltage; + else + ups_utility_deviation = ups_utility_voltage - 120.0; + + if (check_variable == UPS_UTILITY) { + if (check_crit==TRUE && ups_utility_deviation>=critical_value) { + result = STATE_CRITICAL; + } + else if (check_warn==TRUE && ups_utility_deviation>=warning_value) { + result = max_state (result, STATE_WARNING); + } + asprintf (&data, "%s", + perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", + check_warn, (long)(1000*warning_value), + check_crit, (long)(1000*critical_value), + TRUE, 0, FALSE, 0)); + } else { + asprintf (&data, "%s", + perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", + FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); + } + } + + /* get the ups battery percent if possible */ + res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer)); + if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT; + else if ( res != OK) + return STATE_CRITICAL; + else { + supported_options |= UPS_BATTPCT; + ups_battery_percent = atof (temp_buffer); + asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent); + + if (check_variable == UPS_BATTPCT) { + if (check_crit==TRUE && ups_battery_percent <= critical_value) { + result = STATE_CRITICAL; + } + else if (check_warn==TRUE && ups_battery_percent<=warning_value) { + result = max_state (result, STATE_WARNING); + } + asprintf (&data, "%s %s", data, + perfdata ("battery", (long)ups_battery_percent, "%", + check_warn, (long)(1000*warning_value), + check_crit, (long)(1000*critical_value), + TRUE, 0, TRUE, 100)); + } else { + asprintf (&data, "%s %s", data, + perfdata ("battery", (long)ups_battery_percent, "%", + FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100)); + } + } + + /* get the ups load percent if possible */ + res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer)); + if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT; + else if ( res != OK) + return STATE_CRITICAL; + else { + supported_options |= UPS_LOADPCT; + ups_load_percent = atof (temp_buffer); + asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent); + + if (check_variable == UPS_LOADPCT) { + if (check_crit==TRUE && ups_load_percent>=critical_value) { + result = STATE_CRITICAL; + } + else if (check_warn==TRUE && ups_load_percent>=warning_value) { + result = max_state (result, STATE_WARNING); + } + asprintf (&data, "%s %s", data, + perfdata ("load", (long)ups_load_percent, "%", + check_warn, (long)(1000*warning_value), + check_crit, (long)(1000*critical_value), + TRUE, 0, TRUE, 100)); + } else { + asprintf (&data, "%s %s", data, + perfdata ("load", (long)ups_load_percent, "%", + FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100)); + } + } + + /* get the ups temperature if possible */ + res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer)); + if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP; + else if ( res != OK) + return STATE_CRITICAL; + else { + supported_options |= UPS_TEMP; + ups_temperature = (atof (temp_buffer) * 1.8) + 32; + asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature); + + if (check_variable == UPS_TEMP) { + if (check_crit==TRUE && ups_temperature>=critical_value) { + result = STATE_CRITICAL; + } + else if (check_warn == TRUE && ups_temperature>=warning_value) { + result = max_state (result, STATE_WARNING); + } + asprintf (&data, "%s %s", data, + perfdata ("temp", (long)ups_temperature, "degF", + check_warn, (long)(1000*warning_value), + check_crit, (long)(1000*critical_value), + TRUE, 0, FALSE, 0)); + } else { + asprintf (&data, "%s %s", data, + perfdata ("temp", (long)ups_temperature, "degF", + FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); + } + } + + /* if the UPS does not support any options we are looking for, report an error */ + if (supported_options == UPS_NONE) { + result = STATE_CRITICAL; + asprintf (&message, "UPS does not support any available options\n"); + } + + /* reset timeout */ + alarm (0); + + printf ("UPS %s - %s|%s\n", state_text(result), message, data); + return result; +} + + + +/* determines what options are supported by the UPS */ +int +determine_status (void) +{ + char recv_buffer[MAX_INPUT_BUFFER]; + char temp_buffer[MAX_INPUT_BUFFER]; + char *ptr; + int res; + + res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); + if (res == NOSUCHVAR) return OK; + if (res != STATE_OK) { + printf ("Invalid response received from hostn"); + return ERROR; + } + + supported_options |= UPS_STATUS; + + strcpy (temp_buffer, recv_buffer); + for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL; + ptr = (char *) strtok (NULL, " ")) { + if (!strcmp (ptr, "OFF")) + status |= UPSSTATUS_OFF; + else if (!strcmp (ptr, "OL")) + status |= UPSSTATUS_OL; + else if (!strcmp (ptr, "OB")) + status |= UPSSTATUS_OB; + else if (!strcmp (ptr, "LB")) + status |= UPSSTATUS_LB; + else if (!strcmp (ptr, "CAL")) + status |= UPSSTATUS_CAL; + else if (!strcmp (ptr, "RB")) + status |= UPSSTATUS_RB; + else + status |= UPSSTATUS_UNKOWN; + } + + return OK; +} + + +/* gets a variable value for a specific UPS */ +int +get_ups_variable (const char *varname, char *buf, size_t buflen) +{ + /* char command[MAX_INPUT_BUFFER]; */ + char temp_buffer[MAX_INPUT_BUFFER]; + char send_buffer[MAX_INPUT_BUFFER]; + char *ptr; + int len; + + *buf=0; + + /* create the command string to send to the UPS daemon */ + sprintf (send_buffer, "GET VAR %s %s\n", ups_name, varname); + + /* send the command to the daemon and get a response back */ + if (process_tcp_request + (server_address, server_port, send_buffer, temp_buffer, + sizeof (temp_buffer)) != STATE_OK) { + printf ("Invalid response received from host\n"); + return ERROR; + } + + ptr = temp_buffer; + len = strlen(ptr); + if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0; + if (strcmp (ptr, "ERR UNKNOWN-UPS") == 0) { + printf ("Error: no such ups '%s' on that host\n", ups_name); + return ERROR; + } + + if (strcmp (ptr, "ERR VAR-NOT-SUPPORTED") == 0) { + //printf ("Error: Variable '%s' is not supported\n", varname); + return NOSUCHVAR; + } + + if (strcmp (ptr, "ERR DATA-STALE") == 0) { + printf ("Error: UPS data is stale\n"); + return ERROR; + } + + if (strncmp (ptr, "ERR", 3) == 0) { + printf ("Unkown error: %s\n", ptr); + return ERROR; + } + + ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6; + len = strlen(ptr); + if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') { + printf ("Error: unable to parse variable\n"); + return ERROR; + } + strncpy (buf, ptr+1, len - 2); + buf[len - 2] = 0; + + return OK; +} + + +/* Command line: CHECK_UPS -H -u ups [-p port] [-v variable] + [-wv warn_value] [-cv crit_value] [-to to_sec] */ + + +/* process command-line arguments */ +int +process_arguments (int argc, char **argv) +{ + int c; + + int option = 0; + static struct option longopts[] = { + {"hostname", required_argument, 0, 'H'}, + {"ups", required_argument, 0, 'u'}, + {"port", required_argument, 0, 'p'}, + {"critical", required_argument, 0, 'c'}, + {"warning", required_argument, 0, 'w'}, + {"timeout", required_argument, 0, 't'}, + {"variable", required_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'h'}, + {0, 0, 0, 0} + }; + + if (argc < 2) + return ERROR; + + for (c = 1; c < argc; c++) { + if (strcmp ("-to", argv[c]) == 0) + strcpy (argv[c], "-t"); + else if (strcmp ("-wt", argv[c]) == 0) + strcpy (argv[c], "-w"); + else if (strcmp ("-ct", argv[c]) == 0) + strcpy (argv[c], "-c"); + } + + while (1) { + c = getopt_long (argc, argv, "hVH:u:p:v:c:w:t:", longopts, + &option); + + if (c == -1 || c == EOF) + break; + + switch (c) { + case '?': /* help */ + usage3 ("Unknown option", optopt); + case 'H': /* hostname */ + if (is_host (optarg)) { + server_address = optarg; + } + else { + usage2 ("Invalid host name", optarg); + } + break; + case 'u': /* ups name */ + ups_name = optarg; + break; + case 'p': /* port */ + if (is_intpos (optarg)) { + server_port = atoi (optarg); + } + else { + usage2 ("Server port must be a positive integer", optarg); + } + break; + case 'c': /* critical time threshold */ + if (is_intnonneg (optarg)) { + critical_value = atoi (optarg); + check_crit = TRUE; + } + else { + usage2 ("Critical time must be a nonnegative integer", optarg); + } + break; + case 'w': /* warning time threshold */ + if (is_intnonneg (optarg)) { + warning_value = atoi (optarg); + check_warn = TRUE; + } + else { + usage2 ("Warning time must be a nonnegative integer", optarg); + } + break; + case 'v': /* variable */ + if (!strcmp (optarg, "LINE")) + check_variable = UPS_UTILITY; + else if (!strcmp (optarg, "TEMP")) + check_variable = UPS_TEMP; + else if (!strcmp (optarg, "BATTPCT")) + check_variable = UPS_BATTPCT; + else if (!strcmp (optarg, "LOADPCT")) + check_variable = UPS_LOADPCT; + else + usage2 ("Unrecognized UPS variable", optarg); + break; + case 't': /* timeout */ + if (is_intnonneg (optarg)) { + socket_timeout = atoi (optarg); + } + else { + usage ("Time interval must be a nonnegative integer\n"); + } + break; + case 'V': /* version */ + print_revision (progname, "$Revision: 1.13 $"); + exit (STATE_OK); + case 'h': /* help */ + print_help (); + exit (STATE_OK); + } + } + + + if (server_address == NULL && argc > optind) { + if (is_host (argv[optind])) + server_address = argv[optind++]; + else + usage ("Invalid host name"); + } + + if (server_address == NULL) + server_address = strdup("127.0.0.1"); + + return validate_arguments(); +} + + + + + +int +validate_arguments (void) +{ + if (! ups_name) { + printf ("Error : no ups indicated\n"); + return ERROR; + } + return OK; +} + + + + + + +void +print_help (void) +{ + char *myport; + asprintf (&myport, "%d", PORT); + + print_revision (progname, revision); + + printf (_("Copyright (c) 2000 Tom Shields")); + printf (_(COPYRIGHT), copyright, email); + + printf (_("This plugin tests the UPS service on the specified host.\n\ +Network UPS Tools from www.exploits.org must be running for this plugin to\n\ +work.\n\n")); + + print_usage (); + + printf (_(UT_HELP_VRSN)); + + printf (_(UT_HOST_PORT), 'p', myport); + + printf (_("\ + -u, --ups=STRING\n\ + Name of UPS\n")); + + printf (_(UT_WARN_CRIT)); + + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); + + printf (_("\ +This plugin attempts to determine the status of a UPS (Uninterruptible Power\n\ +Supply) on a local or remote host. If the UPS is online or calibrating, the\n\ +plugin will return an OK state. If the battery is on it will return a WARNING\n\ +state. If the UPS is off or has a low battery the plugin will return a CRITICAL\n\ +state.\n\n")); + + printf (_("\ +You may also specify a variable to check [such as temperature, utility voltage,\n\ +battery load, etc.] as well as warning and critical thresholds for the value of\n\ +that variable. If the remote host has multiple UPS that are being monitored you\n\ +will have to use the [ups] option to specify which UPS to check.\n\n")); + + printf (_("Notes:\n\n\ +This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ +Smart UPS Tools be installed on the remote host. If you do not have the\n\ +package installed on your system, you can download it from\n\ +http://www.exploits.org/nut\n\n")); + + printf (_(UT_SUPPORT)); +} + + + + +void +print_usage (void) +{ + printf (_("\ +Usage: %s -H host -u ups [-p port] [-v variable] [-wv warn_value] [-cv crit_value] [-to to_sec]\n"), progname); + printf (_(UT_HLP_VRS), progname, progname); +} + diff --git a/web/attachments/103460-check_ups-NUT2.0.diff b/web/attachments/103460-check_ups-NUT2.0.diff new file mode 100644 index 0000000..e28c718 --- /dev/null +++ b/web/attachments/103460-check_ups-NUT2.0.diff @@ -0,0 +1,588 @@ +diff -ru nagiosplug/AUTHORS nagiosplug_AQ/AUTHORS +--- nagiosplug/AUTHORS 2004-08-23 23:59:37.000000000 +0200 ++++ nagiosplug_AQ/AUTHORS 2004-09-30 10:23:42.000000000 +0200 +@@ -119,3 +119,5 @@ + Sean Finney + Bill Kunkel + Paulo Afonso Graner Fessel ++Alain Richard ++Arnaud Quette +diff -ru nagiosplug/command.cfg.in nagiosplug_AQ/command.cfg.in +--- nagiosplug/command.cfg.in 2003-06-12 06:46:10.000000000 +0200 ++++ nagiosplug_AQ/command.cfg.in 2004-10-01 12:31:15.000000000 +0200 +@@ -91,6 +91,7 @@ + command[check_procs_zombie]=@libexecdir@/check_procs -w $ARG1$ -c $ARG2$ -s Z + command[check_procs_httpd]=@libexecdir@/check_procs -w 5:$ARG1$ -c 1:$ARG2$ -C httpd + command[check_procs_vsz]=@libexecdir@/check_procs -w 8096 -c 16182 -C httpd --metric VSZ ++command[check_ups]=@libexecdir@/check_ups -H $HOSTADDRESS$ -u $UPS$ + + # An example of using check_by_ssh as an active service check + command[ssh_disk]=@libexecdir@/check_by_ssh -H $HOSTADDRESS$ -C '@libexecdir@/check_disk -w 85% -c 95% -p $ARG1$' +diff -ru nagiosplug/plugins/check_ups.c nagiosplug_AQ/plugins/check_ups.c +--- nagiosplug/plugins/check_ups.c 2004-03-14 05:09:19.000000000 +0100 ++++ nagiosplug_AQ/plugins/check_ups.c 2004-10-01 11:35:19.000000000 +0200 +@@ -1,26 +1,35 @@ + /****************************************************************************** +- +- 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 2 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. See the GNU +- General Public License for more details. +- +- You should have received a copy of the GNU General Public License +- along with this program; if not, write to the Free Software +- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +- +-******************************************************************************/ ++ * ++ * check_ups ++ * ++ * Program: Network UPS Tools plugin for Nagios ++ * License: GPL ++ * Copyright (c) 2000 Tom Shields ++ * 2004 Alain Richard ++ * 2004 Arnaud Quette ++ * ++ * 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 2 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. See the GNU ++ * General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ * ++ ******************************************************************************/ + + const char *progname = "check_ups"; +-const char *revision = "$Revision: 1.14 $"; +-const char *copyright = "2000-2002"; ++const char *revision = "$Revision: 1.20 $"; ++const char *copyright = "2000-2004"; + const char *email = "nagiosplug-devel@lists.sourceforge.net"; + ++#include + #include "common.h" + #include "netutils.h" + #include "utils.h" +@@ -38,14 +47,22 @@ + #define UPS_TEMP 8 /* supports UPS temperature */ + #define UPS_LOADPCT 16 /* supports load percent */ + +-#define UPSSTATUS_NONE 0 +-#define UPSSTATUS_OFF 1 +-#define UPSSTATUS_OL 2 +-#define UPSSTATUS_OB 4 +-#define UPSSTATUS_LB 8 +-#define UPSSTATUS_CAL 16 +-#define UPSSTATUS_RB 32 /*Replace Battery */ +-#define UPSSTATUS_UNKOWN 64 ++#define UPSSTATUS_NONE 0 ++#define UPSSTATUS_OFF 1 ++#define UPSSTATUS_OL 2 ++#define UPSSTATUS_OB 4 ++#define UPSSTATUS_LB 8 ++#define UPSSTATUS_CAL 16 ++#define UPSSTATUS_RB 32 /*Replace Battery */ ++#define UPSSTATUS_BYPASS 64 ++#define UPSSTATUS_OVER 128 ++#define UPSSTATUS_TRIM 256 ++#define UPSSTATUS_BOOST 512 ++#define UPSSTATUS_CHRG 1024 ++#define UPSSTATUS_DISCHRG 2048 ++#define UPSSTATUS_UNKOWN 4096 ++ ++enum { NOSUCHVAR = ERROR-1 }; + + int server_port = PORT; + char *server_address; +@@ -63,9 +80,9 @@ + double ups_load_percent = 0.0; + double ups_temperature = 0.0; + char *ups_status; ++int temp_output_c = 0; + + int determine_status (void); +-int determine_supported_vars (void); + int get_ups_variable (const char *, char *, size_t); + + int process_arguments (int, char **); +@@ -73,7 +90,7 @@ + void print_help (void); + void print_usage (void); + +-int ++ int + main (int argc, char **argv) + { + int result = STATE_OK; +@@ -81,6 +98,7 @@ + char *data; + char temp_buffer[MAX_INPUT_BUFFER]; + double ups_utility_deviation = 0.0; ++ int res; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); +@@ -88,6 +106,7 @@ + + ups_status = strdup ("N/A"); + data = strdup (""); ++ message = strdup (""); + + if (process_arguments (argc, argv) != OK) + usage ("Invalid command arguments supplied\n"); +@@ -98,15 +117,11 @@ + /* set socket timeout */ + alarm (socket_timeout); + +- /* determine what variables the UPS supports */ +- if (determine_supported_vars () != OK) +- return STATE_CRITICAL; +- + /* get the ups status if possible */ ++ if (determine_status () != OK) ++ return STATE_CRITICAL; + if (supported_options & UPS_STATUS) { + +- if (determine_status () != OK) +- return STATE_CRITICAL; + ups_status = strdup (""); + result = STATE_OK; + +@@ -138,6 +153,24 @@ + asprintf (&ups_status, "%s%s", ups_status, ", Replace Battery"); + result = STATE_WARNING; + } ++ if (status & UPSSTATUS_BYPASS) { ++ asprintf (&ups_status, "%s%s", ups_status, ", On Bypass"); ++ } ++ if (status & UPSSTATUS_OVER) { ++ asprintf (&ups_status, "%s%s", ups_status, ", Overload"); ++ } ++ if (status & UPSSTATUS_TRIM) { ++ asprintf (&ups_status, "%s%s", ups_status, ", Trimming"); ++ } ++ if (status & UPSSTATUS_BOOST) { ++ asprintf (&ups_status, "%s%s", ups_status, ", Boosting"); ++ } ++ if (status & UPSSTATUS_CHRG) { ++ asprintf (&ups_status, "%s%s", ups_status, ", Charging"); ++ } ++ if (status & UPSSTATUS_DISCHRG) { ++ asprintf (&ups_status, "%s%s", ups_status, ", Discharging"); ++ } + if (status & UPSSTATUS_UNKOWN) { + asprintf (&ups_status, "%s%s", ups_status, ", Unknown"); + } +@@ -146,10 +179,12 @@ + } + + /* get the ups utility voltage if possible */ +- if (supported_options & UPS_UTILITY) { +- +- if (get_ups_variable ("UTILITY", temp_buffer, sizeof (temp_buffer)) != OK) +- return STATE_CRITICAL; ++ res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer)); ++ if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY; ++ else if (res != OK) ++ return STATE_CRITICAL; ++ else { ++ supported_options |= UPS_UTILITY; + + ups_utility_voltage = atof (temp_buffer); + asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage); +@@ -167,23 +202,24 @@ + result = max_state (result, STATE_WARNING); + } + asprintf (&data, "%s", +- fperfdata ("voltage", ups_utility_voltage, "V", +- check_warn, warning_value, +- check_crit, critical_value, ++ perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", ++ check_warn, (long)(1000*warning_value), ++ check_crit, (long)(1000*critical_value), + TRUE, 0, FALSE, 0)); + } else { + asprintf (&data, "%s", +- fperfdata ("voltage", ups_utility_voltage, "V", ++ perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", + FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); + } + } + + /* get the ups battery percent if possible */ +- if (supported_options & UPS_BATTPCT) { +- +- if (get_ups_variable ("BATTPCT", temp_buffer, sizeof (temp_buffer)) != OK) +- return STATE_CRITICAL; +- ++ res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer)); ++ if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT; ++ else if ( res != OK) ++ return STATE_CRITICAL; ++ else { ++ supported_options |= UPS_BATTPCT; + ups_battery_percent = atof (temp_buffer); + asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent); + +@@ -207,11 +243,12 @@ + } + + /* get the ups load percent if possible */ +- if (supported_options & UPS_LOADPCT) { +- +- if (get_ups_variable ("LOADPCT", temp_buffer, sizeof (temp_buffer)) != OK) +- return STATE_CRITICAL; +- ++ res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer)); ++ if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT; ++ else if ( res != OK) ++ return STATE_CRITICAL; ++ else { ++ supported_options |= UPS_LOADPCT; + ups_load_percent = atof (temp_buffer); + asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent); + +@@ -235,13 +272,20 @@ + } + + /* get the ups temperature if possible */ +- if (supported_options & UPS_TEMP) { +- +- if (get_ups_variable ("UPSTEMP", temp_buffer, sizeof (temp_buffer)) != OK) +- return STATE_CRITICAL; +- +- ups_temperature = (atof (temp_buffer) * 1.8) + 32; +- asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature); ++ res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer)); ++ if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP; ++ else if ( res != OK) ++ return STATE_CRITICAL; ++ else { ++ supported_options |= UPS_TEMP; ++ if (temp_output_c) { ++ ups_temperature = atof (temp_buffer); ++ asprintf (&message, "%sTemp=%3.1fC", message, ups_temperature); ++ } ++ else { ++ ups_temperature = (atof (temp_buffer) * 1.8) + 32; ++ asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature); ++ } + + if (check_variable == UPS_TEMP) { + if (check_crit==TRUE && ups_temperature>=critical_value) { +@@ -284,15 +328,17 @@ + char recv_buffer[MAX_INPUT_BUFFER]; + char temp_buffer[MAX_INPUT_BUFFER]; + char *ptr; +- +- if (get_ups_variable ("STATUS", recv_buffer, sizeof (recv_buffer)) != +- STATE_OK) { ++ int res; ++ ++ res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); ++ if (res == NOSUCHVAR) return OK; ++ if (res != STATE_OK) { + printf ("Invalid response received from hostn"); + return ERROR; + } +- +- recv_buffer[strlen (recv_buffer) - 1] = 0; +- ++ ++ supported_options |= UPS_STATUS; ++ + strcpy (temp_buffer, recv_buffer); + for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL; + ptr = (char *) strtok (NULL, " ")) { +@@ -308,6 +354,18 @@ + status |= UPSSTATUS_CAL; + else if (!strcmp (ptr, "RB")) + status |= UPSSTATUS_RB; ++ else if (!strcmp (ptr, "BYPASS")) ++ status |= UPSSTATUS_BYPASS; ++ else if (!strcmp (ptr, "OVER")) ++ status |= UPSSTATUS_OVER; ++ else if (!strcmp (ptr, "TRIM")) ++ status |= UPSSTATUS_TRIM; ++ else if (!strcmp (ptr, "BOOST")) ++ status |= UPSSTATUS_BOOST; ++ else if (!strcmp (ptr, "CHRG")) ++ status |= UPSSTATUS_CHRG; ++ else if (!strcmp (ptr, "DISCHRG")) ++ status |= UPSSTATUS_DISCHRG; + else + status |= UPSSTATUS_UNKOWN; + } +@@ -316,55 +374,6 @@ + } + + +-/* determines what options are supported by the UPS */ +-int +-determine_supported_vars (void) +-{ +- char send_buffer[MAX_INPUT_BUFFER]; +- char recv_buffer[MAX_INPUT_BUFFER]; +- char temp_buffer[MAX_INPUT_BUFFER]; +- char *ptr; +- +- +- /* get the list of variables that this UPS supports */ +- if (ups_name) +- sprintf (send_buffer, "LISTVARS %s\r\n", ups_name); +- else +- sprintf (send_buffer, "LISTVARS\r\n"); +- if (process_tcp_request +- (server_address, server_port, send_buffer, recv_buffer, +- sizeof (recv_buffer)) != STATE_OK) { +- printf ("Invalid response received from host\n"); +- return ERROR; +- } +- +- recv_buffer[strlen (recv_buffer) - 1] = 0; +- +- if (ups_name) +- ptr = recv_buffer + 5 + strlen (ups_name) + 2; +- else +- ptr = recv_buffer + 5; +- +- strcpy (temp_buffer, recv_buffer); +- +- for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL; +- ptr = (char *) strtok (NULL, " ")) { +- if (!strcmp (ptr, "UTILITY")) +- supported_options |= UPS_UTILITY; +- else if (!strcmp (ptr, "BATTPCT")) +- supported_options |= UPS_BATTPCT; +- else if (!strcmp (ptr, "LOADPCT")) +- supported_options |= UPS_LOADPCT; +- else if (!strcmp (ptr, "STATUS")) +- supported_options |= UPS_STATUS; +- else if (!strcmp (ptr, "UPSTEMP")) +- supported_options |= UPS_TEMP; +- } +- +- return OK; +-} +- +- + /* gets a variable value for a specific UPS */ + int + get_ups_variable (const char *varname, char *buf, size_t buflen) +@@ -373,12 +382,12 @@ + char temp_buffer[MAX_INPUT_BUFFER]; + char send_buffer[MAX_INPUT_BUFFER]; + char *ptr; ++ int len; + ++ *buf=0; ++ + /* create the command string to send to the UPS daemon */ +- if (ups_name) +- sprintf (send_buffer, "REQ %s@%s\n", varname, ups_name); +- else +- sprintf (send_buffer, "REQ %s\n", varname); ++ sprintf (send_buffer, "GET VAR %s %s\n", ups_name, varname); + + /* send the command to the daemon and get a response back */ + if (process_tcp_request +@@ -388,40 +397,43 @@ + return ERROR; + } + +- if (ups_name) +- ptr = temp_buffer + strlen (varname) + 5 + strlen (ups_name) + 1; +- else +- ptr = temp_buffer + strlen (varname) + 5; +- +- if (!strcmp (ptr, "NOT-SUPPORTED")) { +- printf ("Error: Variable '%s' is not supported\n", varname); ++ ptr = temp_buffer; ++ len = strlen(ptr); ++ if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0; ++ if (strcmp (ptr, "ERR UNKNOWN-UPS") == 0) { ++ printf ("Error: no such ups '%s' on that host\n", ups_name); + return ERROR; + } + +- if (!strcmp (ptr, "DATA-STALE")) { ++ if (strcmp (ptr, "ERR VAR-NOT-SUPPORTED") == 0) { ++ //printf ("Error: Variable '%s' is not supported\n", varname); ++ return NOSUCHVAR; ++ } ++ ++ if (strcmp (ptr, "ERR DATA-STALE") == 0) { + printf ("Error: UPS data is stale\n"); + return ERROR; + } + +- if (!strcmp (ptr, "UNKNOWN-UPS")) { +- if (ups_name) +- printf ("Error: UPS '%s' is unknown\n", ups_name); +- else +- printf ("Error: UPS is unknown\n"); ++ if (strncmp (ptr, "ERR", 3) == 0) { ++ printf ("Unkown error: %s\n", ptr); + return ERROR; + } + +- strncpy (buf, ptr, buflen - 1); +- buf[buflen - 1] = 0; ++ ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6; ++ len = strlen(ptr); ++ if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') { ++ printf ("Error: unable to parse variable\n"); ++ return ERROR; ++ } ++ strncpy (buf, ptr+1, len - 2); ++ buf[len - 2] = 0; + + return OK; + } + + +- +- +- +-/* Command line: CHECK_UPS [-u ups] [-p port] [-v variable] ++/* Command line: CHECK_UPS -H -u ups [-p port] [-v variable] + [-wv warn_value] [-cv crit_value] [-to to_sec] */ + + +@@ -439,6 +451,7 @@ + {"critical", required_argument, 0, 'c'}, + {"warning", required_argument, 0, 'w'}, + {"timeout", required_argument, 0, 't'}, ++ {"temperature", no_argument, 0, 'T'}, + {"variable", required_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'h'}, +@@ -458,7 +471,7 @@ + } + + while (1) { +- c = getopt_long (argc, argv, "hVH:u:p:v:c:w:t:", longopts, ++ c = getopt_long (argc, argv, "hVTH:u:p:v:c:w:t:", longopts, + &option); + + if (c == -1 || c == EOF) +@@ -475,6 +488,9 @@ + usage2 ("Invalid host name", optarg); + } + break; ++ case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Farenheit) */ ++ temp_output_c = 1; ++ break; + case 'u': /* ups name */ + ups_name = optarg; + break; +@@ -525,7 +541,7 @@ + } + break; + case 'V': /* version */ +- print_revision (progname, "$Revision: 1.14 $"); ++ print_revision (progname, revision); + exit (STATE_OK); + case 'h': /* help */ + print_help (); +@@ -548,20 +564,17 @@ + } + + +- +- +- + int + validate_arguments (void) + { +- return OK; ++ if (! ups_name) { ++ printf ("Error : no ups indicated\n"); ++ return ERROR; ++ } ++ return OK; + } + + +- +- +- +- + void + print_help (void) + { +@@ -571,11 +584,13 @@ + print_revision (progname, revision); + + printf (_("Copyright (c) 2000 Tom Shields")); ++ printf (_("Copyright (c) 2004 Alain Richard \n")); ++ printf (_("Copyright (c) 2004 Arnaud Quette \n")); + printf (_(COPYRIGHT), copyright, email); + + printf (_("This plugin tests the UPS service on the specified host.\n\ +-Network UPS Tools from www.exploits.org must be running for this plugin to\n\ +-work.\n\n")); ++Network UPS Tools from www.networkupstools.org must be running for this \n\ ++plugin to work.\n\n")); + + print_usage (); + +@@ -587,6 +602,9 @@ + -u, --ups=STRING\n\ + Name of UPS\n")); + ++ printf (_("-T, --temperature\n\ ++ Output of temperatures in Celsius\n")); ++ + printf (_(UT_WARN_CRIT)); + + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); +@@ -607,10 +625,10 @@ + will have to use the [ups] option to specify which UPS to check.\n\n")); + + printf (_("Notes:\n\n\ +-This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ +-Smart UPS Tools be installed on the remote host. If you do not have the\n\ ++This plugin requires that the UPSD daemon distributed with the NUT - Network\n\ ++UPS Tools to be installed on the remote host. If you do not have the\n\ + package installed on your system, you can download it from\n\ +-http://www.exploits.org/nut\n\n")); ++http://www.networkupstools.org\n\n")); + + printf (_(UT_SUPPORT)); + } +@@ -622,7 +640,7 @@ + print_usage (void) + { + printf (_("\ +-Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\ +- [-t timeout] [-v]\n"), progname); ++Usage: %s -H host -u ups [-p port] [-v variable] [-wv warn_value] [-cv crit_value] [-to to_sec] [-T]\n"), progname); + printf (_(UT_HLP_VRS), progname, progname); + } ++ +diff -ru nagiosplug/REQUIREMENTS nagiosplug_AQ/REQUIREMENTS +--- nagiosplug/REQUIREMENTS 2004-04-29 13:12:20.000000000 +0200 ++++ nagiosplug_AQ/REQUIREMENTS 2004-10-01 12:42:55.000000000 +0200 +@@ -65,6 +65,9 @@ + - Requires NSClient to run on the NT server to monitor + http://nsclient.ready2run.nl/ + ++check_ups: ++ - Requires Network UPS Tools (>= 1.4) to run on the server to monitor ++ http://www.networkupstools.org/ + + OS Specific Issues + ------------------ diff --git a/web/attachments/104058-check_tcp.c.patch b/web/attachments/104058-check_tcp.c.patch new file mode 100644 index 0000000..d9c435e --- /dev/null +++ b/web/attachments/104058-check_tcp.c.patch @@ -0,0 +1,272 @@ +*** check_tcp.c Tue Jun 10 00:56:47 2003 +--- /usr/local/projects/nagios-plugins-1.3.1/plugins//check_tcp.c Wed Sep 29 15:14:33 2004 +*************** +*** 50,62 **** +--- 50,67 ---- + #include + #include + #endif + + #ifdef HAVE_SSL ++ int check_cert = FALSE; ++ int days_till_exp; ++ char *randbuff = ""; + SSL_CTX *ctx; + SSL *ssl; ++ X509 *server_cert; + int connect_SSL (void); ++ int check_certificate (X509 **); + #endif + + enum { + TCP_PROTOCOL = 1, + UDP_PROTOCOL = 2, +*************** +*** 74,83 **** +--- 79,89 ---- + char *EXPECT = NULL; + char *QUIT = NULL; + int PROTOCOL = 0; + int PORT = 0; + ++ char timestamp[17] = ""; + int server_port = 0; + char *server_address = NULL; + char *server_send = NULL; + char *server_quit = NULL; + char **server_expect = NULL; +*************** +*** 193,202 **** +--- 199,224 ---- + asprintf (&server_expect[server_expect_count - 1], "201"); + asprintf (&QUIT, "QUIT\r\n"); + PROTOCOL = TCP_PROTOCOL; + PORT = 119; + } ++ #ifdef HAVE_SSL ++ else if (strstr (argv[0], "check_nntps")) { ++ asprintf (&progname, "check_nntps"); ++ asprintf (&SERVICE, "NNTPS"); ++ SEND = NULL; ++ EXPECT = NULL; ++ server_expect = realloc (server_expect, ++server_expect_count); ++ asprintf (&server_expect[server_expect_count - 1], "200"); ++ server_expect = realloc (server_expect, ++server_expect_count); ++ asprintf (&server_expect[server_expect_count - 1], "201"); ++ asprintf (&QUIT, "QUIT\r\n"); ++ PROTOCOL = TCP_PROTOCOL; ++ use_ssl=TRUE; ++ PORT = 563; ++ } ++ #endif + else { + usage ("ERROR: Generic check_tcp called with unknown service\n"); + } + + asprintf (&server_address, "127.0.0.1"); +*************** +*** 220,230 **** + alarm (socket_timeout); + + /* try to connect to the host at the given port number */ + gettimeofday (&tv, NULL); + #ifdef HAVE_SSL +! if (use_ssl) + result = connect_SSL (); + else + #endif + { + if (PROTOCOL == UDP_PROTOCOL) +--- 242,270 ---- + alarm (socket_timeout); + + /* try to connect to the host at the given port number */ + gettimeofday (&tv, NULL); + #ifdef HAVE_SSL +! if (use_ssl && check_cert == TRUE) { +! if (connect_SSL () != OK) +! terminate (STATE_CRITICAL, +! "TCP CRITICAL - Could not make SSL connection\n"); +! if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) { +! result = check_certificate (&server_cert); +! X509_free(server_cert); +! } +! else { +! printf("ERROR: Cannot retrieve server certificate.\n"); +! result = STATE_CRITICAL; +! } +! SSL_shutdown (ssl); +! SSL_free (ssl); +! SSL_CTX_free (ctx); +! close (sd); +! return result; +! } +! else if (use_ssl) + result = connect_SSL (); + else + #endif + { + if (PROTOCOL == UDP_PROTOCOL) +*************** +*** 354,363 **** +--- 394,404 ---- + {"quit", required_argument, 0, 'q'}, + {"delay", required_argument, 0, 'd'}, + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'h'}, ++ {"certificate", required_argument, 0, 'C'}, + {0, 0, 0, 0} + }; + #endif + + if (argc < 2) +*************** +*** 421,434 **** +--- 462,477 ---- + if (!is_intnonneg (optarg)) + usage ("Warning threshold must be a nonnegative integer\n"); + warning_time = strtod (optarg, NULL); + check_warning_time = TRUE; + break; ++ /* + case 'C': + crit_codes = realloc (crit_codes, ++crit_codes_count); + crit_codes[crit_codes_count - 1] = optarg; + break; ++ */ + case 'W': + warn_codes = realloc (warn_codes, ++warn_codes_count); + warn_codes[warn_codes_count - 1] = optarg; + break; + case 't': /* timeout */ +*************** +*** 470,479 **** +--- 513,533 ---- + terminate (STATE_UNKNOWN, + "SSL support not available. Install OpenSSL and recompile."); + #endif + use_ssl = TRUE; + break; ++ case 'C': /* Check SSL cert validity */ ++ #ifdef HAVE_SSL ++ if (!is_intnonneg (optarg)) ++ usage2 ("invalid certificate expiration period", optarg); ++ days_till_exp = atoi (optarg); ++ check_cert = TRUE; ++ #else ++ terminate (STATE_UNKNOWN, ++ "SSL support not available. Install OpenSSL and recompile."); ++ #endif ++ break; + } + } + + if (server_address == NULL) + usage ("You must provide a server address\n"); +*************** +*** 532,541 **** +--- 586,600 ---- + " Seconds before connection times out (default: %d)\n" + " -v, --verbose" + " Show details for command-line debugging (do not use with nagios server)\n" + " -h, --help\n" + " Print detailed help screen\n" ++ #ifdef HAVE_SSL ++ " -C, --certificate=INTEGER\n" ++ "Minimum number of days a certificate has to be valid.\n" ++ "(when this option is used the banner is not checked.)\n" ++ #endif + " -V, --version\n" + " Print version information\n", DEFAULT_SOCKET_TIMEOUT); + } + + /* +*************** +*** 593,603 **** +--- 652,736 ---- + + return STATE_CRITICAL; + } + #endif + ++ #ifdef HAVE_SSL ++ int ++ check_certificate (X509 ** certificate) ++ { ++ ASN1_STRING *tm; ++ int offset; ++ struct tm stamp; ++ int days_left; + ++ ++ /* Retrieve timestamp of certificate */ ++ tm = X509_get_notAfter (*certificate); ++ ++ /* Generate tm structure to process timestamp */ ++ if (tm->type == V_ASN1_UTCTIME) { ++ if (tm->length < 10) { ++ printf ("ERROR: Wrong time format in certificate.\n"); ++ return STATE_CRITICAL; ++ } ++ else { ++ stamp.tm_year = (tm->data[0] - '0') * 10 + (tm->data[1] - '0'); ++ if (stamp.tm_year < 50) ++ stamp.tm_year += 100; ++ offset = 0; ++ } ++ } ++ else { ++ if (tm->length < 12) { ++ printf ("ERROR: Wrong time format in certificate.\n"); ++ return STATE_CRITICAL; ++ } ++ else { ++ stamp.tm_year = ++ (tm->data[0] - '0') * 1000 + (tm->data[1] - '0') * 100 + ++ (tm->data[2] - '0') * 10 + (tm->data[3] - '0'); ++ stamp.tm_year -= 1900; ++ offset = 2; ++ } ++ } ++ stamp.tm_mon = ++ (tm->data[2 + offset] - '0') * 10 + (tm->data[3 + offset] - '0') - 1; ++ stamp.tm_mday = ++ (tm->data[4 + offset] - '0') * 10 + (tm->data[5 + offset] - '0'); ++ stamp.tm_hour = ++ (tm->data[6 + offset] - '0') * 10 + (tm->data[7 + offset] - '0'); ++ stamp.tm_min = ++ (tm->data[8 + offset] - '0') * 10 + (tm->data[9 + offset] - '0'); ++ stamp.tm_sec = 0; ++ stamp.tm_isdst = -1; ++ ++ days_left = (mktime (&stamp) - time (NULL)) / 86400; ++ snprintf ++ (timestamp, 16, "%02d/%02d/%04d %02d:%02d", ++ stamp.tm_mon + 1, ++ stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min); ++ ++ if (days_left > 0 && days_left <= days_till_exp) { ++ printf ("Certificate expires in %d day(s) (%s).\n", days_left, timestamp); ++ return STATE_WARNING; ++ } ++ if (days_left < 0) { ++ printf ("Certificate expired on %s.\n", timestamp); ++ return STATE_CRITICAL; ++ } ++ ++ if (days_left == 0) { ++ printf ("Certificate expires today (%s).\n", timestamp); ++ return STATE_WARNING; ++ } ++ ++ printf ("Certificate will expire on %s.\n", timestamp); ++ ++ return STATE_OK; ++ } ++ #endif + + int + my_recv (void) + { + int i; diff --git a/web/attachments/104059-check_smtp.c.patch b/web/attachments/104059-check_smtp.c.patch new file mode 100644 index 0000000..4977bcc --- /dev/null +++ b/web/attachments/104059-check_smtp.c.patch @@ -0,0 +1,491 @@ +*** check_smtp.c Fri Mar 7 02:15:40 2003 +--- /usr/local/projects/nagios-plugins-1.3.1/plugins//check_smtp.c Wed Sep 29 15:14:33 2004 +*************** +*** 37,46 **** +--- 37,64 ---- + #include "config.h" + #include "common.h" + #include "netutils.h" + #include "utils.h" + ++ #ifdef HAVE_SSL ++ #include ++ #include ++ #include ++ #include ++ #endif ++ ++ #ifdef HAVE_SSL ++ int check_cert = FALSE; ++ int days_till_exp; ++ SSL_CTX *ctx; ++ SSL *ssl; ++ X509 *server_cert; ++ int connect_SSL (void); ++ int check_certificate (X509 **); ++ #endif ++ ++ + const char *progname = "check_smtp"; + + #define SMTP_PORT 25 + #define SMTP_EXPECT "220" + #define SMTP_HELO "HELO " +*************** +*** 57,66 **** +--- 75,85 ---- + */ + + #define SMTP_DUMMYCMD "MAIL " + #define SMTP_USE_DUMMYCMD 1 + #define SMTP_QUIT "QUIT\r\n" ++ #define SMTP_STARTTLS "STARTTLS\r\n" + + int process_arguments (int, char **); + int validate_arguments (void); + void print_help (void); + void print_usage (void); +*************** +*** 72,88 **** + int warning_time = 0; + int check_warning_time = FALSE; + int critical_time = 0; + int check_critical_time = FALSE; + int verbose = FALSE; + + int + main (int argc, char **argv) + { +! int sd; + int result = STATE_UNKNOWN; +- char buffer[MAX_INPUT_BUFFER] = ""; + char *from_str = NULL; + char *helocmd = NULL; + + if (process_arguments (argc, argv) != OK) + usage ("Invalid command arguments supplied\n"); +--- 91,116 ---- + int warning_time = 0; + int check_warning_time = FALSE; + int critical_time = 0; + int check_critical_time = FALSE; + int verbose = FALSE; ++ int use_ssl = FALSE; ++ int sd; ++ char timestamp[17] = ""; ++ //char *buffer = ""; ++ char buffer[MAX_INPUT_BUFFER] = ""; ++ enum { ++ TCP_PROTOCOL = 1, ++ UDP_PROTOCOL = 2, ++ MAXBUF = 1024 ++ }; + + int + main (int argc, char **argv) + { +! + int result = STATE_UNKNOWN; + char *from_str = NULL; + char *helocmd = NULL; + + if (process_arguments (argc, argv) != OK) + usage ("Invalid command arguments supplied\n"); +*************** +*** 114,130 **** + /* we connected, so close connection before exiting */ + if (result == STATE_OK) { + + /* watch for the SMTP connection string and */ + /* return a WARNING status if we couldn't read any data */ +! if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) { +! printf ("recv() failed\n"); + result = STATE_WARNING; + } + else { + /* strip the buffer of carriage returns */ +! strip (buffer); + /* make sure we find the response we are looking for */ + if (!strstr (buffer, server_expect)) { + if (server_port == SMTP_PORT) + printf ("Invalid SMTP response received from host\n"); + else +--- 142,158 ---- + /* we connected, so close connection before exiting */ + if (result == STATE_OK) { + + /* watch for the SMTP connection string and */ + /* return a WARNING status if we couldn't read any data */ +! if (recv(sd, buffer, MAX_INPUT_BUFFER-1, 0) == -1) { +! printf ("my_recv() failed\n"); + result = STATE_WARNING; + } + else { + /* strip the buffer of carriage returns */ +! strip (buffer); + /* make sure we find the response we are looking for */ + if (!strstr (buffer, server_expect)) { + if (server_port == SMTP_PORT) + printf ("Invalid SMTP response received from host\n"); + else +*************** +*** 132,162 **** + server_port); + result = STATE_WARNING; + } + } + + /* send the HELO command */ + send(sd, helocmd, strlen(helocmd), 0); + + /* allow for response to helo command to reach us */ +! recv(sd, buffer, MAX_INPUT_BUFFER-1, 0); +! + #ifdef SMTP_USE_DUMMYCMD + send(sd, from_str, strlen(from_str), 0); + + /* allow for response to DUMMYCMD to reach us */ +! recv(sd, buffer, MAX_INPUT_BUFFER-1, 0); + + if (verbose == TRUE) + printf("DUMMYCMD: %s\n%s\n",from_str,buffer); + #endif /* SMTP_USE_DUMMYCMD */ +! + /* tell the server we're done */ + send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0); + + /* finally close the connection */ +! close (sd); + } + + /* reset the alarm */ + alarm (0); + +--- 160,228 ---- + server_port); + result = STATE_WARNING; + } + } + ++ #ifdef HAVE_SSL ++ if(use_ssl) { ++ /* send the STARTTLS command */ ++ send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0); ++ ++ recv(sd, buffer, MAX_INPUT_BUFFER-1, 0); // wait for it ++ if(connect_STARTTLS() != OK) { ++ printf ("ERROR: Cannot create SSL context.\n"); ++ return STATE_CRITICAL; ++ } ++ if ( check_cert ) { ++ if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) { ++ result = check_certificate (&server_cert); ++ X509_free(server_cert); ++ } ++ else { ++ printf("ERROR: Cannot retrieve server certificate.\n"); ++ result = STATE_CRITICAL; ++ } ++ my_close (); ++ return result; ++ } ++ } ++ #endif ++ + /* send the HELO command */ ++ #ifdef HAVE_SSL ++ if (use_ssl) ++ SSL_write(ssl, helocmd, strlen (helocmd)); ++ else ++ #endif + send(sd, helocmd, strlen(helocmd), 0); + + /* allow for response to helo command to reach us */ +! my_recv(); +! #if defined(SMTP_USE_DUMMYCMD) && defined(HAVE_SSL) +! if (use_ssl) +! SSL_write(ssl,from_str, strlen(from_str)); +! else +! #endif + #ifdef SMTP_USE_DUMMYCMD + send(sd, from_str, strlen(from_str), 0); + + /* allow for response to DUMMYCMD to reach us */ +! my_recv(); + + if (verbose == TRUE) + printf("DUMMYCMD: %s\n%s\n",from_str,buffer); + #endif /* SMTP_USE_DUMMYCMD */ +! #ifdef HAVE_SSL +! if (use_ssl) +! SSL_write(ssl,SMTP_QUIT,strlen (SMTP_QUIT)); +! else +! #endif + /* tell the server we're done */ + send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0); + + /* finally close the connection */ +! my_close (); + } + + /* reset the alarm */ + alarm (0); + +*************** +*** 197,206 **** +--- 263,274 ---- + {"port", required_argument, 0, 'p'}, + {"from", required_argument, 0, 'f'}, + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'h'}, ++ {"starttls",no_argument,0,'S'}, ++ {"certificate",required_argument,0,'C'}, + {0, 0, 0, 0} + }; + #endif + + if (argc < 2) +*************** +*** 216,229 **** + } + + while (1) { + #ifdef HAVE_GETOPT_H + c = +! getopt_long (argc, argv, "+hVvt:p:f:e:c:w:H:", long_options, + &option_index); + #else +! c = getopt (argc, argv, "+?hVvt:p:f:e:c:w:H:"); + #endif + if (c == -1 || c == EOF) + break; + + switch (c) { +--- 284,297 ---- + } + + while (1) { + #ifdef HAVE_GETOPT_H + c = +! getopt_long (argc, argv, "+hVvt:p:f:e:c:w:H:SC:", long_options, + &option_index); + #else +! c = getopt (argc, argv, "+?hVvt:p:f:e:c:w:H:SC:"); + #endif + if (c == -1 || c == EOF) + break; + + switch (c) { +*************** +*** 276,285 **** +--- 344,369 ---- + } + else { + usage ("Time interval must be a nonnegative integer\n"); + } + break; ++ case 'S': ++ /* starttls */ ++ use_ssl = TRUE; ++ break; ++ case 'C': /* Check SSL cert validity */ ++ #ifdef HAVE_SSL ++ if (!is_intnonneg (optarg)) ++ usage2 ("invalid certificate expiration period", optarg); ++ days_till_exp = atoi (optarg); ++ check_cert = TRUE; ++ use_ssl = TRUE; ++ #else ++ terminate (STATE_UNKNOWN, ++ "SSL support not available. Install OpenSSL and recompile."); ++ #endif ++ break; + case 'V': /* version */ + print_revision (progname, "$Revision: 1.9.2.2 $"); + exit (STATE_OK); + case 'h': /* help */ + print_help (); +*************** +*** 344,353 **** +--- 428,443 ---- + " Seconds necessary to result in a warning status\n" + " -c, --critical=INTEGER\n" + " Seconds necessary to result in a critical status\n" + " -t, --timeout=INTEGER\n" + " Seconds before connection attempt times out (default: %d)\n" ++ #ifdef HAVE_SSL ++ " -S, --starttls\n" ++ " Use starttls for connection\n" ++ " -C, --certificate\n" ++ " Check certificate\n" ++ #endif + " -v, --verbose\n" + " Print extra information (command-line use only)\n" + " -h, --help\n" + " Print detailed help screen\n" + " -V, --version\n" +*************** +*** 365,370 **** +--- 455,615 ---- + { + printf + ("Usage: %s -H host [-e expect] [-p port] [-f from addr] [-w warn] [-c crit] [-t timeout] [-v]\n" + " %s --help\n" + " %s --version\n", progname, progname, progname); ++ } ++ ++ #ifdef HAVE_SSL ++ int ++ connect_STARTTLS (void) ++ { ++ SSL_METHOD *meth; ++ ++ /* Initialize SSL context */ ++ SSLeay_add_ssl_algorithms (); ++ meth = SSLv2_client_method (); ++ SSL_load_error_strings (); ++ if ((ctx = SSL_CTX_new (meth)) == NULL) ++ { ++ printf ("ERROR: Cannot create SSL context.\n"); ++ return STATE_CRITICAL; ++ } ++ /* Do the SSL handshake */ ++ if ((ssl = SSL_new (ctx)) != NULL) ++ { ++ SSL_set_fd (ssl, sd); ++ /* original version checked for -1 ++ I look for success instead (1) */ ++ if (SSL_connect (ssl) == 1) ++ return OK; ++ ERR_print_errors_fp (stderr); ++ } ++ else ++ { ++ printf ("ERROR: Cannot initiate SSL handshake.\n"); ++ } ++ /* this causes a seg fault ++ not sure why, being sloppy ++ and commenting it out */ ++ // SSL_free (ssl); ++ ++ ++ SSL_CTX_free (ctx); ++ my_close (); ++ ++ return STATE_CRITICAL; ++ } ++ #endif ++ ++ #ifdef HAVE_SSL ++ int ++ check_certificate (X509 ** certificate) ++ { ++ ASN1_STRING *tm; ++ int offset; ++ struct tm stamp; ++ int days_left; ++ ++ ++ /* Retrieve timestamp of certificate */ ++ tm = X509_get_notAfter (*certificate); ++ ++ /* Generate tm structure to process timestamp */ ++ if (tm->type == V_ASN1_UTCTIME) { ++ if (tm->length < 10) { ++ printf ("ERROR: Wrong time format in certificate.\n"); ++ return STATE_CRITICAL; ++ } ++ else { ++ stamp.tm_year = (tm->data[0] - '0') * 10 + (tm->data[1] - '0'); ++ if (stamp.tm_year < 50) ++ stamp.tm_year += 100; ++ offset = 0; ++ } ++ } ++ else { ++ if (tm->length < 12) { ++ printf ("ERROR: Wrong time format in certificate.\n"); ++ return STATE_CRITICAL; ++ } ++ else { ++ stamp.tm_year = ++ (tm->data[0] - '0') * 1000 + (tm->data[1] - '0') * 100 + ++ (tm->data[2] - '0') * 10 + (tm->data[3] - '0'); ++ stamp.tm_year -= 1900; ++ offset = 2; ++ } ++ } ++ stamp.tm_mon = ++ (tm->data[2 + offset] - '0') * 10 + (tm->data[3 + offset] - '0') - 1; ++ stamp.tm_mday = ++ (tm->data[4 + offset] - '0') * 10 + (tm->data[5 + offset] - '0'); ++ stamp.tm_hour = ++ (tm->data[6 + offset] - '0') * 10 + (tm->data[7 + offset] - '0'); ++ stamp.tm_min = ++ (tm->data[8 + offset] - '0') * 10 + (tm->data[9 + offset] - '0'); ++ stamp.tm_sec = 0; ++ stamp.tm_isdst = -1; ++ ++ days_left = (mktime (&stamp) - time (NULL)) / 86400; ++ snprintf ++ (timestamp, 16, "%02d/%02d/%04d %02d:%02d", ++ stamp.tm_mon + 1, ++ stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min); ++ ++ if (days_left > 0 && days_left <= days_till_exp) { ++ printf ("Certificate expires in %d day(s) (%s).\n", days_left, timestamp); ++ return STATE_WARNING; ++ } ++ if (days_left < 0) { ++ printf ("Certificate expired on %s.\n", timestamp); ++ return STATE_CRITICAL; ++ } ++ ++ if (days_left == 0) { ++ printf ("Certificate expires today (%s).\n", timestamp); ++ return STATE_WARNING; ++ } ++ ++ printf ("Certificate will expire on %s.\n", timestamp); ++ ++ return STATE_OK; ++ } ++ #endif ++ ++ int ++ my_recv (void) ++ { ++ int i; ++ ++ #ifdef HAVE_SSL ++ if (use_ssl) { ++ i = SSL_read (ssl, buffer, MAXBUF - 1); ++ } ++ else { ++ #endif ++ i = read (sd, buffer, MAXBUF - 1); ++ #ifdef HAVE_SSL ++ } ++ #endif ++ ++ return i; ++ } ++ ++ int ++ my_close (void) ++ { ++ #ifdef HAVE_SSL ++ if (use_ssl == TRUE) { ++ SSL_shutdown (ssl); ++ SSL_free (ssl); ++ SSL_CTX_free (ctx); ++ return 0; ++ } ++ else { ++ #endif ++ return close (sd); ++ #ifdef HAVE_SSL ++ } ++ #endif + } diff --git a/web/attachments/105911-check_tcp.c.patch b/web/attachments/105911-check_tcp.c.patch new file mode 100644 index 0000000..d080c65 --- /dev/null +++ b/web/attachments/105911-check_tcp.c.patch @@ -0,0 +1,22 @@ +--- check_tcp.c.orig Thu Sep 16 13:03:28 2004 ++++ check_tcp.c Wed Oct 20 12:52:06 2004 +@@ -553,8 +553,9 @@ + + /* Initialize SSL context */ + SSLeay_add_ssl_algorithms (); +- meth = SSLv2_client_method (); ++ meth = SSLv23_client_method (); + SSL_load_error_strings (); ++ OpenSSL_add_all_algorithms(); + if ((ctx = SSL_CTX_new (meth)) == NULL) + { + printf ("ERROR: Cannot create SSL context.\n"); +@@ -577,7 +578,7 @@ + if ((ssl = SSL_new (ctx)) != NULL) + { + SSL_set_fd (ssl, sd); +- if (SSL_connect (ssl) != -1) ++ if (SSL_connect(ssl) == 1) + return OK; + ERR_print_errors_fp (stderr); + } diff --git a/web/attachments/106626-check_nwstat.c.patch b/web/attachments/106626-check_nwstat.c.patch new file mode 100644 index 0000000..28ac31d --- /dev/null +++ b/web/attachments/106626-check_nwstat.c.patch @@ -0,0 +1,18 @@ +--- check_nwstat.c.orig Tue Oct 26 15:38:55 2004 ++++ check_nwstat.c Tue Oct 26 15:40:36 2004 +@@ -178,13 +178,13 @@ + if(result!=STATE_OK) + return result; + if(!strcmp(recv_buffer,"-1\n")) +- asprintf(&netware_version,""); ++ netware_version = strdup(""); + else { + recv_buffer[strlen(recv_buffer)-1]=0; + asprintf(&netware_version,"NetWare %s: ",recv_buffer); + } + } else +- asprintf(&netware_version,""); ++ netware_version = strdup(""); + + + diff --git a/web/attachments/106646-check_nwstat.c.patch b/web/attachments/106646-check_nwstat.c.patch new file mode 100644 index 0000000..28ac31d --- /dev/null +++ b/web/attachments/106646-check_nwstat.c.patch @@ -0,0 +1,18 @@ +--- check_nwstat.c.orig Tue Oct 26 15:38:55 2004 ++++ check_nwstat.c Tue Oct 26 15:40:36 2004 +@@ -178,13 +178,13 @@ + if(result!=STATE_OK) + return result; + if(!strcmp(recv_buffer,"-1\n")) +- asprintf(&netware_version,""); ++ netware_version = strdup(""); + else { + recv_buffer[strlen(recv_buffer)-1]=0; + asprintf(&netware_version,"NetWare %s: ",recv_buffer); + } + } else +- asprintf(&netware_version,""); ++ netware_version = strdup(""); + + + diff --git a/web/attachments/106647-check_tcp.c.patch b/web/attachments/106647-check_tcp.c.patch new file mode 100644 index 0000000..d080c65 --- /dev/null +++ b/web/attachments/106647-check_tcp.c.patch @@ -0,0 +1,22 @@ +--- check_tcp.c.orig Thu Sep 16 13:03:28 2004 ++++ check_tcp.c Wed Oct 20 12:52:06 2004 +@@ -553,8 +553,9 @@ + + /* Initialize SSL context */ + SSLeay_add_ssl_algorithms (); +- meth = SSLv2_client_method (); ++ meth = SSLv23_client_method (); + SSL_load_error_strings (); ++ OpenSSL_add_all_algorithms(); + if ((ctx = SSL_CTX_new (meth)) == NULL) + { + printf ("ERROR: Cannot create SSL context.\n"); +@@ -577,7 +578,7 @@ + if ((ssl = SSL_new (ctx)) != NULL) + { + SSL_set_fd (ssl, sd); +- if (SSL_connect (ssl) != -1) ++ if (SSL_connect(ssl) == 1) + return OK; + ERR_print_errors_fp (stderr); + } diff --git a/web/attachments/109117-check_dns.c.patch b/web/attachments/109117-check_dns.c.patch new file mode 100644 index 0000000..9546cd6 --- /dev/null +++ b/web/attachments/109117-check_dns.c.patch @@ -0,0 +1,64 @@ +--- check_dns.c.old 2004-11-17 13:18:35.000000000 -0700 ++++ check_dns.c 2004-11-17 12:53:21.000000000 -0700 +@@ -38,6 +38,7 @@ + #define ADDRESS_LENGTH 256 + char query_address[ADDRESS_LENGTH] = ""; + char dns_server[ADDRESS_LENGTH] = ""; ++int dns_server_port = 53; + char ptr_server[ADDRESS_LENGTH] = ""; + int verbose = FALSE; + char expected_address[ADDRESS_LENGTH] = ""; +@@ -76,7 +77,7 @@ + } + + /* get the command to run */ +- asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server); ++ asprintf (&command_line, "%s %s %s -port=%d", NSLOOKUP_COMMAND, query_address, dns_server, dns_server_port); + + alarm (timeout_interval); + gettimeofday (&tv, NULL); +@@ -275,6 +276,7 @@ + {"timeout", required_argument, 0, 't'}, + {"hostname", required_argument, 0, 'H'}, + {"server", required_argument, 0, 's'}, ++ {"port", required_argument, 0, 'p'}, + {"reverse-server", required_argument, 0, 'r'}, + {"expected-address", required_argument, 0, 'a'}, + {"expect-authority", no_argument, 0, 'A'}, +@@ -289,7 +291,7 @@ + strcpy (argv[c], "-t"); + + while (1) { +- c = getopt_long (argc, argv, "hVvAt:H:s:r:a:", long_opts, &opt_index); ++ c = getopt_long (argc, argv, "hVvAt:H:p:s:r:a:", long_opts, &opt_index); + + if (c == -1 || c == EOF) + break; +@@ -316,6 +318,9 @@ + die (STATE_UNKNOWN, _("Input buffer overflow\n")); + strcpy (query_address, optarg); + break; ++ case 'p': /* hostname */ ++ dns_server_port = atoi(optarg); ++ break; + case 's': /* server name */ + /* TODO: this is_host check is probably unnecessary. */ + /* Better to confirm nslookup response matches */ +@@ -403,6 +408,8 @@ + The name or address you want to query\n\ + -s, --server=HOST\n\ + Optional DNS server you want to use for the lookup\n\ ++-p, --port=HOST\n\ ++ Optional DNS server port, defaults to 53\n\ + -a, --expected-address=IP-ADDRESS\n\ + Optional IP address you expect the DNS server to return\n\ + -A, --expect-authority\n\ +@@ -426,7 +433,7 @@ + print_usage (void) + { + printf (_("\ +-Usage: %s -H host [-s server] [-a expected-address] [-A] [-t timeout]\n\ ++Usage: %s -H host [-s server] [-p port] [-a expected-address] [-A] [-t timeout]\n\ + %s --help\n\ + %s --version\n"), progname, progname, progname); + } diff --git a/web/attachments/110840-check_snmp_disk_monitor.pl.patch b/web/attachments/110840-check_snmp_disk_monitor.pl.patch new file mode 100644 index 0000000..b617909 --- /dev/null +++ b/web/attachments/110840-check_snmp_disk_monitor.pl.patch @@ -0,0 +1,13 @@ +--- check_snmp_disk_monitor.pl.orig 2004-12-01 16:20:14.502241047 +0300 ++++ check_snmp_disk_monitor.pl 2004-12-01 16:20:34.524424531 +0300 +@@ -37,8 +37,8 @@ + 'H:s' => \$opt_host, 'hostname:s' => \$opt_host, + 'p:i' => \$opt_port, 'port:i' => \$opt_port, + 'C:s' => \$opt_community, 'community:s' => \$opt_community, +- 'c:i' => \$opt_crit, 'critical:i' => \$opt_crit, +- 'w:i' => \$opt_warn, 'warning:i' => \$opt_warn, ++ 'c:i' => \$opt_critical, 'critical:i' => \$opt_critical, ++ 'w:i' => \$opt_warning, 'warning:i' => \$opt_warning, + 't:i' => \$TIMEOUT, 'timeout:i' => \$TIMEOUT, + 'm:s' => \$opt_mountpoint, 'mountpoint:s'=> \$opt_mountpoint + ); diff --git a/web/attachments/111261-nagiosplug-prototypes_-Wall-cleanup.diff b/web/attachments/111261-nagiosplug-prototypes_-Wall-cleanup.diff new file mode 100644 index 0000000..43b3e43 --- /dev/null +++ b/web/attachments/111261-nagiosplug-prototypes_-Wall-cleanup.diff @@ -0,0 +1,1311 @@ +diff -urN ../nagiosplug.orig/plugins/Makefile.in plugins/Makefile.in +--- ../nagiosplug.orig/plugins/Makefile.in 1970-01-01 01:00:00.000000000 +0100 ++++ plugins/Makefile.in 2004-12-04 16:20:36.000000000 +0100 +@@ -0,0 +1,945 @@ ++# Makefile.in generated by automake 1.9.3 from Makefile.am. ++# @configure_input@ ++ ++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, ++# 2003, 2004 Free Software Foundation, Inc. ++# This Makefile.in is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without ++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A ++# PARTICULAR PURPOSE. ++ ++@SET_MAKE@ ++ ++SOURCES = check_by_ssh.c check_dig.c check_disk.c check_dns.c check_dummy.c check_fping.c check_game.c check_hpjd.c check_http.c check_icmp.c check_ide-smart.c check_ldap.c check_load.c check_mrtg.c check_mrtgtraf.c check_mysql.c check_nagios.c check_nt.c check_nwstat.c check_overcr.c check_pgsql.c check_ping.c check_procs.c check_radius.c check_real.c check_smtp.c check_snmp.c check_ssh.c check_swap.c check_tcp.c check_time.c check_udp.c check_ups.c check_users.c negate.c urlize.c ++ ++srcdir = @srcdir@ ++top_srcdir = @top_srcdir@ ++pkgdatadir = $(datadir)/@PACKAGE@ ++pkglibdir = $(libdir)/@PACKAGE@ ++pkgincludedir = $(includedir)/@PACKAGE@ ++top_builddir = .. ++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd ++install_sh_DATA = $(install_sh) -c -m 644 ++install_sh_PROGRAM = $(install_sh) -c ++install_sh_SCRIPT = $(install_sh) -c ++INSTALL_HEADER = $(INSTALL_DATA) ++transform = $(program_transform_name) ++NORMAL_INSTALL = : ++PRE_INSTALL = : ++POST_INSTALL = : ++NORMAL_UNINSTALL = : ++PRE_UNINSTALL = : ++POST_UNINSTALL = : ++build_triplet = @build@ ++host_triplet = @host@ ++libexec_PROGRAMS = check_disk$(EXEEXT) check_dummy$(EXEEXT) \ ++ check_http$(EXEEXT) check_load$(EXEEXT) check_mrtg$(EXEEXT) \ ++ check_mrtgtraf$(EXEEXT) check_nwstat$(EXEEXT) \ ++ check_overcr$(EXEEXT) check_ping$(EXEEXT) check_real$(EXEEXT) \ ++ check_smtp$(EXEEXT) check_ssh$(EXEEXT) check_tcp$(EXEEXT) \ ++ check_time$(EXEEXT) check_udp$(EXEEXT) check_ups$(EXEEXT) \ ++ check_users$(EXEEXT) negate$(EXEEXT) urlize$(EXEEXT) \ ++ check_icmp$(EXEEXT) @EXTRAS@ ++EXTRA_PROGRAMS = check_mysql$(EXEEXT) check_radius$(EXEEXT) \ ++ check_pgsql$(EXEEXT) check_snmp$(EXEEXT) check_hpjd$(EXEEXT) \ ++ check_swap$(EXEEXT) check_fping$(EXEEXT) check_ldap$(EXEEXT) \ ++ check_game$(EXEEXT) check_dig$(EXEEXT) check_nagios$(EXEEXT) \ ++ check_by_ssh$(EXEEXT) check_dns$(EXEEXT) check_nt$(EXEEXT) \ ++ check_ide-smart$(EXEEXT) check_procs$(EXEEXT) ++subdir = plugins ++DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ++am__aclocal_m4_deps = $(top_srcdir)/lib/codeset.m4 \ ++ $(top_srcdir)/lib/error.m4 $(top_srcdir)/lib/fstypename.m4 \ ++ $(top_srcdir)/lib/fsusage.m4 $(top_srcdir)/lib/gettext.m4 \ ++ $(top_srcdir)/lib/glibc21.m4 $(top_srcdir)/lib/iconv.m4 \ ++ $(top_srcdir)/lib/intdiv0.m4 $(top_srcdir)/lib/inttypes-pri.m4 \ ++ $(top_srcdir)/lib/inttypes.m4 $(top_srcdir)/lib/inttypes_h.m4 \ ++ $(top_srcdir)/lib/lcmessage.m4 $(top_srcdir)/lib/lib-ld.m4 \ ++ $(top_srcdir)/lib/lib-link.m4 $(top_srcdir)/lib/lib-prefix.m4 \ ++ $(top_srcdir)/lib/ls-mntd-fs.m4 $(top_srcdir)/lib/onceonly.m4 \ ++ $(top_srcdir)/lib/progtest.m4 $(top_srcdir)/lib/stdint_h.m4 \ ++ $(top_srcdir)/lib/uintmax_t.m4 $(top_srcdir)/lib/ulonglong.m4 \ ++ $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.in ++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ ++ $(ACLOCAL_M4) ++mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs ++CONFIG_HEADER = $(top_builddir)/config.h ++CONFIG_CLEAN_FILES = ++am__installdirs = "$(DESTDIR)$(libexecdir)" ++libexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM) ++PROGRAMS = $(libexec_PROGRAMS) ++check_by_ssh_SOURCES = check_by_ssh.c ++check_by_ssh_OBJECTS = check_by_ssh.$(OBJEXT) ++am__DEPENDENCIES_1 = utils.o ../lib/libnagiosplug.a ++am__DEPENDENCIES_2 = ++am__DEPENDENCIES_3 = netutils.o $(am__DEPENDENCIES_1) \ ++ $(am__DEPENDENCIES_2) ++am__DEPENDENCIES_4 = $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_2) ++check_dig_SOURCES = check_dig.c ++check_dig_OBJECTS = check_dig.$(OBJEXT) ++check_disk_SOURCES = check_disk.c ++check_disk_OBJECTS = check_disk.$(OBJEXT) ++check_dns_SOURCES = check_dns.c ++check_dns_OBJECTS = check_dns.$(OBJEXT) ++check_dummy_SOURCES = check_dummy.c ++check_dummy_OBJECTS = check_dummy.$(OBJEXT) ++check_fping_SOURCES = check_fping.c ++check_fping_OBJECTS = check_fping.$(OBJEXT) ++check_game_SOURCES = check_game.c ++check_game_OBJECTS = check_game.$(OBJEXT) ++check_hpjd_SOURCES = check_hpjd.c ++check_hpjd_OBJECTS = check_hpjd.$(OBJEXT) ++check_http_SOURCES = check_http.c ++check_http_OBJECTS = check_http.$(OBJEXT) ++check_icmp_SOURCES = check_icmp.c ++check_icmp_OBJECTS = check_icmp.$(OBJEXT) ++check_icmp_LDADD = $(LDADD) ++check_ide_smart_SOURCES = check_ide-smart.c ++check_ide_smart_OBJECTS = check_ide-smart.$(OBJEXT) ++check_ide_smart_LDADD = $(LDADD) ++check_ldap_SOURCES = check_ldap.c ++check_ldap_OBJECTS = check_ldap.$(OBJEXT) ++check_load_SOURCES = check_load.c ++check_load_OBJECTS = check_load.$(OBJEXT) ++check_mrtg_SOURCES = check_mrtg.c ++check_mrtg_OBJECTS = check_mrtg.$(OBJEXT) ++check_mrtgtraf_SOURCES = check_mrtgtraf.c ++check_mrtgtraf_OBJECTS = check_mrtgtraf.$(OBJEXT) ++check_mysql_SOURCES = check_mysql.c ++check_mysql_OBJECTS = check_mysql.$(OBJEXT) ++check_nagios_SOURCES = check_nagios.c ++check_nagios_OBJECTS = check_nagios.$(OBJEXT) ++check_nt_SOURCES = check_nt.c ++check_nt_OBJECTS = check_nt.$(OBJEXT) ++check_nwstat_SOURCES = check_nwstat.c ++check_nwstat_OBJECTS = check_nwstat.$(OBJEXT) ++check_overcr_SOURCES = check_overcr.c ++check_overcr_OBJECTS = check_overcr.$(OBJEXT) ++check_pgsql_SOURCES = check_pgsql.c ++check_pgsql_OBJECTS = check_pgsql.$(OBJEXT) ++check_ping_SOURCES = check_ping.c ++check_ping_OBJECTS = check_ping.$(OBJEXT) ++check_procs_SOURCES = check_procs.c ++check_procs_OBJECTS = check_procs.$(OBJEXT) ++check_radius_SOURCES = check_radius.c ++check_radius_OBJECTS = check_radius.$(OBJEXT) ++check_real_SOURCES = check_real.c ++check_real_OBJECTS = check_real.$(OBJEXT) ++check_smtp_SOURCES = check_smtp.c ++check_smtp_OBJECTS = check_smtp.$(OBJEXT) ++check_snmp_SOURCES = check_snmp.c ++check_snmp_OBJECTS = check_snmp.$(OBJEXT) ++check_ssh_SOURCES = check_ssh.c ++check_ssh_OBJECTS = check_ssh.$(OBJEXT) ++check_swap_SOURCES = check_swap.c ++check_swap_OBJECTS = check_swap.$(OBJEXT) ++check_tcp_SOURCES = check_tcp.c ++check_tcp_OBJECTS = check_tcp.$(OBJEXT) ++check_time_SOURCES = check_time.c ++check_time_OBJECTS = check_time.$(OBJEXT) ++check_udp_SOURCES = check_udp.c ++check_udp_OBJECTS = check_udp.$(OBJEXT) ++check_ups_SOURCES = check_ups.c ++check_ups_OBJECTS = check_ups.$(OBJEXT) ++check_users_SOURCES = check_users.c ++check_users_OBJECTS = check_users.$(OBJEXT) ++negate_SOURCES = negate.c ++negate_OBJECTS = negate.$(OBJEXT) ++urlize_SOURCES = urlize.c ++urlize_OBJECTS = urlize.$(OBJEXT) ++DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) ++depcomp = $(SHELL) $(top_srcdir)/depcomp ++am__depfiles_maybe = depfiles ++COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ ++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) ++CCLD = $(CC) ++LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ ++SOURCES = check_by_ssh.c check_dig.c check_disk.c check_dns.c \ ++ check_dummy.c check_fping.c check_game.c check_hpjd.c \ ++ check_http.c check_icmp.c check_ide-smart.c check_ldap.c \ ++ check_load.c check_mrtg.c check_mrtgtraf.c check_mysql.c \ ++ check_nagios.c check_nt.c check_nwstat.c check_overcr.c \ ++ check_pgsql.c check_ping.c check_procs.c check_radius.c \ ++ check_real.c check_smtp.c check_snmp.c check_ssh.c \ ++ check_swap.c check_tcp.c check_time.c check_udp.c check_ups.c \ ++ check_users.c negate.c urlize.c ++DIST_SOURCES = check_by_ssh.c check_dig.c check_disk.c check_dns.c \ ++ check_dummy.c check_fping.c check_game.c check_hpjd.c \ ++ check_http.c check_icmp.c check_ide-smart.c check_ldap.c \ ++ check_load.c check_mrtg.c check_mrtgtraf.c check_mysql.c \ ++ check_nagios.c check_nt.c check_nwstat.c check_overcr.c \ ++ check_pgsql.c check_ping.c check_procs.c check_radius.c \ ++ check_real.c check_smtp.c check_snmp.c check_ssh.c \ ++ check_swap.c check_tcp.c check_time.c check_udp.c check_ups.c \ ++ check_users.c negate.c urlize.c ++ETAGS = etags ++CTAGS = ctags ++DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ++VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t ++INSTALL = @INSTALL@ ++ACLOCAL = @ACLOCAL@ ++ALLOCA = @ALLOCA@ ++AMDEP_FALSE = @AMDEP_FALSE@ ++AMDEP_TRUE = @AMDEP_TRUE@ ++AMTAR = @AMTAR@ ++AUTOCONF = @AUTOCONF@ ++AUTOHEADER = @AUTOHEADER@ ++AUTOMAKE = @AUTOMAKE@ ++AWK = @AWK@ ++BASENAME = @BASENAME@ ++BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ ++CATOBJEXT = @CATOBJEXT@ ++CC = @CC@ ++CCDEPMODE = @CCDEPMODE@ ++CFLAGS = @CFLAGS@ ++CPP = @CPP@ ++CPPFLAGS = @CPPFLAGS@ ++CYGPATH_W = @CYGPATH_W@ ++DATADIRNAME = @DATADIRNAME@ ++DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ ++DEPDIR = @DEPDIR@ ++DEPLIBS = @DEPLIBS@ ++ECHO_C = @ECHO_C@ ++ECHO_N = @ECHO_N@ ++ECHO_T = @ECHO_T@ ++EGREP = @EGREP@ ++EXEEXT = @EXEEXT@ ++EXTRAS = @EXTRAS@ ++EXTRA_NETOBJS = @EXTRA_NETOBJS@ ++GENCAT = @GENCAT@ ++GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ ++GLIBC21 = @GLIBC21@ ++GMSGFMT = @GMSGFMT@ ++HOSTNAME = @HOSTNAME@ ++INSTALL_DATA = @INSTALL_DATA@ ++INSTALL_OPTS = @INSTALL_OPTS@ ++INSTALL_PROGRAM = @INSTALL_PROGRAM@ ++INSTALL_SCRIPT = @INSTALL_SCRIPT@ ++INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ ++INSTOBJEXT = @INSTOBJEXT@ ++INTLBISON = @INTLBISON@ ++INTLLIBS = @INTLLIBS@ ++INTLOBJS = @INTLOBJS@ ++INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ ++KMEM_GROUP = @KMEM_GROUP@ ++KRBINCLUDE = @KRBINCLUDE@ ++LDAPINCLUDE = @LDAPINCLUDE@ ++LDAPLIBS = @LDAPLIBS@ ++LDFLAGS = @LDFLAGS@ ++LIBICONV = @LIBICONV@ ++LIBINTL = @LIBINTL@ ++LIBOBJS = @LIBOBJS@ ++LIBS = @LIBINTL@ @LIBS@ ++LTLIBICONV = @LTLIBICONV@ ++LTLIBINTL = @LTLIBINTL@ ++LTLIBOBJS = @LTLIBOBJS@ ++MAKEINFO = @MAKEINFO@ ++MKINSTALLDIRS = @MKINSTALLDIRS@ ++MSGFMT = @MSGFMT@ ++MSGMERGE = @MSGMERGE@ ++MYSQLINCLUDE = @MYSQLINCLUDE@ ++MYSQLLIBS = @MYSQLLIBS@ ++NEED_SETGID = @NEED_SETGID@ ++NEED_VA_LIST = @NEED_VA_LIST@ ++OBJEXT = @OBJEXT@ ++OPENSSL = @OPENSSL@ ++PACKAGE = @PACKAGE@ ++PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ ++PACKAGE_NAME = @PACKAGE_NAME@ ++PACKAGE_STRING = @PACKAGE_STRING@ ++PACKAGE_TARNAME = @PACKAGE_TARNAME@ ++PACKAGE_VERSION = @PACKAGE_VERSION@ ++PATH_SEPARATOR = @PATH_SEPARATOR@ ++PATH_TO_DIG = @PATH_TO_DIG@ ++PATH_TO_FPING = @PATH_TO_FPING@ ++PATH_TO_HOST = @PATH_TO_HOST@ ++PATH_TO_LMSTAT = @PATH_TO_LMSTAT@ ++PATH_TO_LSPS = @PATH_TO_LSPS@ ++PATH_TO_MAILQ = @PATH_TO_MAILQ@ ++PATH_TO_NSLOOKUP = @PATH_TO_NSLOOKUP@ ++PATH_TO_NTPDATE = @PATH_TO_NTPDATE@ ++PATH_TO_NTPDC = @PATH_TO_NTPDC@ ++PATH_TO_NTPQ = @PATH_TO_NTPQ@ ++PATH_TO_PING = @PATH_TO_PING@ ++PATH_TO_PING6 = @PATH_TO_PING6@ ++PATH_TO_PS = @PATH_TO_PS@ ++PATH_TO_QMAIL_QSTAT = @PATH_TO_QMAIL_QSTAT@ ++PATH_TO_QSTAT = @PATH_TO_QSTAT@ ++PATH_TO_QUAKESTAT = @PATH_TO_QUAKESTAT@ ++PATH_TO_RPCINFO = @PATH_TO_RPCINFO@ ++PATH_TO_SMBCLIENT = @PATH_TO_SMBCLIENT@ ++PATH_TO_SNMPGET = @PATH_TO_SNMPGET@ ++PATH_TO_SNMPGETNEXT = @PATH_TO_SNMPGETNEXT@ ++PATH_TO_SSH = @PATH_TO_SSH@ ++PATH_TO_SWAP = @PATH_TO_SWAP@ ++PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@ ++PATH_TO_UPTIME = @PATH_TO_UPTIME@ ++PATH_TO_WHO = @PATH_TO_WHO@ ++PERL = @PERL@ ++PGINCLUDE = @PGINCLUDE@ ++PGLIBS = @PGLIBS@ ++PKG_ARCH = @PKG_ARCH@ ++PLUGIN_TEST = @PLUGIN_TEST@ ++POSUB = @POSUB@ ++POW_LIB = @POW_LIB@ ++PYTHON = @PYTHON@ ++RADIUSLIBS = @RADIUSLIBS@ ++RANLIB = @RANLIB@ ++RELEASE = @RELEASE@ ++REV_DATESTAMP = @REV_DATESTAMP@ ++REV_TIMESTAMP = @REV_TIMESTAMP@ ++SCRIPT_TEST = @SCRIPT_TEST@ ++SET_MAKE = @SET_MAKE@ ++SH = @SH@ ++SHELL = @SHELL@ ++SOCKETLIBS = @SOCKETLIBS@ ++SSLINCLUDE = @SSLINCLUDE@ ++SSLLIBS = @SSLLIBS@ ++STRIP = @STRIP@ ++SUPPORT = @SUPPORT@ ++USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ ++USE_NLS = @USE_NLS@ ++VERSION = @VERSION@ ++WARRANTY = @WARRANTY@ ++XGETTEXT = @XGETTEXT@ ++ac_ct_CC = @ac_ct_CC@ ++ac_ct_RANLIB = @ac_ct_RANLIB@ ++ac_ct_STRIP = @ac_ct_STRIP@ ++am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ ++am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ ++am__include = @am__include@ ++am__leading_dot = @am__leading_dot@ ++am__quote = @am__quote@ ++am__tar = @am__tar@ ++am__untar = @am__untar@ ++bindir = @bindir@ ++build = @build@ ++build_alias = @build_alias@ ++build_cpu = @build_cpu@ ++build_os = @build_os@ ++build_vendor = @build_vendor@ ++check_mysql_LDFLAGS = @check_mysql_LDFLAGS@ ++check_tcp_ssl = @check_tcp_ssl@ ++datadir = @datadir@ ++exec_prefix = @exec_prefix@ ++host = @host@ ++host_alias = @host_alias@ ++host_cpu = @host_cpu@ ++host_os = @host_os@ ++host_vendor = @host_vendor@ ++includedir = @includedir@ ++infodir = @infodir@ ++install_sh = @install_sh@ ++libdir = @libdir@ ++libexecdir = @libexecdir@ ++localstatedir = @localstatedir@ ++mandir = @mandir@ ++mkdir_p = @mkdir_p@ ++oldincludedir = @oldincludedir@ ++prefix = @prefix@ ++program_transform_name = @program_transform_name@ ++sbindir = @sbindir@ ++sharedstatedir = @sharedstatedir@ ++sysconfdir = @sysconfdir@ ++target_alias = @target_alias@ ++with_nagios_group = @with_nagios_group@ ++with_nagios_user = @with_nagios_user@ ++with_trusted_path = @with_trusted_path@ ++INCLUDES = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/intl \ ++@LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@ ++ ++localedir = $(datadir)/locale ++check_tcp_programs = check_ftp check_imap check_nntp check_pop check_udp2 \ ++ @check_tcp_ssl@ ++ ++EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \ ++ getaddrinfo.c getaddrinfo.h gethostbyname.c gethostbyname.h ++ ++PLUGINHDRS = common.h ++BASEOBJS = utils.o ../lib/libnagiosplug.a ++NETOBJS = netutils.o $(BASEOBJS) $(EXTRA_NETOBJS) ++NETLIBS = $(NETOBJS) $(SOCKETLIBS) ++TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir) ++TESTS = @PLUGIN_TEST@ ++AM_INSTALL_PROGRAM_FLAGS = @INSTALL_OPTS@ ++ ++############################################################################## ++# the actual targets ++check_dig_LDADD = $(NETLIBS) popen.o ++check_disk_LDADD = $(BASEOBJS) popen.o ++check_dns_LDADD = $(NETLIBS) popen.o ++check_dummy_LDADD = $(BASEOBJS) ++check_fping_LDADD = $(NETLIBS) popen.o ++check_game_LDADD = $(BASEOBJS) popen.o ++check_http_LDADD = $(NETLIBS) $(SSLLIBS) ++check_hpjd_LDADD = $(NETLIBS) popen.o ++check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS) ++check_load_LDADD = $(BASEOBJS) popen.o ++check_mrtg_LDADD = $(BASEOBJS) ++check_mrtgtraf_LDADD = $(BASEOBJS) ++check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS) ++check_nagios_LDADD = $(BASEOBJS) popen.o ++check_nt_LDADD = $(NETLIBS) ++check_nwstat_LDADD = $(NETLIBS) ++check_overcr_LDADD = $(NETLIBS) ++check_pgsql_LDADD = $(NETLIBS) $(PGLIBS) ++check_ping_LDADD = $(NETLIBS) popen.o ++check_procs_LDADD = $(BASEOBJS) popen.o ++check_radius_LDADD = $(NETLIBS) $(RADIUSLIBS) ++check_real_LDADD = $(NETLIBS) ++check_snmp_LDADD = $(BASEOBJS) popen.o ++check_smtp_LDADD = $(NETLIBS) ++check_ssh_LDADD = $(NETLIBS) ++check_swap_LDADD = $(BASEOBJS) popen.o ++check_tcp_LDADD = $(NETLIBS) $(SSLLIBS) ++check_time_LDADD = $(NETLIBS) ++check_udp_LDADD = $(NETLIBS) ++check_ups_LDADD = $(NETLIBS) ++check_users_LDADD = $(BASEOBJS) popen.o ++check_by_ssh_LDADD = $(NETLIBS) popen.o ++negate_LDADD = $(BASEOBJS) popen.o ++urlize_LDADD = $(BASEOBJS) popen.o ++check_dig_DEPENDENCIES = check_dig.c $(NETOBJS) popen.o $(DEPLIBS) ++check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) popen.o $(DEPLIBS) ++check_dns_DEPENDENCIES = check_dns.c $(NETOBJS) popen.o $(DEPLIBS) ++check_dummy_DEPENDENCIES = check_dummy.c $(DEPLIBS) ++check_fping_DEPENDENCIES = check_fping.c $(NETOBJS) popen.o $(DEPLIBS) ++check_game_DEPENDENCIES = check_game.c $(DEPLIBS) ++check_http_DEPENDENCIES = check_http.c $(NETOBJS) $(DEPLIBS) ++check_hpjd_DEPENDENCIES = check_hpjd.c $(NETOBJS) popen.o $(DEPLIBS) ++check_ldap_DEPENDENCIES = check_ldap.c $(NETOBJS) $(DEPLIBS) ++check_load_DEPENDENCIES = check_load.c $(BASEOBJS) popen.o $(DEPLIBS) ++check_mrtg_DEPENDENCIES = check_mrtg.c $(DEPLIBS) ++check_mrtgtraf_DEPENDENCIES = check_mrtgtraf.c $(DEPLIBS) ++check_mysql_DEPENDENCIES = check_mysql.c $(NETOBJS) $(DEPLIBS) ++check_nagios_DEPENDENCIES = check_nagios.c $(BASEOBJS) popen.o $(DEPLIBS) ++check_nt_DEPENDENCIES = check_nt.c $(NETOBJS) $(DEPLIBS) ++check_nwstat_DEPENDENCIES = check_nwstat.c $(NETOBJS) $(DEPLIBS) ++check_overcr_DEPENDENCIES = check_overcr.c $(NETOBJS) $(DEPLIBS) ++check_pgsql_DEPENDENCIES = check_pgsql.c $(NETOBJS) $(DEPLIBS) ++check_ping_DEPENDENCIES = check_ping.c $(NETOBJS) popen.o $(DEPLIBS) ++check_procs_DEPENDENCIES = check_procs.c $(BASEOBJS) popen.o $(DEPLIBS) ++check_radius_DEPENDENCIES = check_radius.c $(NETOBJS) $(DEPLIBS) ++check_real_DEPENDENCIES = check_real.c $(NETOBJS) $(DEPLIBS) ++check_snmp_DEPENDENCIES = check_snmp.c $(BASEOBJS) popen.o $(DEPLIBS) ++check_smtp_DEPENDENCIES = check_smtp.c $(NETOBJS) $(DEPLIBS) ++check_ssh_DEPENDENCIES = check_ssh.c $(NETOBJS) $(DEPLIBS) ++check_swap_DEPENDENCIES = check_swap.c $(BASEOBJS) popen.o $(DEPLIBS) ++check_tcp_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS) ++check_time_DEPENDENCIES = check_time.c $(NETOBJS) $(DEPLIBS) ++check_udp_DEPENDENCIES = check_udp.c $(NETOBJS) $(DEPLIBS) ++check_ups_DEPENDENCIES = check_ups.c $(NETOBJS) $(DEPLIBS) ++check_users_DEPENDENCIES = check_users.c $(BASEOBJS) popen.o $(DEPLIBS) ++check_by_ssh_DEPENDENCIES = check_by_ssh.c $(NETOBJS) popen.o $(DEPLIBS) ++negate_DEPENDENCIES = negate.c $(BASEOBJS) popen.o $(DEPLIBS) ++urlize_DEPENDENCIES = urlize.c $(BASEOBJS) popen.o $(DEPLIBS) ++check_icmp_DEPENDENCIES = check_icmp.c $(DEPLIBS) ++all: all-am ++ ++.SUFFIXES: ++.SUFFIXES: .c .o .obj ++$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) ++ @for dep in $?; do \ ++ case '$(am__configure_deps)' in \ ++ *$$dep*) \ ++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ ++ && exit 0; \ ++ exit 1;; \ ++ esac; \ ++ done; \ ++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins/Makefile'; \ ++ cd $(top_srcdir) && \ ++ $(AUTOMAKE) --gnu plugins/Makefile ++.PRECIOUS: Makefile ++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status ++ @case '$?' in \ ++ *config.status*) \ ++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ ++ *) \ ++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ ++ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ ++ esac; ++ ++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) ++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ++ ++$(top_srcdir)/configure: $(am__configure_deps) ++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ++$(ACLOCAL_M4): $(am__aclocal_m4_deps) ++ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ++install-libexecPROGRAMS: $(libexec_PROGRAMS) ++ @$(NORMAL_INSTALL) ++ test -z "$(libexecdir)" || $(mkdir_p) "$(DESTDIR)$(libexecdir)" ++ @list='$(libexec_PROGRAMS)'; for p in $$list; do \ ++ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ ++ if test -f $$p \ ++ ; then \ ++ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ ++ echo " $(INSTALL_PROGRAM_ENV) $(libexecPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(libexecdir)/$$f'"; \ ++ $(INSTALL_PROGRAM_ENV) $(libexecPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(libexecdir)/$$f" || exit 1; \ ++ else :; fi; \ ++ done ++ ++uninstall-libexecPROGRAMS: ++ @$(NORMAL_UNINSTALL) ++ @list='$(libexec_PROGRAMS)'; for p in $$list; do \ ++ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ ++ echo " rm -f '$(DESTDIR)$(libexecdir)/$$f'"; \ ++ rm -f "$(DESTDIR)$(libexecdir)/$$f"; \ ++ done ++ ++clean-libexecPROGRAMS: ++ -test -z "$(libexec_PROGRAMS)" || rm -f $(libexec_PROGRAMS) ++check_by_ssh$(EXEEXT): $(check_by_ssh_OBJECTS) $(check_by_ssh_DEPENDENCIES) ++ @rm -f check_by_ssh$(EXEEXT) ++ $(LINK) $(check_by_ssh_LDFLAGS) $(check_by_ssh_OBJECTS) $(check_by_ssh_LDADD) $(LIBS) ++check_dig$(EXEEXT): $(check_dig_OBJECTS) $(check_dig_DEPENDENCIES) ++ @rm -f check_dig$(EXEEXT) ++ $(LINK) $(check_dig_LDFLAGS) $(check_dig_OBJECTS) $(check_dig_LDADD) $(LIBS) ++check_disk$(EXEEXT): $(check_disk_OBJECTS) $(check_disk_DEPENDENCIES) ++ @rm -f check_disk$(EXEEXT) ++ $(LINK) $(check_disk_LDFLAGS) $(check_disk_OBJECTS) $(check_disk_LDADD) $(LIBS) ++check_dns$(EXEEXT): $(check_dns_OBJECTS) $(check_dns_DEPENDENCIES) ++ @rm -f check_dns$(EXEEXT) ++ $(LINK) $(check_dns_LDFLAGS) $(check_dns_OBJECTS) $(check_dns_LDADD) $(LIBS) ++check_dummy$(EXEEXT): $(check_dummy_OBJECTS) $(check_dummy_DEPENDENCIES) ++ @rm -f check_dummy$(EXEEXT) ++ $(LINK) $(check_dummy_LDFLAGS) $(check_dummy_OBJECTS) $(check_dummy_LDADD) $(LIBS) ++check_fping$(EXEEXT): $(check_fping_OBJECTS) $(check_fping_DEPENDENCIES) ++ @rm -f check_fping$(EXEEXT) ++ $(LINK) $(check_fping_LDFLAGS) $(check_fping_OBJECTS) $(check_fping_LDADD) $(LIBS) ++check_game$(EXEEXT): $(check_game_OBJECTS) $(check_game_DEPENDENCIES) ++ @rm -f check_game$(EXEEXT) ++ $(LINK) $(check_game_LDFLAGS) $(check_game_OBJECTS) $(check_game_LDADD) $(LIBS) ++check_hpjd$(EXEEXT): $(check_hpjd_OBJECTS) $(check_hpjd_DEPENDENCIES) ++ @rm -f check_hpjd$(EXEEXT) ++ $(LINK) $(check_hpjd_LDFLAGS) $(check_hpjd_OBJECTS) $(check_hpjd_LDADD) $(LIBS) ++check_http$(EXEEXT): $(check_http_OBJECTS) $(check_http_DEPENDENCIES) ++ @rm -f check_http$(EXEEXT) ++ $(LINK) $(check_http_LDFLAGS) $(check_http_OBJECTS) $(check_http_LDADD) $(LIBS) ++check_icmp$(EXEEXT): $(check_icmp_OBJECTS) $(check_icmp_DEPENDENCIES) ++ @rm -f check_icmp$(EXEEXT) ++ $(LINK) $(check_icmp_LDFLAGS) $(check_icmp_OBJECTS) $(check_icmp_LDADD) $(LIBS) ++check_ide-smart$(EXEEXT): $(check_ide_smart_OBJECTS) $(check_ide_smart_DEPENDENCIES) ++ @rm -f check_ide-smart$(EXEEXT) ++ $(LINK) $(check_ide_smart_LDFLAGS) $(check_ide_smart_OBJECTS) $(check_ide_smart_LDADD) $(LIBS) ++check_ldap$(EXEEXT): $(check_ldap_OBJECTS) $(check_ldap_DEPENDENCIES) ++ @rm -f check_ldap$(EXEEXT) ++ $(LINK) $(check_ldap_LDFLAGS) $(check_ldap_OBJECTS) $(check_ldap_LDADD) $(LIBS) ++check_load$(EXEEXT): $(check_load_OBJECTS) $(check_load_DEPENDENCIES) ++ @rm -f check_load$(EXEEXT) ++ $(LINK) $(check_load_LDFLAGS) $(check_load_OBJECTS) $(check_load_LDADD) $(LIBS) ++check_mrtg$(EXEEXT): $(check_mrtg_OBJECTS) $(check_mrtg_DEPENDENCIES) ++ @rm -f check_mrtg$(EXEEXT) ++ $(LINK) $(check_mrtg_LDFLAGS) $(check_mrtg_OBJECTS) $(check_mrtg_LDADD) $(LIBS) ++check_mrtgtraf$(EXEEXT): $(check_mrtgtraf_OBJECTS) $(check_mrtgtraf_DEPENDENCIES) ++ @rm -f check_mrtgtraf$(EXEEXT) ++ $(LINK) $(check_mrtgtraf_LDFLAGS) $(check_mrtgtraf_OBJECTS) $(check_mrtgtraf_LDADD) $(LIBS) ++check_mysql$(EXEEXT): $(check_mysql_OBJECTS) $(check_mysql_DEPENDENCIES) ++ @rm -f check_mysql$(EXEEXT) ++ $(LINK) $(check_mysql_LDFLAGS) $(check_mysql_OBJECTS) $(check_mysql_LDADD) $(LIBS) ++check_nagios$(EXEEXT): $(check_nagios_OBJECTS) $(check_nagios_DEPENDENCIES) ++ @rm -f check_nagios$(EXEEXT) ++ $(LINK) $(check_nagios_LDFLAGS) $(check_nagios_OBJECTS) $(check_nagios_LDADD) $(LIBS) ++check_nt$(EXEEXT): $(check_nt_OBJECTS) $(check_nt_DEPENDENCIES) ++ @rm -f check_nt$(EXEEXT) ++ $(LINK) $(check_nt_LDFLAGS) $(check_nt_OBJECTS) $(check_nt_LDADD) $(LIBS) ++check_nwstat$(EXEEXT): $(check_nwstat_OBJECTS) $(check_nwstat_DEPENDENCIES) ++ @rm -f check_nwstat$(EXEEXT) ++ $(LINK) $(check_nwstat_LDFLAGS) $(check_nwstat_OBJECTS) $(check_nwstat_LDADD) $(LIBS) ++check_overcr$(EXEEXT): $(check_overcr_OBJECTS) $(check_overcr_DEPENDENCIES) ++ @rm -f check_overcr$(EXEEXT) ++ $(LINK) $(check_overcr_LDFLAGS) $(check_overcr_OBJECTS) $(check_overcr_LDADD) $(LIBS) ++check_pgsql$(EXEEXT): $(check_pgsql_OBJECTS) $(check_pgsql_DEPENDENCIES) ++ @rm -f check_pgsql$(EXEEXT) ++ $(LINK) $(check_pgsql_LDFLAGS) $(check_pgsql_OBJECTS) $(check_pgsql_LDADD) $(LIBS) ++check_ping$(EXEEXT): $(check_ping_OBJECTS) $(check_ping_DEPENDENCIES) ++ @rm -f check_ping$(EXEEXT) ++ $(LINK) $(check_ping_LDFLAGS) $(check_ping_OBJECTS) $(check_ping_LDADD) $(LIBS) ++check_procs$(EXEEXT): $(check_procs_OBJECTS) $(check_procs_DEPENDENCIES) ++ @rm -f check_procs$(EXEEXT) ++ $(LINK) $(check_procs_LDFLAGS) $(check_procs_OBJECTS) $(check_procs_LDADD) $(LIBS) ++check_radius$(EXEEXT): $(check_radius_OBJECTS) $(check_radius_DEPENDENCIES) ++ @rm -f check_radius$(EXEEXT) ++ $(LINK) $(check_radius_LDFLAGS) $(check_radius_OBJECTS) $(check_radius_LDADD) $(LIBS) ++check_real$(EXEEXT): $(check_real_OBJECTS) $(check_real_DEPENDENCIES) ++ @rm -f check_real$(EXEEXT) ++ $(LINK) $(check_real_LDFLAGS) $(check_real_OBJECTS) $(check_real_LDADD) $(LIBS) ++check_smtp$(EXEEXT): $(check_smtp_OBJECTS) $(check_smtp_DEPENDENCIES) ++ @rm -f check_smtp$(EXEEXT) ++ $(LINK) $(check_smtp_LDFLAGS) $(check_smtp_OBJECTS) $(check_smtp_LDADD) $(LIBS) ++check_snmp$(EXEEXT): $(check_snmp_OBJECTS) $(check_snmp_DEPENDENCIES) ++ @rm -f check_snmp$(EXEEXT) ++ $(LINK) $(check_snmp_LDFLAGS) $(check_snmp_OBJECTS) $(check_snmp_LDADD) $(LIBS) ++check_ssh$(EXEEXT): $(check_ssh_OBJECTS) $(check_ssh_DEPENDENCIES) ++ @rm -f check_ssh$(EXEEXT) ++ $(LINK) $(check_ssh_LDFLAGS) $(check_ssh_OBJECTS) $(check_ssh_LDADD) $(LIBS) ++check_swap$(EXEEXT): $(check_swap_OBJECTS) $(check_swap_DEPENDENCIES) ++ @rm -f check_swap$(EXEEXT) ++ $(LINK) $(check_swap_LDFLAGS) $(check_swap_OBJECTS) $(check_swap_LDADD) $(LIBS) ++check_tcp$(EXEEXT): $(check_tcp_OBJECTS) $(check_tcp_DEPENDENCIES) ++ @rm -f check_tcp$(EXEEXT) ++ $(LINK) $(check_tcp_LDFLAGS) $(check_tcp_OBJECTS) $(check_tcp_LDADD) $(LIBS) ++check_time$(EXEEXT): $(check_time_OBJECTS) $(check_time_DEPENDENCIES) ++ @rm -f check_time$(EXEEXT) ++ $(LINK) $(check_time_LDFLAGS) $(check_time_OBJECTS) $(check_time_LDADD) $(LIBS) ++check_udp$(EXEEXT): $(check_udp_OBJECTS) $(check_udp_DEPENDENCIES) ++ @rm -f check_udp$(EXEEXT) ++ $(LINK) $(check_udp_LDFLAGS) $(check_udp_OBJECTS) $(check_udp_LDADD) $(LIBS) ++check_ups$(EXEEXT): $(check_ups_OBJECTS) $(check_ups_DEPENDENCIES) ++ @rm -f check_ups$(EXEEXT) ++ $(LINK) $(check_ups_LDFLAGS) $(check_ups_OBJECTS) $(check_ups_LDADD) $(LIBS) ++check_users$(EXEEXT): $(check_users_OBJECTS) $(check_users_DEPENDENCIES) ++ @rm -f check_users$(EXEEXT) ++ $(LINK) $(check_users_LDFLAGS) $(check_users_OBJECTS) $(check_users_LDADD) $(LIBS) ++negate$(EXEEXT): $(negate_OBJECTS) $(negate_DEPENDENCIES) ++ @rm -f negate$(EXEEXT) ++ $(LINK) $(negate_LDFLAGS) $(negate_OBJECTS) $(negate_LDADD) $(LIBS) ++urlize$(EXEEXT): $(urlize_OBJECTS) $(urlize_DEPENDENCIES) ++ @rm -f urlize$(EXEEXT) ++ $(LINK) $(urlize_LDFLAGS) $(urlize_OBJECTS) $(urlize_LDADD) $(LIBS) ++ ++mostlyclean-compile: ++ -rm -f *.$(OBJEXT) ++ ++distclean-compile: ++ -rm -f *.tab.c ++ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_by_ssh.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_dig.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_disk.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_dns.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_dummy.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_fping.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_game.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_hpjd.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_http.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_icmp.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_ide-smart.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_ldap.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_load.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_mrtg.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_mrtgtraf.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_mysql.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_nagios.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_nt.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_nwstat.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_overcr.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_pgsql.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_ping.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_procs.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_radius.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_real.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_smtp.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_snmp.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_ssh.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_swap.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_tcp.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_time.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_udp.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_ups.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_users.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/negate.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/urlize.Po@am__quote@ ++ ++.c.o: ++@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ ++@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ ++@am__fastdepCC_FALSE@ $(COMPILE) -c $< ++ ++.c.obj: ++@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ ++@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ ++@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` ++uninstall-info-am: ++ ++ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) ++ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ ++ unique=`for i in $$list; do \ ++ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ ++ done | \ ++ $(AWK) ' { files[$$0] = 1; } \ ++ END { for (i in files) print i; }'`; \ ++ mkid -fID $$unique ++tags: TAGS ++ ++TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ ++ $(TAGS_FILES) $(LISP) ++ tags=; \ ++ here=`pwd`; \ ++ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ ++ unique=`for i in $$list; do \ ++ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ ++ done | \ ++ $(AWK) ' { files[$$0] = 1; } \ ++ END { for (i in files) print i; }'`; \ ++ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ ++ test -n "$$unique" || unique=$$empty_fix; \ ++ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ ++ $$tags $$unique; \ ++ fi ++ctags: CTAGS ++CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ ++ $(TAGS_FILES) $(LISP) ++ tags=; \ ++ here=`pwd`; \ ++ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ ++ unique=`for i in $$list; do \ ++ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ ++ done | \ ++ $(AWK) ' { files[$$0] = 1; } \ ++ END { for (i in files) print i; }'`; \ ++ test -z "$(CTAGS_ARGS)$$tags$$unique" \ ++ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ ++ $$tags $$unique ++ ++GTAGS: ++ here=`$(am__cd) $(top_builddir) && pwd` \ ++ && cd $(top_srcdir) \ ++ && gtags -i $(GTAGS_ARGS) $$here ++ ++distclean-tags: ++ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags ++ ++check-TESTS: $(TESTS) ++ @failed=0; all=0; xfail=0; xpass=0; skip=0; \ ++ srcdir=$(srcdir); export srcdir; \ ++ list='$(TESTS)'; \ ++ if test -n "$$list"; then \ ++ for tst in $$list; do \ ++ if test -f ./$$tst; then dir=./; \ ++ elif test -f $$tst; then dir=; \ ++ else dir="$(srcdir)/"; fi; \ ++ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ ++ all=`expr $$all + 1`; \ ++ case " $(XFAIL_TESTS) " in \ ++ *" $$tst "*) \ ++ xpass=`expr $$xpass + 1`; \ ++ failed=`expr $$failed + 1`; \ ++ echo "XPASS: $$tst"; \ ++ ;; \ ++ *) \ ++ echo "PASS: $$tst"; \ ++ ;; \ ++ esac; \ ++ elif test $$? -ne 77; then \ ++ all=`expr $$all + 1`; \ ++ case " $(XFAIL_TESTS) " in \ ++ *" $$tst "*) \ ++ xfail=`expr $$xfail + 1`; \ ++ echo "XFAIL: $$tst"; \ ++ ;; \ ++ *) \ ++ failed=`expr $$failed + 1`; \ ++ echo "FAIL: $$tst"; \ ++ ;; \ ++ esac; \ ++ else \ ++ skip=`expr $$skip + 1`; \ ++ echo "SKIP: $$tst"; \ ++ fi; \ ++ done; \ ++ if test "$$failed" -eq 0; then \ ++ if test "$$xfail" -eq 0; then \ ++ banner="All $$all tests passed"; \ ++ else \ ++ banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ ++ fi; \ ++ else \ ++ if test "$$xpass" -eq 0; then \ ++ banner="$$failed of $$all tests failed"; \ ++ else \ ++ banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ ++ fi; \ ++ fi; \ ++ dashes="$$banner"; \ ++ skipped=""; \ ++ if test "$$skip" -ne 0; then \ ++ skipped="($$skip tests were not run)"; \ ++ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ ++ dashes="$$skipped"; \ ++ fi; \ ++ report=""; \ ++ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ ++ report="Please report to $(PACKAGE_BUGREPORT)"; \ ++ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ ++ dashes="$$report"; \ ++ fi; \ ++ dashes=`echo "$$dashes" | sed s/./=/g`; \ ++ echo "$$dashes"; \ ++ echo "$$banner"; \ ++ test -z "$$skipped" || echo "$$skipped"; \ ++ test -z "$$report" || echo "$$report"; \ ++ echo "$$dashes"; \ ++ test "$$failed" -eq 0; \ ++ else :; fi ++ ++distdir: $(DISTFILES) ++ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ ++ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ ++ list='$(DISTFILES)'; for file in $$list; do \ ++ case $$file in \ ++ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ ++ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ ++ esac; \ ++ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ ++ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ ++ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ ++ dir="/$$dir"; \ ++ $(mkdir_p) "$(distdir)$$dir"; \ ++ else \ ++ dir=''; \ ++ fi; \ ++ if test -d $$d/$$file; then \ ++ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ ++ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ ++ fi; \ ++ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ ++ else \ ++ test -f $(distdir)/$$file \ ++ || cp -p $$d/$$file $(distdir)/$$file \ ++ || exit 1; \ ++ fi; \ ++ done ++check-am: all-am ++ $(MAKE) $(AM_MAKEFLAGS) check-TESTS ++check: check-am ++all-am: Makefile $(PROGRAMS) all-local ++installdirs: ++ for dir in "$(DESTDIR)$(libexecdir)"; do \ ++ test -z "$$dir" || $(mkdir_p) "$$dir"; \ ++ done ++install: install-am ++install-exec: install-exec-am ++install-data: install-data-am ++uninstall: uninstall-am ++ ++install-am: all-am ++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am ++ ++installcheck: installcheck-am ++install-strip: ++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ ++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ ++ `test -z '$(STRIP)' || \ ++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install ++mostlyclean-generic: ++ ++clean-generic: ++ ++distclean-generic: ++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) ++ ++maintainer-clean-generic: ++ @echo "This command is intended for maintainers to use" ++ @echo "it deletes files that may require special tools to rebuild." ++clean: clean-am ++ ++clean-am: clean-generic clean-libexecPROGRAMS clean-local \ ++ mostlyclean-am ++ ++distclean: distclean-am ++ -rm -rf ./$(DEPDIR) ++ -rm -f Makefile ++distclean-am: clean-am distclean-compile distclean-generic \ ++ distclean-tags ++ ++dvi: dvi-am ++ ++dvi-am: ++ ++html: html-am ++ ++info: info-am ++ ++info-am: ++ ++install-data-am: ++ ++install-exec-am: install-libexecPROGRAMS ++ @$(NORMAL_INSTALL) ++ $(MAKE) $(AM_MAKEFLAGS) install-exec-hook ++ ++install-info: install-info-am ++ ++install-man: ++ ++installcheck-am: ++ ++maintainer-clean: maintainer-clean-am ++ -rm -rf ./$(DEPDIR) ++ -rm -f Makefile ++maintainer-clean-am: distclean-am maintainer-clean-generic ++ ++mostlyclean: mostlyclean-am ++ ++mostlyclean-am: mostlyclean-compile mostlyclean-generic ++ ++pdf: pdf-am ++ ++pdf-am: ++ ++ps: ps-am ++ ++ps-am: ++ ++uninstall-am: uninstall-info-am uninstall-libexecPROGRAMS \ ++ uninstall-local ++ ++.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \ ++ clean clean-generic clean-libexecPROGRAMS clean-local ctags \ ++ distclean distclean-compile distclean-generic distclean-tags \ ++ distdir dvi dvi-am html html-am info info-am install \ ++ install-am install-data install-data-am install-exec \ ++ install-exec-am install-exec-hook install-info install-info-am \ ++ install-libexecPROGRAMS install-man install-strip installcheck \ ++ installcheck-am installdirs maintainer-clean \ ++ maintainer-clean-generic mostlyclean mostlyclean-compile \ ++ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ ++ uninstall-am uninstall-info-am uninstall-libexecPROGRAMS \ ++ uninstall-local ++ ++ ++test: ++ perl -I $(top_builddir) -I $(top_srcdir) ../test.pl ++ ++############################################################################## ++# secondary dependencies ++ ++popen.o: popen.c popen.h $(PLUGINHDRS) ++ ++utils.o: utils.c utils.h $(PLUGINHDRS) ++ ++netutils.o: netutils.c netutils.h $(PLUGINHDRS) ++ ++getaddrinfo.o: getaddrinfo.h $(PLUGINHDRS) ++ ++gethostbyname.o: gethostbyname.h $(PLUGINHDRS) ++ ++all-local: $(check_tcp_programs) ++ ++$(check_tcp_programs): check_tcp ++ rm -f $@ ++ ln -s check_tcp $@ ++ ++install-exec-hook: ++ cd $(DESTDIR)$(libexecdir) && \ ++ for i in $(check_tcp_programs) ; do rm -f $$i; ln -s check_tcp $$i ; done ++ ++clean-local: ++ rm -f $(check_tcp_programs) ++ ++uninstall-local: ++ cd $(DESTDIR)$(libexecdir) && rm -f $(check_tcp_programs) ++# Tell versions [3.59,3.63) of GNU make to not export all variables. ++# Otherwise a system limit (for SysV at least) may be exceeded. ++.NOEXPORT: +diff -urN ../nagiosplug.orig/plugins/check_http.c plugins/check_http.c +--- ../nagiosplug.orig/plugins/check_http.c 2004-12-04 00:55:28.000000000 +0100 ++++ plugins/check_http.c 2004-12-04 16:57:05.000000000 +0100 +@@ -676,17 +676,17 @@ + } else if (!document_date || !*document_date) { + die (STATE_CRITICAL, _("Document modification date unknown\n")); + } else { +- time_t sd = parse_time_string (server_date); +- time_t dd = parse_time_string (document_date); ++ time_t srv_data = parse_time_string (server_date); ++ time_t doc_data = parse_time_string (document_date); + +- if (sd <= 0) { ++ if (srv_data <= 0) { + die (STATE_CRITICAL, _("CRITICAL - Server date \"%100s\" unparsable"), server_date); +- } else if (dd <= 0) { ++ } else if (doc_data <= 0) { + die (STATE_CRITICAL, _("CRITICAL - Document date \"%100s\" unparsable"), document_date); +- } else if (dd > sd + 30) { +- die (STATE_CRITICAL, _("CRITICAL - Document is %d seconds in the future\n"), dd - sd); +- } else if (dd < sd - maximum_age) { +- int n = (sd - dd); ++ } else if (doc_data > srv_data + 30) { ++ die (STATE_CRITICAL, _("CRITICAL - Document is %d seconds in the future\n"), (int)doc_data - (int)srv_data); ++ } else if (doc_data < srv_data - maximum_age) { ++ int n = (srv_data - doc_data); + if (n > (60 * 60 * 24 * 2)) + die (STATE_CRITICAL, + _("CRITICAL - Last modified %.1f days ago\n"), +diff -urN ../nagiosplug.orig/plugins/check_icmp.c plugins/check_icmp.c +--- ../nagiosplug.orig/plugins/check_icmp.c 2004-12-02 09:44:36.000000000 +0100 ++++ plugins/check_icmp.c 2004-12-04 17:04:18.000000000 +0100 +@@ -1,6 +1,8 @@ + /* +- * check_icmp - A hack of fping2 to work with nagios. +- * This way we don't have to use the output parser. ++ * $Id: check_icmp.c,v 1.9 2004/09/24 10:07:23 exon Exp $ ++ * ++ * This is a hack of fping2 made to work with nagios. ++ * It's fast and removes the necessity of parsing another programs output. + * + * VIEWING NOTES: + * This file was formatted with tab indents at a tab stop of 4. +@@ -40,14 +42,8 @@ + #include + #include + +-/* Linux has bizarre ip.h and ip_icmp.h */ +-/* Taken from the fping distro. Thank you. */ +-#if defined( __linux__ ) +-#include "linux.h" +-#else + #include + #include +-#endif /* defined(__linux__) */ + + #include + #include +@@ -70,9 +66,8 @@ + extern int optind, opterr; + + /*** Constants ***/ +-#define REV_DATE "2004-09-06" + #define EMAIL "ae@op5.se" +-#define VERSION "0.8" ++#define VERSION "0.8.1" + + #ifndef INADDR_NONE + # define INADDR_NONE 0xffffffU +@@ -441,7 +436,7 @@ + break; + + case 'v': +- printf("%s: Version %s $Date: 2004/12/02 08:44:36 $\n", prog, VERSION, REV_DATE); ++ printf("%s: Version %s $Date: 2004/09/24 10:07:23 $\n", prog, VERSION); + printf("%s: comments to %s\n", prog, EMAIL); + exit(STATE_OK); + +@@ -1275,7 +1270,7 @@ + * crash on any other errrors + ************************************************************/ + /* TODO: add MSG_DONTWAIT to recvfrom flags (currently 0) */ +-int recvfrom_wto(int sock, char *buf, int len, struct sockaddr *saddr, int timo) ++int recvfrom_wto(int lsock, char *buf, int len, struct sockaddr *saddr, int timo) + { + int nfound = 0, slen, n; + struct timeval to; +@@ -1289,8 +1284,8 @@ + + FD_ZERO(&readset); + FD_ZERO(&writeset); +- FD_SET(sock, &readset); +- nfound = select(sock + 1, &readset, &writeset, NULL, &to); ++ FD_SET(lsock, &readset); ++ nfound = select(lsock + 1, &readset, &writeset, NULL, &to); + if(nfound < 0) crash("select() in recvfrom_wto"); + + if(nfound == 0) return -1; /* timeout */ +diff -urN ../nagiosplug.orig/plugins/check_nt.c plugins/check_nt.c +--- ../nagiosplug.orig/plugins/check_nt.c 2004-12-04 00:55:29.000000000 +0100 ++++ plugins/check_nt.c 2004-12-04 17:05:20.000000000 +0100 +@@ -86,7 +86,7 @@ + int return_code = STATE_UNKNOWN; + char *send_buffer=NULL; + char *output_message=NULL; +- char *perfdata=NULL; ++ char *perf_data=NULL; + char *temp_string=NULL; + char *temp_string_perf=NULL; + char *description=NULL,*counter_unit = NULL; +@@ -103,7 +103,7 @@ + unsigned long utilization; + unsigned long uptime; + unsigned long age_in_minutes; +- double counter_value; ++ double counter_value = 0.0; + int offset=0; + int updays=0; + int uphours=0; +@@ -174,15 +174,15 @@ + + asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]); + asprintf(&temp_string,"%s%s",temp_string,output_message); +- asprintf(&perfdata,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization, ++ asprintf(&perf_data,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization, + lvalue_list[1+offset], lvalue_list[2+offset]); +- asprintf(&temp_string_perf,"%s%s",temp_string_perf,perfdata); ++ asprintf(&temp_string_perf,"%s%s",temp_string_perf,perf_data); + offset+=3; /* move across the array */ + } + + if (strlen(temp_string)>10) { /* we had at least one loop */ + output_message = strdup (temp_string); +- perfdata = temp_string_perf; ++ perf_data = temp_string_perf; + } else + output_message = strdup (_("not enough values for -l parameters")); + } +@@ -231,7 +231,7 @@ + return_code=STATE_OK; + + output_message = strdup (temp_string); +- perfdata = temp_string_perf; ++ perf_data = temp_string_perf; + } else { + output_message = strdup (_("Free disk space : Invalid drive ")); + return_code=STATE_UNKNOWN; +@@ -270,7 +270,7 @@ + asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"), + mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space, + (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100); +- asprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567, ++ asprintf(&perf_data,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567, + warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567); + + return_code=STATE_OK; +@@ -285,11 +285,11 @@ + + + /* +- CHECK_COUNTER has been modified to provide extensive perfdata information. ++ CHECK_COUNTER has been modified to provide extensive perf_data information. + In order to do this, some modifications have been done to the code + and some constraints have been introduced. + +- 1) For the sake of simplicity of the code, perfdata information will only be ++ 1) For the sake of simplicity of the code, perf_data information will only be + provided when the "description" field is added. + + 2) If the counter you're going to measure is percent-based, the code will detect +@@ -426,10 +426,10 @@ + /* reset timeout */ + alarm(0); + +- if (perfdata==NULL) ++ if (perf_data==NULL) + printf("%s\n",output_message); + else +- printf("%s | %s\n",output_message,perfdata); ++ printf("%s | %s\n",output_message,perf_data); + return return_code; + } + +diff -urN ../nagiosplug.orig/plugins/check_nwstat.c plugins/check_nwstat.c +--- ../nagiosplug.orig/plugins/check_nwstat.c 2004-12-04 00:55:29.000000000 +0100 ++++ plugins/check_nwstat.c 2004-12-04 16:57:52.000000000 +0100 +@@ -909,8 +909,7 @@ + + printf (_("\ + This plugin attempts to contact the MRTGEXT NLM running on a\n\ +-Novell server to gather the requested system information.\n\n"), +- progname); ++Novell server to gather the requested system information.\n\n")); + + print_usage(); + +diff -urN ../nagiosplug.orig/plugins/check_smtp.c plugins/check_smtp.c +--- ../nagiosplug.orig/plugins/check_smtp.c 2004-12-04 00:55:29.000000000 +0100 ++++ plugins/check_smtp.c 2004-12-04 16:58:37.000000000 +0100 +@@ -218,11 +218,12 @@ + microsec = deltime (tv); + elapsed_time = (double)microsec / 1.0e6; + +- if (result == STATE_OK) ++ if (result == STATE_OK) { + if (check_critical_time && elapsed_time > (double) critical_time) + result = STATE_CRITICAL; + else if (check_warning_time && elapsed_time > (double) warning_time) + result = STATE_WARNING; ++ } + + printf (_("SMTP %s - %.3f sec. response time%s%s|%s\n"), + state_text (result), elapsed_time, +diff -urN ../nagiosplug.orig/plugins/check_ssh.c plugins/check_ssh.c +--- ../nagiosplug.orig/plugins/check_ssh.c 2004-12-04 00:55:29.000000000 +0100 ++++ plugins/check_ssh.c 2004-12-04 16:51:10.000000000 +0100 +@@ -44,7 +44,7 @@ + void print_help (void); + void print_usage (void); + +-int ssh_connect (char *haddr, int hport, char *remote_version); ++int ssh_connect (char *, int); + + + +@@ -66,7 +66,7 @@ + alarm (socket_timeout); + + /* ssh_connect exits if error is found */ +- result = ssh_connect (server_name, port, remote_version); ++ result = ssh_connect (server_name, port); + + alarm (0); + +@@ -197,7 +197,7 @@ + + + int +-ssh_connect (char *haddr, int hport, char *remote_version) ++ssh_connect (char *haddr, int hport) + { + int sd; + int result; +diff -urN ../nagiosplug.orig/plugins/check_swap.c plugins/check_swap.c +--- ../nagiosplug.orig/plugins/check_swap.c 2004-12-04 01:23:41.000000000 +0100 ++++ plugins/check_swap.c 2004-12-04 17:02:41.000000000 +0100 +@@ -56,10 +56,10 @@ + int result = STATE_UNKNOWN; + char input_buffer[MAX_INPUT_BUFFER]; + char *perf; +- int conv_factor = SWAP_CONVERSION; + #ifdef HAVE_PROC_MEMINFO + FILE *fp; + #else ++ int conv_factor = SWAP_CONVERSION; + # ifdef HAVE_SWAP + char *temp_buffer; + char *swap_command; +diff -urN ../nagiosplug.orig/plugins/utils.h plugins/utils.h +--- ../nagiosplug.orig/plugins/utils.h 2004-12-03 18:48:53.000000000 +0100 ++++ plugins/utils.h 2004-12-04 16:40:13.000000000 +0100 +@@ -16,9 +16,9 @@ + /* $Id: utils.h,v 1.21 2004/12/03 17:48:53 opensides Exp $ */ + + void support (void); +-char *clean_revstring (const char *revstring); ++char *clean_revstring (const char *); + void print_revision (const char *, const char *); +-void die (int result, const char *fmt, ...) __attribute__((noreturn,format(printf, 2, 3))); ++void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3))); + + /* Handle timeouts */ + +@@ -57,7 +57,7 @@ + #endif + + #ifndef HAVE_GETTIMEOFDAY +-int gettimeofday(struct timeval *tv, struct timezone *tz); ++int gettimeofday(struct timeval *, struct timezone *); + #endif + + double delta_time (struct timeval tv); +@@ -65,46 +65,47 @@ + + /* Handle strings safely */ + +-void strip (char *buffer); +-char *strscpy (char *dest, const char *src); +-char *strnl (char *str); +-char *strpcpy (char *dest, const char *src, const char *str); +-char *strpcat (char *dest, const char *src, const char *str); ++void strip (char *); ++char *strscpy (char *, const char *); ++char *strnl (char *); ++char *strpcpy (char *, const char *, const char *); ++char *strpcat (char *, const char *, const char *); + + int max_state (int a, int b); + +-void usage (const char *msg) __attribute__((noreturn)); +-void usage2(const char *msg, const char *arg) __attribute__((noreturn)); +-void usage3(const char *msg, int arg) __attribute__((noreturn)); ++void usage (const char *) __attribute__((noreturn)); ++void usage2(const char *, const char *) __attribute__((noreturn)); ++void usage3(const char *, int) __attribute__((noreturn)); ++void usage4(const char *); + +-const char *state_text (int result); ++const char *state_text (int); + + #define max(a,b) (((a)>(b))?(a):(b)) + #define min(a,b) (((a)<(b))?(a):(b)) + +-char *perfdata (const char *label, +- long int val, +- const char *uom, +- int warnp, +- long int warn, +- int critp, +- long int crit, +- int minp, +- long int minv, +- int maxp, +- long int maxv); +- +-char *fperfdata (const char *label, +- double val, +- const char *uom, +- int warnp, +- double warn, +- int critp, +- double crit, +- int minp, +- double minv, +- int maxp, +- double maxv); ++char *perfdata (const char *, ++ long int, ++ const char *, ++ int, ++ long int, ++ int, ++ long int, ++ int, ++ long int, ++ int, ++ long int); ++ ++char *fperfdata (const char *, ++ double, ++ const char *, ++ int, ++ double, ++ int, ++ double, ++ int, ++ double, ++ int, ++ double); + + /* The idea here is that, although not every plugin will use all of these, + most will or should. Therefore, for consistency, these very common diff --git a/web/attachments/111856-check_tcp.c.mismatch.diff b/web/attachments/111856-check_tcp.c.mismatch.diff new file mode 100644 index 0000000..d3a32c6 --- /dev/null +++ b/web/attachments/111856-check_tcp.c.mismatch.diff @@ -0,0 +1,66 @@ +--- check_tcp.c.orig Thu Dec 9 13:01:37 2004 ++++ check_tcp.c Thu Dec 9 16:52:52 2004 +@@ -97,6 +97,7 @@ + int use_ssl = FALSE; + int sd = 0; + char *buffer; ++int expect_mismatch_state = STATE_WARNING; + + + +@@ -333,7 +334,7 @@ + if (verbose) + printf ("%d %d\n", i, (int)server_expect_count); + if (i >= (int)server_expect_count) +- die (STATE_WARNING, _("Invalid response from host\n")); ++ die (expect_mismatch_state, _("Unexpected response from host: %s\n"), status); + if (strstr (status, server_expect[i])) + break; + } +@@ -416,6 +417,7 @@ + {"jail", required_argument, 0, 'j'}, + {"delay", required_argument, 0, 'd'}, + {"refuse", required_argument, 0, 'r'}, ++ {"mismatch", required_argument, 0, 'M'}, + {"use-ipv4", no_argument, 0, '4'}, + {"use-ipv6", no_argument, 0, '6'}, + {"verbose", no_argument, 0, 'v'}, +@@ -548,7 +550,17 @@ + else if (!strncmp(optarg,"crit",4)) + econn_refuse_state = STATE_CRITICAL; + else +- usage (_("Refuse mut be one of ok, warn, crit\n")); ++ usage (_("Refuse must be one of ok, warn, crit\n")); ++ break; ++ case 'M': ++ if (!strncmp(optarg,"ok",2)) ++ expect_mismatch_state = STATE_OK; ++ else if (!strncmp(optarg,"warn",4)) ++ expect_mismatch_state = STATE_WARNING; ++ else if (!strncmp(optarg,"crit",4)) ++ expect_mismatch_state = STATE_CRITICAL; ++ else ++ usage (_("Mismatch must be one of ok, warn, crit\n")); + break; + case 'd': + if (is_intpos (optarg)) +@@ -764,6 +776,8 @@ + printf (_("\ + -r, --refuse=ok|warn|crit\n\ + Accept tcp refusals with states ok, warn, crit (default: crit)\n\ ++ -M, --mismatch=ok|warn|crit\n\ ++ Accept expect mismatches with states ok, warn, crit (default: warn)\n\ + -j, --jail\n\ + Hide output from TCP socket\n\ + -m, --maxbytes=INTEGER\n\ +@@ -798,8 +812,8 @@ + Usage: %s -H host -p port [-w ] [-c ]\n\ + [-s ] [-e ] [-q ]\n\ + [-m ] [-d ] [-t ]\n\ +- [-r ] [-v] [-4|-6] [-j] [-D ]\n\ +- [-S ]\n"), progname); ++ [-r ] [-M ] [-v] [-4|-6] [-j]\n\ ++ [-D ] [-S ]\n"), progname); + printf (" %s (-h|--help)\n", progname); + printf (" %s (-V|--version)\n", progname); + } diff --git a/web/attachments/112577-check_smtp.c.patch.cvs.HEAD.20041215 b/web/attachments/112577-check_smtp.c.patch.cvs.HEAD.20041215 new file mode 100644 index 0000000..8dedb8c --- /dev/null +++ b/web/attachments/112577-check_smtp.c.patch.cvs.HEAD.20041215 @@ -0,0 +1,504 @@ +*** check_smtp.c.orig 2004-12-15 13:08:34.000000000 -0500 +--- check_smtp.c 2004-12-15 14:35:05.521604150 -0500 +*************** +*** 25,45 **** +--- 25,77 ---- + + #include "common.h" + #include "netutils.h" + #include "utils.h" + ++ #ifdef HAVE_SSL_H ++ # include ++ # include ++ # include ++ # include ++ # include ++ # include ++ #else ++ # ifdef HAVE_OPENSSL_SSL_H ++ # include ++ # include ++ # include ++ # include ++ # include ++ # include ++ # endif ++ #endif ++ ++ #ifdef HAVE_SSL ++ ++ int check_cert = FALSE; ++ int days_till_exp; ++ SSL_CTX *ctx; ++ SSL *ssl; ++ X509 *server_cert; ++ int connect_STARTTLS (void); ++ int check_certificate (X509 **); ++ #endif ++ + enum { + SMTP_PORT = 25 + }; + const char *SMTP_EXPECT = "220"; + const char *SMTP_HELO = "HELO "; + const char *SMTP_QUIT = "QUIT\r\n"; ++ const char *SMTP_STARTTLS = "STARTTLS\r\n"; + + int process_arguments (int, char **); + int validate_arguments (void); + void print_help (void); + void print_usage (void); ++ int myrecv(void); ++ int my_close(void); + + #ifdef HAVE_REGEX_H + #include + char regex_expect[MAX_INPUT_BUFFER] = ""; + regex_t preg; +*************** +*** 66,87 **** + int warning_time = 0; + int check_warning_time = FALSE; + int critical_time = 0; + int check_critical_time = FALSE; + int verbose = 0; +! +! + + int + main (int argc, char **argv) + { +! int sd; + int n = 0; + double elapsed_time; + long microsec; + int result = STATE_UNKNOWN; +- char buffer[MAX_INPUT_BUFFER]; + char *cmd_str = NULL; + char *helocmd = NULL; + struct timeval tv; + + setlocale (LC_ALL, ""); +--- 98,124 ---- + int warning_time = 0; + int check_warning_time = FALSE; + int critical_time = 0; + int check_critical_time = FALSE; + int verbose = 0; +! int use_ssl = FALSE; +! int sd; +! char buffer[MAX_INPUT_BUFFER]; +! enum { +! TCP_PROTOCOL = 1, +! UDP_PROTOCOL = 2, +! MAXBUF = 1024 +! }; + + int + main (int argc, char **argv) + { +! + int n = 0; + double elapsed_time; + long microsec; + int result = STATE_UNKNOWN; + char *cmd_str = NULL; + char *helocmd = NULL; + struct timeval tv; + + setlocale (LC_ALL, ""); +*************** +*** 138,153 **** + printf (_("Invalid SMTP response received from host on port %d\n"), + server_port); + result = STATE_WARNING; + } + } +! + /* send the HELO command */ + send(sd, helocmd, strlen(helocmd), 0); + + /* allow for response to helo command to reach us */ +! recv(sd, buffer, MAX_INPUT_BUFFER-1, 0); + + /* sendmail will syslog a "NOQUEUE" error if session does not attempt + * to do something useful. This can be prevented by giving a command + * even if syntax is illegal (MAIL requires a FROM:<...> argument) + * +--- 175,223 ---- + printf (_("Invalid SMTP response received from host on port %d\n"), + server_port); + result = STATE_WARNING; + } + } +! #ifdef HAVE_SSL +! if(use_ssl) { +! /* send the STARTTLS command */ +! send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0); +! +! recv(sd,buffer, MAX_INPUT_BUFFER-1, 0); // wait for it +! if (!strstr (buffer, server_expect)) { +! printf (_("Server does not support STARTTLS\n")); +! return STATE_UNKNOWN; +! } +! if(connect_STARTTLS() != OK) { +! printf (_("ERROR: Cannot create SSL context.\n")); +! return STATE_CRITICAL; +! } +! if ( check_cert ) { +! if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) { +! result = check_certificate (&server_cert); +! X509_free(server_cert); +! } +! else { +! printf (_("ERROR: Cannot retrieve server certificate.\n")); +! result = STATE_CRITICAL; +! +! } +! my_close(); +! return result; +! } +! } +! #endif + /* send the HELO command */ ++ #ifdef HAVE_SSL ++ if (use_ssl) ++ SSL_write(ssl, helocmd, strlen(helocmd)); ++ else ++ #endif + send(sd, helocmd, strlen(helocmd), 0); + + /* allow for response to helo command to reach us */ +! myrecv(); + + /* sendmail will syslog a "NOQUEUE" error if session does not attempt + * to do something useful. This can be prevented by giving a command + * even if syntax is illegal (MAIL requires a FROM:<...> argument) + * +*************** +*** 156,175 **** + * + * You can disable sending mail_command with '--nocommand' + * Use the -f option to provide a FROM address + */ + if (smtp_use_dummycmd) { +! send(sd, cmd_str, strlen(cmd_str), 0); +! recv(sd, buffer, MAX_INPUT_BUFFER-1, 0); +! if (verbose) +! printf("%s", buffer); + } + + while (n < ncommands) { + asprintf (&cmd_str, "%s%s", commands[n], "\r\n"); + send(sd, cmd_str, strlen(cmd_str), 0); +! recv(sd, buffer, MAX_INPUT_BUFFER-1, 0); + if (verbose) + printf("%s", buffer); + strip (buffer); + if (n < nresponses) { + #ifdef HAVE_REGEX_H +--- 226,255 ---- + * + * You can disable sending mail_command with '--nocommand' + * Use the -f option to provide a FROM address + */ + if (smtp_use_dummycmd) { +! #ifdef HAVE_SSL +! if (use_ssl) +! SSL_write(ssl, cmd_str, strlen(cmd_str)); +! else +! #endif +! send(sd, cmd_str, strlen(cmd_str), 0); +! myrecv(); +! if (verbose) +! printf("%s", buffer); + } + + while (n < ncommands) { + asprintf (&cmd_str, "%s%s", commands[n], "\r\n"); ++ #ifdef HAVE_SSL ++ if (use_ssl) ++ SSL_write(ssl,cmd_str, strlen(cmd_str)); ++ else ++ #endif + send(sd, cmd_str, strlen(cmd_str), 0); +! myrecv(); + if (verbose) + printf("%s", buffer); + strip (buffer); + if (n < nresponses) { + #ifdef HAVE_REGEX_H +*************** +*** 204,213 **** +--- 284,298 ---- + } + n++; + } + + /* tell the server we're done */ ++ #ifdef HAVE_SSL ++ if (use_ssl) ++ SSL_write(ssl,SMTP_QUIT, strlen (SMTP_QUIT)); ++ else ++ #endif + send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0); + + /* finally close the connection */ + close (sd); + } +*************** +*** 259,268 **** +--- 344,355 ---- + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"use-ipv4", no_argument, 0, '4'}, + {"use-ipv6", no_argument, 0, '6'}, + {"help", no_argument, 0, 'h'}, ++ {"starttls",no_argument,0,'S'}, ++ {"certificate",required_argument,0,'D'}, + {0, 0, 0, 0} + }; + + if (argc < 2) + return ERROR; +*************** +*** 275,285 **** + else if (strcmp ("-ct", argv[c]) == 0) + strcpy (argv[c], "-c"); + } + + while (1) { +! c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:", + longopts, &option); + + if (c == -1 || c == EOF) + break; + +--- 362,372 ---- + else if (strcmp ("-ct", argv[c]) == 0) + strcpy (argv[c], "-c"); + } + + while (1) { +! c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:", + longopts, &option); + + if (c == -1 || c == EOF) + break; + +*************** +*** 352,361 **** +--- 439,464 ---- + } + else { + usage4 (_("Time interval must be a positive integer")); + } + break; ++ case 'S': ++ /* starttls */ ++ use_ssl = TRUE; ++ break; ++ case 'D': ++ /* Check SSL cert validity */ ++ #ifdef HAVE_SSL ++ if (!is_intnonneg (optarg)) ++ usage2 ("invalid certificate expiration period",optarg); ++ days_till_exp = atoi (optarg); ++ check_cert = TRUE; ++ #else ++ terminate (STATE_UNKNOWN, ++ "SSL support not available. Install OpenSSL and recompile."); ++ #endif ++ break; + case '4': + address_family = AF_INET; + break; + case '6': + #ifdef USE_IPV6 +*************** +*** 443,452 **** +--- 546,562 ---- + -R, --command=STRING\n\ + Expected response to command (may be used repeatedly)\n\ + -f, --from=STRING\n\ + FROM-address to include in MAIL command, required by Exchange 2000\n"), + SMTP_EXPECT); ++ #ifdef HAVE_SSL ++ printf (_("\ ++ -D, --certificate=INTEGER\n\ ++ Minimum number of days a certificate has to be valid.\n\ ++ -S, --starttls\n\ ++ Use STARTTLS for the connection.\n")); ++ #endif + + printf (_(UT_WARN_CRIT)); + + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + +*************** +*** 466,472 **** + void + print_usage (void) + { + printf ("\ + Usage: %s -H host [-p port] [-e expect] [-C command] [-f from addr]\n\ +! [-w warn] [-c crit] [-t timeout] [-n] [-v] [-4|-6]\n", progname); + } +--- 576,731 ---- + void + print_usage (void) + { + printf ("\ + Usage: %s -H host [-p port] [-e expect] [-C command] [-f from addr]\n\ +! [-w warn] [-c crit] [-t timeout] [-S] [-D days] [-n] [-v] [-4|-6]\n", progname); +! } +! +! #ifdef HAVE_SSL +! int +! connect_STARTTLS (void) +! { +! SSL_METHOD *meth; +! +! /* Initialize SSL context */ +! SSLeay_add_ssl_algorithms (); +! meth = SSLv2_client_method (); +! SSL_load_error_strings (); +! if ((ctx = SSL_CTX_new (meth)) == NULL) +! { +! printf(_("ERROR: Cannot create SSL context.\n")); +! return STATE_CRITICAL; +! } +! /* do the SSL handshake */ +! if ((ssl = SSL_new (ctx)) != NULL) +! { +! SSL_set_fd (ssl, sd); +! /* original version checked for -1 +! I look for success instead (1) */ +! if (SSL_connect (ssl) == 1) +! return OK; +! ERR_print_errors_fp (stderr); +! } +! else +! { +! printf (_("ERROR: Cannot initiate SSL handshake.\n")); +! } +! /* this causes a seg faul +! not sure why, being sloppy +! and commenting it out */ +! // SSL_free (ssl); +! SSL_CTX_free(ctx); +! my_close(); +! +! return STATE_CRITICAL; +! } +! +! int +! check_certificate (X509 ** certificate) +! { +! ASN1_STRING *tm; +! int offset; +! struct tm stamp; +! int days_left; +! +! /* Retrieve timestamp of certificate */ +! tm = X509_get_notAfter (*certificate); +! +! /* Generate tm structure to process timestamp */ +! if (tm->type == V_ASN1_UTCTIME) { +! if (tm->length < 10) { +! printf (_("ERROR: Wrong time format in certificate.\n")); +! return STATE_CRITICAL; +! } +! else { +! stamp.tm_year = (tm->data[0] - '0') * 10 + (tm->data[1] - '0'); +! if (stamp.tm_year < 50) +! stamp.tm_year += 100; +! offset = 0; +! } +! } +! else { +! if (tm->length < 12) { +! printf (_("ERROR: Wrong time format in certificate.\n")); +! return STATE_CRITICAL; +! } +! else { +! stamp.tm_year = +! (tm->data[0] - '0') * 1000 + (tm->data[1] - '0') * 100 + +! (tm->data[2] - '0') * 10 + (tm->data[3] - '0'); +! stamp.tm_year -= 1900; +! offset = 2; +! } +! } +! stamp.tm_mon = +! (tm->data[2 + offset] - '0') * 10 + (tm->data[3 + offset] - '0') - 1; +! stamp.tm_mday = +! (tm->data[4 + offset] - '0') * 10 + (tm->data[5 + offset] - '0'); +! stamp.tm_hour = +! (tm->data[6 + offset] - '0') * 10 + (tm->data[7 + offset] - '0'); +! stamp.tm_min = +! (tm->data[8 + offset] - '0') * 10 + (tm->data[9 + offset] - '0'); +! stamp.tm_sec = 0; +! stamp.tm_isdst = -1; +! +! days_left = (mktime (&stamp) - time (NULL)) / 86400; +! snprintf +! (timestamp, 16, "%02d/%02d/%04d %02d:%02d", +! stamp.tm_mon + 1, +! stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min); +! +! if (days_left > 0 && days_left <= days_till_exp) { +! printf ("Certificate expires in %d day(s) (%s).\n", days_left, timestamp); +! return STATE_WARNING; +! } +! if (days_left < 0) { +! printf ("Certificate expired on %s.\n", timestamp); +! return STATE_CRITICAL; +! } +! +! if (days_left == 0) { +! printf ("Certificate expires today (%s).\n", timestamp); +! return STATE_WARNING; +! } +! +! printf ("Certificate will expire on %s.\n", timestamp); +! +! return STATE_OK; +! } +! #endif +! +! int +! myrecv (void) +! { +! int i; +! +! #ifdef HAVE_SSL +! if (use_ssl) { +! i = SSL_read (ssl, buffer, MAXBUF - 1); +! } +! else { +! #endif +! i = read (sd, buffer, MAXBUF - 1); +! #ifdef HAVE_SSL +! } +! #endif +! return i; +! } +! +! int +! my_close (void) +! { +! #ifdef HAVE_SSL +! if (use_ssl == TRUE) { +! SSL_shutdown (ssl); +! SSL_free (ssl); +! SSL_CTX_free (ctx); +! return 0; +! } +! else { +! #endif +! return close(sd); +! #ifdef HAVE_SSL +! } +! #endif + } diff --git a/web/attachments/112620-check_range.patch b/web/attachments/112620-check_range.patch new file mode 100644 index 0000000..2ddd8a3 --- /dev/null +++ b/web/attachments/112620-check_range.patch @@ -0,0 +1,116 @@ +? plugins-scripts/t/utils.pm.t +Index: test.pl.in +=================================================================== +RCS file: /cvsroot/nagiosplug/nagiosplug/test.pl.in,v +retrieving revision 1.2 +diff -u -w -u -r1.2 test.pl.in +--- test.pl.in 25 Nov 2004 05:06:24 -0000 1.2 ++++ test.pl.in 15 Dec 2004 23:59:46 -0000 +@@ -69,7 +69,7 @@ + $tstdir = './t' unless ($tstdir); + opendir(DIR, $tstdir) || die "can't opendir $tstdir: $!"; + while ($file = readdir(DIR)) { +- push @dots, "$tstdir/$file" if ($file =~ m/^[^\.]+\.t$/); ++ push @dots, "$tstdir/$file" if ($file =~ m/^[^\.]+.*\.t$/); + } + closedir DIR; + } +Index: plugins-scripts/utils.pm.in +=================================================================== +RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-scripts/utils.pm.in,v +retrieving revision 1.7 +diff -u -w -u -r1.7 utils.pm.in +--- plugins-scripts/utils.pm.in 13 Apr 2003 04:25:36 -0000 1.7 ++++ plugins-scripts/utils.pm.in 15 Dec 2004 23:59:46 -0000 +@@ -25,13 +25,14 @@ + + require Exporter; + @ISA = qw(Exporter); +-@EXPORT_OK = qw($TIMEOUT %ERRORS &print_revision &support &usage); ++@EXPORT_OK = qw($TIMEOUT %ERRORS &print_revision &support &usage &check_range); + + #use strict; + #use vars($TIMEOUT %ERRORS); + sub print_revision ($$); + sub usage; + sub support(); ++sub check_range($$); + sub is_hostname; + + ## updated by autoconf +@@ -80,4 +81,75 @@ + } + } + ++sub check_range ($$) ++{ ++ # Takes two parameters. The first is a metric. The second is ++ # a range using Nagios plugin range syntax. ++ # No explicit checking is done that the metric or the range consists ++ # of non-numeric values - they will be treated as zero. ++ ++ # Accepts ranges of the following form: ++ # ++ # min:max (between min and max inclusive) ++ # min: (equivalent to min:infinity) ++ # :max (equivalent to 0:max) ++ # max (equivalent :max which is equivalent to 0:max) ++ # 0 (equivalent to 0:infinity) ++ # ++ # The symbol ~ may be specified as the minimum portion of a range ++ # to represent -infinity. The range may be prefixed by @ to negate ++ # the result (so the metric is critical if within the range). ++ # Note that ~:~ is treated as an invalid range ++ ++ my($metric) = shift(@_); ++ my($range) = shift(@_); ++ ++ # Take third and any subsequent parameters and concatenate with spaces ++ # to form the name of the range for use in error messages. ++ my($range_name) = join(' ', @_); ++ $range_name = " for $range_name." if ($range_name); ++ ++ # Use strict doesn't let us do string/numeric conversions, so turn ++ # off warnings to get around that problem and the problem of undefined ++ # variables from the regex below. ++ local($^W) = 0; ++ ++ my($range_ok) = 0; ++ ++ # Split the range into the optional 'invert range' prefix (@), minimum ++ # bound and upper bound, allowing all the variations. ++ my($invert_range, $lower, $upper) = $range =~ /^(\@)?(?:([^:])*:)?(.*)?$/; ++ ++ # The above regex has problems with 0 (which means 0:infinity), so ++ # we have to correct for that (but not for :0, which means 0:0 and is ++ # handled correctly by the regex). ++ ($lower, $upper) = ($upper, $lower) if ++ (($upper eq '0' and not $lower) and $range !~ /:/); ++ ++ # Check that upper >= lower, including the case when lower or upper is ++ # ~ (negative infinity). ++ if ($upper eq '~' or ($lower ne '~' and $upper ne '' and $lower > $upper )) ++ { ++ return -1; ++ } ++ ++ # If the lower bound is not ~ (negative infinity) then check that the ++ # metric is greater than or equal to the lower bound. If the lower bound ++ # is ~ then the metric has to be OK because any metric has to be higher ++ # than negative infinity. ++ if ($lower ne '~') ++ { ++ $range_ok++ if ($metric >= $lower + 0); ++ } ++ else ++ { ++ $range_ok++; ++ } ++ ++ $range_ok = 0 if ($upper ne '' and $metric > $upper + 0); ++ $range_ok ^= 1 if ($invert_range); ++ ++ return($range_ok); ++} ++ + 1; diff --git a/web/attachments/112621-utils.pm.t b/web/attachments/112621-utils.pm.t new file mode 100644 index 0000000..630985c --- /dev/null +++ b/web/attachments/112621-utils.pm.t @@ -0,0 +1,141 @@ +#! /usr/bin/perl -w +BEGIN {use File::Basename; use lib(dirname($0) . "/.."); } + +use strict; +use Test::Simple tests => 80; +use utils qw(&check_range); + + +my @tests = +( + # Format: [metric, range, name, expected result] + # + # 'Expected result' is the result expected from check_range: 0 if + # check_range should return 0 (metric is outside of range), 1 if + # check_range should return 1 (metric is inside range). The expected + # result can also be -1, indicating that check_range should exit with + # plugin error code of 'UNKNOWN' after a usage error (caused by an + # invalid range). + + # Check min:max ranges + [-1, '2:4', 'Test 1', 0], + [0, '2:4', 'Test 2', 0], + [1, '2:4', 'Test 3', 0], + [2, '2:4', 'Test 4', 1], + [3, '2:4', 'Test 5', 1], + [4, '2:4', 'Test 6', 1], + [5, '2:4', 'Test 7', 0], + + # Check max ranges + [-1, 2, 'Test 8', 0], + [0, 2, 'Test 9', 1], + [1, 2, 'Test 10', 1], + [2, 2, 'Test 11', 1], + [3, 2, 'Test 12', 0], + + # Check :max ranges + [-1, ':2', 'Test 13', 0], + [0, ':2', 'Test 14', 1], + [1, ':2', 'Test 15', 1], + [2, ':2', 'Test 16', 1], + [3, ':2', 'Test 17', 0], + [-1, '1:', 'Test 18', 0], + + # Check min: ranges + [0, '1:', 'Test 19', 0], + [1, '1:', 'Test 20', 1], + [2, '1:', 'Test 21', 1], + + # Check 0 + [-1, 0, 'Test 22', 0], + [0, 0, 'Test 23', 1], + [1, 0, 'Test 24', 1], + + # Check ~:max ranges + [-1, '~:1', 'Test 25', 1], + [0, '~:1', 'Test 26', 1], + [1, '~:1', 'Test 27', 1], + [2, '~:1', 'Test 28', 0], + + # Check min:max ranges where min and max are the same, including :0 + # which should be equivalent to 0:0. + [-1, '1:1', 'Test 29', 0], + [0, '1:1', 'Test 30', 0], + [1, '1:1', 'Test 31', 1], + [2, '1:1', 'Test 32', 0], + [-1, '0:0', 'Test 33', 0], + [0, '0:0', 'Test 34', 1], + [1, '0:0', 'Test 35', 0], + [-1, ':0', 'Test 36', 0], + [0, ':0', 'Test 37', 1], + [1, ':0', 'Test 38', 0], + + # Check min:max ranges which are invalid + [1, '4:2', 'Test 39', -1], + [1, '~:~', 'Test 40', -1], + + # Check @min:max ranges + [-1, '@2:4', 'Test 1', 1], + [0, '@2:4', 'Test 2', 1], + [1, '@2:4', 'Test 3', 1], + [2, '@2:4', 'Test 4', 0], + [3, '@2:4', 'Test 5', 0], + [4, '@2:4', 'Test 6', 0], + [5, '@2:4', 'Test 7', 1], + + # Check @max ranges + [-1, '@2', 'Test 8', 1], + [0, '@2', 'Test 9', 0], + [1, '@2', 'Test 10', 0], + [2, '@2', 'Test 11', 0], + [3, '@2', 'Test 12', 1], + + # Check @:max ranges + [-1, '@:2', 'Test 13', 1], + [0, '@:2', 'Test 14', 0], + [1, '@:2', 'Test 15', 0], + [2, '@:2', 'Test 16', 0], + [3, '@:2', 'Test 17', 1], + [-1, '@1:', 'Test 18', 1], + + # Check @min: ranges + [0, '@1:', 'Test 19', 1], + [1, '@1:', 'Test 20', 0], + [2, '@1:', 'Test 21', 0], + + # Check @0 + [-1, '@0', 'Test 22', 1], + [0, '@0', 'Test 23', 0], + [1, '@0', 'Test 24', 0], + + # Check @~:max ranges + [-1, '@~:1', 'Test 25', 0], + [0, '@~:1', 'Test 26', 0], + [1, '@~:1', 'Test 27', 0], + [2, '@~:1', 'Test 28', 1], + + # Check @min:max ranges where min and max are the same, including @:0 + # which should be equivalent to @0:0. + [-1, '@1:1', 'Test 29', 1], + [0, '@1:1', 'Test 30', 1], + [1, '@1:1', 'Test 31', 0], + [2, '@1:1', 'Test 32', 1], + [-1, '@0:0', 'Test 33', 1], + [0, '@0:0', 'Test 34', 0], + [1, '@0:0', 'Test 35', 1], + [-1, '@:0', 'Test 36', 1], + [0, '@:0', 'Test 37', 0], + [1, '@:0', 'Test 38', 1], + + # Check @min:max ranges which are invalid + [1, '@4:2', 'Test 39', -1], + [1, '@~:~', 'Test 40', -1], +); + +foreach my $test (@tests) +{ + ok(check_range($test->[0], $test->[1]) == $test->[3],$test->[2]); +} + +exit; + diff --git a/web/attachments/112910-check_mysql_slave b/web/attachments/112910-check_mysql_slave new file mode 100644 index 0000000..9b1e3c8 --- /dev/null +++ b/web/attachments/112910-check_mysql_slave @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Check that a mysql-slave is running +# +# usage: check_mysql_slave host user password +# +# @author peter.romianowski@optivo.net +# @version 1.0 19.12.2004 + +IO=`mysql -h$1 -u$2 -p$3 -B -e "SHOW SLAVE STATUS" | cut -f 10 | tr "\n" " "` + +if [ "$IO" != "Slave_IO_Running Yes " ] ; then + echo "CRITICAL Slave IO-Thread is not running (response was: $IO)" + exit 1 +fi + +SQL=`mysql -h$1 -u$2 -p$3 -B -e "SHOW SLAVE STATUS" | cut -f 11 | tr "\n" " "` + +if [ "$SQL" != "Slave_SQL_Running Yes " ] ; then + echo "CRITICAL Slave SQL-Thread is not running (response was: $SQL)" + exit 2 +fi + +echo "OK Slave IO- and SQL-Thread are running" +exit 0 \ No newline at end of file diff --git a/web/attachments/112982-config.log.gz b/web/attachments/112982-config.log.gz new file mode 100644 index 0000000..d7291df Binary files /dev/null and b/web/attachments/112982-config.log.gz differ diff --git a/web/attachments/113107-config.log.gz b/web/attachments/113107-config.log.gz new file mode 100644 index 0000000..e48e30f Binary files /dev/null and b/web/attachments/113107-config.log.gz differ diff --git a/web/attachments/113111-config.log.gz b/web/attachments/113111-config.log.gz new file mode 100644 index 0000000..883038a Binary files /dev/null and b/web/attachments/113111-config.log.gz differ diff --git a/web/attachments/113160-check_http.diff b/web/attachments/113160-check_http.diff new file mode 100644 index 0000000..c2b1a45 --- /dev/null +++ b/web/attachments/113160-check_http.diff @@ -0,0 +1,65 @@ +--- check_http.c.old 2004-12-01 15:57:08.000000000 +0100 ++++ check_http.c 2004-12-06 11:56:11.000000000 +0100 +@@ -112,6 +112,7 @@ + char *http_method; + char *http_post_data; + char buffer[MAX_INPUT_BUFFER]; ++int do_soap = FALSE; + + int process_arguments (int, char **); + static char *base64 (const char *bin, size_t len); +@@ -210,6 +211,7 @@ + {"min", required_argument, 0, 'm'}, + {"use-ipv4", no_argument, 0, '4'}, + {"use-ipv6", no_argument, 0, '6'}, ++ {"soap", no_argument, 0, 'W'}, + {0, 0, 0, 0} + }; + +@@ -230,7 +232,7 @@ + } + + while (1) { +- c = getopt_long (argc, argv, "Vvh46t:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLSm:", longopts, &option); ++ c = getopt_long (argc, argv, "Vvh46tW:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLSm:", longopts, &option); + if (c == -1 || c == EOF) + break; + +@@ -384,6 +386,9 @@ + case 'm': /* min_page_length */ + min_page_len = atoi (optarg); + break; ++ case 'W': /* use SOAP mode */ ++ do_soap = TRUE; ++ break; + } + } + +@@ -519,9 +524,16 @@ + + /* either send http POST data */ + if (http_post_data) { +- asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); +- asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, strlen (http_post_data)); +- asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); ++ if (do_soap) { ++ asprintf (&buf, "%sSOAPAction:\r\n", buf); ++ asprintf (&buf, "%sContent-Type: text/xml; charset=utf-8\r\n", buf); ++ asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, strlen (http_post_data)); ++ asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); ++ } else { ++ asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); ++ asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, strlen (http_post_data)); ++ asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); ++ } + } + else { + /* or just a newline so the server knows we're done with the request */ +@@ -1214,6 +1226,6 @@ + [-w ] [-c ] [-t ] [-L]\n\ + [-a auth] [-f ] [-e ]\n\ + [-s string] [-l] [-r | -R ]\n\ +- [-P string] [-m min_pg_size] [-4|-6]\n"), progname); ++ [-P string] [-m min_pg_size] [-4|-6] [-W]\n"), progname); + printf (_(UT_HLP_VRS), progname, progname); + } diff --git a/web/attachments/113191-config.log.nagios-plugins-HEAD-200412210547.gz b/web/attachments/113191-config.log.nagios-plugins-HEAD-200412210547.gz new file mode 100644 index 0000000..e5f2cd7 Binary files /dev/null and b/web/attachments/113191-config.log.nagios-plugins-HEAD-200412210547.gz differ diff --git a/web/attachments/113337-config.log.nagios-plugins-HEAD-200412221747.gz b/web/attachments/113337-config.log.nagios-plugins-HEAD-200412221747.gz new file mode 100644 index 0000000..b00c693 Binary files /dev/null and b/web/attachments/113337-config.log.nagios-plugins-HEAD-200412221747.gz differ diff --git a/web/attachments/113402-check_disk.diff b/web/attachments/113402-check_disk.diff new file mode 100644 index 0000000..5d87ebe --- /dev/null +++ b/web/attachments/113402-check_disk.diff @@ -0,0 +1,11 @@ +31,32d30 +< * - patched by Tim Wootton 08032004 to ignore zero size fs, useful for multi +< * disk checks on solaris (tim.wootton@emea.telerate.com) +111,115d108 +< if (total_disk==0){ +< if (verbose>0) +< printf ("ignoring zero size fs %s.", file_system); +< continue; +< } +277d269 +< printf ("patched with 0 size fs patch by Tim Wootton 08032004"); diff --git a/web/attachments/113590-config.log.nagios-plugins-HEAD-200412231747.gz b/web/attachments/113590-config.log.nagios-plugins-HEAD-200412231747.gz new file mode 100644 index 0000000..1626bad Binary files /dev/null and b/web/attachments/113590-config.log.nagios-plugins-HEAD-200412231747.gz differ diff --git a/web/attachments/114200-hpux swapinfo.txt b/web/attachments/114200-hpux swapinfo.txt new file mode 100644 index 0000000..1f4a47e --- /dev/null +++ b/web/attachments/114200-hpux swapinfo.txt @@ -0,0 +1,6 @@ +d40:/# swapinfo -dfM + Kb Kb Kb PCT START/ Kb +TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME +dev 1572864 0 1572864 0% 0 - 1 /dev/vg00/lvol2 +dev 17776640 0 17776640 0% 0 - 1 /dev/vgswap/lvol1 +memory 2185432 1637604 547828 75% diff --git a/web/attachments/114314-check_dhcp.c.patch.1.4-beta1 b/web/attachments/114314-check_dhcp.c.patch.1.4-beta1 new file mode 100644 index 0000000..9556f39 --- /dev/null +++ b/web/attachments/114314-check_dhcp.c.patch.1.4-beta1 @@ -0,0 +1,27 @@ +*** check_dhcp.c.orig Mon Jan 3 13:27:56 2005 +--- check_dhcp.c Mon Jan 3 13:40:28 2005 +*************** +*** 60,70 **** + + #include + #include + #include + +! #elif defined(__sun__) || defined(__solaris__) || defined(__hpux__) + + #define INSAP 22 + #define OUTSAP 24 + + #include +--- 60,70 ---- + + #include + #include + #include + +! #elif defined(__sun) || defined(__solaris__) || defined(__hpux__) + + #define INSAP 22 + #define OUTSAP 24 + + #include diff --git a/web/attachments/115229-check_tcp.c.diff b/web/attachments/115229-check_tcp.c.diff new file mode 100644 index 0000000..bd40d79 --- /dev/null +++ b/web/attachments/115229-check_tcp.c.diff @@ -0,0 +1,102 @@ +--- check_tcp.c.orig Thu Jan 6 12:20:54 2005 ++++ check_tcp.c Thu Jan 6 12:31:24 2005 +@@ -63,6 +63,11 @@ + MAXBUF = 1024 + }; + ++enum { ++ CRLF = 1, ++ LF = 2 ++}; ++ + int process_arguments (int, char **); + int my_recv (void); + void print_help (void); +@@ -100,6 +105,7 @@ + int sd = 0; + char *buffer; + int expect_mismatch_state = STATE_WARNING; ++int lineterm = CRLF; + int exact_matching = TRUE; + + int +@@ -312,7 +318,9 @@ + while ((i = my_recv ()) > 0) { + buffer[i] = '\0'; + asprintf (&status, "%s%s", status, buffer); +- if (buffer[i-2] == '\r' && buffer[i-1] == '\n') ++ if (buffer[i-2] == '\r' && buffer[i-1] == '\n' && lineterm == CRLF) ++ break; ++ if (buffer[i-1] == '\n' && lineterm == LF) + break; + if (maxbytes>0 && strlen(status) >= (unsigned)maxbytes) + break; +@@ -421,6 +429,7 @@ + {"delay", required_argument, 0, 'd'}, + {"refuse", required_argument, 0, 'r'}, + {"mismatch", required_argument, 0, 'M'}, ++ {"lineterm", required_argument, 0, 'l'}, + {"use-ipv4", no_argument, 0, '4'}, + {"use-ipv6", no_argument, 0, '6'}, + {"verbose", no_argument, 0, 'v'}, +@@ -454,7 +463,7 @@ + } + + while (1) { +- c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:", ++ c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:l:", + longopts, &option); + + if (c == -1 || c == EOF || c == 1) +@@ -566,13 +575,31 @@ + else + usage4 (_("Mismatch must be one of ok, warn, crit")); + break; ++ case 'l': ++ if (is_intpos (optarg)) { ++ int num = atoi(optarg); ++ ++ switch (num) { ++ case 1: ++ lineterm = CRLF; ++ break; ++ case 2: ++ lineterm = LF; ++ break; ++ default: ++ usage4 (_("Line termination must be 1 (CRLF) or 2 (LF)")); ++ break; ++ } ++ } else ++ usage4 (_("Line termination must be a positive integer")); ++ break; + case 'd': + if (is_intpos (optarg)) + delay = atoi (optarg); + else + usage4 (_("Delay must be a positive integer")); + break; +- case 'D': /* Check SSL cert validity - days 'til certificate expiration */ ++ case 'D': /* Check SSL cert validity - days 'til certificate expiration */ + #ifdef HAVE_SSL + if (!is_intnonneg (optarg)) + usage2 ("invalid certificate expiration period", optarg); +@@ -784,6 +811,8 @@ + Accept tcp refusals with states ok, warn, crit (default: crit)\n\ + -M, --mismatch=ok|warn|crit\n\ + Accept expected string mismatches with states ok, warn, crit (default: warn)\n\ ++ -l, --lineterm=1|2\r\ ++ Line termination expected from remote peer (1 is CRLF; 2 is LF only)\n\ + -j, --jail\n\ + Hide output from TCP socket\n\ + -m, --maxbytes=INTEGER\n\ +@@ -817,6 +846,7 @@ + Usage: %s -H host -p port [-w ] [-c ]\n\ + [-s ] [-e ] [-q ]\n\ + [-m ] [-d ] [-t ]\n\ +- [-r ] [-M ] [-v] [-4|-6] [-j]\n\ +- [-D ] [-S ]\n", progname); ++ [-r ] [-M ] [-l <1|2>] [-v]\n\ ++ [-4|-6] [-j] [-D ] [-S ]\n", ++ progname); + } diff --git a/web/attachments/115753-check_disk.patch b/web/attachments/115753-check_disk.patch new file mode 100644 index 0000000..aafe4dc --- /dev/null +++ b/web/attachments/115753-check_disk.patch @@ -0,0 +1,28 @@ +diff -u check_disk.c-orig check_disk.c +--- check_disk.c-orig 2005-01-14 10:14:18.650350000 +1100 ++++ check_disk.c 2005-01-14 10:19:13.238477000 +1100 +@@ -20,6 +20,7 @@ + * error. + * + * Notes: ++ * - Fixed logic error with -e switch where result not set (DA, 14/1/2005) + * - IRIX support added by Charlie Cook 4-16-1999 + * - Modifications by Karl DeBisschop 1999-11-24 + * reformat code to 80 char screen width +@@ -118,6 +119,8 @@ + if (strcmp (file_system, "none") == 0) + strncpy (file_system, mntp, MAX_INPUT_BUFFER-1); + ++ result = max_state (result, disk_result); ++ + if (disk_result==STATE_OK && erronly && !verbose) + continue; + +@@ -125,7 +128,6 @@ + asprintf (&output, "%s [%.0f kB (%d%%) free on %s]", output, + free_disk, 100 - usp, display_mntp ? mntp : file_system); + +- result = max_state (result, disk_result); + } + + else { diff --git a/web/attachments/115805-check_sybase-0.2_0.3.diff b/web/attachments/115805-check_sybase-0.2_0.3.diff new file mode 100644 index 0000000..e3c37de --- /dev/null +++ b/web/attachments/115805-check_sybase-0.2_0.3.diff @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + SourceForge.net: ERROR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + +
+
+
+
+
+ + + + + +

There was an error processing your request ...

+ +
+ +

ERROR +
+ +ArtifactFile: Invalid ArtifactFile ID + + +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+ + diff --git a/web/attachments/115806-check_sybase-0.2_0.3.diff b/web/attachments/115806-check_sybase-0.2_0.3.diff new file mode 100644 index 0000000..50c3f54 --- /dev/null +++ b/web/attachments/115806-check_sybase-0.2_0.3.diff @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + SourceForge.net: ERROR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + +
+
+
+
+
+ + + + + +

There was an error processing your request ...

+ +
+ +

ERROR +
+ +ArtifactFile: Invalid ArtifactFile ID + + +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+ + diff --git a/web/attachments/116237-check_snmp.tar.gz b/web/attachments/116237-check_snmp.tar.gz new file mode 100644 index 0000000..737e8c4 Binary files /dev/null and b/web/attachments/116237-check_snmp.tar.gz differ diff --git a/web/attachments/116575-check_nt.c.patch.1.39 b/web/attachments/116575-check_nt.c.patch.1.39 new file mode 100644 index 0000000..de85bad --- /dev/null +++ b/web/attachments/116575-check_nt.c.patch.1.39 @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + SourceForge.net: ERROR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + +
+
+
+
+
+ + + + + +

There was an error processing your request ...

+ +
+ +

ERROR +
+ +ArtifactFile: Invalid ArtifactFile ID + + +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+ + diff --git a/web/attachments/116576-check_nt.c.patch b/web/attachments/116576-check_nt.c.patch new file mode 100644 index 0000000..30a4653 --- /dev/null +++ b/web/attachments/116576-check_nt.c.patch @@ -0,0 +1,55 @@ +--- plugins/check_nt.c.orig 2005-01-20 17:17:40.000000000 -0500 ++++ plugins/check_nt.c 2005-01-20 18:01:43.000000000 -0500 +@@ -43,6 +43,7 @@ + #define CHECK_MEMUSE 7 + #define CHECK_COUNTER 8 + #define CHECK_FILEAGE 9 ++#define CHECK_FREEDISKSPACE 10 + #define MAX_VALUE_LIST 30 + + #define PORT 1248 +@@ -185,7 +186,7 @@ + return_code=STATE_OK; + } + +- else if(vars_to_check==CHECK_USEDDISKSPACE){ ++ else if(vars_to_check==CHECK_USEDDISKSPACE || vars_to_check==CHECK_FREEDISKSPACE){ + + return_code=STATE_UNKNOWN; + if (check_value_list==TRUE) { +@@ -210,9 +211,13 @@ + free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); + + +- if(check_critical_value==TRUE && percent_used_space >= critical_value) ++ if(check_critical_value==TRUE && ( ++ (vars_to_check==CHECK_USEDDISKSPACE && percent_used_space >= critical_value) || ++ (vars_to_check==CHECK_FREEDISKSPACE && free_disk_space / 1048576 <= critical_value))) + return_code=STATE_CRITICAL; +- else if (check_warning_value==TRUE && percent_used_space >= warning_value) ++ else if (check_warning_value==TRUE && ( ++ (vars_to_check==CHECK_USEDDISKSPACE && percent_used_space >= warning_value) || ++ (vars_to_check==CHECK_FREEDISKSPACE && free_disk_space / 1048576 <= warning_value))) + return_code=STATE_WARNING; + else + return_code=STATE_OK; +@@ -477,6 +482,8 @@ + vars_to_check=CHECK_COUNTER; + else if(!strcmp(optarg,"FILEAGE")) + vars_to_check=CHECK_FILEAGE; ++ else if(!strcmp(optarg,"FREEDISKSPACE")) ++ vars_to_check=CHECK_FREEDISKSPACE; + else + return ERROR; + break; +@@ -541,7 +548,9 @@ + " Thresholds are percentage and up to 10 requests can be done in one shot. ie: -l 60,90,95,120,90,95\n" + " UPTIME = Get the uptime of the machine. No specific parameters. No warning or critical threshold\n" + " USEDDISKSPACE = Size and percentage of disk use. Request a -l parameter containing the drive letter only.\n" +- " Warning and critical thresholds can be specified with -w and -c.\n" ++ " Warning and critical thresholds can be specified (in percentage used) with -w and -c.\n" ++ " FREEDISKSPACE = Size and percentage of disk use. Request a -l parameter containing the drive letter only.\n" ++ " Warning and critical thresholds can be specified (in megabytes free) with -w and -c.\n" + " MEMUSE = Memory use. Warning and critical thresholds can be specified with -w and -c.\n" + " SERVICESTATE = Check the state of one or several services. Request a -l parameters with the following syntax:\n" + " -l ,,,... You can specify -d SHOWALL in case you want to see working services\n" diff --git a/web/attachments/116577-check_nt.c.patch b/web/attachments/116577-check_nt.c.patch new file mode 100644 index 0000000..0d2daba --- /dev/null +++ b/web/attachments/116577-check_nt.c.patch @@ -0,0 +1,65 @@ +--- plugins/check_nt.c.orig 2005-01-20 17:27:47.000000000 -0500 ++++ plugins/check_nt.c 2005-01-20 18:01:41.000000000 -0500 +@@ -49,7 +49,8 @@ + CHECK_PROCSTATE, + CHECK_MEMUSE, + CHECK_COUNTER, +- CHECK_FILEAGE ++ CHECK_FILEAGE, ++ CHECK_FREEDISKSPACE + }; + + enum { +@@ -201,6 +202,7 @@ + break; + + case CHECK_USEDDISKSPACE: ++ case CHECK_FREEDISKSPACE: + + if (value_list==NULL) + output_message = strdup (_("missing -l parameters")); +@@ -212,8 +214,8 @@ + free_disk_space=atof(strtok(recv_buffer,"&")); + total_disk_space=atof(strtok(NULL,"&")); + percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100; +- warning_used_space = ((float)warning_value / 100) * total_disk_space; +- critical_used_space = ((float)critical_value / 100) * total_disk_space; ++ warning_used_space = (vars_to_check==CHECK_FREEDISKSPACE)?(float)warning_value:((float)warning_value / 100) * total_disk_space; ++ critical_used_space = (vars_to_check==CHECK_FREEDISKSPACE)?(float)critical_value:((float)critical_value / 100) * total_disk_space; + + if (free_disk_space>=0) { + asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"), +@@ -223,9 +225,9 @@ + (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824, + critical_used_space / 1073741824, total_disk_space / 1073741824); + +- if(check_critical_value==TRUE && percent_used_space >= critical_value) ++ if(check_critical_value==TRUE && free_disk_space <= critical_used_space) + return_code=STATE_CRITICAL; +- else if (check_warning_value==TRUE && percent_used_space >= warning_value) ++ else if (check_warning_value==TRUE && free_disk_space <= warning_used_space) + return_code=STATE_WARNING; + else + return_code=STATE_OK; +@@ -527,6 +529,8 @@ + vars_to_check=CHECK_COUNTER; + else if(!strcmp(optarg,"FILEAGE")) + vars_to_check=CHECK_FILEAGE; ++ else if(!strcmp(optarg,"FREEDISKSPACE")) ++ vars_to_check=CHECK_FREEDISKSPACE; + else + return ERROR; + break; +@@ -656,7 +660,11 @@ + printf (_("\ + USEDDISKSPACE = Size and percentage of disk use.\n\ + Request a -l parameter containing the drive letter only.\n\ +- Warning and critical thresholds can be specified with -w and -c.\n")); ++ Thresholds can be specified (in precentage used) with -w and -c.\n")); ++ printf (_("\ ++ FREEDISKSPACE = Size and percentage of disk use.\n\ ++ Request a -l parameter containing the drive letter only.\n\ ++ Thresholds can be specified (in megabytes free) with -w and -c.\n")); + printf (_("\ + MEMUSE = Memory use.\n\ + Warning and critical thresholds can be specified with -w and -c.\n")); diff --git a/web/attachments/116583-check_snmp.c b/web/attachments/116583-check_snmp.c new file mode 100644 index 0000000..e2695e1 --- /dev/null +++ b/web/attachments/116583-check_snmp.c @@ -0,0 +1,963 @@ +/****************************************************************************** + + 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 2 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. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: check_snmp.c,v 1.52 2004/12/30 00:41:39 opensides Exp $ + +******************************************************************************/ + +const char *progname = "check_snmp"; +const char *revision = "$Revision: 1.52 $"; +const char *copyright = "1999-2004"; +const char *email = "nagiosplug-devel@lists.sourceforge.net"; + +#include "common.h" +#include "utils.h" +#include "popen.h" + +#define DEFAULT_COMMUNITY "public" +#define DEFAULT_PORT "161" +#define DEFAULT_MIBLIST "ALL" +#define DEFAULT_PROTOCOL "1" +#define DEFAULT_TIMEOUT 1 +#define DEFAULT_RETRIES 5 +#define DEFAULT_AUTH_PROTOCOL "MD5" +#define DEFAULT_DELIMITER "=" +#define DEFAULT_OUTPUT_DELIMITER " " + +#define mark(a) ((a)!=0?"*":"") + +#define CHECK_UNDEF 0 +#define CRIT_PRESENT 1 +#define CRIT_STRING 2 +#define CRIT_REGEX 4 +#define CRIT_GT 8 +#define CRIT_LT 16 +#define CRIT_GE 32 +#define CRIT_LE 64 +#define CRIT_EQ 128 +#define CRIT_NE 256 +#define CRIT_RANGE 512 +#define WARN_PRESENT 1024 +#define WARN_STRING 2048 +#define WARN_REGEX 4096 +#define WARN_GT 8192 +#define WARN_LT 16384 +#define WARN_GE 32768 +#define WARN_LE 65536 +#define WARN_EQ 131072 +#define WARN_NE 262144 +#define WARN_RANGE 524288 + +#define MAX_OIDS 8 +#define MAX_DELIM_LENGTH 8 + +int process_arguments (int, char **); +int validate_arguments (void); +char *clarify_message (char *); +int check_num (int); +int lu_getll (unsigned long *, char *); +int lu_getul (unsigned long *, char *); +char *thisarg (char *str); +char *nextarg (char *str); +void print_usage (void); +void print_help (void); + +#ifdef HAVE_REGEX_H +#include +char regex_expect[MAX_INPUT_BUFFER] = ""; +regex_t preg; +regmatch_t pmatch[10]; +char timestamp[10] = ""; +char errbuf[MAX_INPUT_BUFFER]; +int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; +int eflags = 0; +int errcode, excode; +#endif + +char *server_address = NULL; +char *community = NULL; +char *authpriv = NULL; +char *proto = NULL; +char *seclevel = NULL; +char *secname = NULL; +char *authproto = NULL; +char *authpasswd = NULL; +char *privpasswd = NULL; +char *oid; +char *label; +char *units; +char *port; +char string_value[MAX_INPUT_BUFFER] = ""; +char **labels = NULL; +char **unitv = NULL; +size_t nlabels = 0; +size_t labels_size = 8; +size_t nunits = 0; +size_t unitv_size = 8; +int verbose = FALSE; +unsigned long lower_warn_lim[MAX_OIDS]; +unsigned long upper_warn_lim[MAX_OIDS]; +unsigned long lower_crit_lim[MAX_OIDS]; +unsigned long upper_crit_lim[MAX_OIDS]; +unsigned long response_value[MAX_OIDS]; +int check_warning_value = FALSE; +int check_critical_value = FALSE; +int retries = 0; +unsigned long eval_method[MAX_OIDS]; +char *delimiter; +char *output_delim; +char *miblist; + +int +main (int argc, char **argv) +{ + int i = 0; + int iresult = STATE_UNKNOWN; + int found = 0; + int result = STATE_DEPENDENT; + char input_buffer[MAX_INPUT_BUFFER]; + char *command_line = NULL; + char *response = NULL; + char *outbuff; + char *output; + char *ptr = NULL; + char *p2 = NULL; + char *show = NULL; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + labels = malloc (labels_size); + unitv = malloc (unitv_size); + for (i = 0; i < MAX_OIDS; i++) + eval_method[i] = CHECK_UNDEF; + i = 0; + + oid = strdup (""); + label = strdup ("SNMP"); + units = strdup (""); + port = strdup (DEFAULT_PORT); + outbuff = strdup (""); + output = strdup (""); + delimiter = strdup (DEFAULT_DELIMITER); + output_delim = strdup (DEFAULT_OUTPUT_DELIMITER); + miblist = strdup (DEFAULT_MIBLIST); + timeout_interval = DEFAULT_TIMEOUT; + retries = DEFAULT_RETRIES; + + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); + + /* create the command line to execute */ + asprintf (&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", + PATH_TO_SNMPGET, timeout_interval, retries, miblist, proto, + authpriv, server_address, port, oid); + if (verbose) + printf ("%s\n", command_line); + + /* run the command */ + child_process = spopen (command_line); + if (child_process == NULL) { + printf (_("Could not open pipe: %s\n"), command_line); + exit (STATE_UNKNOWN); + } + + child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); + if (child_stderr == NULL) { + printf (_("Could not open stderr for %s\n"), command_line); + } + + while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) + asprintf (&output, "%s%s", output, input_buffer); + + if (verbose) + printf ("%s\n", output); + + ptr = output; + + while (ptr) { + + ptr = strstr (ptr, delimiter); + if (ptr == NULL) + break; + + ptr += strlen (delimiter); + ptr += strspn (ptr, " "); + + found++; + + if (ptr[0] == '"') { + ptr++; + response = strpcpy (response, ptr, "\""); + ptr = strpbrk (ptr, "\""); + ptr += strspn (ptr, "\"\n"); + } + else { + response = strpcpy (response, ptr, "\n"); + ptr = strpbrk (ptr, "\n"); + ptr += strspn (ptr, "\n"); + while + (strstr (ptr, delimiter) && + strstr (ptr, "\n") && strstr (ptr, "\n") < strstr (ptr, delimiter)) { + response = strpcat (response, ptr, "\n"); + ptr = strpbrk (ptr, "\n"); + } + if (ptr && strstr (ptr, delimiter) == NULL) { + asprintf (&response, "%s%s", response, ptr); + ptr = NULL; + } + } + + /* We strip out the datatype indicator for PHBs */ + if (strstr (response, "Gauge: ")) + show = strstr (response, "Gauge: ") + 7; + else if (strstr (response, "Gauge32: ")) + show = strstr (response, "Gauge32: ") + 9; + else if (strstr (response, "Counter32: ")) + show = strstr (response, "Counter32: ") + 11; + else if (strstr (response, "INTEGER: ")) + show = strstr (response, "INTEGER: ") + 9; + else if (strstr (response, "STRING: ")) + show = strstr (response, "STRING: ") + 8; + else + show = response; + p2 = show; + + iresult = STATE_DEPENDENT; + + /* Process this block for integer comparisons */ + if (eval_method[i] & CRIT_GT || + eval_method[i] & CRIT_LT || + eval_method[i] & CRIT_GE || + eval_method[i] & CRIT_LE || + eval_method[i] & CRIT_EQ || + eval_method[i] & CRIT_NE || + eval_method[i] & WARN_GT || + eval_method[i] & WARN_LT || + eval_method[i] & WARN_GE || + eval_method[i] & WARN_LE || + eval_method[i] & WARN_EQ || + eval_method[i] & WARN_NE) { + p2 = strpbrk (p2, "0123456789"); + if (p2 == NULL) + die (STATE_UNKNOWN,_("No valid data returned")); + response_value[i] = strtoul (p2, NULL, 10); + iresult = check_num (i); + asprintf (&show, "%lu", response_value[i]); + } + + /* Process this block for string matching */ + else if (eval_method[i] & CRIT_STRING) { + if (strcmp (show, string_value)) + iresult = STATE_CRITICAL; + else + iresult = STATE_OK; + } + + /* Process this block for regex matching */ + else if (eval_method[i] & CRIT_REGEX) { +#ifdef HAVE_REGEX_H + excode = regexec (&preg, response, 10, pmatch, eflags); + if (excode == 0) { + iresult = STATE_OK; + } + else if (excode != REG_NOMATCH) { + regerror (excode, &preg, errbuf, MAX_INPUT_BUFFER); + printf (_("Execute Error: %s\n"), errbuf); + exit (STATE_CRITICAL); + } + else { + iresult = STATE_CRITICAL; + } +#else + printf (_("Call for regex which was not a compiled option")); + exit (STATE_UNKNOWN); +#endif + } + + /* Process this block for existence-nonexistence checks */ + else { + if (eval_method[i] & CRIT_PRESENT) + iresult = STATE_CRITICAL; + else if (eval_method[i] & WARN_PRESENT) + iresult = STATE_WARNING; + else if (response && iresult == STATE_DEPENDENT) + iresult = STATE_OK; + } + + /* Result is the worst outcome of all the OIDs tested */ + result = max_state (result, iresult); + + /* Prepend a label for this OID if there is one */ + if (nlabels > (size_t)1 && (size_t)i < nlabels && labels[i] != NULL) + asprintf (&outbuff, "%s%s%s %s%s%s", outbuff, + (i == 0) ? " " : output_delim, + labels[i], mark (iresult), show, mark (iresult)); + else + asprintf (&outbuff, "%s%s%s%s%s", outbuff, (i == 0) ? " " : output_delim, + mark (iresult), show, mark (iresult)); + + /* Append a unit string for this OID if there is one */ + if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL) + asprintf (&outbuff, "%s %s", outbuff, unitv[i]); + + i++; + + } /* end while (ptr) */ + + if (found == 0) + die (STATE_UNKNOWN, + _("%s problem - No data received from host\nCMD: %s\n"), + label, + command_line); + + /* WARNING if output found on stderr */ + if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) + result = max_state (result, STATE_WARNING); + + /* close stderr */ + (void) fclose (child_stderr); + + /* close the pipe */ + if (spclose (child_process)) + result = max_state (result, STATE_WARNING); + +/* if (nunits == 1 || i == 1) */ +/* printf ("%s %s -%s %s\n", label, state_text (result), outbuff, units); */ +/* else */ + printf ("%s %s -%s\n", label, state_text (result), outbuff); + + return result; +} + + + +/* process command-line arguments */ +int +process_arguments (int argc, char **argv) +{ + char *ptr; + int c = 1; + int j = 0, jj = 0, ii = 0; + + int option = 0; + static struct option longopts[] = { + STD_LONG_OPTS, + {"community", required_argument, 0, 'C'}, + {"oid", required_argument, 0, 'o'}, + {"object", required_argument, 0, 'o'}, + {"delimiter", required_argument, 0, 'd'}, + {"output-delimiter", required_argument, 0, 'D'}, + {"string", required_argument, 0, 's'}, + {"timeout", required_argument, 0, 't'}, + {"regex", required_argument, 0, 'r'}, + {"ereg", required_argument, 0, 'r'}, + {"eregi", required_argument, 0, 'R'}, + {"label", required_argument, 0, 'l'}, + {"units", required_argument, 0, 'u'}, + {"port", required_argument, 0, 'p'}, + {"retries", required_argument, 0, 'e'}, + {"miblist", required_argument, 0, 'm'}, + {"protocol", required_argument, 0, 'P'}, + {"seclevel", required_argument, 0, 'L'}, + {"secname", required_argument, 0, 'U'}, + {"authproto", required_argument, 0, 'a'}, + {"authpasswd", required_argument, 0, 'A'}, + {"privpasswd", required_argument, 0, 'X'}, + {0, 0, 0, 0} + }; + + if (argc < 2) + return ERROR; + + /* reverse compatibility for very old non-POSIX usage forms */ + for (c = 1; c < argc; c++) { + if (strcmp ("-to", argv[c]) == 0) + strcpy (argv[c], "-t"); + if (strcmp ("-wv", argv[c]) == 0) + strcpy (argv[c], "-w"); + if (strcmp ("-cv", argv[c]) == 0) + strcpy (argv[c], "-c"); + } + + while (1) { + c = getopt_long (argc, argv, "hvVt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:A:X:", + longopts, &option); + + if (c == -1 || c == EOF) + break; + + switch (c) { + case '?': /* usage */ + usage2 (_("Unknown argument"), optarg); + case 'h': /* help */ + print_help (); + exit (STATE_OK); + case 'V': /* version */ + print_revision (progname, revision); + exit (STATE_OK); + case 'v': /* verbose */ + verbose = TRUE; + break; + + /* Connection info */ + case 'C': /* group or community */ + community = optarg; + break; + case 'H': /* Host or server */ + server_address = optarg; + break; + case 'p': /* TCP port number */ + port = optarg; + break; + case 'm': /* List of MIBS */ + miblist = optarg; + break; + case 'P': /* SNMP protocol version */ + proto = optarg; + break; + case 'L': /* security level */ + seclevel = optarg; + break; + case 'U': /* security username */ + secname = optarg; + break; + case 'a': /* auth protocol */ + authproto = optarg; + break; + case 'A': /* auth passwd */ + authpasswd = optarg; + break; + case 'X': /* priv passwd */ + privpasswd = optarg; + break; + case 't': /* timeout period */ + if (!is_integer (optarg)) + usage2 (_("Timeout interval must be a positive integer"), optarg); + else + timeout_interval = atoi (optarg); + break; + + /* Test parameters */ + case 'c': /* critical time threshold */ + if (strspn (optarg, "0123456789:,") < strlen (optarg)) + usage2 (_("Invalid critical threshold: %s\n"), optarg); + for (ptr = optarg; ptr && jj < MAX_OIDS; jj++) { + if (lu_getll (&lower_crit_lim[jj], ptr) == 1) + eval_method[jj] |= CRIT_LT; + if (lu_getul (&upper_crit_lim[jj], ptr) == 1) + eval_method[jj] |= CRIT_GT; + (ptr = index (ptr, ',')) ? ptr++ : ptr; + } + break; + case 'w': /* warning time threshold */ + if (strspn (optarg, "0123456789:,") < strlen (optarg)) + usage2 (_("Invalid warning threshold: %s\n"), optarg); + for (ptr = optarg; ptr && ii < MAX_OIDS; ii++) { + if (lu_getll (&lower_warn_lim[ii], ptr) == 1) + eval_method[ii] |= WARN_LT; + if (lu_getul (&upper_warn_lim[ii], ptr) == 1) + eval_method[ii] |= WARN_GT; + (ptr = index (ptr, ',')) ? ptr++ : ptr; + } + break; + case 'e': /* PRELIMINARY - may change */ + case 'E': /* PRELIMINARY - may change */ + if (!is_integer (optarg)) + usage2 (_("Retries interval must be a positive integer"), optarg); + else + retries = atoi(optarg); + break; + case 'o': /* object identifier */ + for (ptr = optarg; (ptr = index (ptr, ',')); ptr++) + ptr[0] = ' '; /* relpace comma with space */ + for (ptr = optarg; (ptr = index (ptr, ' ')); ptr++) + j++; /* count OIDs */ + asprintf (&oid, "%s %s", (oid?oid:""), optarg); + if (c == 'E' || c == 'e') { + jj++; + ii++; + } + if (c == 'E') + eval_method[j+1] |= WARN_PRESENT; + else if (c == 'e') + eval_method[j+1] |= CRIT_PRESENT; + break; + case 's': /* string or substring */ + strncpy (string_value, optarg, sizeof (string_value) - 1); + string_value[sizeof (string_value) - 1] = 0; + eval_method[jj++] = CRIT_STRING; + ii++; + break; + case 'R': /* regex */ +#ifdef HAVE_REGEX_H + cflags = REG_ICASE; +#endif + case 'r': /* regex */ +#ifdef HAVE_REGEX_H + cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; + strncpy (regex_expect, optarg, sizeof (regex_expect) - 1); + regex_expect[sizeof (regex_expect) - 1] = 0; + errcode = regcomp (&preg, regex_expect, cflags); + if (errcode != 0) { + regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); + printf (_("Could Not Compile Regular Expression")); + return ERROR; + } + eval_method[jj++] = CRIT_REGEX; + ii++; +#else + printf (_("call for regex which was not a compiled option")); + exit (STATE_UNKNOWN); +#endif + break; + + /* Format */ + case 'd': /* delimiter */ + delimiter = strscpy (delimiter, optarg); + break; + case 'D': /* output-delimiter */ + output_delim = strscpy (output_delim, optarg); + break; + case 'l': /* label */ + label = optarg; + nlabels++; + if (nlabels >= labels_size) { + labels_size += 8; + labels = realloc (labels, labels_size); + if (labels == NULL) + die (STATE_UNKNOWN, _("Could not reallocate labels[%d]"), nlabels); + } + labels[nlabels - 1] = optarg; + ptr = thisarg (optarg); + labels[nlabels - 1] = ptr; + if (strstr (ptr, "'") == ptr) + labels[nlabels - 1] = ptr + 1; + while (ptr && (ptr = nextarg (ptr))) { + if (nlabels >= labels_size) { + labels_size += 8; + labels = realloc (labels, labels_size); + if (labels == NULL) + die (STATE_UNKNOWN, _("Could not reallocate labels\n")); + } + labels++; + ptr = thisarg (ptr); + if (strstr (ptr, "'") == ptr) + labels[nlabels - 1] = ptr + 1; + else + labels[nlabels - 1] = ptr; + } + break; + case 'u': /* units */ + units = optarg; + nunits++; + if (nunits >= unitv_size) { + unitv_size += 8; + unitv = realloc (unitv, unitv_size); + if (unitv == NULL) + die (STATE_UNKNOWN, _("Could not reallocate units [%d]\n"), nunits); + } + unitv[nunits - 1] = optarg; + ptr = thisarg (optarg); + unitv[nunits - 1] = ptr; + if (strstr (ptr, "'") == ptr) + unitv[nunits - 1] = ptr + 1; + while (ptr && (ptr = nextarg (ptr))) { + if (nunits >= unitv_size) { + unitv_size += 8; + unitv = realloc (unitv, unitv_size); + if (units == NULL) + die (STATE_UNKNOWN, _("Could not realloc() units\n")); + } + nunits++; + ptr = thisarg (ptr); + if (strstr (ptr, "'") == ptr) + unitv[nunits - 1] = ptr + 1; + else + unitv[nunits - 1] = ptr; + } + break; + + } + } + + if (server_address == NULL) + server_address = argv[optind]; + + if (community == NULL) + community = strdup (DEFAULT_COMMUNITY); + + return validate_arguments (); +} + + +/****************************************************************************** + +@@- + +validate_arguments + +&PROTO_validate_arguments; + +Given a database name, this function returns TRUE if the string +is a valid PostgreSQL database name, and returns false if it is +not. + +Valid PostgreSQL database names are less than &NAMEDATALEN; +characters long and consist of letters, numbers, and underscores. The +first character cannot be a number, however. + + +-@@ +******************************************************************************/ + + + +int +validate_arguments () +{ + + /* Need better checks to verify seclevel and authproto choices */ + + if (seclevel == NULL) + asprintf (&seclevel, "noAuthNoPriv"); + + + if (authproto == NULL ) + asprintf(&authproto, DEFAULT_AUTH_PROTOCOL); + + + + if (proto == NULL || (strcmp(proto,DEFAULT_PROTOCOL) == 0) ) { /* default protocol version */ + asprintf(&proto, DEFAULT_PROTOCOL); + asprintf(&authpriv, "%s%s", "-c ", community); + } + else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */ + asprintf(&proto, "%s", "3"); + + if ( (strcmp(seclevel, "noAuthNoPriv") == 0) || seclevel == NULL ) { + asprintf(&authpriv, "%s", "-l noAuthNoPriv" ); + } + else if ( strcmp(seclevel, "authNoPriv") == 0 ) { + if ( secname == NULL || authpasswd == NULL) { + printf (_("Missing secname (%s) or authpassword (%s) ! \n"),secname, authpasswd ); + print_usage (); + exit (STATE_UNKNOWN); + } + asprintf(&authpriv, "-l authNoPriv -a %s -u %s -A %s ", authproto, secname, authpasswd); + } + else if ( strcmp(seclevel, "authPriv") == 0 ) { + if ( secname == NULL || authpasswd == NULL || privpasswd == NULL ) { + printf (_("Missing secname (%s), authpassword (%s), or privpasswd (%s)! \n"),secname, authpasswd,privpasswd ); + print_usage (); + exit (STATE_UNKNOWN); + } + asprintf(&authpriv, "-l authPriv -a %s -u %s -A %s -x DES -X %s ", authproto, secname, authpasswd, privpasswd); + } + + } + else { + usage2 (_("Invalid SNMP version"), proto); + } + + return OK; +} + + + +char * +clarify_message (char *msg) +{ + int i = 0; + int foo; + char tmpmsg_c[MAX_INPUT_BUFFER]; + char *tmpmsg = (char *) &tmpmsg_c; + tmpmsg = strcpy (tmpmsg, msg); + if (!strncmp (tmpmsg, " Hex:", 5)) { + tmpmsg = strtok (tmpmsg, ":"); + while ((tmpmsg = strtok (NULL, " "))) { + foo = strtol (tmpmsg, NULL, 16); + /* Translate chars that are not the same value in the printers + * character set. + */ + switch (foo) { + case 208: + { + foo = 197; + break; + } + case 216: + { + foo = 196; + break; + } + } + msg[i] = foo; + i++; + } + msg[i] = 0; + } + return (msg); +} + + + +int +check_num (int i) +{ + int result; + result = STATE_OK; + if (eval_method[i] & WARN_GT && eval_method[i] & WARN_LT && + lower_warn_lim[i] > upper_warn_lim[i]) { + if (response_value[i] <= lower_warn_lim[i] && + response_value[i] >= upper_warn_lim[i]) { + result = STATE_WARNING; + } + } + else if + ((eval_method[i] & WARN_GT && response_value[i] > upper_warn_lim[i]) || + (eval_method[i] & WARN_GE && response_value[i] >= upper_warn_lim[i]) || + (eval_method[i] & WARN_LT && response_value[i] < lower_warn_lim[i]) || + (eval_method[i] & WARN_LE && response_value[i] <= lower_warn_lim[i]) || + (eval_method[i] & WARN_EQ && response_value[i] == upper_warn_lim[i]) || + (eval_method[i] & WARN_NE && response_value[i] != upper_warn_lim[i])) { + result = STATE_WARNING; + } + + if (eval_method[i] & CRIT_GT && eval_method[i] & CRIT_LT && + lower_crit_lim[i] > upper_crit_lim[i]) { + if (response_value[i] <= lower_crit_lim[i] && + response_value[i] >= upper_crit_lim[i]) { + result = STATE_CRITICAL; + } + } + else if + ((eval_method[i] & CRIT_GT && response_value[i] > upper_crit_lim[i]) || + (eval_method[i] & CRIT_GE && response_value[i] >= upper_crit_lim[i]) || + (eval_method[i] & CRIT_LT && response_value[i] < lower_crit_lim[i]) || + (eval_method[i] & CRIT_LE && response_value[i] <= lower_crit_lim[i]) || + (eval_method[i] & CRIT_EQ && response_value[i] == upper_crit_lim[i]) || + (eval_method[i] & CRIT_NE && response_value[i] != upper_crit_lim[i])) { + result = STATE_CRITICAL; + } + + return result; +} + + + +int +lu_getll (unsigned long *ll, char *str) +{ + char tmp[100]; + if (strchr (str, ':') == NULL) + return 0; + if (strchr (str, ',') != NULL && (strchr (str, ',') < strchr (str, ':'))) + return 0; + if (sscanf (str, "%lu%[:]", ll, tmp) == 2) + return 1; + return 0; +} + + + +int +lu_getul (unsigned long *ul, char *str) +{ + char tmp[100]; + if (sscanf (str, "%lu%[^,]", ul, tmp) == 1) + return 1; + if (sscanf (str, ":%lu%[^,]", ul, tmp) == 1) + return 1; + if (sscanf (str, "%*u:%lu%[^,]", ul, tmp) == 1) + return 1; + return 0; +} + + + +/* trim leading whitespace + if there is a leading quote, make sure it balances */ + +char * +thisarg (char *str) +{ + str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ + if (strstr (str, "'") == str) { /* handle SIMPLE quoted strings */ + if (strlen (str) == 1 || !strstr (str + 1, "'")) + die (STATE_UNKNOWN, _("Unbalanced quotes\n")); + } + return str; +} + + + +/* if there's a leading quote, advance to the trailing quote + set the trailing quote to '\x0' + if the string continues, advance beyond the comma */ + +char * +nextarg (char *str) +{ + if (strstr (str, "'") == str) { + str[0] = 0; + if (strlen (str) > 1) { + str = strstr (str + 1, "'"); + return (++str); + } + else { + return NULL; + } + } + if (strstr (str, ",") == str) { + str[0] = 0; + if (strlen (str) > 1) { + return (++str); + } + else { + return NULL; + } + } + if ((str = strstr (str, ",")) && strlen (str) > 1) { + str[0] = 0; + return (++str); + } + return NULL; +} + + + +void +print_help (void) +{ + print_revision (progname, revision); + + printf (COPYRIGHT, copyright, email); + + printf (_("\ +Check status of remote machines and obtain sustem information via SNMP\n\n")); + + print_usage (); + + printf (_(UT_HELP_VRSN)); + + printf (_(UT_HOST_PORT), 'p', DEFAULT_PORT); + + /* SNMP and Authentication Protocol */ + printf (_("\ + -P, --protocol=[1|3]\n\ + SNMP protocol version\n\ + -L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]\n\ + SNMPv3 securityLevel\n\ + -a, --authproto=[MD5|SHA]\n\ + SNMPv3 auth proto\n")); + + /* Authentication Tokens*/ + printf (_("\ + -C, --community=STRING\n\ + Optional community string for SNMP communication\n\ + (default is \"%s\")\n\ + -U, --secname=USERNAME\n\ + SNMPv3 username\n\ + -A, --authpassword=PASSWORD\n\ + SNMPv3 authentication password\n\ + -X, --privpasswd=PASSWORD\n\ + SNMPv3 crypt passwd (DES)\n"), DEFAULT_COMMUNITY); + + /* OID Stuff */ + printf (_("\ + -o, --oid=OID(s)\n\ + Object identifier(s) whose value you wish to query\n\ + -m, --miblist=STRING\n\ + List of MIBS to be loaded (default = ALL)\n -d, --delimiter=STRING\n\ + Delimiter to use when parsing returned data. Default is \"%s\"\n\ + Any data on the right hand side of the delimiter is considered\n\ + to be the data that should be used in the evaluation.\n"), DEFAULT_DELIMITER); + + /* Tests Against Integers */ + printf (_("\ + -w, --warning=INTEGER_RANGE(s)\n\ + Range(s) which will not result in a WARNING status\n\ + -c, --critical=INTEGER_RANGE(s)\n\ + Range(s) which will not result in a CRITICAL status\n")); + + /* Tests Against Strings */ + printf (_("\ + -s, --string=STRING\n\ + Return OK state (for that OID) if STRING is an exact match\n\ + -r, --ereg=REGEX\n\ + Return OK state (for that OID) if extended regular expression REGEX matches\n\ + -R, --eregi=REGEX\n\ + Return OK state (for that OID) if case-insensitive extended REGEX matches\n\ + -l, --label=STRING\n\ + Prefix label for output from plugin (default -s 'SNMP')\n")); + + /* Output Formatting */ + printf (_("\ + -u, --units=STRING\n\ + Units label(s) for output data (e.g., 'sec.').\n\ + -D, --output-delimiter=STRING\n\ + Separates output on multiple OID requests\n")); + + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); + + printf (_("\n\ +- This plugin uses the 'snmpget' command included with the NET-SNMP package.\n\ + If you don't have the package installed, you will need to download it from\n\ + http://net-snmp.sourceforge.net before you can use this plugin.\n")); + + printf (_("\ +- Multiple OIDs may be indicated by a comma- or space-delimited list (lists with\n\ + internal spaces must be quoted) [max 8 OIDs]\n")); + + printf (_("\ +- Ranges are inclusive and are indicated with colons. When specified as\n\ + 'min:max' a STATE_OK will be returned if the result is within the indicated\n\ + range or is equal to the upper or lower bound. A non-OK state will be\n\ + returned if the result is outside the specified range.\n")); + + printf (_("\ +- If specified in the order 'max:min' a non-OK state will be returned if the\n\ + result is within the (inclusive) range.\n")); + + printf (_("\ +- Upper or lower bounds may be omitted to skip checking the respective limit.\n\ +- Bare integers are interpreted as upper limits.\n\ +- When checking multiple OIDs, separate ranges by commas like '-w 1:10,1:,:20'\n\ +- Note that only one string and one regex may be checked at present\n\ +- All evaluation methods other than PR, STR, and SUBSTR expect that the value\n\ + returned from the SNMP query is an unsigned integer.\n")); + + printf (_(UT_SUPPORT)); +} + + + +void +print_usage (void) +{ + printf ("\ +Usage: %s -H -o [-w warn_range] [-c crit_range] \n\ + [-C community] [-s string] [-r regex] [-R regexi]\n\ + [-t timeout] [-e retries]\n\ + [-l label] [-u units] [-p port-number] [-d delimiter]\n\ + [-D output-delimiter] [-m miblist] [-P snmp version]\n\ + [-L seclevel] [-U secname] [-a authproto] [-A authpasswd]\n\ + [-X privpasswd]\n", progname); +} diff --git a/web/attachments/116587-diffs.txt b/web/attachments/116587-diffs.txt new file mode 100644 index 0000000..f685d0d --- /dev/null +++ b/web/attachments/116587-diffs.txt @@ -0,0 +1,32 @@ +34c34 +< -H -o [-n] [-w warn_range] [-c crit_range] \n\ +--- +> -H -o [-w warn_range] [-c crit_range] \n\ +46,47d45 +< -n\n\ +< Use snmpgetnext instead of snmpget\n\ +199d196 +< int usesnmpgetnext = FALSE; +239,244c236 +< if (usesnmpgetnext == TRUE) { +< asprintf (&command_line, "%s -t 1 -r %d -m %s -v %s %s %s:%s %s", +< PATH_TO_SNMPGETNEXT, timeout_interval - 1, miblist, proto, +< authpriv, server_address, port, oid); +< } else { +< asprintf (&command_line, "%s -t 1 -r %d -m %s -v %s %s %s:%s %s", +--- +> asprintf (&command_line, "%s -t 1 -r %d -m %s -v %s %s %s:%s %s", +247d238 +< } +477c468 +< getopt_long (argc, argv, "nhvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:m:P:L:U:a:A:X:", +--- +> getopt_long (argc, argv, "hvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:m:P:L:U:a:A:X:", +480c471 +< c = getopt (argc, argv, "nhvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:m:P:L:U:a:A:X:"); +--- +> c = getopt (argc, argv, "hvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:m:P:L:U:a:A:X:"); +498,500d488 +< case 'n': /* usesnmpgetnext */ +< usesnmpgetnext = TRUE; +< break; diff --git a/web/attachments/116649-check_procs_perfdata.diff b/web/attachments/116649-check_procs_perfdata.diff new file mode 100644 index 0000000..94bcddf --- /dev/null +++ b/web/attachments/116649-check_procs_perfdata.diff @@ -0,0 +1,49 @@ +--- nagios-plugins-HEAD-200501200547/plugins/check_procs.c 2004-12-29 22:41:39.000000000 -0200 ++++ check_procs.c 2005-01-20 14:37:19.000000000 -0200 +@@ -54,6 +54,9 @@ + #define ELAPSED 512 + /* Different metrics */ + char *metric_name; ++char *perf_procs; ++char *perf_metric; ++ + enum metric { + METRIC_PROCS, + METRIC_VSZ, +@@ -290,6 +293,36 @@ + } + printf (ngettext ("%d process", "%d processes", (unsigned long) procs), procs); + ++ perf_procs = NULL; ++ perf_metric = NULL; ++ ++ if (metric == METRIC_PROCS) { ++ perf_procs = strscpy(perf_procs,perfdata("Processes", procs, "", ++ (wmax > 0), wmax , (cmax > 0), cmax , ++ 0, 0, 0, 0)); ++ } else { ++ perf_metric = strscpy(perf_metric, "Processes: Normal "); ++ perf_metric = strcat(perf_metric, metric_name); ++ perf_procs = strscpy(perf_procs, perfdata(perf_metric, procs, "", ++ 0, 0, 0, 0, ++ 0, 0, 0, 0)); ++ perf_metric = strscpy(perf_metric, "Processes: Warning "); ++ perf_metric = strcat(perf_metric, metric_name); ++ perf_procs = strcat(perf_procs, " "); ++ perf_procs = strcat(perf_procs, perfdata(perf_metric, warn, "", ++ 0, 0, 0, 0, ++ 0, 0, 0, 0)); ++ perf_metric = strscpy(perf_metric, "Processes: Critical "); ++ perf_metric = strcat(perf_metric, metric_name); ++ perf_procs = strcat(perf_procs, " "); ++ perf_procs = strcat(perf_procs, perfdata(perf_metric, crit, "", ++ 0, 0, 0, 0, ++ 1, 0, 0, 0)); ++ } ++ ++ printf (" | %s", perf_procs); ++ ++ + if (strcmp(fmt,"") != 0) { + printf (_(" with %s"), fmt); + } diff --git a/web/attachments/116760-nagiosplug-check_nt.diff b/web/attachments/116760-nagiosplug-check_nt.diff new file mode 100644 index 0000000..0d1a578 --- /dev/null +++ b/web/attachments/116760-nagiosplug-check_nt.diff @@ -0,0 +1,76 @@ +--- check_nt.c 2005-01-22 05:16:38.000000000 -0500 ++++ check_nt.c.1.4snapshot 2005-01-22 03:26:29.000000000 -0500 +@@ -32,7 +32,7 @@ + + const char *progname = "check_nt"; + const char *revision = "$Revision: 1.39 $"; +-const char *copyright = "2003-2005"; ++const char *copyright = "2003-2004"; + const char *email = "nagiosplug-devel@lists.sourceforge.net"; + + #include "common.h" +@@ -392,7 +392,7 @@ + case CHECK_FILEAGE: + + if (value_list==NULL) +- output_message = strdup (_("No file specified")); ++ output_message = strdup (_("No counter specified")); + else { + preparelist(value_list); /* replace , between services with & to send the request */ + asprintf(&send_buffer,"%s&9&%s", req_password,value_list); +@@ -573,7 +573,7 @@ + die (result, _("could not fetch information from server\n")); + + if (!strncmp(recv_buffer,"ERROR",5)) +- die (STATE_UNKNOWN, "Client - %s\n",recv_buffer); /*changed from NSClient to be inclsive of NC_Net*/ ++ die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer); + } + + int strtoularray(unsigned long *array, char *string, const char *delim) { +@@ -614,7 +614,7 @@ + printf ("Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n"); + printf (COPYRIGHT, copyright, email); + +- printf (_("This plugin collects data from the NSClient or NC_Net service running on a\n\ ++ printf (_("This plugin collects data from the NSClient service running on a\n\ + Windows NT/2000/XP/2003 server.\n\n")); + + print_usage(); +@@ -665,32 +665,24 @@ + Request a -l parameters with the following syntax:\n\ + -l ,,,...\n\ + You can specify -d SHOWALL in case you want to see working services\n\ +- in the returned string.\n")); ++ in the returned string.\n")); + printf (_("\ + PROCSTATE = Check if one or several process are running.\n\ + Same syntax as SERVICESTATE.\n")); + printf (_("\ + COUNTER = Check any performance counter of Windows NT/2000.\n\ + Request a -l parameters with the following syntax:\n\ +- -l \"\\\\\\\\counter\",\"\n\ ++ -l \"\\\\\\\\counter\",\"\n\ + The parameter is optional and \n\ + is given to a printf output command which requires a float parameter.\n\ + If does not include \"%%\", it is used as a label.\n\ + Some examples:\n\ + \"Paging file usage is %%.2f %%%%\"\n\ + \"%%.f %%%% paging file used.\"\n")); +- printf (_("\ +- FILEAGE = Checks how old a file is .\n\ +- Request a -l parameters with the following syntax:\n\ +- -l \"\\\\\" +- Warning and critical thresholds can be specified with -w and -c.\n")); +- + printf (_("Notes:\n\ +- - The NSClient service should be running on the server to get any information\n\ +- (http://nsclient.ready2run.nl).\n\ +- or NC_Net should be running. DO not run both at the same time.\n\ +- (http://www.shatterit.com/NC_Net).\n\ +- - Critical thresholds should be lower than warning thresholds\n")); ++ - The NSClient service should be running on the server to get any information\n\ ++ (http://nsclient.ready2run.nl).\n\ ++ - Critical thresholds should be lower than warning thresholds\n")); + } + + diff --git a/web/attachments/116765-nagiosplug-check_nt.diff b/web/attachments/116765-nagiosplug-check_nt.diff new file mode 100644 index 0000000..9aaef28 --- /dev/null +++ b/web/attachments/116765-nagiosplug-check_nt.diff @@ -0,0 +1,56 @@ +--- check_nt.c 2005-01-22 07:01:52.000000000 -0500 ++++ check_nt.c.1.4snapshot 2005-01-22 03:26:29.000000000 -0500 +@@ -49,8 +49,7 @@ + CHECK_PROCSTATE, + CHECK_MEMUSE, + CHECK_COUNTER, +- CHECK_FILEAGE, +- CHECK_INSTANCES ++ CHECK_FILEAGE + }; + + enum { +@@ -421,19 +420,6 @@ + } + break; + +- case CHECK_INSTANCES: +- +- if (value_list==NULL) +- output_message = strdup (_("No Perfomance counter Category specified")); +- else { +- preparelist(value_list); /* replace , between services with & to send the request */ +- asprintf(&send_buffer,"%s&10&%s", req_password,value_list); +- fetch_data (server_address, server_port, send_buffer); +- asprintf (&output_message, "%s", recv_buffer); +- return_code = STATE_OK; +- } +- break; +- + case CHECK_NONE: + default: + usage4 (_("Please specify a variable to check")); +@@ -541,8 +527,6 @@ + vars_to_check=CHECK_COUNTER; + else if(!strcmp(optarg,"FILEAGE")) + vars_to_check=CHECK_FILEAGE; +- else if(!strcmp(optarg,"INSTANCES")) +- vars_to_check=CHECK_INSTANCES; + else + return ERROR; + break; +@@ -695,14 +679,6 @@ + Some examples:\n\ + \"Paging file usage is %%.2f %%%%\"\n\ + \"%%.f %%%% paging file used.\"\n")); +- printf (_("\ +- CHECK_INSTANCES = Check any performance counter Category for availible instances.\n\ +- Request a -l parameters with the following syntax:\n\ +- -l ,,...\n\ +- Does not use -w or -c, \n\ +- returns a list of Instances for each Category in the list of categories.\n\ +- example: \n\ +- -l \"Memory,Process,Print Queue\"\n")); + printf (_("Notes:\n\ + - The NSClient service should be running on the server to get any information\n\ + (http://nsclient.ready2run.nl).\n\ diff --git a/web/attachments/116832-check_dig_tabspatch.diff b/web/attachments/116832-check_dig_tabspatch.diff new file mode 100644 index 0000000..552c6b9 --- /dev/null +++ b/web/attachments/116832-check_dig_tabspatch.diff @@ -0,0 +1,38 @@ +Index: check_dig.c +=================================================================== +RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dig.c,v +retrieving revision 1.39 +diff -c -r1.39 check_dig.c +*** check_dig.c 25 Dec 2004 23:17:38 -0000 1.39 +--- check_dig.c 23 Jan 2005 05:00:19 -0000 +*************** +*** 124,129 **** +--- 124,133 ---- + result = STATE_OK; + } + ++ /* rmo: 050122 - Translate output TAB -> SPACE */ ++ char *t = output; ++ while ((t = index(t, '\t')) != NULL) {*t = ' ';} ++ + } while (!strstr (input_buffer, ";; ")); + + if (result == STATE_UNKNOWN) { +*************** +*** 334,340 **** + + printf (_("\ + -a, --expected_address=STRING\n\ +! an address expected to be in the asnwer section.\n\ + if not set, uses whatever was in -l\n")); + + printf (_(UT_WARN_CRIT)); +--- 338,344 ---- + + printf (_("\ + -a, --expected_address=STRING\n\ +! an address expected to be in the answer section.\n\ + if not set, uses whatever was in -l\n")); + + printf (_(UT_WARN_CRIT)); + diff --git a/web/attachments/116909-nagiosplug-check_nt.diff b/web/attachments/116909-nagiosplug-check_nt.diff new file mode 100644 index 0000000..c9426b8 --- /dev/null +++ b/web/attachments/116909-nagiosplug-check_nt.diff @@ -0,0 +1,83 @@ +--- check_nt.c 2005-01-24 03:18:40.000000000 -0500 ++++ check_nt.c.1.4snapshot 2005-01-22 03:26:29.000000000 -0500 +@@ -49,8 +49,7 @@ + CHECK_PROCSTATE, + CHECK_MEMUSE, + CHECK_COUNTER, +- CHECK_FILEAGE, +- CHECK_EVENTLOG ++ CHECK_FILEAGE + }; + + enum { +@@ -421,18 +420,6 @@ + } + break; + +- case CHECK_EVENTLOG: +- if (value_list==NULL) +- asprintf(&send_buffer,"%s&11", req_password); +- else { +- asprintf(&send_buffer,"%s&11&%s", req_password,value_list); +- } +- fetch_data (server_address, server_port, send_buffer); +- return_code=atoi(strtok(recv_buffer,"&")); +- temp_string=strtok(NULL,"&"); +- output_message = strdup (temp_string); +- break; +- + case CHECK_NONE: + default: + usage4 (_("Please specify a variable to check")); +@@ -540,8 +527,6 @@ + vars_to_check=CHECK_COUNTER; + else if(!strcmp(optarg,"FILEAGE")) + vars_to_check=CHECK_FILEAGE; +- else if(!strcmp(optarg,"EVENTLOG")) +- vars_to_check=CHECK_EVENTLOG; + else + return ERROR; + break; +@@ -694,42 +679,6 @@ + Some examples:\n\ + \"Paging file usage is %%.2f %%%%\"\n\ + \"%%.f %%%% paging file used.\"\n")); +- printf (_("\ +- EVENTLOG = Check any Event Log in Windows for any entry.\n\ +- Request a -l parameters with the following syntax:\n\ +- -l \",,,\n\ +- ,,\"\n\ +- - any, System, Application, Security \n\ +- or any other non-standard Event Log. 'any' will check all logs.\n\ +- - any, Information, Warning, Error,\n\ +- or other non-standard Event Type. 'any' will check all Types.\n\ +- - Maximum age in minutes of event entries to check.\n\ +- Use 0 to check all event Entries in log.\n\ +- Use 0 to diable the Source Filter.\n\ +- Otherwise enter a comma seperated list \n\ +- with the first element being the number of items in the list.\n\ +- Use a negitive number to Exclude matching entries.\n\ +- Use a positive number to Include only matching entries.\n\ +- Use 0 to diable the Message Filter.\n\ +- (Message Filter accepts Regular Expressions) \n\ +- Otherwise enter a comma seperated list \n\ +- with the first element being the number of items in the list.\n\ +- Use a negitive number to Exclude matching entries.\n\ +- Use a Positive number to Include only matching entries.\n\ +- Use 0 to diable the Event ID Filter.\n\ +- Otherwise enter a comma seperated list with the first element\n\ +- being the number of items in the list.\n\ +- Use a negitive sign to Exclude matching entries.\n\ +- Use a positive number to Include only matching entries.\n\ +- Examples:\n\ +- The Following examples will list all events in the System Event Log\n\ +- that have a source of eventlog and have the word start or stop\n\ +- withing the event message.\n\ +- -l \"System,any,0,1,eventlog,2,start,stop,0\"\n\ +- -l \"System,any,0,1,eventlog,1,(start|stop),0\"\n\ +- \n")); +- +- + printf (_("Notes:\n\ + - The NSClient service should be running on the server to get any information\n\ + (http://nsclient.ready2run.nl).\n\ diff --git a/web/attachments/117424-check_log.sh.patch b/web/attachments/117424-check_log.sh.patch new file mode 100644 index 0000000..6d6fdb8 --- /dev/null +++ b/web/attachments/117424-check_log.sh.patch @@ -0,0 +1,13 @@ +--- check_log.sh 2002-10-28 13:05:07.000000000 +0000 ++++ check_log.sh.new 2005-01-27 18:51:26.000000000 +0000 +@@ -164,8 +164,8 @@ + + # If the source log file doesn't exist, exit + +-if [ ! -e $logfile ]; then +- $ECHO "Log check error: Log file $logfile does not exist!\n" ++if [ ! -r $logfile ]; then ++ $ECHO "Log check error: Log file $logfile does not exist or you do not have read permission!\n" + exit $STATE_UNKNOWN + fi + diff --git a/web/attachments/117526-cel.diff b/web/attachments/117526-cel.diff new file mode 100644 index 0000000..f205f63 --- /dev/null +++ b/web/attachments/117526-cel.diff @@ -0,0 +1,71 @@ +*** /tools/nagios/libexec/check_email_loop.pl.orig Fri Jan 28 08:08:29 2005 +--- /tools/nagios/libexec/check_email_loop.pl Fri Jan 28 08:38:01 2005 +*************** +*** 42,51 **** + my $state = "UNKNOWN"; + my ($sender,$receiver, $pophost, $popuser, $poppasswd, $smtphost); + my ($poptimeout,$smtptimeout,$pinginterval)=(60,60,5); +! my ($lostwarn, $lostcrit,$pendwarn, $pendcrit); + + # Internal Vars + my ($pop,$msgcount,@msglines,$statinfo,@messageids,$newestid); + my ($matchcount,$statfile) = (0,"check_email_loop.stat"); + + # Subs declaration +--- 42,52 ---- + my $state = "UNKNOWN"; + my ($sender,$receiver, $pophost, $popuser, $poppasswd, $smtphost); + my ($poptimeout,$smtptimeout,$pinginterval)=(60,60,5); +! my ($lostwarn, $lostcrit,$pendwarn, $pendcrit, $debug); + + # Internal Vars + my ($pop,$msgcount,@msglines,$statinfo,@messageids,$newestid); ++ my(%other_smtp_opts); + my ($matchcount,$statfile) = (0,"check_email_loop.stat"); + + # Subs declaration +*************** +*** 65,70 **** +--- 66,72 ---- + my $status = GetOptions( + "from=s",\$sender, + "to=s",\$receiver, ++ "debug", \$debug, + "pophost=s",\$pophost, + "popuser=s",\$popuser, + "passwd=s",\$poppasswd, +*************** +*** 101,108 **** + my $serial = time(); + $serial = "ID#" . $serial . "#$$"; + + # sending new ping email +! my $smtp = Net::SMTP->new($smtphost,Timeout=>$smtptimeout) + || nsexit("SMTP connect timeout ($smtptimeout s)",'CRITICAL'); + ($smtp->mail($sender) && + $smtp->to($receiver) && +--- 103,116 ---- + my $serial = time(); + $serial = "ID#" . $serial . "#$$"; + ++ + # sending new ping email +! %other_smtp_opts={}; +! if ( $debug == 1 ) { +! $other_smtp_opts{'Debug'} = 1; +! } +! +! my $smtp = Net::SMTP->new($smtphost,Timeout=>$smtptimeout, %other_smtp_opts) + || nsexit("SMTP connect timeout ($smtptimeout s)",'CRITICAL'); + ($smtp->mail($sender) && + $smtp->to($receiver) && +*************** +*** 216,221 **** +--- 224,230 ---- + print " -lostcrit=num CRITICAL \n"; + print " -pendwarn=num WARNING-state if more than num pending emails\n"; + print " -pendcrit=num CRITICAL \n"; ++ print " -debug send SMTP tranaction info to stderr\n"; + print " Options may abbreviated!\n"; + print " LOST mails are mails, being sent before the last mail arrived back.\n"; + print " PENDING mails are those, which are not. (supposed to be on the way)\n"; diff --git a/web/attachments/118230-check_http.c.diff b/web/attachments/118230-check_http.c.diff new file mode 100644 index 0000000..336ea2e --- /dev/null +++ b/web/attachments/118230-check_http.c.diff @@ -0,0 +1,133 @@ +*** nagios-plugins-1.4-beta1/plugins/check_http.c 2004-12-24 03:54:24.000000000 +0900 +--- check_http.c 2005-01-26 15:31:53.374334612 +0900 +*************** +*** 66,71 **** +--- 66,73 ---- + X509 *server_cert; + int connect_SSL (void); + int check_certificate (X509 **); ++ # define VERIFY_CERTIFICATE 10 ++ # define CAFILE 11 + #endif + int no_body = FALSE; + int maximum_age = -1; +*************** +*** 111,116 **** +--- 113,123 ---- + char *http_opt_headers; + int onredirect = STATE_OK; + int use_ssl = FALSE; ++ int verify_certificate = FALSE; ++ int use_cafile = FALSE; ++ int CAfile = FALSE; ++ int cert_verify_result; ++ char *trusted_ca_file=NULL; + int verbose = FALSE; + int sd; + int min_page_len = 0; +*************** +*** 206,211 **** +--- 213,220 ---- + {"link", no_argument, 0, 'L'}, + {"nohtml", no_argument, 0, 'n'}, + {"ssl", no_argument, 0, 'S'}, ++ {"certverify", no_argument, 0, VERIFY_CERTIFICATE}, ++ {"CAfile", required_argument, 0, CAFILE}, + {"verbose", no_argument, 0, 'v'}, + {"post", required_argument, 0, 'P'}, + {"IP-address", required_argument, 0, 'I'}, +*************** +*** 315,320 **** +--- 324,351 ---- + usage4 (_("Invalid option - SSL is not available")); + #endif + break; ++ #ifdef HAVE_SSL ++ case VERIFY_CERTIFICATE : ++ use_ssl = TRUE; ++ verify_certificate = TRUE; ++ if (specify_port == FALSE) ++ server_port = HTTPS_PORT; ++ #else ++ usage4 (_("Invalid option - SSL is not available")); ++ #endif ++ break; ++ ++ #ifdef HAVE_SSL ++ case CAFILE : ++ if (!verify_certificate) usage2(_("Verify Certificate option not enabled"),optarg); ++ use_cafile = TRUE; ++ trusted_ca_file = strdup (optarg); ++ #else ++ usage4 (_("Invalid option - SSL is not available")); ++ #endif ++ break; ++ ++ + case 'f': /* onredirect */ + if (!strcmp (optarg, "follow")) + onredirect = STATE_DEPENDENT; +*************** +*** 732,738 **** +--- 763,771 ---- + die (STATE_CRITICAL, _("Unable to open TCP socket\n")); + } + ++ SSL_get_peer_cert_chain(ssl); /* We don't really mind if there is no cert chain as only the peer cert is needed */ + if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) { ++ cert_verify_result = SSL_get_verify_result( ssl ); + X509_free (server_cert); + } + else { +*************** +*** 740,745 **** +--- 773,785 ---- + return STATE_CRITICAL; + } + ++ if (verify_certificate) { ++ if (cert_verify_result != X509_V_OK) { ++ printf ("CRITICAL - Certificate error : %s\n", X509_verify_cert_error_string(cert_verify_result) ); ++ return STATE_CRITICAL; ++ } ++ } ++ + } + else { + #endif +*************** +*** 1191,1196 **** +--- 1231,1246 ---- + return STATE_CRITICAL; + } + ++ if (use_cafile) { ++ SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(trusted_ca_file)); ++ if (!SSL_CTX_load_verify_locations(ctx, trusted_ca_file, NULL)) { ++ printf (_("CRITICAL - Cannot load CAfile.\n")); ++ }else { ++ SSL_CTX_set_default_verify_paths(ctx); ++ } ++ } ++ ++ + /* Initialize alarm signal handling */ + signal (SIGALRM, socket_timeout_alarm_handler); + +*************** +*** 1477,1482 **** +--- 1527,1540 ---- + STATE_OK is returned. When the certificate is still valid, but for less than\n\ + 14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when\n\ + the certificate is expired.\n")); ++ ++ printf (_("\n\ ++ CHECK CERTIFICATE VALIDITY: check_http www.myhost.com --certverify \n\n\ ++ Checks to see the validity of a certificate, will return a critical on any \n\ ++ certificate error including self signed, untrusted issuer, decryption errors\n\ ++ or certificate revocation.\n\ ++ Full list : http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS\n\n")); ++ + #endif + + printf (_(UT_SUPPORT)); diff --git a/web/attachments/119194-check_procs.patch b/web/attachments/119194-check_procs.patch new file mode 100644 index 0000000..3510483 --- /dev/null +++ b/web/attachments/119194-check_procs.patch @@ -0,0 +1,34 @@ +*** check_procs.c.orig Wed Dec 29 16:41:39 2004 +--- check_procs.c Tue Feb 8 10:42:34 2005 +*************** +*** 187,197 **** + procppid, procpcpu, procstat, + procetime, procprog, procargs); + +! /* Ignore self */ + if (strcmp (procprog, progname) == 0) { + continue; + } + + if ((options & STAT) && (strstr (statopts, procstat))) + resultsum |= STAT; + if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL)) +--- 187,204 ---- + procppid, procpcpu, procstat, + procetime, procprog, procargs); + +! /* Ignore command line self */ +! + if (strcmp (procprog, progname) == 0) { + continue; + } + ++ /* Ignore self in process arguments to prevent problems when ++ check_procs is called via shell (i.e. check_nrpe) */ ++ ++ if (strstr (procargs, progname) != NULL) ++ continue; ++ + if ((options & STAT) && (strstr (statopts, procstat))) + resultsum |= STAT; + if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL)) diff --git a/web/attachments/119417-check_ntp-diff b/web/attachments/119417-check_ntp-diff new file mode 100644 index 0000000..11d424d --- /dev/null +++ b/web/attachments/119417-check_ntp-diff @@ -0,0 +1,68 @@ +10,19c10 +< # $Id: check_ntp.pl,v 1.30 2005/02/09 11:15 mevertse Exp $ +< # +< # (c) 2005 Merijn Evertse, SARA Computing and Networking Services +< # 9-2-2005, 11:15 +< # +< # Modified the script to accept parameters -4, -6 to choose between the ipv4 and ipv6 protocol. +< # When no parameter is specified ipv4 is chosen as the default. +< # +< # (c) 2004 Matthew Kent +< # 19-11-2004, 04:00 +--- +> # $Id: check_ntp.pl,v 1.20 2004/11/19 03:59:43 mattkent Exp $ +73,74c64,65 +< use vars qw($opt_V $opt_h $opt_H $opt_t $opt_w $opt_c $opt_j $opt_k $verbose $PROGNAME $def_jitter $ipv4 $ipv6); +< use lib utils.pm; +--- +> use vars qw($opt_V $opt_h $opt_H $opt_t $opt_w $opt_c $opt_j $opt_k $verbose $PROGNAME $def_jitter); +> use lib utils.pm; +97,99c88 +< "v" => \$verbose, "verbose" => \$verbose, +< "4" => \$ipv4, "use-ipv4" => \$ipv4, +< "6" => \$ipv6, "use-ipv6" => \$ipv6, +--- +> "v" => \$verbose, "verbose" => \$verbose, +191,206d179 +< # Determine protocol te be used for ntpdate and ntpq +< my $ntpdate; +< my $ntpq; +< if ($ipv4) { +< $ntpdate = $utils::PATH_TO_NTPDATE . " -4"; +< $ntpq = $utils::PATH_TO_NTPQ . " -4"; +< } +< elsif ($ipv6) { +< $ntpdate = $utils::PATH_TO_NTPDATE . " -6"; +< $ntpq = $utils::PATH_TO_NTPQ . " -6"; +< } +< else { +< # Use IPv4 as the default value +< $ntpdate = $utils::PATH_TO_NTPDATE . " -4"; +< $ntpq = $utils::PATH_TO_NTPQ . " -4"; +< } +214c187 +< if (!open (NTPDATE, $ntpdate . " -q $host 2>&1 |")) { +--- +> if (!open (NTPDATE, "$utils::PATH_TO_NTPDATE -q $host 2>&1 |")) { +289c262 +< if ( open(NTPQ, $ntpq . " -np $host 2>&1 |") ) { +--- +> if ( open(NTPQ,"$utils::PATH_TO_NTPQ -np $host 2>&1 |") ) { +439c412 +< print "Usage: $PROGNAME -H [-46] [-w ] [-c ] [-j ] [-k ] [-v verbose]\n"; +--- +> print "Usage: $PROGNAME -H [-w ] [-c ] [-j ] [-k ] [-v verbose]\n"; +457c430 +< Clock jitter in milliseconds at which a warning message will be generated.\n Defaults to $DEFAULT_JITTER_CRIT. +--- +> Clock jitter in milliseconds at which a warning message will be generated.\n Defaults to $DEFAULT_JITTER_CRIT.\n +460,465c433,434 +< warning is returned.\n +< -4 (--use-ipv4) +< Use IPv4 connection +< -6 (--use-ipv6) +< Use IPv6 connection +< \n"; +--- +> warning is returned. +> "; diff --git a/web/attachments/119444-nagios-plugins-1.4_mysql41-slave-fix.patch b/web/attachments/119444-nagios-plugins-1.4_mysql41-slave-fix.patch new file mode 100644 index 0000000..fb4f11e --- /dev/null +++ b/web/attachments/119444-nagios-plugins-1.4_mysql41-slave-fix.patch @@ -0,0 +1,127 @@ +diff -rNu nagios-plugins-1.4/plugins/check_mysql.c nagios-plugins-1.4_mysql41-slave-fix/plugins/check_mysql.c +--- nagios-plugins-1.4/plugins/check_mysql.c Sun Dec 26 00:17:44 2004 ++++ nagios-plugins-1.4_mysql41-slave-fix/plugins/check_mysql.c Thu Feb 10 13:27:13 2005 +@@ -12,6 +12,11 @@ + * Description: + * + * This plugin is for testing a mysql server. ++* ++****************************************************************************** ++* Modified by wouter@widexs.nl: ++* - Changed static column numbers in the slave-check, to dynamic, ++* so newer MySQL versions (eg. 4.1.x) are supported as well (09-02-2005) + ******************************************************************************/ + + const char *progname = "check_mysql"; +@@ -49,12 +54,19 @@ + MYSQL mysql; + MYSQL_RES *res; + MYSQL_ROW row; ++ MYSQL_FIELD *field; + + /* should be status */ + + char *result = NULL; + char slaveresult[SLAVERESULTSIZE]; + ++ int local_mysql_server_version = 0; ++ int local_mysql_client_version = 0; ++ int col_slave_err = 0; ++ int col_slave_run = 0; ++ int col_slave_sql_run = 0; ++ + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); +@@ -107,6 +119,21 @@ + die (STATE_CRITICAL, _("slave store_result error: %s\n"), mysql_error (&mysql)); + } + ++ /* Get client & server version */ ++ local_mysql_client_version = mysql_get_client_version(); ++ local_mysql_server_version = (local_mysql_client_version >= 40000 ? mysql_get_server_version(&mysql) : local_mysql_get_server_version()); ++ ++ /* Fetch column names */ ++ while((field = mysql_fetch_field(res))) ++ { ++ if(strcmp (field->name, (local_mysql_server_version >= 40000 ? "Slave_IO_Running" : "Slave_Running")) == 0) { ++ col_slave_run = (mysql_field_tell(res) -1); ++ } ++ if(strcmp (field->name, "Slave_SQL_Running") == 0) { ++ col_slave_sql_run = (mysql_field_tell(res) -1); ++ } ++ } ++ + /* fetch the first row */ + if ( (row = mysql_fetch_row (res)) == NULL) { + mysql_free_result (res); +@@ -114,27 +141,38 @@ + die (STATE_CRITICAL, _("slave fetch row error: %s\n"), mysql_error (&mysql)); + } + +- if (mysql_field_count (&mysql) == 12) { +- /* mysql 3.23.x */ +- snprintf (slaveresult, SLAVERESULTSIZE, _("Slave running: %s"), row[6]); +- if (strcmp (row[6], "Yes") != 0) { +- mysql_free_result (res); +- mysql_close (&mysql); +- die (STATE_CRITICAL, "%s\n", slaveresult); ++ if (local_mysql_server_version >= 40000) { ++ /* mysql 4.x.x */ ++ if ((col_slave_run > 0) && (col_slave_sql_run > 0)) { ++ snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[col_slave_run], row[col_slave_sql_run]); ++ if (strcmp (row[col_slave_run], "Yes") != 0 || strcmp (row[col_slave_sql_run], "Yes") != 0) { ++ col_slave_err = 1; ++ } ++ } else { ++ snprintf (slaveresult, SLAVERESULTSIZE, "Required Slave columns not found"); ++ col_slave_err = 1; + } +- + } else { +- /* mysql 4.x.x */ +- snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[9], row[10]); +- if (strcmp (row[9], "Yes") != 0 || strcmp (row[10], "Yes") != 0) { +- mysql_free_result (res); +- mysql_close (&mysql); +- die (STATE_CRITICAL, "%s\n", slaveresult); ++ /* mysql 3.23.x */ ++ if (col_slave_run > 0) { ++ snprintf (slaveresult, SLAVERESULTSIZE, _("Slave running: %s"), row[col_slave_run]); ++ if (strcmp (row[col_slave_run], "Yes") != 0) { ++ col_slave_err = 1; ++ } ++ } else { ++ snprintf (slaveresult, SLAVERESULTSIZE, "Required Slave column not found"); ++ col_slave_err = 1; + } + } + + /* free the result */ + mysql_free_result (res); ++ ++ /* Check for trouble */ ++ if(col_slave_err > 0) { ++ mysql_close (&mysql); ++ die (STATE_CRITICAL, "%s\n", slaveresult); ++ } + } + + /* close the connection */ +@@ -150,6 +188,16 @@ + return STATE_OK; + } + ++/* Get version number for server */ ++local_mysql_get_server_version(MYSQL *mysql) ++{ ++ uint major, minor, version; ++ char *pos= mysql->server_version, *end_pos; ++ major= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1; ++ minor= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1; ++ version= (uint) strtoul(pos, &end_pos, 10); ++ return (ulong) major*10000L+(ulong) (minor*100+version); ++} + + /* process command-line arguments */ + int diff --git a/web/attachments/119447-check_by_ssh.diff b/web/attachments/119447-check_by_ssh.diff new file mode 100644 index 0000000..a915d9f --- /dev/null +++ b/web/attachments/119447-check_by_ssh.diff @@ -0,0 +1,49 @@ +--- check_by_ssh.c.orig 2005-02-08 18:17:08.000000000 +0300 ++++ check_by_ssh.c 2005-02-08 18:13:37.000000000 +0300 +@@ -191,6 +191,7 @@ + {"user", required_argument, 0, 'u'}, + {"logname", required_argument, 0, 'l'}, + {"command", required_argument, 0, 'C'}, ++ {"quiet", required_argument, 0, 'q'}, + {"use-ipv4", no_argument, 0, '4'}, + {"use-ipv6", no_argument, 0, '6'}, + {0, 0, 0, 0} +@@ -207,10 +208,10 @@ + while (1) { + #ifdef HAVE_GETOPT_H + c = +- getopt_long (argc, argv, "Vvh46ft:H:O:p:i:u:l:C:n:s:", long_options, ++ getopt_long (argc, argv, "Vvhq46ft:H:O:p:i:u:l:C:n:s:", long_options, + &option_index); + #else +- c = getopt (argc, argv, "Vvh46ft:H:O:p:i:u:l:C:n:s:"); ++ c = getopt (argc, argv, "Vvhq46ft:H:O:p:i:u:l:C:n:s:"); + #endif + + if (c == -1 || c == EOF) +@@ -268,6 +269,7 @@ + case 'i': /* identity */ + asprintf (&comm, "%s -%c %s", comm, c, optarg); + break; ++ case 'q': /* quiet */ + case '4': /* Pass these switches directly to ssh */ + case '6': /* -4 for IPv4, -6 for IPv6 */ + case 'f': /* fork to background */ +@@ -364,6 +366,8 @@ + " list of nagios service names, separated by ':' [optional]\n" + "-n, --name=NAME\n" + " short name of host in nagios configuration [optional]\n" ++ "-q, --quiet\n" ++ " tell ssh to run in quiet mode\n" + "-4, --use-ipv4\n" + " tell ssh to use IPv4\n" + "-6, --use-ipv6\n" +@@ -391,7 +395,7 @@ + { + printf + ("Usage:\n" +- "check_by_ssh [-f46] [-t timeout] [-i identity] [-l user] -H -C \n" ++ "check_by_ssh [-fq46] [-t timeout] [-i identity] [-l user] -H -C \n" + " [-n name] [-s servicelist] [-O outputfile] [-p port]\n" + "check_by_ssh -V prints version info\n" + "check_by_ssh -h prints more detailed help\n"); diff --git a/web/attachments/119648-check_disk.c.diff b/web/attachments/119648-check_disk.c.diff new file mode 100644 index 0000000..1e0e5fc --- /dev/null +++ b/web/attachments/119648-check_disk.c.diff @@ -0,0 +1,15 @@ +--- check_disk.c.orig 2005-02-11 17:37:48.254928480 +0300 ++++ check_disk.c 2005-02-11 17:37:44.193545904 +0300 +@@ -118,8 +118,11 @@ + if (strcmp (file_system, "none") == 0) + strncpy (file_system, mntp, MAX_INPUT_BUFFER-1); + +- if (disk_result==STATE_OK && erronly && !verbose) ++ /* FIX: If everything is ok set result */ ++ if (disk_result==STATE_OK && erronly && !verbose) { ++ result = max_state (result, disk_result); + continue; ++ } + + if (disk_result!=STATE_OK || verbose>=0) + asprintf (&output, "%s [%.0f kB (%d%%) free on %s]", output, diff --git a/web/attachments/121772-nagiosplug-cvs-timeout_status.diff b/web/attachments/121772-nagiosplug-cvs-timeout_status.diff new file mode 100644 index 0000000..cf1e66a --- /dev/null +++ b/web/attachments/121772-nagiosplug-cvs-timeout_status.diff @@ -0,0 +1,208 @@ +diff -urN ./plugins/check_nt.c ../plugins/plugins/check_nt.c +--- ./plugins/check_nt.c 2005-01-24 08:29:53.000000000 +0100 ++++ ../plugins/plugins/check_nt.c 2005-02-17 12:26:57.000000000 +0100 +@@ -35,6 +35,9 @@ + const char *copyright = "2003-2004"; + const char *email = "nagiosplug-devel@lists.sourceforge.net"; + ++extern const char *status_strings; ++extern int timeout_status; ++ + #include "common.h" + #include "netutils.h" + #include "utils.h" +@@ -454,6 +457,7 @@ + {"hostname", required_argument,0,'H'}, + {"version", no_argument, 0,'V'}, + {"help", no_argument, 0,'h'}, ++ {"timeout-status", required_argument, 0, 'T'}, + {0,0,0,0} + }; + +@@ -478,7 +482,7 @@ + } + + while (1){ +- c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:",longopts,&option); ++ c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:T:",longopts,&option); + + if (c==-1||c==EOF||c==1) + break; +@@ -549,8 +553,11 @@ + socket_timeout=atoi(optarg); + if(socket_timeout<=0) + return ERROR; ++ break; ++ case 'T': ++ if(set_timeout_status(optarg) == ERROR) return ERROR; ++ break; + } +- + } + + if (vars_to_check==CHECK_NONE) +diff -urN ./plugins/common.h ../plugins/plugins/common.h +--- ./plugins/common.h 2004-12-10 11:42:00.000000000 +0100 ++++ ../plugins/plugins/common.h 2005-02-17 12:26:57.000000000 +0100 +@@ -157,8 +157,13 @@ + ERROR = -1 + }; + +-/* AIX seems to have this defined somewhere else */ +-#ifndef FALSE ++/* AIX seems to have FALSE defined somewhere else, so make sure ++ * TRUE means something else (we assume it does if it's already defined) */ ++#ifdef FALSE ++# ifndef TRUE ++# define TRUE (FALSE ^ 1) ++# endif ++#else + enum { + FALSE, + TRUE +@@ -170,7 +175,8 @@ + STATE_WARNING, + STATE_CRITICAL, + STATE_UNKNOWN, +- STATE_DEPENDENT ++ STATE_DEPENDENT, ++ STATE_OOB /* result out of bounds (keep last in list!) */ + }; + + enum { +diff -urN ./plugins/netutils.c ../plugins/plugins/netutils.c +--- ./plugins/netutils.c 2005-01-05 21:53:22.000000000 +0100 ++++ ../plugins/plugins/netutils.c 2005-02-17 12:34:23.000000000 +0100 +@@ -38,18 +38,23 @@ + int econn_refuse_state = STATE_CRITICAL; + int was_refused = FALSE; + int address_family = AF_UNSPEC; ++extern char *status_strings; ++extern int timeout_status; + + static int my_connect(const char *address, int port, int *sd, int proto); + /* handles socket timeouts */ + void + socket_timeout_alarm_handler (int sig) + { +- if (sig == SIGALRM) +- printf (_("CRITICAL - Socket timeout after %d seconds\n"), socket_timeout); +- else +- printf (_("CRITICAL - Abnormal timeout after %d seconds\n"), socket_timeout); ++ /* this can only happen with poorly written plugins, so chalk ++ * it up as input validation error and return STATE_UNKNOWN */ ++ if(timeout_status < 0 || timeout_status >= STATE_OOB) ++ timeout_status = STATE_UNKNOWN; + +- exit (STATE_CRITICAL); ++ printf (_("%s - Socket timeout after %d seconds\n"), ++ status_strings[timeout_status], socket_timeout); ++ ++ exit (timeout_status); + } + + +diff -urN ./plugins/utils.c ../plugins/plugins/utils.c +--- ./plugins/utils.c 2005-01-05 21:53:23.000000000 +0100 ++++ ../plugins/plugins/utils.c 2005-02-17 12:26:57.000000000 +0100 +@@ -23,6 +23,20 @@ + extern void print_usage (void); + extern const char *progname; + ++/* NULL-terminate these arrays just to be prudent ++ * It's a bit faster and a lot more portable to use two separate ++ * arrays for this, as we don't need to rely on strcasecmp being available ++ */ ++const char *status_strings[] = { ++ "OK", "WARNING", "CRITICAL", "UNKNOWN", "DEPENDENT", NULL ++}; ++const char *lowercase_status_strings[] = { ++ "ok", "warning", "critical", "unknown", "dependent", NULL ++}; ++/* plugins may set this themselves, so export it from here ++ * and have the plugins import it explicitly as extern */ ++int timeout_status = STATE_CRITICAL; ++ + #define STRLEN 64 + #define TXTBLK 128 + +@@ -105,18 +119,10 @@ + const char * + state_text (int result) + { +- switch (result) { +- case STATE_OK: +- return "OK"; +- case STATE_WARNING: +- return "WARNING"; +- case STATE_CRITICAL: +- return "CRITICAL"; +- case STATE_DEPENDENT: +- return "DEPENDENT"; +- default: ++ if(result < 0 || result >= STATE_OOB) + return "UNKNOWN"; +- } ++ ++ return status_strings[result]; + } + + void +@@ -129,14 +135,54 @@ + exit (result); + } + ++int ++set_timeout_status(const char *arg) ++{ ++ int i; ++ ++ timeou_status = -1; ++ for(i = 0; status_strings[i],lowercase_status_strings[i]; i++) { ++ if(status_strings[i][0] = arg[0] || ++ lowercase_status_strings[i][0] = arg[0]) ++ { ++ timeout_status = i; ++ break; ++ } ++ ++ if(timeout_status != -1) return OK; ++ ++ errno = 0; ++ timeout_status = (int)strtol(arg, NULL, 0); ++ if(timeout_status < STATE_OK || timeout_status >= STATE_OOB || ++ (!timeout_status && errno)) ++ { ++ timeout_status = STATE_UNKNOWN; ++ return ERROR; ++ } ++ } ++ ++ return OK; ++} ++ ++ + void + timeout_alarm_handler (int signo) + { ++ /* don't segfault if someone stupid has set this arbitrarily */ ++ if(timeout_status < 0 || timeout_status >= STATE_OOB) ++ timeout_status = STATE_UNKNOWN; ++ + if (signo == SIGALRM) { +- printf (_("CRITICAL - Plugin timed out after %d seconds\n"), +- timeout_interval); +- exit (STATE_CRITICAL); ++ printf (_("%s - Plugin timed out after %d seconds\n"), ++ status_strings[timeout_status], timeout_interval); ++ exit (timeout_status); + } ++ ++ /* fallthrough so we print something in case some stupid plugin ++ * contributor has set this function to the catch-all sighandler */ ++ printf(_("Caught signal %d in timeout_alarm_handler (bad coding).\n"), ++ signo); ++ exit(STATE_UNKNOWN); + } + + int diff --git a/web/attachments/121773-check_icmp-bundled.diff b/web/attachments/121773-check_icmp-bundled.diff new file mode 100644 index 0000000..4bb56b4 --- /dev/null +++ b/web/attachments/121773-check_icmp-bundled.diff @@ -0,0 +1,742 @@ +diff -urN ../plugins/plugins/check_icmp.c ./plugins/check_icmp.c +--- ../plugins/plugins/check_icmp.c 2005-02-01 15:31:11.000000000 +0100 ++++ ./plugins/check_icmp.c 2005-02-18 15:57:08.000000000 +0100 +@@ -1,5 +1,5 @@ + /* +- * $Id: check_icmp.c,v 1.5 2005/02/01 07:33:13 stanleyhopcroft Exp $ ++ * $Id: check_icmp.c,v 1.12 2005/01/29 23:23:23 exon Exp $ + * + * Author: Andreas Ericsson + * +@@ -14,6 +14,15 @@ + * redundant routes. The only remainders of fping is currently a few + * function names. + * ++ * Kudos to; ++ * Joe Rhett ++ * Wickus Botha ++ * Aaron Carr ++ * Harper Mann ++ * Phil Costelloe ++ * Carsten Schmitz ++ * for lending me system resources, testing and feedback ++ * + */ + + #include +@@ -84,7 +93,7 @@ + char *msg; /* icmp error message, if any */ + struct sockaddr_in saddr_in; /* the address of this host */ + struct in_addr error_addr; /* stores address of error replies */ +- unsigned long long time_waited; /* total time waited, in usecs */ ++ unsigned long int time_waited; /* total time waited, in usecs */ + unsigned int icmp_sent, icmp_recv, icmp_lost; /* counters */ + unsigned char icmp_type, icmp_code; /* type and code from errors */ + unsigned short flags; /* control/status flags */ +@@ -137,18 +146,19 @@ + #define IP_HDR_SIZE 20 + #define MAX_PING_DATA (MAX_IP_PKT_SIZE - IP_HDR_SIZE - ICMP_MINLEN) + #define DEFAULT_PING_DATA_SIZE (MIN_PING_DATA_SIZE + 44) ++#define DEFAULT_TTL 64 + +-/* various target states */ +-#define TSTATE_INACTIVE 0x01 /* don't ping this host anymore */ +-#define TSTATE_WAITING 0x02 /* unanswered packets on the wire */ +-#define TSTATE_ALIVE 0x04 /* target is alive (has answered something) */ +-#define TSTATE_UNREACH 0x08 ++#define MIN_PKT_INTERVAL 25000 /* min pkt_interval, microsecs */ ++#define NOFORCE_WAIT 0 ++#define FORCE_WAIT 1 + + /** prototypes **/ +-static void usage(unsigned char, char *); ++static void usage(unsigned char, char *, ...); + static u_int get_timevar(const char *); + static u_int get_timevaldiff(struct timeval *, struct timeval *); +-static int wait_for_reply(int, u_int); ++static int reap_replies(int, u_int, int); ++void u_sleep(u_int u_sec); ++static u_int wait_for_reply(int, u_int); + static int recvfrom_wto(int, char *, unsigned int, struct sockaddr *, u_int *); + static int send_icmp_ping(int, struct rta_host *); + static int get_threshold(char *str, threshold *th); +@@ -162,6 +172,7 @@ + + /** external **/ + extern int optind, opterr, optopt; ++/* extern int h_errno; */ + extern char *optarg; + extern char **environ; + +@@ -173,15 +184,15 @@ + static unsigned short icmp_pkt_size, icmp_data_size = DEFAULT_PING_DATA_SIZE; + static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0; + #define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost)) +-static unsigned short targets_down = 0, targets = 0, packets = 0; ++static unsigned int targets_down = 0, targets = 0, packets = 0; + #define targets_alive (targets - targets_down) + static unsigned int retry_interval, pkt_interval, target_interval; + static int icmp_sock, tcp_sock, udp_sock, status = STATE_OK; + static pid_t pid; + static struct timezone tz; + static struct timeval prog_start; +-static unsigned long long max_completion_time = 0; +-static unsigned char ttl = 0; /* outgoing ttl */ ++static unsigned long int max_completion_time = 0; ++static unsigned char ttl = 64; /* outgoing ttl */ + static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */ + float pkt_backoff_factor = 1.5; + float target_backoff_factor = 1.5; +@@ -210,7 +221,8 @@ + { + char *msg = "unreachable"; + +- if(debug > 1) printf("get_icmp_error_msg(%u, %u)\n", icmp_type, icmp_code); ++ if(debug > 3) printf("get_icmp_error_msg(%u, %u) called\n", ++ icmp_type, icmp_code); + switch(icmp_type) { + case ICMP_UNREACH: + switch(icmp_code) { +@@ -269,7 +281,7 @@ + unsigned char *ptr; + + if(p->icmp_type == ICMP_ECHO && p->icmp_id == pid) { +- /* echo request from us to us (pinging localhost) */ ++ if(debug > 2) printf("echo request from us to us (pinging localhost)\n"); + return 0; + } + +@@ -286,9 +298,13 @@ + * TIMXCEED actually sends a proper icmp response we will have passed + * too many hops to have a hope of reaching it later, in which case it + * indicates overconfidence in the network, poor routing or both. */ ++ if(debug > 2) printf("random ICMP response type: %u, code: %u\n", ++ p->icmp_type, p->icmp_code); + if(p->icmp_type != ICMP_UNREACH && p->icmp_type != ICMP_TIMXCEED && + p->icmp_type != ICMP_SOURCEQUENCH && p->icmp_type != ICMP_PARAMPROB) + { ++ if(debug > 1) printf("Unsafe to handle unknown type %u, returning\n", ++ p->icmp_type); + return 0; + } + +@@ -298,7 +314,7 @@ + if(sent_icmp->icmp_type != ICMP_ECHO || sent_icmp->icmp_id != pid || + sent_icmp->icmp_seq >= targets) + { +- if(debug) printf("Packet is no response to a packet we sent\n"); ++ if(debug) printf("not a response to a packet we sent, or target failed to duplicate request\n"); + return 0; + } + +@@ -394,12 +410,12 @@ + } + else if(!strcmp(progname, "check_host")) { + mode = MODE_HOSTCHECK; +- pkt_interval = 1000000; ++ pkt_interval = 200000; + packets = 5; + crit.rta = warn.rta = 1000000; + crit.pl = warn.pl = 100; + } +- else if(!strcmp(progname, "check_rta_multi")) { ++ else if(!strcmp(progname, "check_icmp_multi")) { + mode = MODE_ALL; + target_interval = 0; + pkt_interval = 50000; +@@ -408,6 +424,8 @@ + + /* parse the arguments */ + for(i = 1; i < argc; i++) { ++ /* the leading '-' of the optstring makes non-argument options ++ * return with arg 1, meaning it's */ + while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:i:b:I:l:")) != EOF) { + switch(arg) { + case 'v': +@@ -436,7 +454,8 @@ + timeout = strtoul(optarg, NULL, 0); + if(!timeout) timeout = 10; + break; +- case 'H': ++ case 'H': case 1: /* 1 is default for non-option arguments */ ++ /* printf("arg: %ld, optarg: %s\n", arg, optarg); */ + add_target(optarg); + break; + case 'l': +@@ -460,11 +479,10 @@ + add_target(*argv); + argv++; + } +- if(!targets) { +- errno = 0; +- crash("No hosts to check"); +- exit(3); +- } ++ if(!targets) usage('h', "No hosts to check"); ++ ++ if(getuid() && pkt_interval < MIN_PKT_INTERVAL) ++ pkt_interval = MIN_PKT_INTERVAL; + + if(!sockets) { + if(icmp_sock == -1) { +@@ -486,10 +504,12 @@ + if(!ttl) ttl = 64; + + if(icmp_sock) { ++ errno = 0; + result = setsockopt(icmp_sock, SOL_IP, IP_TTL, &ttl, sizeof(ttl)); + if(debug) { +- if(result == -1) printf("setsockopt failed\n"); +- else printf("ttl set to %u\n", ttl); ++ printf("setsockopt(icmp_sock, SOL_IP, IP_TTL, %u) = %d (%s)\n", ++ ttl, result, strerror(errno)); ++ if(result != -1) printf("outgoing ttl set to %u\n", ttl); + } + } + +@@ -505,7 +525,7 @@ + signal(SIGHUP, finish); + signal(SIGTERM, finish); + signal(SIGALRM, finish); +- if(debug) printf("Setting alarm timeout to %u seconds\n", timeout); ++ if(debug > 1) printf("Setting alarm timeout to %u seconds\n", timeout); + alarm(timeout); + + /* make sure we don't wait any longer than necessary */ +@@ -514,10 +534,9 @@ + ((targets * packets * pkt_interval) + (targets * target_interval)) + + (targets * packets * crit.rta) + crit.rta; + +- if(debug) { ++ if(debug > 1) { + printf("packets: %u, targets: %u\n" +- "target_interval: %0.3f, pkt_interval %0.3f\n" +- "crit.rta: %0.3f\n" ++ "target_interval: %0.3f, pkt_interval %0.3f, crit.rta: %0.3f\n" + "max_completion_time: %0.3f\n", + packets, targets, + (float)target_interval / 1000, (float)pkt_interval / 1000, +@@ -527,9 +546,9 @@ + + if(debug) { + if(max_completion_time > (u_int)timeout * 1000000) { +- printf("max_completion_time: %llu timeout: %u\n", ++ printf("max_completion_time: %lu timeout: %u\n", + max_completion_time, timeout); +- printf("Timout must be at lest %llu\n", ++ printf("Timout must be at lest %lu\n", + max_completion_time / 1000000 + 1); + } + } +@@ -579,24 +598,27 @@ + u_int i, t, result; + u_int final_wait, time_passed; + +- /* this loop might actually violate the pkt_interval or target_interval +- * settings, but only if there aren't any packets on the wire which +- * indicates that the target can handle an increased packet rate */ +- for(i = 0; i < packets; i++) { +- for(t = 0; t < targets; t++) { ++ /* send the packets */ ++ for(t = 0; t < targets; t++) { ++ for(i = 0; i < packets; i++) { ++ + /* don't send useless packets */ +- if(!targets_alive) finish(0); + if(table[t]->flags & FLAG_LOST_CAUSE) { + if(debug) printf("%s is a lost cause. not sending any more\n", + table[t]->name); + continue; + } +- ++ + /* we're still in the game, so send next packet */ + (void)send_icmp_ping(icmp_sock, table[t]); +- result = wait_for_reply(icmp_sock, target_interval); ++ ++ /* pause for a while so we don't flood the network */ ++ result = reap_replies(icmp_sock, pkt_interval, FORCE_WAIT); + } +- result = wait_for_reply(icmp_sock, pkt_interval * targets); ++ ++ /* wait for all incoming packets from all hosts */ ++ if(target_interval > pkt_interval) ++ result = reap_replies(icmp_sock, target_interval - pkt_interval, FORCE_WAIT); + } + + if(icmp_pkts_en_route && targets_alive) { +@@ -604,7 +626,7 @@ + final_wait = max_completion_time - time_passed; + + if(debug) { +- printf("time_passed: %u final_wait: %u max_completion_time: %llu\n", ++ printf("time_passed: %u final_wait: %u max_completion_time: %lu\n", + time_passed, final_wait, max_completion_time); + } + if(time_passed > max_completion_time) { +@@ -616,8 +638,61 @@ + * haven't yet */ + if(debug) printf("Waiting for %u micro-seconds (%0.3f msecs)\n", + final_wait, (float)final_wait / 1000); +- result = wait_for_reply(icmp_sock, final_wait); ++ result = reap_replies(icmp_sock, final_wait, NOFORCE_WAIT); ++ } ++} ++ ++/* ++ * select() is posix, so we expect it to be around ++ */ ++void ++u_sleep(u_int u_sec) ++{ ++ int nfound; ++ struct timeval to; ++ fd_set readset, writeset; ++ ++ if(debug > 3) printf("sleeping for %u microseconds\n", u_sec); ++ if(!u_sec) return; ++ ++ to.tv_sec = u_sec / 1000000; ++ to.tv_usec = u_sec % 1000000; ++ FD_ZERO(&writeset); ++ FD_ZERO(&readset); ++ nfound = select(0, &readset, &writeset, NULL, &to); ++ if(nfound < 0) ++ crash("select() in u_sleep"); ++ ++ return; ++} /* u_sleep() */ ++ ++static int ++reap_replies(int sock, u_int t, int wait_forced) ++{ ++ /* wrap up if all targets are declared dead */ ++ if(debug > 3) printf("reap_replies(%d, %u, %d) called\n", sock, t, wait_forced); ++ ++ if(!targets_alive || ++ get_timevaldiff(&prog_start, NULL) >= max_completion_time) ++ { ++ finish(0); ++ } ++ ++ /* listen til timeout while there are packets en route (rhymes!) ;) */ ++ while(t && icmp_pkts_en_route) { ++ t = wait_for_reply(sock, t); ++ ++ /* the dead won't sing to us */ ++ if(!targets_alive) finish(0); + } ++ ++ if(icmp_recv == (targets_alive * (int)packets)) finish(0); ++ ++ if(!t || !wait_forced) return 0; ++ ++ u_sleep(t); ++ ++ return 0; + } + + /* response structure: +@@ -625,126 +700,98 @@ + * icmp header : 28 bytes + * icmp echo reply : the rest + */ +-static int ++static u_int + wait_for_reply(int sock, u_int t) + { + int n, hlen; + static char buf[4096]; + struct sockaddr_in resp_addr; + struct ip *ip; +- struct icmp *icp, *sent_icmp; ++ struct icmp *icp; + struct rta_host *host; + struct icmp_ping_data *data; + struct timeval wait_start, now; +- u_int tdiff, i, per_pkt_wait; +- +- /* if we can't listen or don't have anything to listen to, just return */ +- if(!t || !icmp_pkts_en_route) return 0; ++ u_int tdiff, timo = t; + + gettimeofday(&wait_start, &tz); + +- i = t; +- per_pkt_wait = t / icmp_pkts_en_route; +- while(icmp_pkts_en_route && get_timevaldiff(&wait_start, NULL) < i) { +- t = per_pkt_wait; +- +- /* wrap up if all targets are declared dead */ +- if(!targets_alive || +- get_timevaldiff(&prog_start, NULL) >= max_completion_time || +- (mode == MODE_HOSTCHECK && targets_down)) +- { +- finish(0); +- } ++ n = recvfrom_wto(sock, buf, sizeof(buf), (struct sockaddr *)&resp_addr, &timo); ++ if(!n) { /* timeout */ ++ if(debug > 2) printf("recvfrom_wto() timed out during a %u usecs wait\n", t); ++ return 0; /* no time left, so return just that */ ++ } + +- /* reap responses until we hit a timeout */ +- n = recvfrom_wto(sock, buf, sizeof(buf), +- (struct sockaddr *)&resp_addr, &t); +- if(!n) { +- if(debug > 1) { +- printf("recvfrom_wto() timed out during a %u usecs wait\n", +- per_pkt_wait); +- } +- continue; /* timeout for this one, so keep trying */ +- } +- if(n < 0) { +- if(debug) printf("recvfrom_wto() returned errors\n"); +- return n; +- } ++ gettimeofday(&now, &tz); ++ tdiff = get_timevaldiff(&wait_start, &now); ++ /* make sure we can return time left */ ++ if(t > tdiff) t -= tdiff; ++ else t = 0; + +- ip = (struct ip *)buf; +- if(debug > 1) printf("received %u bytes from %s\n", ++ ip = (struct ip *)buf; ++ if(debug > 1) printf("received %u bytes from %s\n", + ntohs(ip->ip_len), inet_ntoa(resp_addr.sin_addr)); + +-/* obsolete. alpha on tru64 provides the necessary defines, but isn't broken */ ++/* obsolete, or at least not globally applicable */ + /* #if defined( __alpha__ ) && __STDC__ && !defined( __GLIBC__ ) */ + /* alpha headers are decidedly broken. Using an ansi compiler, + * they provide ip_vhl instead of ip_hl and ip_v, so we mask + * off the bottom 4 bits */ + /* hlen = (ip->ip_vhl & 0x0f) << 2; */ + /* #else */ +- hlen = ip->ip_hl << 2; ++ hlen = ip->ip_hl << 2; + /* #endif */ + +- if(n < (hlen + ICMP_MINLEN)) { +- crash("received packet too short for ICMP (%d bytes, expected %d) from %s\n", +- n, hlen + icmp_pkt_size, inet_ntoa(resp_addr.sin_addr)); +- } +- /* else if(debug) { */ +- /* printf("ip header size: %u, packet size: %u (expected %u, %u)\n", */ +- /* hlen, ntohs(ip->ip_len) - hlen, */ +- /* sizeof(struct ip), icmp_pkt_size); */ +- /* } */ +- +- /* check the response */ +- icp = (struct icmp *)(buf + hlen); +- sent_icmp = (struct icmp *)(buf + hlen + ICMP_MINLEN); +- /* printf("buf: %p, icp: %p, distance: %u (expected %u)\n", */ +- /* buf, icp, */ +- /* (u_int)icp - (u_int)buf, hlen); */ +- /* printf("buf: %p, sent_icmp: %p, distance: %u (expected %u)\n", */ +- /* buf, sent_icmp, */ +- /* (u_int)sent_icmp - (u_int)buf, hlen + ICMP_MINLEN); */ +- +- if(icp->icmp_id != pid) { +- handle_random_icmp(icp, &resp_addr); +- continue; +- } +- +- if(icp->icmp_type != ICMP_ECHOREPLY || icp->icmp_seq >= targets) { +- if(debug > 2) printf("not a proper ICMP_ECHOREPLY\n"); +- handle_random_icmp(icp, &resp_addr); +- continue; +- } +- +- /* this is indeed a valid response */ +- data = (struct icmp_ping_data *)(icp->icmp_data); +- +- host = table[icp->icmp_seq]; +- gettimeofday(&now, &tz); +- tdiff = get_timevaldiff(&data->stime, &now); ++ if(n < (hlen + ICMP_MINLEN)) { ++ crash("received packet too short for ICMP (%d bytes, expected %d) from %s\n", ++ n, hlen + icmp_pkt_size, inet_ntoa(resp_addr.sin_addr)); ++ } ++ else if(debug > 2) { ++ printf("ip header size: %u, packet size: %u (expected %u, %u)\n", ++ hlen, ntohs(ip->ip_len) - hlen, ++ sizeof(struct ip), (u_int)icmp_pkt_size); ++ } + +- host->time_waited += tdiff; +- host->icmp_recv++; +- icmp_recv++; ++ /* check the response */ ++ icp = (struct icmp *)(buf + hlen); + ++ if(icp->icmp_id != pid || icp->icmp_type != ICMP_ECHOREPLY || icp->icmp_seq >= targets) { + if(debug) { +- printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u\n", +- (float)tdiff / 1000, inet_ntoa(resp_addr.sin_addr), +- ttl, ip->ip_ttl); +- } ++ printf("inbound packet is:\n"); ++ if(icp->icmp_id != pid) printf("\tnot marked by me\n"); ++ if(icp->icmp_type != ICMP_ECHOREPLY) printf("\tnot an echo reply\n"); ++ if(icp->icmp_seq >= targets) printf("\ttagged with a too high seq number\n"); ++ } ++ handle_random_icmp(icp, &resp_addr); ++ return t; ++ } ++ if(debug > 2) puts("inbound packet is a valid ICMP_ECHOREPLY to a packet we sent"); ++ ++ /* this is indeed a valid response */ ++ data = (struct icmp_ping_data *)(icp->icmp_data); ++ host = table[icp->icmp_seq]; ++ tdiff = get_timevaldiff(&data->stime, &now); ++ ++ host->time_waited += tdiff; ++ host->icmp_recv++; ++ icmp_recv++; + +- /* if we're in hostcheck mode, exit with limited printouts */ +- if(mode == MODE_HOSTCHECK) { +- printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|" +- "pkt=%u;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n", +- host->name, icmp_recv, (float)tdiff / 1000, +- icmp_recv, packets, (float)tdiff / 1000, +- (float)warn.rta / 1000, (float)crit.rta / 1000); +- exit(STATE_OK); +- } ++ if(debug) { ++ printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u\n", ++ (float)tdiff / 1000, inet_ntoa(resp_addr.sin_addr), ++ ttl, ip->ip_ttl); ++ } ++ ++ /* if we're in hostcheck mode, exit with limited printouts */ ++ if(mode == MODE_HOSTCHECK) { ++ printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|" ++ "pkt=%u;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n", ++ host->name, icmp_recv, (float)tdiff / 1000, ++ icmp_recv, packets, (float)tdiff / 1000, ++ (float)warn.rta / 1000, (float)crit.rta / 1000); ++ exit(STATE_OK); + } + +- return 0; ++ return t; + } + + /* the ping functions */ +@@ -776,8 +823,6 @@ + } + memset(buf, 0, icmp_pkt_size + sizeof(struct ip)); + +- if((gettimeofday(&tv, &tz)) == -1) return -1; +- + icp = (struct icmp *)buf; + icp->icmp_type = ICMP_ECHO; + icp->icmp_code = 0; +@@ -785,7 +830,9 @@ + icp->icmp_id = pid; + icp->icmp_seq = host->id; + data = (struct icmp_ping_data *)icp->icmp_data; +- data->ping_id = 10; /* host->icmp.icmp_sent; */ ++ data->ping_id = host->icmp_sent; ++ ++ if((gettimeofday(&tv, &tz)) == -1) return -1; + memcpy(&data->stime, &tv, sizeof(struct timeval)); + icp->icmp_cksum = icmp_checksum((u_short *)icp, icmp_pkt_size); + +@@ -798,6 +845,7 @@ + return -1; + } + ++ /* increment the counters */ + icmp_sent++; + host->icmp_sent++; + +@@ -809,7 +857,7 @@ + u_int *timo) + { + u_int slen; +- int n; ++ int n, result; + struct timeval to, then, now; + fd_set rd, wr; + +@@ -835,7 +883,10 @@ + + slen = sizeof(struct sockaddr); + +- return recvfrom(sock, buf, len, 0, saddr, &slen); ++ result = recvfrom(sock, buf, len, 0, saddr, &slen); ++ if(result < 0) crash("recvfrom in recvfrom_wto"); ++ ++ return result; + } + + static void +@@ -849,7 +900,7 @@ + {"OK", "WARNING", "CRITICAL", "UNKNOWN", "DEPENDENT"}; + + alarm(0); +- if(debug > 1) printf("finish(%d) called\n", sig); ++ if(debug > 2) printf("finish(%d) called\n", sig); + + if(icmp_sock != -1) close(icmp_sock); + if(udp_sock != -1) close(udp_sock); +@@ -1016,23 +1067,20 @@ + struct hostent *he; + struct in_addr *in, ip; + +- /* don't resolve if we don't have to */ +- if((ip.s_addr = inet_addr(arg)) != INADDR_NONE) { +- /* don't add all ip's if we were given a specific one */ +- return add_target_ip(arg, &ip); +- /* he = gethostbyaddr((char *)in, sizeof(struct in_addr), AF_INET); */ +- /* if(!he) return add_target_ip(arg, in); */ +- } +- else { +- errno = 0; ++ /* don't resolve if we don't have to, don't add all ip's if we were ++ * given a specific one, even if we're in hostcheck mode */ ++ if(inet_aton(arg, &ip)) return add_target_ip(arg, &ip); ++ ++ /* not an IP, so resolve */ ++ errno = 0; ++ he = gethostbyname(arg); ++ if(!he && h_errno == TRY_AGAIN) { ++ u_sleep(500000); + he = gethostbyname(arg); +- if(!he) { +- errno = 0; +- crash("Failed to resolve %s", arg); +- return -1; +- } + } + ++ if(!he) usage(0, "Failed to resolve %s: %s", arg, hstrerror(h_errno)); ++ + /* possibly add all the IP's as targets */ + for(i = 0; he->h_addr_list[i]; i++) { + in = (struct in_addr *)he->h_addr_list[i]; +@@ -1040,7 +1088,7 @@ + + /* this is silly, but it works */ + if(mode == MODE_HOSTCHECK || mode == MODE_ALL) { +- printf("mode: %d\n", mode); ++ if(debug) printf("mode: %d\n", mode); + continue; + } + break; +@@ -1048,6 +1096,7 @@ + + return 0; + } ++ + /* + * u = micro + * m = milli +@@ -1073,12 +1122,12 @@ + if(len >= 2 && !isdigit((int)str[len - 2])) p = str[len - 2]; + if(p && u == 's') u = p; + else if(!p) p = u; +- if(debug > 2) printf("evaluating %s, u: %c, p: %c\n", str, u, p); ++ if(debug > 3) printf("evaluating %s, u: %c, p: %c\n", str, u, p); + + if(u == 'u') factor = 1; /* microseconds */ + else if(u == 'm') factor = 1000; /* milliseconds */ + else if(u == 's') factor = 1000000; /* seconds */ +- if(debug > 2) printf("factor is %u\n", factor); ++ if(debug > 3) printf("factor is %u\n", factor); + + i = strtoul(str, &ptr, 0); + if(!ptr || *ptr != '.' || strlen(ptr) < 2 || factor == 1) +@@ -1149,51 +1198,58 @@ + + /* make core plugin developers happy (silly, really) */ + static void +-usage(unsigned char arg, char *msg) ++usage(unsigned char arg, char *fmt, ...) + { +- if(msg) printf("%s: %s\n", progname, msg); ++ if(fmt) { ++ va_list ap; ++ ++ printf("%s: ", progname); ++ ++ va_start(ap, fmt); ++ vprintf(fmt, ap); ++ va_end(ap); ++ puts("\n"); ++ } + + if(arg == 'V') { +- printf("$Id: check_icmp.c,v 1.5 2005/02/01 07:33:13 stanleyhopcroft Exp $\n"); ++ printf("$Id: check_icmp.c,v 1.12 2005/01/29 23:23:23 exon Exp $\n"); + exit(STATE_UNKNOWN); + } + + printf("Usage: %s [options] [-H] host1 host2 hostn\n\n", progname); + +- if(arg != 'h') exit(3); ++ if(arg != 'h') { ++ printf("%s -h for details\n", progname); ++ exit(3); ++ } + + printf("Where options are any combination of:\n" +- " * -H | --host specify a target\n" +- " * -w | --warn warning threshold (currently %0.3fms,%u%%)\n" +- " * -c | --crit critical threshold (currently %0.3fms,%u%%)\n" +- " * -n | --packets number of packets to send (currently %u)\n" +- " * -i | --interval max packet interval (currently %0.3fms)\n" +- " * -I | --hostint max target interval (currently %0.3fms)\n" +- " * -l | --ttl TTL on outgoing packets (currently %u)\n" +- " * -t | --timeout timeout value (seconds, currently %u)\n" +- " * -b | --bytes icmp packet size (currenly ignored)\n" +- " -v | --verbose verbosity++\n" +- " -h | --help this cruft\n", ++ " * -H | --host specify a target\n" ++ " * -w | --warn warning threshold (currently %0.3fms,%u%%)\n" ++ " * -c | --crit critical threshold (currently %0.3fms,%u%%)\n" ++ " * -n | --packets number of packets to send (currently %u)\n" ++ " * -i | --interval max packet interval (currently %0.3fms)\n" ++ " * -I | --hostint max target interval (currently %0.3fms)\n", + (float)warn.rta / 1000, warn.pl, (float)crit.rta / 1000, crit.pl, + packets, +- (float)pkt_interval / 1000, (float)target_interval / 1000, ++ (float)pkt_interval / 1000, (float)target_interval / 1000); ++ ++ printf(" * -l | --ttl outgoing TTL (currently %u, not supported on all platforms)\n" ++ " * -t | --timeout timeout value (seconds, currently %u)\n" ++ " * -b | --bytes icmp packet size (currenly ignored)\n" ++ " -v | --verbose verbosity++ (4 is sort of max)\n" ++ " -h | --help this cruft\n", + ttl, timeout); + +- puts("\nThe -H switch is optional. Naming a host (or several) to check is not.\n\n" +- "Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%\n" +- "packet loss. The default values should work well for most users.\n" ++ puts("\nThreshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%\n" ++ "packet loss. All threshold values match inclusively.\n" + "You can specify different RTA factors using the standardized abbreviations\n" +- "us (microseconds), ms (milliseconds, default) or just plain s for seconds.\n\n" +- "Threshold format for -d is warn,crit. 12,14 means WARNING if >= 12 hops\n" +- "are spent and CRITICAL if >= 14 hops are spent.\n" +- "NOTE: Some systems decrease TTL when forming ICMP_ECHOREPLY, others do not.\n\n" +- "The -v switch can be specified several times for increased verbosity.\n\n" +- "Long options are currently unsupported.\n\n" +- "Options marked with * require an argument\n"); +- +- puts("The latest version of this plugin can be found at http://oss.op5.se/nagios\n" +- "or https://devel.op5.se/oss until the day it is included in the official\n" +- "plugin distribution.\n"); ++ "us (microseconds), ms (milliseconds, default) or just plain s for seconds.\n"); ++ puts("Long options are currently unsupported.\n"); ++ puts("Options marked with * require an argument\n"); ++ puts("If this program is invoked as check_host (with a symlink, preferrably), it will exit with status\n" ++ "OK upon the first properly received ICMP_ECHOREPLY, making it ideal\n" ++ "for hostchecks (less network load and much, much faster on OK)\n"); + + exit(3); + } diff --git a/web/attachments/121775-nagiosplug-cvs-ansiC.diff b/web/attachments/121775-nagiosplug-cvs-ansiC.diff new file mode 100644 index 0000000..ba408b6 --- /dev/null +++ b/web/attachments/121775-nagiosplug-cvs-ansiC.diff @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + SourceForge.net: ERROR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + +
+
+
+
+
+ + + + + +

There was an error processing your request ...

+ +
+ +

ERROR +
+ +ArtifactFile: Invalid ArtifactFile ID + + +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+ + diff --git a/web/attachments/121776-nagiosplug-cvs-ansiC.diff b/web/attachments/121776-nagiosplug-cvs-ansiC.diff new file mode 100644 index 0000000..58d67fd --- /dev/null +++ b/web/attachments/121776-nagiosplug-cvs-ansiC.diff @@ -0,0 +1,33 @@ +diff -urN ./plugins/check_by_ssh.c ../plugins/plugins/check_by_ssh.c +--- ./plugins/check_by_ssh.c 2005-01-05 21:53:11.000000000 +0100 ++++ ../plugins/plugins/check_by_ssh.c 2005-02-17 13:19:35.000000000 +0100 +@@ -246,7 +246,7 @@ + case 's': /* description of service to check */ + service = realloc (service, (++services) * sizeof(char *)); + p1 = optarg; +- while ((p2 = index (p1, ':'))) { ++ while ((p2 = strchr (p1, ':'))) { + *p2 = '\0'; + asprintf (&service[services-1], "%s", p1); + service = realloc (service, (++services) * sizeof(char *)); +diff -urN ./plugins/check_dig.c ../plugins/plugins/check_dig.c +--- ./plugins/check_dig.c 2005-01-28 15:00:58.000000000 +0100 ++++ ../plugins/plugins/check_dig.c 2005-02-17 13:55:05.000000000 +0100 +@@ -127,7 +127,7 @@ + + /* Translate output TAB -> SPACE */ + t = output; +- while ((t = index(t, '\t')) != NULL) ++ while ((t = strchr(t, '\t')) != NULL) + *t = ' '; + + } while (!strstr (input_buffer, ";; ")); +@@ -149,7 +149,7 @@ + result = max_state (result, STATE_WARNING); + printf ("%s", input_buffer); + if (strlen (output) == 0) +- output = strdup (1 + index (input_buffer, ':')); ++ output = strdup (1 + strchr (input_buffer, ':')); + } + + (void) fclose (child_stderr); diff --git a/web/attachments/121777-nagiosplug-cvs-check_hpjd.diff b/web/attachments/121777-nagiosplug-cvs-check_hpjd.diff new file mode 100644 index 0000000..77d2699 --- /dev/null +++ b/web/attachments/121777-nagiosplug-cvs-check_hpjd.diff @@ -0,0 +1,332 @@ +diff -urN ./plugins/check_hpjd.c ../plugins/plugins/check_hpjd.c +--- ./plugins/check_hpjd.c 2005-01-05 21:53:13.000000000 +0100 ++++ ../plugins/plugins/check_hpjd.c 2005-02-18 13:02:58.000000000 +0100 +@@ -44,6 +44,7 @@ + #define HPJD_GD_DOOR_OPEN ".1.3.6.1.4.1.11.2.3.9.1.1.2.17" + #define HPJD_GD_PAPER_OUTPUT ".1.3.6.1.4.1.11.2.3.9.1.1.2.19" + #define HPJD_GD_STATUS_DISPLAY ".1.3.6.1.4.1.11.2.3.9.1.1.3" ++#define SNMP_VARS 12 + + #define ONLINE 0 + #define OFFLINE 1 +@@ -61,23 +62,30 @@ + { + char command_line[1024]; + int result = STATE_UNKNOWN; +- int line; ++ int line, val = 0; + char input_buffer[MAX_INPUT_BUFFER]; + char query_string[512]; + char *errmsg; + char *temp_buffer; + int line_status = ONLINE; +- int paper_status = 0; +- int intervention_required = 0; +- int peripheral_error = 0; +- int paper_jam = 0; +- int paper_out = 0; +- int toner_low = 0; +- int page_punt = 0; +- int memory_out = 0; +- int door_open = 0; +- int paper_output = 0; +- char display_message[MAX_INPUT_BUFFER]; ++ int errorflag = 0; /* bitflag error tracker */ ++ char *display_message; ++ char *errmsg_strings[11]; ++ int i; ++ ++ /* get the error messages. Will complain about discarded qualifiers ++ * with --disable-nls, but that doesn't matter since they're immutable */ ++ errmsg_strings[0] = _("Paper Jam"); ++ errmsg_strings[1] = _("Out of Paper"); ++ errmsg_strings[2] = _("Printer Offline"); ++ errmsg_strings[3] = _("Peripheral Error"); ++ errmsg_strings[4] = _("Intervention Required"); ++ errmsg_strings[5] = _("Toner Low"); ++ errmsg_strings[6] = _("Insufficient Memory"); ++ errmsg_strings[7] = _("A Door is Open"); ++ errmsg_strings[8] = _("Output Tray is Full"); ++ errmsg_strings[9] = _("Data too Slow for Engine"); ++ errmsg_strings[10] = _("Unknown Paper Error"); + + errmsg = malloc(MAX_INPUT_BUFFER); + +@@ -90,9 +98,12 @@ + + /* removed ' 2>1' at end of command 10/27/1999 - EG */ + /* create the query string */ ++ /* get status display line first, so we can match line status against ++ * powersave as we parse it */ + sprintf + (query_string, + "%s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0", ++ HPJD_GD_STATUS_DISPLAY, + HPJD_LINE_STATUS, + HPJD_PAPER_STATUS, + HPJD_INTERVENTION_REQUIRED, +@@ -102,11 +113,11 @@ + HPJD_GD_TONER_LOW, + HPJD_GD_PAGE_PUNT, + HPJD_GD_MEMORY_OUT, +- HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); ++ HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT); + + /* get the command to run */ +- sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s %s", PATH_TO_SNMPGET, community, +- address, query_string); ++ sprintf (command_line, "%s -Oqa -m : -v 1 -c %s %s %s", PATH_TO_SNMPGET, community, ++ address, query_string); + + /* run the command */ + child_process = spopen (command_line); +@@ -117,170 +128,98 @@ + + child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); + if (child_stderr == NULL) { +- printf (_("Could not open stderr for %s\n"), command_line); ++ /* don't print newline here, or we might return OK while ++ * only printing an error message (highly confusing) */ ++ printf (_("Could not open stderr for %s :: "), command_line); + } + + result = STATE_OK; + + line = 0; ++ /* end parsing when we have display_message, since we won't know ++ * what to do with line 13 or more anyway */ + while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { ++ /* strip the newline character from the end of the input, if any */ ++ temp_buffer = strrchr(input_buffer, '\n'); ++ if(temp_buffer) *temp_buffer = '\0'; ++ ++ if(line == 0) { ++ display_message = strdup(input_buffer); ++ continue; ++ } ++ val = (int)strtol(input_buffer, NULL, 0); ++ if(!val) continue; /* no errors here, so don't handle it */ ++ errorflag |= 1 << (line - 1); /* set the error flag */ ++ ++ /* this switch statement is largely for adding additional ++ * exception handling (POWERSAVE and such) */ ++ switch (line) { ++ case 1: /* line status */ ++ /* clear the flag if it's powersaving */ ++ if(!strstr("POWERSAVE ON", display_message) != 0) ++ errorflag ^= 1 << (line - 1); ++ break; + +- /* strip the newline character from the end of the input */ +- if (input_buffer[strlen (input_buffer) - 1] == '\n') +- input_buffer[strlen (input_buffer) - 1] = 0; +- +- line++; +- +- temp_buffer = strtok (input_buffer, "="); +- temp_buffer = strtok (NULL, "="); +- +- if (temp_buffer == NULL) { +- +- result = STATE_UNKNOWN; +- strcpy (errmsg, input_buffer); +- +- } else { +- +- switch (line) { +- +- case 1: /* 1st line should contain the line status */ +- line_status = atoi (temp_buffer); +- break; +- case 2: /* 2nd line should contain the paper status */ +- paper_status = atoi (temp_buffer); +- break; +- case 3: /* 3rd line should be intervention required */ +- intervention_required = atoi (temp_buffer); +- break; +- case 4: /* 4th line should be peripheral error */ +- peripheral_error = atoi (temp_buffer); +- break; +- case 5: /* 5th line should contain the paper jam status */ +- paper_jam = atoi (temp_buffer); +- break; +- case 6: /* 6th line should contain the paper out status */ +- paper_out = atoi (temp_buffer); +- break; +- case 7: /* 7th line should contain the toner low status */ +- toner_low = atoi (temp_buffer); +- break; +- case 8: /* did data come too slow for engine */ +- page_punt = atoi (temp_buffer); +- break; +- case 9: /* did we run out of memory */ +- memory_out = atoi (temp_buffer); +- break; +- case 10: /* is there a door open */ +- door_open = atoi (temp_buffer); +- break; +- case 11: /* is output tray full */ +- paper_output = atoi (temp_buffer); +- break; +- case 12: /* display panel message */ +- strcpy (display_message, temp_buffer + 1); +- break; +- default: +- break; +- } +- ++ case 2: /* paper status */ ++ case 3: /* intervention required */ ++ case 4: /* peripheral error */ ++ case 5: /* paper jam */ ++ case 6: /* paper out */ ++ case 7: /* toner low */ ++ case 8: /* data came too slow for engine */ ++ case 9: /* out of memory */ ++ case 10: /* is there a door open */ ++ case 11: /* is output tray full */ ++ default: /* notreached */ ++ break; + } + +- /* break out of the read loop if we encounter an error */ +- if (result != STATE_OK) ++ if(++line >= SNMP_VARS) + break; + } + +- /* WARNING if output found on stderr */ +- if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { ++ /* WARNING if output found on stderr, but only if we ++ * haven't already found an error condition */ ++ if (!errorflag && fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { + result = max_state (result, STATE_WARNING); + /* remove CRLF */ + if (input_buffer[strlen (input_buffer) - 1] == '\n') + input_buffer[strlen (input_buffer) - 1] = 0; +- sprintf (errmsg, "%s", input_buffer ); +- ++ strncpy(errmsg, input_buffer, sizeof(errmsg)); + } +- ++ + /* close stderr */ + (void) fclose (child_stderr); + +- /* close the pipe */ ++ /* close the pipe. set warning at least if snmpget didn't return 0 */ + if (spclose (child_process)) +- result = max_state (result, STATE_WARNING); ++ result = STATE_WARNING; + + /* if there wasn't any output, display an error */ + if (line == 0) { +- +- /* might not be the problem, but most likely is. */ +- result = STATE_UNKNOWN ; +- asprintf (&errmsg, "%s : Timeout from host %s\n", errmsg, address ); +- +- } +- +- /* if we had no read errors, check the printer status results... */ +- if (result == STATE_OK) { +- +- if (paper_jam) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Paper Jam")); +- } +- else if (paper_out) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Out of Paper")); +- } +- else if (line_status == OFFLINE) { +- if (strcmp (errmsg, "POWERSAVE ON") != 0) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Printer Offline")); +- } +- } +- else if (peripheral_error) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Peripheral Error")); +- } +- else if (intervention_required) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Intervention Required")); +- } +- else if (toner_low) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Toner Low")); +- } +- else if (memory_out) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Insufficient Memory")); +- } +- else if (door_open) { +- result = STATE_WARNING; +- strcpy (errmsg, _("A Door is Open")); +- } +- else if (paper_output) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Output Tray is Full")); +- } +- else if (page_punt) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Data too Slow for Engine")); +- } +- else if (paper_status) { +- result = STATE_WARNING; +- strcpy (errmsg, _("Unknown Paper Error")); +- } ++ /* timeout is not necessarily the problem, and produces wildly ++ * inaccurate error messages when it isn't, so just say ++ * the host didn't return anything and return immediately ++ * (old plugin unconditionally escalated STATE_UNKNOWN to ++ * STATE_CRITICAL at the end, so this just saves a bit of ++ * indentation. */ ++ printf (_("%s : No data returned from %s\n"), errmsg, address ); ++ return STATE_CRITICAL; + } + +- if (result == STATE_OK) ++ /* obviously no read errors, so check the printer status results... */ ++ if (!errors) { ++ result = STATE_OK; + printf (_("Printer ok - (%s)\n"), display_message); +- +- else if (result == STATE_UNKNOWN) { +- +- printf ("%s\n", errmsg); +- +- /* if printer could not be reached, escalate to critical */ +- if (strstr (errmsg, "Timeout")) +- result = STATE_CRITICAL; + } +- +- else if (result == STATE_WARNING) +- printf ("%s (%s)\n", errmsg, display_message); ++ else { ++ /* some error occured, so print them all */ ++ while(i < SNMP_VARS) { ++ printf ("%s (%s)\n", errmsg ? errmsg : "", display_message); ++ if((errorflag >> i) & 1) /* only print if flag is set */ ++ printf(":: %s", errmsg_strings[i++]); ++ } ++ } + + return result; + } +@@ -346,12 +285,12 @@ + usage2 (_("Invalid hostname/address"), argv[c]); + } + } +- ++ + if (community == NULL) { + if (argv[c] != NULL ) + community = argv[c]; + else +- community = strdup (DEFAULT_COMMUNITY); ++ community = DEFAULT_COMMUNITY; + } + + return validate_arguments (); diff --git a/web/attachments/121778-nagiosplug-cvs-check_mysql-paranoia.diff b/web/attachments/121778-nagiosplug-cvs-check_mysql-paranoia.diff new file mode 100644 index 0000000..6639e29 --- /dev/null +++ b/web/attachments/121778-nagiosplug-cvs-check_mysql-paranoia.diff @@ -0,0 +1,89 @@ +diff -urN ./plugins/check_mysql.c ../plugins/plugins/check_mysql.c +--- ./plugins/check_mysql.c 2005-01-05 21:53:16.000000000 +0100 ++++ ../plugins/plugins/check_mysql.c 2005-02-17 16:08:30.000000000 +0100 +@@ -155,7 +155,7 @@ + int + process_arguments (int argc, char **argv) + { +- int c; ++ int c, i; + + int option = 0; + static struct option longopts[] = { +@@ -193,10 +193,19 @@ + db = optarg; + break; + case 'u': /* username */ +- db_user = optarg; ++ if((db_user = strdup(optarg))) { ++ for(i = 0; i < strlen(argv[optind]); i++) argv[optind][i] = 'x'; ++ } ++ else ++ db_user = optarg; + break; + case 'p': /* authentication information: password */ +- db_pass = optarg; ++ if((db_pass = strdup(optarg))) { ++ /* strdup was successful, so obscure passwd from ps view */ ++ for(i = 0; i < strlen(argv[optind]); i++) argv[optind][i] = 'x'; ++ } ++ else /* strdup failed, so point it to password input string */ ++ db_pass = optarg; + break; + case 'P': /* critical time threshold */ + db_port = atoi (optarg); +@@ -219,18 +228,27 @@ + + while ( argc > c ) { + +- if (strlen(db_host) == 0) ++ if (db_host == NULL || strlen(db_host) == 0) { + if (is_host (argv[c])) { + db_host = argv[c++]; + } + else { + usage2 (_("Invalid hostname/address"), optarg); + } +- else if (strlen(db_user) == 0) +- db_user = argv[c++]; +- else if (strlen(db_pass) == 0) +- db_pass = argv[c++]; +- else if (strlen(db) == 0) ++ } ++ else if (db_user == NULL || strlen(db_user) == 0) { ++ if((db_user = strdup(argv[c++]))) ++ for(i = 0; i < strlen(argv[c]); i++) argv[c][i] = 'x'; ++ else ++ db_user = argv[c]; ++ } ++ else if (db_pass == NULL || strlen(db_pass) == 0) { ++ if((db_pass = strdup(argv[c++]))) ++ for(i = 0; i < strlen(argv[c]); i++) argv[c][i] = 'x'; ++ else ++ db_pass = argv[c]; ++ } ++ else if (db == NULL || strlen(db) == 0) + db = argv[c++]; + else if (is_intnonneg (argv[c])) + db_port = atoi (argv[c++]); +@@ -246,16 +264,16 @@ + validate_arguments (void) + { + if (db_user == NULL) +- db_user = strdup(""); ++ db_user = ""; + + if (db_host == NULL) +- db_host = strdup(""); ++ db_host = ""; + + if (db_pass == NULL) +- db_pass == strdup(""); ++ db_pass == ""; + + if (db == NULL) +- db = strdup(""); ++ db = ""; + + return OK; + } diff --git a/web/attachments/121779-nagiosplug-cvs-check_snmp.diff b/web/attachments/121779-nagiosplug-cvs-check_snmp.diff new file mode 100644 index 0000000..d2c1cde --- /dev/null +++ b/web/attachments/121779-nagiosplug-cvs-check_snmp.diff @@ -0,0 +1,116 @@ +diff -urN ./plugins/check_snmp.c ../plugins/plugins/check_snmp.c +--- ./plugins/check_snmp.c 2005-01-24 08:29:54.000000000 +0100 ++++ ../plugins/plugins/check_snmp.c 2005-02-17 16:53:58.000000000 +0100 +@@ -36,6 +36,7 @@ + #define DEFAULT_AUTH_PROTOCOL "MD5" + #define DEFAULT_DELIMITER "=" + #define DEFAULT_OUTPUT_DELIMITER " " ++#define DEFAULT_SEC_LEVEL "noAuthNoPriv" + + #define mark(a) ((a)!=0?"*":"") + +@@ -88,12 +89,12 @@ + #endif + + char *server_address = NULL; +-char *community = NULL; ++char *community = DEFAULT_COMMUNITY; + char *authpriv = NULL; +-char *proto = NULL; +-char *seclevel = NULL; ++char *proto = DEFAULT_PROTOCOL; ++char *seclevel = DEFAULT_SEC_LEVEL; + char *secname = NULL; +-char *authproto = NULL; ++char *authproto = DEFAULT_AUTH_PROTOCOL; + char *authpasswd = NULL; + char *privpasswd = NULL; + char *oid; +@@ -147,15 +148,15 @@ + eval_method[i] = CHECK_UNDEF; + i = 0; + +- oid = strdup (""); +- label = strdup ("SNMP"); +- units = strdup (""); +- port = strdup (DEFAULT_PORT); +- outbuff = strdup (""); +- output = strdup (""); +- delimiter = strdup (DEFAULT_DELIMITER); +- output_delim = strdup (DEFAULT_OUTPUT_DELIMITER); +- miblist = strdup (DEFAULT_MIBLIST); ++ oid = ""; ++ label = "SNMP"; ++ units = ""; ++ port = DEFAULT_PORT; ++ outbuff = ""; ++ output = ""; ++ delimiter = DEFAULT_DELIMITER; ++ output_delim = DEFAULT_OUTPUT_DELIMITER; ++ miblist = DEFAULT_MIBLIST; + timeout_interval = DEFAULT_TIMEOUT; + retries = DEFAULT_RETRIES; + +@@ -598,9 +599,6 @@ + if (server_address == NULL) + server_address = argv[optind]; + +- if (community == NULL) +- community = strdup (DEFAULT_COMMUNITY); +- + return validate_arguments (); + } + +@@ -631,30 +629,28 @@ + validate_arguments () + { + +- /* Need better checks to verify seclevel and authproto choices */ +- +- if (seclevel == NULL) +- asprintf (&seclevel, "noAuthNoPriv"); ++ /* Need checks to verify seclevel and authproto choices */ + ++ /* default protocol is set in variable declaraion, so this can't ++ * possibly be NULL any-more. It can, however, be a zero length string ++ * (if a check_command is specified that can use either v1 or v2c, the ++ * $ARGx$ macro is quote-escaped and not given in service-description) ++ * in which case we don't fuss much about it but just set it to default */ ++ if (!strlen(proto)) ++ proto = DEFAULT_PROTOCOL; + +- if (authproto == NULL ) +- asprintf(&authproto, DEFAULT_AUTH_PROTOCOL); +- +- +- +- if (proto == NULL || (strcmp(proto,DEFAULT_PROTOCOL) == 0) ) { /* default protocol version */ +- asprintf(&proto, DEFAULT_PROTOCOL); ++ if (proto[0] == '1' || proto[0] == '2') { /* community based access */ + asprintf(&authpriv, "%s%s", "-c ", community); + } + else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */ +- asprintf(&proto, "%s", "3"); +- ++ proto = "3"; ++ + if ( (strcmp(seclevel, "noAuthNoPriv") == 0) || seclevel == NULL ) { +- asprintf(&authpriv, "%s", "-l noAuthNoPriv" ); ++ asprintf(&authpriv, "%s %s", "-l", DEFAULT_SEC_LEVEL); + } + else if ( strcmp(seclevel, "authNoPriv") == 0 ) { + if ( secname == NULL || authpasswd == NULL) { +- printf (_("Missing secname (%s) or authpassword (%s) ! \n"),secname, authpasswd ); ++ printf (_("Missing secname or authpassword!\n")); + print_usage (); + exit (STATE_UNKNOWN); + } +@@ -662,7 +658,7 @@ + } + else if ( strcmp(seclevel, "authPriv") == 0 ) { + if ( secname == NULL || authpasswd == NULL || privpasswd == NULL ) { +- printf (_("Missing secname (%s), authpassword (%s), or privpasswd (%s)! \n"),secname, authpasswd,privpasswd ); ++ printf (_("Missing secname, authpassword or privpasswd!\n")); + print_usage (); + exit (STATE_UNKNOWN); + } diff --git a/web/attachments/121780-nagiosplug-cvs-check_tcp.diff b/web/attachments/121780-nagiosplug-cvs-check_tcp.diff new file mode 100644 index 0000000..8f80d0e --- /dev/null +++ b/web/attachments/121780-nagiosplug-cvs-check_tcp.diff @@ -0,0 +1,204 @@ +diff -urN ./plugins/check_tcp.c ../foo/plugins/check_tcp.c +--- ./plugins/check_tcp.c 2005-01-05 21:53:20.000000000 +0100 ++++ ../foo/plugins/check_tcp.c 2005-02-18 16:10:17.000000000 +0100 +@@ -114,138 +114,105 @@ + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + +- if (strstr (argv[0], "check_udp")) { +- progname = strdup ("check_udp"); +- SERVICE = strdup ("UDP"); +- SEND = NULL; +- EXPECT = NULL; +- QUIT = NULL; ++ progname = strrchr(argv[0], '/'); ++ if(progname && strlen(progname) > 1) progname++; ++ else progname = argv[0]; ++ ++ /* determine service, if possible */ ++ SERVICE = strrchr(progname, '_'); ++ if(SERVICE && strlen(SERVICE) > 1) { ++ /* get a unique pointer and upcase it */ ++ SERVICE++; ++ SERVICE = strdup(SERVICE); ++ for(i = 0; i < strlen(SERVICE); i++) ++ SERVICE[i] = toupper(SERVICE[i]); ++ } ++ else SERVICE = "UNKNOWN SERVICE"; ++ ++ PROTOCOL = TCP_PROTOCOL; /* majority, so default */ ++ ++ if (!strncmp(SERVICE, "UDP", 3)) { /* strncmp to match check_udp2 also */ + PROTOCOL = UDP_PROTOCOL; +- PORT = 0; + } +- else if (strstr (argv[0], "check_tcp")) { +- progname = strdup ("check_tcp"); +- SERVICE = strdup ("TCP"); +- SEND = NULL; +- EXPECT = NULL; +- QUIT = NULL; +- PROTOCOL = TCP_PROTOCOL; +- PORT = 0; +- } +- else if (strstr (argv[0], "check_ftp")) { +- progname = strdup ("check_ftp"); +- SERVICE = strdup ("FTP"); +- SEND = NULL; +- EXPECT = strdup ("220"); +- QUIT = strdup ("QUIT\r\n"); +- PROTOCOL = TCP_PROTOCOL; ++ else if (!strcmp (SERVICE, "FTP")) { ++ EXPECT = "220"; ++ QUIT = "QUIT\r\n"; + PORT = 21; + } +- else if (strstr (argv[0], "check_smtp")) { +- progname = strdup ("check_smtp"); +- SERVICE = strdup ("SMTP"); +- SEND = NULL; +- EXPECT = strdup ("220"); +- QUIT = strdup ("QUIT\r\n"); +- PROTOCOL = TCP_PROTOCOL; ++ else if (!strcmp (SERVICE, "SMTP")) { ++ EXPECT = "220"; ++ QUIT = "QUIT\r\n"; + PORT = 25; + } +- else if (strstr (argv[0], "check_pop")) { +- progname = strdup ("check_pop"); +- SERVICE = strdup ("POP"); +- SEND = NULL; +- EXPECT = strdup ("+OK"); +- QUIT = strdup ("QUIT\r\n"); +- PROTOCOL = TCP_PROTOCOL; ++ else if (!strcmp (SERVICE, "POP")) { + PORT = 110; + } +- else if (strstr (argv[0], "check_imap")) { +- progname = strdup ("check_imap"); +- SERVICE = strdup ("IMAP"); +- SEND = NULL; +- EXPECT = strdup ("* OK"); +- QUIT = strdup ("a1 LOGOUT\r\n"); +- PROTOCOL = TCP_PROTOCOL; ++ else if (!strcmp (SERVICE, "IMAP")) { ++ SERVICE = "IMAP"; + PORT = 143; + } + #ifdef HAVE_SSL +- else if (strstr(argv[0],"check_simap")) { +- progname = strdup ("check_simap"); +- SERVICE = strdup ("SIMAP"); +- SEND=NULL; +- EXPECT = strdup ("* OK"); +- QUIT = strdup ("a1 LOGOUT\r\n"); +- PROTOCOL=TCP_PROTOCOL; ++ else if (!strcmp(SERVICE,"SIMAP")) { ++ SERVICE = "SIMAP"; + use_ssl=TRUE; + PORT=993; + } +- else if (strstr(argv[0],"check_spop")) { +- progname = strdup ("check_spop"); +- SERVICE = strdup ("SPOP"); +- SEND=NULL; +- EXPECT = strdup ("+OK"); +- QUIT = strdup ("QUIT\r\n"); +- PROTOCOL=TCP_PROTOCOL; ++ else if (!strcmp(SERVICE,"SPOP")) { + use_ssl=TRUE; + PORT=995; + } +- else if (strstr(argv[0],"check_jabber")) { +- progname = strdup("check_jabber"); +- SERVICE = strdup("JABBER"); +- SEND = strdup("\n"); +- EXPECT = strdup("\n"); +- PROTOCOL=TCP_PROTOCOL; ++ else if (!strcmp(SERVICE, "JABBER")) { ++ SEND = "\n"; ++ EXPECT = " 1)) progname++; ++ else progname = argv[0]; + + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); diff --git a/web/attachments/121784-nagiosplug-cvs-silly.diff b/web/attachments/121784-nagiosplug-cvs-silly.diff new file mode 100644 index 0000000..a518e81 --- /dev/null +++ b/web/attachments/121784-nagiosplug-cvs-silly.diff @@ -0,0 +1,806 @@ +diff -urN ./plugins/check_by_ssh.c ../plugins/plugins/check_by_ssh.c +--- ./plugins/check_by_ssh.c 2005-01-05 21:53:11.000000000 +0100 ++++ ../plugins/plugins/check_by_ssh.c 2005-02-17 13:19:35.000000000 +0100 +@@ -59,9 +59,9 @@ + time_t local_time; + FILE *fp = NULL; + +- remotecmd = strdup (""); +- comm = strdup (SSH_COMMAND); +- result_text = strdup (""); ++ remotecmd = ""; ++ comm = SSH_COMMAND; ++ result_text = ""; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); +@@ -137,7 +137,7 @@ + printf ("%s", result_text); + return result; + } +- asprintf (&output, "%s", result_text); ++ output = result_text; + result_text = strnl (status_text); + eol = strpbrk (output, "\r\n"); + if (eol != NULL) +diff -urN ./plugins/check_dig.c ../plugins/plugins/check_dig.c +--- ./plugins/check_dig.c 2005-01-28 15:00:58.000000000 +0100 ++++ ../plugins/plugins/check_dig.c 2005-02-17 13:55:05.000000000 +0100 +@@ -59,7 +59,7 @@ + double elapsed_time; + int result = STATE_UNKNOWN; + +- output = strdup (""); ++ output = ""; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); +@@ -293,7 +293,7 @@ + } + } + else { +- dns_server = strdup ("127.0.0.1"); ++ dns_server = "127.0.0.1"; + } + } + +diff -urN ./plugins/check_disk.c ../plugins/plugins/check_disk.c +--- ./plugins/check_disk.c 2005-01-05 21:53:12.000000000 +0100 ++++ ../plugins/plugins/check_disk.c 2005-02-17 13:12:09.000000000 +0100 +@@ -153,9 +153,9 @@ + struct fs_usage fsp; + struct name_list *temp_list; + +- output = strdup (" - free space:"); +- details = strdup (""); +- perf = strdup (""); ++ output = " - free space:"; ++ details = ""; ++ perf = ""; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); +@@ -283,7 +283,7 @@ + return ERROR; + + se = (struct name_list *) malloc (sizeof (struct name_list)); +- se->name = strdup ("iso9660"); ++ se->name = "iso9660"; + se->name_next = NULL; + *fstail = se; + fstail = &se->name_next; +@@ -346,19 +346,19 @@ + free(units); + if (! strcmp (optarg, "bytes")) { + mult = (uintmax_t)1; +- units = strdup ("B"); ++ units = "B"; + } else if (! strcmp (optarg, "kB")) { + mult = (uintmax_t)1024; +- units = strdup ("kB"); ++ units = "kB"; + } else if (! strcmp (optarg, "MB")) { + mult = (uintmax_t)1024 * 1024; +- units = strdup ("MB"); ++ units = "MB"; + } else if (! strcmp (optarg, "GB")) { + mult = (uintmax_t)1024 * 1024 * 1024; +- units = strdup ("GB"); ++ units = "GB"; + } else if (! strcmp (optarg, "TB")) { + mult = (uintmax_t)1024 * 1024 * 1024 * 1024; +- units = strdup ("TB"); ++ units = "TB"; + } else { + die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); + } +@@ -369,13 +369,13 @@ + mult = 1024; + if (units) + free(units); +- units = strdup ("kB"); ++ units = "kB"; + break; + case 'm': /* display mountpoint */ + mult = 1024 * 1024; + if (units) + free(units); +- units = strdup ("MB"); ++ units = "MB"; + break; + case 'l': + show_local_fs = 1; +@@ -518,7 +518,7 @@ + } + + if (units == NULL) { +- units = strdup ("MB"); ++ units = "MB"; + mult = (uintmax_t)1024 * 1024; + } + return OK; +diff -urN ./plugins/check_game.c ../plugins/plugins/check_game.c +--- ./plugins/check_game.c 2005-01-05 21:53:13.000000000 +0100 ++++ ../plugins/plugins/check_game.c 2005-02-17 13:12:09.000000000 +0100 +@@ -110,7 +110,7 @@ + + /* initialize the returned data buffer */ + for (i = 0; i < QSTAT_MAX_RETURN_ARGS; i++) +- ret[i] = strdup(""); ++ ret[i] = ""; + + i = 0; + p = (char *) strtok (input_buffer, QSTAT_DATA_DELIMITER); +diff -urN ./plugins/check_http.c ../plugins/plugins/check_http.c +--- ./plugins/check_http.c 2005-01-24 08:29:53.000000000 +0100 ++++ ../plugins/plugins/check_http.c 2005-02-17 15:34:59.000000000 +0100 +@@ -60,7 +60,6 @@ + #ifdef HAVE_SSL + int check_cert = FALSE; + int days_till_exp; +-char *randbuff; + SSL_CTX *ctx; + SSL *ssl; + X509 *server_cert; +@@ -357,7 +356,7 @@ + break; + case 'P': /* HTTP POST data in URL encoded format */ + if (http_method || http_post_data) break; +- http_method = strdup("POST"); ++ http_method = "POST"; + http_post_data = strdup (optarg); + break; + case 's': /* string or substring */ +@@ -473,7 +472,7 @@ + socket_timeout = (int)critical_time + 1; + + if (http_method == NULL) +- http_method = strdup ("GET"); ++ http_method = "GET"; + + return TRUE; + } +@@ -869,7 +868,7 @@ + #endif + + /* fetch the page */ +- full_page = strdup(""); ++ full_page = ""; + while ((i = my_recv ()) > 0) { + buffer[i] = '\0'; + asprintf (&full_page, "%s%s", full_page, buffer); +@@ -1250,8 +1249,9 @@ + int connect_SSL (void) + { + SSL_METHOD *meth; +- +- asprintf (&randbuff, "%s", "qwertyuiopasdfghjklqwertyuiopasdfghjkl"); ++ char *randbuff; ++ ++ randbuff = "qwertyuiopasdfghjklqwertyuiopasdfghjkl"; + RAND_seed (randbuff, (int)strlen(randbuff)); + if (verbose) + printf(_("SSL seeding: %s\n"), (RAND_status()==1 ? _("OK") : _("Failed")) ); +diff -urN ./plugins/check_mrtg.c ../plugins/plugins/check_mrtg.c +--- ./plugins/check_mrtg.c 2005-01-05 21:53:15.000000000 +0100 ++++ ../plugins/plugins/check_mrtg.c 2005-02-17 15:58:02.000000000 +0100 +@@ -113,7 +113,7 @@ + /* if we couldn't read enough data, return an unknown error */ + if (line <= 2) { + result = STATE_UNKNOWN; +- asprintf (&message, _("Unable to process MRTG log file\n")); ++ message = _("Unable to process MRTG log file\n"); + } + + /* make sure the MRTG data isn't too old */ +@@ -122,8 +122,8 @@ + if (expire_minutes > 0 + && (current_time - timestamp) > (expire_minutes * 60)) { + result = STATE_WARNING; +- asprintf (&message, _("MRTG data has expired (%d minutes old)\n"), +- (int) ((current_time - timestamp) / 60)); ++ message = _("MRTG data has expired (%d minutes old)\n"), ++ (int) ((current_time - timestamp) / 60)); + } + } + +@@ -294,10 +294,10 @@ + usage4 (_("You must supply the variable number")); + + if (label == NULL) +- label = strdup ("value"); ++ label = "value"; + + if (units == NULL) +- units = strdup (""); ++ units = ""; + + return OK; + } +diff -urN ./plugins/check_nt.c ../plugins/plugins/check_nt.c +--- ./plugins/check_nt.c 2005-02-17 13:01:02.000000000 +0100 ++++ ../plugins/plugins/check_nt.c 2005-02-17 16:18:53.000000000 +0100 +@@ -153,7 +153,7 @@ + /* -l parameters is present with only integers */ + return_code=STATE_OK; + temp_string = strdup (_("CPU Load")); +- temp_string_perf = strdup (" "); ++ temp_string_perf = " "; + + /* loop until one of the parameters is wrong or not present */ + while (lvalue_list[0+offset]> (unsigned long)0 && +@@ -327,7 +327,7 @@ + asprintf (&output_message, "%.f", counter_value); + else if (isPercent) + { +- counter_unit = strdup ("%"); ++ counter_unit = "%"; + allRight = TRUE; + } + +diff -urN ./plugins/check_nwstat.c ../plugins/plugins/check_nwstat.c +--- ./plugins/check_nwstat.c 2005-01-05 21:53:17.000000000 +0100 ++++ ../plugins/plugins/check_nwstat.c 2005-02-17 16:24:36.000000000 +0100 +@@ -135,18 +135,18 @@ + + /* get OS version string */ + if (check_netware_version==TRUE) { +- send_buffer = strdup ("S19\r\n"); ++ send_buffer = "S19\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; + if (!strcmp(recv_buffer,"-1\n")) +- netware_version = strdup(""); ++ netware_version = ""; + else { + recv_buffer[strlen(recv_buffer)-1]=0; + asprintf (&netware_version,_("NetWare %s: "),recv_buffer); + } + } else +- netware_version = strdup(""); ++ netware_version = ""; + + + /* check CPU load */ +@@ -154,13 +154,13 @@ + + switch(vars_to_check) { + case LOAD1: +- temp_buffer = strdup ("1"); ++ temp_buffer = "1"; + break; + case LOAD5: +- temp_buffer = strdup ("5"); ++ temp_buffer = "5"; + break; + default: +- temp_buffer = strdup ("15"); ++ temp_buffer = "15"; + break; + } + +@@ -169,7 +169,7 @@ + if (result!=STATE_OK) + return result; + utilization=strtoul(recv_buffer,NULL,10); +- send_buffer = strdup ("UPTIME\r\n"); ++ send_buffer = "UPTIME\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -191,7 +191,7 @@ + /* check number of user connections */ + } else if (vars_to_check==CONNS) { + +- send_buffer = strdup ("CONNECT\r\n"); ++ send_buffer = "CONNECT\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -210,7 +210,7 @@ + /* check % long term cache hits */ + } else if (vars_to_check==LTCH) { + +- send_buffer = strdup ("S1\r\n"); ++ send_buffer = "S1\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -229,7 +229,7 @@ + /* check cache buffers */ + } else if (vars_to_check==CBUFF) { + +- send_buffer = strdup ("S2\r\n"); ++ send_buffer = "S2\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -248,7 +248,7 @@ + /* check dirty cache buffers */ + } else if (vars_to_check==CDBUFF) { + +- send_buffer = strdup ("S3\r\n"); ++ send_buffer = "S3\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -267,7 +267,7 @@ + /* check LRU sitting time in minutes */ + } else if (vars_to_check==LRUM) { + +- send_buffer = strdup ("S5\r\n"); ++ send_buffer = "S5\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -344,7 +344,7 @@ + /* check to see if DS Database is open or closed */ + } else if (vars_to_check==DSDB) { + +- send_buffer = strdup ("S11\r\n"); ++ send_buffer = "S11\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -353,7 +353,7 @@ + else + result=STATE_WARNING; + +- send_buffer = strdup ("S13\r\n"); ++ send_buffer = "S13\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + temp_buffer=strtok(recv_buffer,"\r\n"); + +@@ -362,7 +362,7 @@ + /* check to see if logins are enabled */ + } else if (vars_to_check==LOGINS) { + +- send_buffer = strdup ("S12\r\n"); ++ send_buffer = "S12\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -617,7 +617,7 @@ + /* check LRU sitting time in secondss */ + } else if (vars_to_check==LRUS) { + +- send_buffer = strdup ("S4\r\n"); ++ send_buffer = "S4\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -633,7 +633,7 @@ + /* check % dirty cacheobuffers as a percentage of the total*/ + } else if (vars_to_check==DCB) { + +- send_buffer = strdup ("S6\r\n"); ++ send_buffer = "S6\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -648,7 +648,7 @@ + /* check % total cache buffers as a percentage of the original*/ + } else if (vars_to_check==TCB) { + +- send_buffer = strdup ("S7\r\n"); ++ send_buffer = "S7\r\n"; + result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); + if (result!=STATE_OK) + return result; +@@ -695,7 +695,7 @@ + + } else { + +- output_message = strdup (_("Nothing to check!\n")); ++ output_message = _("Nothing to check!\n"); + result=STATE_UNKNOWN; + + } +@@ -806,15 +806,15 @@ + vars_to_check=LRUS; + else if (strncmp(optarg,"VPF",3)==0) { + vars_to_check=VPF; +- volume_name = strdup (optarg+3); ++ volume_name = optarg+3; + if (!strcmp(volume_name,"")) +- volume_name = strdup ("SYS"); ++ volume_name = "SYS"; + } + else if (strncmp(optarg,"VKF",3)==0) { + vars_to_check=VKF; +- volume_name = strdup (optarg+3); ++ volume_name = optarg+3; + if (!strcmp(volume_name,"")) +- volume_name = strdup ("SYS"); ++ volume_name = "SYS"; + } + else if (!strcmp(optarg,"DSDB")) + vars_to_check=DSDB; +@@ -835,27 +835,27 @@ + vars_to_check=OFILES; + else if (strncmp(optarg,"VKP",3)==0) { + vars_to_check=VKP; +- volume_name = strdup (optarg+3); ++ volume_name = optarg+3; + if (!strcmp(volume_name,"")) +- volume_name = strdup ("SYS"); ++ volume_name = "SYS"; + } + else if (strncmp(optarg,"VPP",3)==0) { + vars_to_check=VPP; +- volume_name = strdup (optarg+3); ++ volume_name = optarg+3; + if (!strcmp(volume_name,"")) +- volume_name = strdup ("SYS"); ++ volume_name = "SYS"; + } + else if (strncmp(optarg,"VKNP",4)==0) { + vars_to_check=VKNP; +- volume_name = strdup (optarg+4); ++ volume_name = optarg+4; + if (!strcmp(volume_name,"")) +- volume_name = strdup ("SYS"); ++ volume_name = "SYS"; + } + else if (strncmp(optarg,"VPNP",4)==0) { + vars_to_check=VPNP; +- volume_name = strdup (optarg+4); ++ volume_name = optarg+4; + if (!strcmp(volume_name,"")) +- volume_name = strdup("SYS"); ++ volume_name = "SYS"; + } + else if (!strcmp(optarg,"ABENDS")) + vars_to_check=ABENDS; +@@ -869,7 +869,7 @@ + vars_to_check=UPTIME; + else if (strncmp(optarg,"NLM:",4)==0) { + vars_to_check=NLM; +- nlm_name=strdup (optarg+4); ++ nlm_name = optarg+4; + } + else + return ERROR; +diff -urN ./plugins/check_ping.c ../plugins/plugins/check_ping.c +--- ./plugins/check_ping.c 2005-01-05 21:53:17.000000000 +0100 ++++ ../plugins/plugins/check_ping.c 2005-02-17 16:29:41.000000000 +0100 +@@ -93,11 +93,11 @@ + + #ifdef PING6_COMMAND + if (is_inet6_addr(addresses[i]) && address_family != AF_INET) +- rawcmd = strdup(PING6_COMMAND); ++ rawcmd = PING6_COMMAND; + else +- rawcmd = strdup(PING_COMMAND); ++ rawcmd = PING_COMMAND; + #else +- rawcmd = strdup(PING_COMMAND); ++ rawcmd = PING_COMMAND; + #endif + + /* does the host address of number of packets argument come first? */ +@@ -452,7 +452,7 @@ + result = max_state (result, STATE_WARNING); + + if (warn_text == NULL) +- warn_text = strdup(""); ++ warn_text = ""; + + return result; + } +@@ -473,7 +473,7 @@ + + if (strstr (buf, "(DUP!)") || strstr (buf, "DUPLICATES FOUND")) { + if (warn_text == NULL) +- warn_text = strdup (_(WARN_DUPLICATES)); ++ warn_text = _(WARN_DUPLICATES); + else if (! strstr (warn_text, _(WARN_DUPLICATES)) && + asprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1) + die (STATE_UNKNOWN, _("Unable to realloc warn_text")); +diff -urN ./plugins/check_procs.c ../plugins/plugins/check_procs.c +--- ./plugins/check_procs.c 2005-01-05 21:53:18.000000000 +0100 ++++ ../plugins/plugins/check_procs.c 2005-02-17 16:35:49.000000000 +0100 +@@ -117,7 +117,7 @@ + input_buffer = malloc (MAX_INPUT_BUFFER); + procprog = malloc (MAX_INPUT_BUFFER); + +- asprintf (&metric_name, "PROCS"); ++ metric_name = "PROCS"; + metric = METRIC_PROCS; + + if (process_arguments (argc, argv) == ERROR) +@@ -147,8 +147,8 @@ + while ( input_buffer[strlen(input_buffer)-1] != '\n' ) + fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); + ++ input_line = ""; + while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { +- asprintf (&input_line, "%s", input_buffer); + while ( input_buffer[strlen(input_buffer)-1] != '\n' ) { + fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); + asprintf (&input_line, "%s%s", input_line, input_buffer); +@@ -157,8 +157,8 @@ + if (verbose >= 3) + printf ("%s", input_line); + +- strcpy (procprog, ""); +- asprintf (&procargs, "%s", ""); ++ *procprog = '\x0'; ++ procargs = ""; + + cols = sscanf (input_line, PS_FORMAT, PS_VARLIST); + +@@ -493,7 +493,7 @@ + if (cmax == -1 && argv[c]) + cmax = atoi (argv[c++]); + if (statopts == NULL && argv[c]) { +- asprintf (&statopts, "%s", argv[c++]); ++ statopts = argv[c++]; + asprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts); + options |= STAT; + } +@@ -531,19 +531,19 @@ + options = ALL; + + if (statopts==NULL) +- statopts = strdup(""); ++ statopts = ""; + + if (prog==NULL) +- prog = strdup(""); ++ prog = ""; + + if (args==NULL) +- args = strdup(""); ++ args = ""; + + if (fmt==NULL) +- fmt = strdup(""); ++ fmt = ""; + + if (fails==NULL) +- fails = strdup(""); ++ fails = ""; + + return options; + } +diff -urN ./plugins/check_radius.c ../plugins/plugins/check_radius.c +--- ./plugins/check_radius.c 2005-01-05 21:53:18.000000000 +0100 ++++ ../plugins/plugins/check_radius.c 2005-02-17 13:12:10.000000000 +0100 +@@ -116,7 +116,7 @@ + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); + +- str = strdup ("dictionary"); ++ str = "dictionary"; + if ((config_file && rc_read_config (config_file)) || + rc_read_dictionary (rc_conf_str (str))) + die (STATE_UNKNOWN, _("Config file error")); +diff -urN ./plugins/check_real.c ../plugins/plugins/check_real.c +--- ./plugins/check_real.c 2005-01-05 21:53:18.000000000 +0100 ++++ ../plugins/plugins/check_real.c 2005-02-17 16:36:39.000000000 +0100 +@@ -369,7 +369,7 @@ + usage4 (_("You must provide a server to check")); + + if (host_name==NULL) +- host_name = strdup (server_address); ++ host_name = server_address; + + if (server_expect == NULL) + server_expect = strdup(EXPECT); +diff -urN ./plugins/check_smtp.c ../plugins/plugins/check_smtp.c +--- ./plugins/check_smtp.c 2005-01-05 21:53:18.000000000 +0100 ++++ ../plugins/plugins/check_smtp.c 2005-02-17 16:38:24.000000000 +0100 +@@ -486,18 +486,18 @@ + usage2 (_("Invalid hostname/address"), argv[c]); + } + else { +- asprintf (&server_address, "127.0.0.1"); ++ server_address = "127.0.0.1"; + } + } + + if (server_expect == NULL) +- server_expect = strdup (SMTP_EXPECT); ++ server_expect = SMTP_EXPECT; + + if (mail_command == NULL) +- mail_command = strdup("MAIL "); ++ mail_command = "MAIL "; + + if (from_arg==NULL) +- from_arg = strdup(" "); ++ from_arg = " "; + + return validate_arguments (); + } +diff -urN ./plugins/check_swap.c ../plugins/plugins/check_swap.c +--- ./plugins/check_swap.c 2005-01-24 08:29:54.000000000 +0100 ++++ ../plugins/plugins/check_swap.c 2005-02-17 16:56:09.000000000 +0100 +@@ -85,9 +85,9 @@ + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + +- status = strdup (""); +- tmp_status = strdup (""); +- perf = strdup (""); ++ status = ""; ++ tmp_status = ""; ++ perf = ""; + + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); +@@ -128,15 +128,15 @@ + free_swap = dskfree; + #else + # ifdef HAVE_SWAP +- asprintf(&swap_command, "%s", SWAP_COMMAND); +- asprintf(&swap_format, "%s", SWAP_FORMAT); ++ swap_command = SWAP_COMMAND; ++ swap_format = SWAP_FORMAT; + + /* These override the command used if a summary (and thus ! allswaps) is required */ + /* The summary flag returns more accurate information about swap usage on these OSes */ + # ifdef _AIX + if (!allswaps) { +- asprintf(&swap_command, "%s", "/usr/sbin/lsps -s"); +- asprintf(&swap_format, "%s", "%f%*s %f"); ++ swap_command = "/usr/sbin/lsps -s"; ++ swap_format = "%f%*s %f"; + conv_factor = 1; + } + # endif +diff -urN ./plugins/check_udp.c ../plugins/plugins/check_udp.c +--- ./plugins/check_udp.c 2005-01-05 21:53:21.000000000 +0100 ++++ ../plugins/plugins/check_udp.c 2005-02-17 13:12:10.000000000 +0100 +@@ -207,7 +207,7 @@ + usage4 (_("Hostname was not supplied")); + + if (server_send == NULL) +- server_send = strdup(""); ++ server_send = ""; + + return c; + } +diff -urN ./plugins/check_ups.c ../plugins/plugins/check_ups.c +--- ./plugins/check_ups.c 2005-01-05 21:53:22.000000000 +0100 ++++ ../plugins/plugins/check_ups.c 2005-02-17 18:21:59.000000000 +0100 +@@ -106,9 +106,9 @@ + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + +- ups_status = strdup ("N/A"); +- data = strdup (""); +- message = strdup (""); ++ ups_status = "N/A"; ++ data = ""; ++ message = ""; + + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); +@@ -124,16 +124,16 @@ + return STATE_CRITICAL; + if (supported_options & UPS_STATUS) { + +- ups_status = strdup (""); ++ ups_status = ""; + result = STATE_OK; + + if (status & UPSSTATUS_OFF) { +- asprintf (&ups_status, "Off"); ++ ups_status = "Off"; + result = STATE_CRITICAL; + } + else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) == + (UPSSTATUS_OB | UPSSTATUS_LB)) { +- asprintf (&ups_status, _("On Battery, Low Battery")); ++ ups_status = _("On Battery, Low Battery"); + result = STATE_CRITICAL; + } + else { +@@ -203,15 +203,13 @@ + else if (check_warn==TRUE && ups_utility_deviation>=warning_value) { + result = max_state (result, STATE_WARNING); + } +- asprintf (&data, "%s", +- perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", +- check_warn, (long)(1000*warning_value), +- check_crit, (long)(1000*critical_value), +- TRUE, 0, FALSE, 0)); ++ data = perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", ++ check_warn, (long)(1000*warning_value), ++ check_crit, (long)(1000*critical_value), ++ TRUE, 0, FALSE, 0)); + } else { +- asprintf (&data, "%s", +- perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", +- FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); ++ data = perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", ++ FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); + } + } + +@@ -560,7 +558,7 @@ + } + + if (server_address == NULL) +- server_address = strdup("127.0.0.1"); ++ server_address = "127.0.0.1"; + + return validate_arguments(); + } +diff -urN ./plugins/check_users.c ../plugins/plugins/check_users.c +--- ./plugins/check_users.c 2005-01-05 21:53:22.000000000 +0100 ++++ ../plugins/plugins/check_users.c 2005-02-17 18:22:57.000000000 +0100 +@@ -48,7 +48,7 @@ + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + +- perf = strdup(""); ++ perf = ""; + + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); +@@ -100,11 +100,8 @@ + if (result == STATE_UNKNOWN) + printf (_("Unable to read output\n")); + else { +- asprintf(&perf, "%s", perfdata ("users", users, "", +- TRUE, wusers, +- TRUE, cusers, +- TRUE, 0, +- FALSE, 0)); ++ perf = perfdata ("users", users, "", TRUE, wusers, TRUE, cusers, ++ TRUE, 0, FALSE, 0)); + printf (_("USERS %s - %d users currently logged in |%s\n"), state_text (result), + users, perf); + } +diff -urN ./plugins/negate.c ../plugins/plugins/negate.c +--- ./plugins/negate.c 2005-01-05 21:53:22.000000000 +0100 ++++ ../plugins/plugins/negate.c 2005-02-17 18:24:35.000000000 +0100 +@@ -192,7 +192,7 @@ + } + } + +- asprintf (&command_line, "%s", argv[optind]); ++ command_line = argv[optind]; + for (c = optind+1; c < argc; c++) { + asprintf (&command_line, "%s %s", command_line, argv[c]); + } +diff -urN ./plugins/popen.c ../plugins/plugins/popen.c +--- ./plugins/popen.c 2005-01-05 21:53:22.000000000 +0100 ++++ ../plugins/plugins/popen.c 2005-02-17 13:12:11.000000000 +0100 +@@ -87,7 +87,7 @@ + setrlimit (RLIMIT_CORE, &limit); + #endif + +- env[0] = strdup("LC_ALL=C"); ++ env[0] = "LC_ALL=C"; + env[1] = '\0'; + + /* if no command was passed, return with no error */ +diff -urN ./plugins/urlize.c ../plugins/plugins/urlize.c +--- ./plugins/urlize.c 2005-01-05 21:53:23.000000000 +0100 ++++ ../plugins/plugins/urlize.c 2005-02-17 18:28:19.000000000 +0100 +@@ -67,7 +67,7 @@ + exit (EXIT_SUCCESS); + break; + case 'u': +- url = strdup (argv[optind]); ++ url = argv[optind]; + break; + case '?': + default: +@@ -76,9 +76,9 @@ + } + + if (url == NULL) +- url = strdup (argv[optind++]); ++ url = argv[optind++]; + +- cmd = strdup (argv[optind++]); ++ cmd = argv[optind++]; + for (c = optind; c < argc; c++) { + asprintf (&cmd, "%s %s", cmd, argv[c]); + } diff --git a/web/attachments/122140-diff b/web/attachments/122140-diff new file mode 100644 index 0000000..736b1c1 --- /dev/null +++ b/web/attachments/122140-diff @@ -0,0 +1,91 @@ +Index: check_tcp.c +=================================================================== +RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v +retrieving revision 1.61 +diff -r1.61 check_tcp.c +99c99 +< int use_ssl = FALSE; +--- +> int use_ssl = FALSE; +170a171,180 +> else if (strstr (argv[0], "check_clamd")) { +> progname = strdup ("check_clamd"); +> SERVICE = strdup ("CLAMD"); +> SEND = strdup ("PING"); +> EXPECT = strdup ("PONG"); +> QUIT = NULL; +> PROTOCOL = TCP_PROTOCOL; +> PORT = 3310; +> } +> +378,379c388,395 +< +< printf +--- +> if(server_address[0]=='/') +> printf +> (_("%s %s%s - %.3f second response on socket %s"), +> SERVICE, +> state_text (result), +> (was_refused) ? " (refused)" : "", +> elapsed_time, server_address); +> else printf +486c502 +< if (is_host (optarg) == FALSE) +--- +> if (optarg[0]!= '/' && is_host (optarg) == FALSE) +761c777 +< printf (_("This plugin tests %s connections with the specified host.\n\n"), +--- +> printf (_("This plugin tests %s connections with the specified host or unix socket.\n\n"), +Index: netutils.c +=================================================================== +RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/netutils.c,v +retrieving revision 1.22 +diff -r1.22 netutils.c +221a222 +> +227a229 +> if (host_name[0] != '/') { +267a270,294 +> } +> else{ // unix socket +> struct sockaddr_un su; +> if (strlen(host_name) >= sizeof(su.sun_path)) { +> printf("Hostname too long for unix domain socket: %s\n", +> host_name); +> return STATE_UNKNOWN; +> } +> memset(&su, 0, sizeof su); +> su.sun_family = AF_UNIX; +> strncpy(su.sun_path, host_name, sizeof su.sun_path); +> *sd = socket(PF_UNIX, SOCK_STREAM, 0); +> if ( sd < 0) { +> printf ("Socket creation failed\n"); +> return STATE_UNKNOWN; +> } +> result=connect(*sd, (struct sockaddr *)&su, sizeof su); +> if (result == -1) { +> printf ("Connect to socket failed\n"); +> close(*sd); +> return STATE_UNKNOWN; +> } +> +> } +> +Index: netutils.h +=================================================================== +RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/netutils.h,v +retrieving revision 1.10 +diff -r1.10 netutils.h +37a38 +> #include +Index: utils.h +=================================================================== +RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.h,v +retrieving revision 1.22 +diff -r1.22 utils.h +139c139 +< Host name or IP Address\n\ +--- +> Host name or IP Address or unix socket (starting with \"/\")\n\ diff --git a/web/attachments/122868-check_ntp.patch b/web/attachments/122868-check_ntp.patch new file mode 100644 index 0000000..b463ed6 --- /dev/null +++ b/web/attachments/122868-check_ntp.patch @@ -0,0 +1,15 @@ +*** nagios-plugins-HEAD-200502231747/plugins-scripts/check_ntp.pl Fri Nov 19 14:59:43 2004 +--- nagios-plugins-NEW/plugins-scripts/check_ntp.pl Thu Feb 24 16:13:59 2005 +*************** +*** 200,209 **** + if (/(offset|adjust)\s+([-.\d]+)/i) { + $offset = $2; + +- # An offset of 0.000000 with an error is probably bogus. Actually, +- # it's probably always bogus, but let's be paranoid here. +- if ($offset == 0) { undef $offset;} +- + $ntpdate_error = defined ($offset) ? $ERRORS{"OK"} : $ERRORS{"CRITICAL"}; + print "ntperr = $ntpdate_error \n" if $verbose; + +--- 200,205 ---- diff --git a/web/attachments/123083-check_mysql.diff.gz b/web/attachments/123083-check_mysql.diff.gz new file mode 100644 index 0000000..95f9d1c Binary files /dev/null and b/web/attachments/123083-check_mysql.diff.gz differ diff --git a/web/attachments/123084-patch-check_mysql.c b/web/attachments/123084-patch-check_mysql.c new file mode 100644 index 0000000..998ad47 --- /dev/null +++ b/web/attachments/123084-patch-check_mysql.c @@ -0,0 +1,20 @@ +--- plugins/check_mysql.c.orig Sun Dec 26 00:17:44 2004 ++++ plugins/check_mysql.c Sun Feb 20 14:12:10 2005 +@@ -123,8 +123,16 @@ + die (STATE_CRITICAL, "%s\n", slaveresult); + } + ++ } else if (mysql_field_count (&mysql) == 33) { ++ /* mysql >= 4.1.1 */ ++ snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[10], row[11]); ++ if (strcmp (row[10], "Yes") != 0 || strcmp (row[11], "Yes") != 0) { ++ mysql_free_result (res); ++ mysql_close (&mysql); ++ die (STATE_CRITICAL, "%s\n", slaveresult); ++ } + } else { +- /* mysql 4.x.x */ ++ /* mysql 4.0.x or 4.1.0 */ + snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s", row[9], row[10]); + if (strcmp (row[9], "Yes") != 0 || strcmp (row[10], "Yes") != 0) { + mysql_free_result (res); diff --git a/web/attachments/123407-long_long_swap.patch b/web/attachments/123407-long_long_swap.patch new file mode 100644 index 0000000..fcd5802 --- /dev/null +++ b/web/attachments/123407-long_long_swap.patch @@ -0,0 +1,173 @@ +Index: check_swap.c +=================================================================== +RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v +retrieving revision 1.9 +diff -u -r1.9 check_swap.c +--- check_swap.c 18 Feb 2003 03:46:15 -0000 1.9 ++++ check_swap.c 27 Feb 2005 23:58:43 -0000 +@@ -36,6 +36,18 @@ + #define EMAIL "kdebisschop@users.sourceforge.net" + #define SUMMARY "Check swap space on local server.\n" + ++#ifdef HAVE_LONGLONG ++typedef long long unsigned int swapsize_t; ++#define SWAPSIZEFORMAT "%llu" ++#define SWAPSIZEFORMAT_OUT SWAPSIZEFORMAT ++#define atos atoll ++#else ++typedef float swapsize_t; ++#define SWAPSIZEFORMAT "%f" ++#define SWAPSIZEFORMAT_OUT "%.0f" ++#define atos (float)atof ++#endif ++ + int process_arguments (int argc, char **argv); + int validate_arguments (void); + void print_usage (void); +@@ -43,8 +55,8 @@ + + int warn_percent = 200; + int crit_percent = 200; +-long unsigned int warn_size = 0; +-long unsigned int crit_size = 0; ++swapsize_t warn_size = 0; ++swapsize_t crit_size = 0; + int verbose; + int allswaps; + +@@ -52,8 +64,8 @@ + main (int argc, char **argv) + { + int percent_used, percent; +- long unsigned int total_swap = 0, used_swap = 0, free_swap = 0; +- long unsigned int total, used, free; ++ swapsize_t total_swap = 0, used_swap = 0, free_swap = 0; ++ swapsize_t total, used, free; + int result = STATE_OK; + char input_buffer[MAX_INPUT_BUFFER]; + #ifdef HAVE_SWAP +@@ -61,6 +73,7 @@ + #endif + #ifdef HAVE_PROC_MEMINFO + FILE *fp; ++ char str_format[32]; + #endif + char str[32]; + char *status = ""; +@@ -70,9 +83,10 @@ + + #ifdef HAVE_PROC_MEMINFO + fp = fopen (PROC_MEMINFO, "r"); ++ sprintf (str_format, " %%s %s %s %s", SWAPSIZEFORMAT, SWAPSIZEFORMAT, SWAPSIZEFORMAT); + asprintf (&status, "%s", "Swap used:"); + while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { +- if (sscanf (input_buffer, " %s %lu %lu %lu", str, &total, &used, &free) == 4 && ++ if (sscanf (input_buffer, str_format, str, &total, &used, &free) == 4 && + strstr (str, "Swap")) { + total_swap += total; + used_swap += used; +@@ -83,8 +97,10 @@ + result = max_state (STATE_CRITICAL, result); + else if (percent >= warn_percent || free <= warn_size) + result = max_state (STATE_WARNING, result); +- if (verbose) +- asprintf (&status, "%s [%lu/%lu]", status, used, total); ++ if (verbose) { ++ sprintf (str_format, "%%s [%s/%s]", SWAPSIZEFORMAT_OUT, SWAPSIZEFORMAT_OUT); ++ asprintf (&status, str_format, status, used, total); ++ } + } + } + } +@@ -93,7 +109,8 @@ + result = max_state (STATE_CRITICAL, result); + else if (percent_used >= warn_percent || free_swap <= warn_size) + result = max_state (STATE_WARNING, result); +- asprintf (&status, "%s %2d%% (%lu out of %lu)", status, percent_used, ++ sprintf (str_format, "%%s %%2d%%%% (%s out of %s)", SWAPSIZEFORMAT_OUT, SWAPSIZEFORMAT_OUT); ++ asprintf (&status, str_format, status, percent_used, + used_swap, total_swap); + fclose (fp); + #else +@@ -137,8 +154,9 @@ + result = max_state (STATE_CRITICAL, result); + else if (percent >= warn_percent || free <= warn_size) + result = max_state (STATE_WARNING, result); +- if (verbose) +- asprintf (&status, "%s [%lu/%lu]", status, used, total); ++ if (verbose) { ++ sprintf (str_format, "%%s [%s/%s]", SWAPSIZEFORMAT_OUT, SWAPSIZEFORMAT_OUT); ++ asprintf (&status, str_format, status, used, total); + } + } + percent_used = 100 * ((double) used_swap) / ((double) total_swap); +@@ -146,8 +164,9 @@ + result = max_state (STATE_CRITICAL, result); + else if (percent_used >= warn_percent || free_swap <= warn_size) + result = max_state (STATE_WARNING, result); +- asprintf (&status, "%s %2d%% (%lu out of %lu)", +- status, percent_used, used_swap, total_swap); ++ sprintf (str_format, "%%s %%2d%%%% (%s out of %s)", SWAPSIZEFORMAT_OUT, SWAPSIZEFORMAT_OUT) ++ asprintf (&status, str_format, ++ status, percent_used, used_swap, total_swap); + + /* If we get anything on STDERR, at least set warning */ + while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) +@@ -198,6 +217,8 @@ + int wc = 0; /* warning counter */ + int cc = 0; /* critical counter */ + ++ char str_format[32]; ++ + #ifdef HAVE_GETOPT_H + int option_index = 0; + static struct option long_options[] = { +@@ -224,15 +245,16 @@ + if (c == -1 || c == EOF) + break; + ++ sprintf (str_format, "%s,%%d%%%%", SWAPSIZEFORMAT); + switch (c) { + case 'w': /* warning time threshold */ + if (is_intnonneg (optarg)) { +- warn_size = atoi (optarg); ++ warn_size = atos (optarg); + break; + } + else if (strstr (optarg, ",") && + strstr (optarg, "%") && +- sscanf (optarg, "%lu,%d%%", &warn_size, &warn_percent) == 2) { ++ sscanf (optarg, str_format, &warn_size, &warn_percent) == 2) { + break; + } + else if (strstr (optarg, "%") && +@@ -245,12 +267,12 @@ + wc++; + case 'c': /* critical time threshold */ + if (is_intnonneg (optarg)) { +- crit_size = atoi (optarg); ++ crit_size = atos (optarg); + break; + } + else if (strstr (optarg, ",") && + strstr (optarg, "%") && +- sscanf (optarg, "%lu,%d%%", &crit_size, &crit_percent) == 2) { ++ sscanf (optarg, str_format, &crit_size, &crit_percent) == 2) { + break; + } + else if (strstr (optarg, "%") && +@@ -292,12 +314,12 @@ + if (c == argc) + return validate_arguments (); + if (warn_size < 0 && is_intnonneg (argv[c])) +- warn_size = atoi (argv[c++]); ++ warn_size = atos (argv[c++]); + + if (c == argc) + return validate_arguments (); + if (crit_size < 0 && is_intnonneg (argv[c])) +- crit_size = atoi (argv[c++]); ++ crit_size = atos (argv[c++]); + + return validate_arguments (); + } diff --git a/web/attachments/123952-check_snmp.c.diff b/web/attachments/123952-check_snmp.c.diff new file mode 100644 index 0000000..9d726bd --- /dev/null +++ b/web/attachments/123952-check_snmp.c.diff @@ -0,0 +1,23 @@ +diff -ruN nagios-plugins-1.4.orig/plugins/check_snmp.c nagios-plugins-1.4/plugins/check_snmp.c +--- nagios-plugins-1.4.orig/plugins/check_snmp.c 2005-01-21 04:03:56.000000000 +0300 ++++ nagios-plugins-1.4/plugins/check_snmp.c 2005-03-03 14:18:55.000000000 +0300 +@@ -646,6 +646,10 @@ + asprintf(&proto, DEFAULT_PROTOCOL); + asprintf(&authpriv, "%s%s", "-c ", community); + } ++ else if ( strcmp (proto, "2c") == 0 ) { /* snmpv2c args */ ++ asprintf(&proto, "%s", "2c"); ++ asprintf(&authpriv, "%s%s", "-c ", community); ++ } + else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */ + asprintf(&proto, "%s", "3"); + +@@ -859,7 +863,7 @@ + + /* SNMP and Authentication Protocol */ + printf (_("\ +- -P, --protocol=[1|3]\n\ ++ -P, --protocol=[1|2c|3]\n\ + SNMP protocol version\n\ + -L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]\n\ + SNMPv3 securityLevel\n\ diff --git a/web/attachments/125109-tcp_bin.patch b/web/attachments/125109-tcp_bin.patch new file mode 100644 index 0000000..1ac15e4 --- /dev/null +++ b/web/attachments/125109-tcp_bin.patch @@ -0,0 +1,214 @@ +diff -rNu nagios_orig/plugins/check_tcp.c nagios-plugins-1.4/plugins/check_tcp.c +--- nagios_orig/plugins/check_tcp.c 2004-12-30 01:41:40.000000000 +0100 ++++ nagios-plugins-1.4/plugins/check_tcp.c 2005-03-09 15:46:03.000000000 +0100 +@@ -80,6 +80,8 @@ + char *server_address = NULL; + char *server_send = NULL; + char *server_quit = NULL; ++char *input_file_name = NULL; ++char *output_file_name = NULL; + char **server_expect = NULL; + size_t server_expect_count = 0; + int maxbytes = 0; +@@ -132,6 +134,15 @@ + PROTOCOL = TCP_PROTOCOL; + PORT = 0; + } ++ else if (strstr (argv[0], "check_tcp_bin")) { ++ progname = strdup ("check_tcp_bin"); ++ SERVICE = strdup ("TCP"); ++ SEND = NULL; ++ EXPECT = NULL; ++ QUIT = NULL; ++ PROTOCOL = TCP_PROTOCOL; ++ PORT = 0; ++ } + else if (strstr (argv[0], "check_ftp")) { + progname = strdup ("check_ftp"); + SERVICE = strdup ("FTP"); +@@ -299,6 +310,42 @@ + send (sd, server_send, strlen(server_send), 0); + } + ++ /* send content of input file ? */ ++ if (input_file_name != NULL) { ++ struct stat istat; ++ if (stat(input_file_name, &istat) != 0) { ++ printf("UNKNOWN - File not found %s\n", input_file_name); ++ return STATE_UNKNOWN; ++ } ++ size_t in_len = istat.st_size; ++ ++ FILE * in = fopen(input_file_name, "rb"); ++ if (in == NULL) { ++ printf("UNKNOWN - Can not open file: %s\n", input_file_name); ++ return STATE_UNKNOWN; ++ } ++ char * indata = malloc(in_len); ++ if (indata == NULL) { ++ printf(_("UNKNOWN - Not enough memory\n")); ++ return STATE_UNKNOWN; ++ } ++ size_t bytes = fread(indata, 1, in_len, in); ++ if (bytes != in_len) { ++ printf("UNKNOWN - Error reading file: \n", input_file_name); ++ free(indata); ++ fclose(in); ++ return STATE_UNKNOWN; ++ } ++ fclose(in); ++#ifdef HAVE_SSL ++ if (use_ssl) ++ SSL_write(ssl, indata, in_len); ++ else ++#endif ++ send (sd, indata, in_len, 0); ++ free(indata); ++ } ++ + if (delay > 0) { + tv.tv_sec += delay; + sleep (delay); +@@ -345,6 +392,57 @@ + } + } + ++ /* Verify server response */ ++ if (output_file_name != NULL) { ++ struct stat ostat; ++ if (stat(output_file_name, &ostat) != 0) { ++ printf("UNKNOWN - File not found %s\n", output_file_name); ++ return STATE_UNKNOWN; ++ } ++ size_t out_len = ostat.st_size; ++ ++ FILE * out = fopen(output_file_name, "rb"); ++ if (out == NULL) { ++ printf("UNKNOWN - Can not open file: %s\n", output_file_name); ++ return STATE_UNKNOWN; ++ } ++ char * outdata = malloc(out_len); ++ if (outdata == NULL) { ++ printf(_("UNKNOWN - Not enough memory\n")); ++ return STATE_UNKNOWN; ++ } ++ size_t bytes = fread(outdata, 1, out_len, out); ++ if (bytes != out_len) { ++ printf("UNKNOWN - Error reading file: \n", output_file_name); ++ free(outdata); ++ fclose(out); ++ return STATE_UNKNOWN; ++ } ++ fclose(out); ++ ++ char * rcvbuf = malloc(out_len); ++ if (rcvbuf != NULL) { ++ char *p = rcvbuf; ++ size_t count = 0; ++ ++ do { ++ count += my_bin_recv(p, out_len-count); ++ p += count; ++ } while (count < out_len); ++ ++ if (memcmp(outdata, rcvbuf, out_len) == 0) { ++ result = STATE_OK; ++ } else { ++ printf(_("WARNING response does not match\n")); ++ result = expect_mismatch_state; ++ } ++ free(rcvbuf); ++ } else { ++ result = STATE_UNKNOWN; ++ } ++ ++ } ++ + if (server_quit != NULL) { + #ifdef HAVE_SSL + if (use_ssl) { +@@ -417,6 +515,8 @@ + {"expect", required_argument, 0, 'e'}, + {"maxbytes", required_argument, 0, 'm'}, + {"quit", required_argument, 0, 'q'}, ++ {"inputfile", required_argument, 0, 'i'}, ++ {"outputfile", required_argument, 0, 'o'}, + {"jail", required_argument, 0, 'j'}, + {"delay", required_argument, 0, 'd'}, + {"refuse", required_argument, 0, 'r'}, +@@ -454,8 +554,8 @@ + } + + while (1) { +- c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:", +- longopts, &option); ++ c = getopt_long (argc, argv, ++ "+hVv46H:s:e:q:m:c:i:o:w:t:p:C:W:d:Sr:jD:M:", longopts, &option); + + if (c == -1 || c == EOF || c == 1) + break; +@@ -527,6 +627,12 @@ + case 's': + server_send = optarg; + break; ++ case 'i': ++ input_file_name = optarg; ++ break; ++ case 'o': ++ output_file_name = optarg; ++ break; + case 'e': /* expect string (may be repeated) */ + EXPECT = NULL; + exact_matching = FALSE; +@@ -748,7 +854,18 @@ + return i; + } + +- ++int my_bin_recv(char * buf, size_t len) { ++ int i; ++#ifdef HAVE_SSL ++ if (use_ssl) { ++ i = SSL_read (ssl, buf, len); ++ } else { ++#endif ++ i = read (sd, buf, len); ++#ifdef HAVE_SSL ++ } ++#endif ++} + + void + print_help (void) +@@ -786,6 +903,10 @@ + Hide output from TCP socket\n\ + -m, --maxbytes=INTEGER\n\ + Close connection once more than this number of bytes are received\n\ ++ -i, --inputfile=file_name\n\ ++ Input file to send to server\n\ ++ -o, --outputfile=file_name\n\ ++ Output file to binary compare with server response\n\ + -d, --delay=INTEGER\n\ + Seconds to wait between sending string and polling for response\n")); + +@@ -816,5 +937,6 @@ + [-s ] [-e ] [-q ]\n\ + [-m ] [-d ] [-t ]\n\ + [-r ] [-M ] [-v] [-4|-6] [-j]\n\ ++ [-i ] [-o ]\n\ + [-D ] [-S ]\n", progname); + } +diff -rNu nagios_orig/plugins/Makefile.am nagios-plugins-1.4/plugins/Makefile.am +--- nagios_orig/plugins/Makefile.am 2005-02-01 13:30:38.000000000 +0100 ++++ nagios-plugins-1.4/plugins/Makefile.am 2005-03-09 17:25:07.000000000 +0100 +@@ -16,8 +16,8 @@ + check_udp check_ups check_users negate urlize check_icmp\ + @EXTRAS@ + +-check_tcp_programs = check_ftp check_imap check_nntp check_pop check_udp2 \ +- @check_tcp_ssl@ ++check_tcp_programs = check_ftp check_imap check_nntp check_pop check_tcp_bin \ ++ check_udp2 @check_tcp_ssl@ + + EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \ + check_swap check_fping check_ldap check_game check_dig \ diff --git a/web/attachments/126077-check_oracle.diff b/web/attachments/126077-check_oracle.diff new file mode 100644 index 0000000..2266ce3 --- /dev/null +++ b/web/attachments/126077-check_oracle.diff @@ -0,0 +1,50 @@ +--- check_oracle.new 2005-03-17 15:12:05.000000000 +0100 ++++ /home/stefan/packages/nagios-plugins-1.4/plugins-scripts/check_oracle.sh 2004-12-01 21:09:59.000000000 +0100 +@@ -241,36 +241,17 @@ + echo "UNKNOWN - Warning level is more then Crit" + exit $STATE_UNKNOWN + fi +- +- +- if [ ${5} = 'TEMP' ] ; then +- result=`sqlplus -s ${3}/${4}@${2} << EOF +- set pagesize 0 +- set numf '9999999.99' +- +- select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc +- from ( +- select tablespace_name,sum(bytes)/1024/1024 total +- from dba_temp_files group by tablespace_name) A, +- ( select tablespace_name,sum(bytes_free)/1024/1024 free +- from v\\$temp_space_header group by tablespace_name) B +- where a.tablespace_name=b.tablespace_name and a.tablespace_name='${5}'; +- EOF` +- else +- result=`sqlplus -s ${3}/${4}@${2} << EOF +- set pagesize 0 +- set numf '9999999.99' +- +- select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc +- from ( +- select tablespace_name,sum(bytes)/1024/1024 total +- from dba_data_files group by tablespace_name) A, +- ( select tablespace_name,sum(bytes)/1024/1024 free +- from dba_Free_space group by tablespace_name) B +- where a.tablespace_name=b.tablespace_name and a.tablespace_name='${5}'; +- EOF` +- fi +- ++ result=`sqlplus -s ${3}/${4}@${2} << EOF ++set pagesize 0 ++set numf '9999999.99' ++select b.free,a.total,100 - trunc(b.free/a.total * 1000) / 10 prc ++from ( ++select tablespace_name,sum(bytes)/1024/1024 total ++from dba_data_files group by tablespace_name) A, ++( select tablespace_name,sum(bytes)/1024/1024 free ++from dba_free_space group by tablespace_name) B ++where a.tablespace_name=b.tablespace_name and a.tablespace_name='${5}'; ++EOF` + + if [ -n "`echo $result | grep ORA-`" ] ; then + error=` echo "$result" | grep "ORA-" | head -1` diff --git a/web/attachments/127602-check_ntp.diff b/web/attachments/127602-check_ntp.diff new file mode 100644 index 0000000..9c585d0 --- /dev/null +++ b/web/attachments/127602-check_ntp.diff @@ -0,0 +1,138 @@ +Index: plugins-scripts/check_ntp.pl +=================================================================== +--- plugins-scripts/check_ntp.pl (revision 18) ++++ plugins-scripts/check_ntp.pl (working copy) +@@ -270,11 +270,11 @@ + if (/^(\*|\+|\#|o])/) { + ++$candidate; + push (@candidates, $_); +- print "Candiate count= $candidate\n" if ($verbose); ++ print "Candidate count= $candidate\n" if ($verbose); + } + + # match sys.peer or pps.peer +- if (/^(\*|o)([-0-9.\s]+)\s+([-0-9A-Za-z.]+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) { ++ if (/^(\*|o)([-0-9.]+)\s+(\S+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) { + $syspeer = $2; + $stratum = $4; + $jitter = $11; +@@ -283,11 +283,14 @@ + print "Jitter_crit = $11 :$jcrit\n" if ($verbose); + $jitter_error = $ERRORS{'CRITICAL'}; + } elsif ($jitter > $jwarn ) { +- print "Jitter_warn = $11 :$jwarn \n" if ($verbose); ++ print "Jitter_warn = $11 :$jwarn\n" if ($verbose); + $jitter_error = $ERRORS{'WARNING'}; + } else { + $jitter_error = $ERRORS{'OK'}; + } ++ } else { ++ print "No match!\n" if $verbose; ++ $jitter = '(not parsed)'; + } + + } +@@ -324,53 +327,53 @@ + if ($ntpdate_error != $ERRORS{'OK'}) { + $state = $ntpdate_error; + if ($ntpdate_error == $ERRORS{'WARNING'} ) { +- $answer = $msg . "\n"; ++ $answer = $msg; + } + else { +- $answer = $msg . "Server for ntp probably down\n"; ++ $answer = $msg . "Server for ntp probably down"; + } + + if (defined($offset) && abs($offset) > $ocrit) { + $state = $ERRORS{'CRITICAL'}; +- $answer = "Server Error and offset $offset sec > +/- $ocrit sec\n"; ++ $answer = "Server Error and offset $offset sec > +/- $ocrit sec"; + } elsif (defined($offset) && abs($offset) > $owarn) { +- $answer = "Server error and offset $offset sec > +/- $owarn sec\n"; ++ $answer = "Server error and offset $offset sec > +/- $owarn sec"; + } elsif (defined($jitter) && abs($jitter) > $jcrit) { +- $answer = "Server error and jitter $jitter msec > +/- $jcrit msec\n"; ++ $answer = "Server error and jitter $jitter msec > +/- $jcrit msec"; + } elsif (defined($jitter) && abs($jitter) > $jwarn) { +- $answer = "Server error and jitter $jitter msec > +/- $jwarn msec\n"; ++ $answer = "Server error and jitter $jitter msec > +/- $jwarn msec"; + } + + } elsif ($have_ntpq && $jitter_error != $ERRORS{'OK'}) { + $state = $jitter_error; +- $answer = "Jitter $jitter too high\n"; ++ $answer = "Jitter $jitter too high"; + if (defined($offset) && abs($offset) > $ocrit) { + $state = $ERRORS{'CRITICAL'}; +- $answer = "Jitter error and offset $offset sec > +/- $ocrit sec\n"; ++ $answer = "Jitter error and offset $offset sec > +/- $ocrit sec"; + } elsif (defined($offset) && abs($offset) > $owarn) { +- $answer = "Jitter error and offset $offset sec > +/- $owarn sec\n"; ++ $answer = "Jitter error and offset $offset sec > +/- $owarn sec"; + } elsif (defined($jitter) && abs($jitter) > $jcrit) { +- $answer = "Jitter error and jitter $jitter msec > +/- $jcrit msec\n"; ++ $answer = "Jitter error and jitter $jitter msec > +/- $jcrit msec"; + } elsif (defined($jitter) && abs($jitter) > $jwarn) { +- $answer = "Jitter error and jitter $jitter msec > +/- $jwarn msec\n"; ++ $answer = "Jitter error and jitter $jitter msec > +/- $jwarn msec"; + } + + } elsif( !$have_ntpq ) { # no errors from ntpdate and no ntpq or ntpq timed out + if (abs($offset) > $ocrit) { + $state = $ERRORS{'CRITICAL'}; +- $answer = "Offset $offset sec > +/- $ocrit sec\n"; ++ $answer = "Offset $offset sec > +/- $ocrit sec"; + } elsif (abs($offset) > $owarn) { + $state = $ERRORS{'WARNING'}; +- $answer = "Offset $offset sec > +/- $owarn sec\n"; ++ $answer = "Offset $offset sec > +/- $owarn sec"; + } elsif (( abs($offset) > $owarn) && $def_jitter ) { + $state = $ERRORS{'WARNING'}; +- $answer = "Offset $offset sec > +/- $owarn sec, ntpq timed out\n"; ++ $answer = "Offset $offset sec > +/- $owarn sec, ntpq timed out"; + } elsif ( $def_jitter ) { + $state = $ERRORS{'WARNING'}; +- $answer = "Offset $offset secs, ntpq timed out\n"; ++ $answer = "Offset $offset secs, ntpq timed out"; + } else{ + $state = $ERRORS{'OK'}; +- $answer = "Offset $offset secs \n"; ++ $answer = "Offset $offset secs "; + } + + +@@ -378,27 +381,27 @@ + } else { # no errors from ntpdate or ntpq + if (abs($offset) > $ocrit) { + $state = $ERRORS{'CRITICAL'}; +- $answer = "Offset $offset sec > +/- $ocrit sec, jitter $jitter msec\n"; ++ $answer = "Offset $offset sec > +/- $ocrit sec, jitter $jitter msec"; + } elsif (abs($jitter) > $jcrit ) { + $state = $ERRORS{'CRITICAL'}; +- $answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset sec \n"; ++ $answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset sec"; + } elsif (abs($offset) > $owarn) { + $state = $ERRORS{'WARNING'}; +- $answer = "Offset $offset sec > +/- $owarn sec, jitter $jitter msec\n"; ++ $answer = "Offset $offset sec > +/- $owarn sec, jitter $jitter msec"; + } elsif (abs($jitter) > $jwarn ) { + $state = $ERRORS{'WARNING'}; +- $answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset sec \n"; ++ $answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset sec"; + + } else { + $state = $ERRORS{'OK'}; +- $answer = "Offset $offset secs, jitter $jitter msec, peer is stratum $stratum\n"; ++ $answer = "Offset $offset secs, jitter $jitter msec, peer is stratum $stratum"; + } + + } + + foreach my $key (keys %ERRORS) { + if ($state==$ERRORS{$key}) { +- print ("NTP $key: $answer"); ++ print ("NTP $key: $answer|offset=$offset, jitter=" . $jitter/1000 . "\n"); + last; + } + } diff --git a/web/attachments/127924-check_smtp.c b/web/attachments/127924-check_smtp.c new file mode 100644 index 0000000..f86a119 --- /dev/null +++ b/web/attachments/127924-check_smtp.c @@ -0,0 +1,739 @@ +/****************************************************************************** + + 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 2 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. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: check_smtp.c,v 1.43 2005/01/01 16:15:39 tonvoon Exp $ + +******************************************************************************/ + +const char *progname = "check_smtp"; +const char *revision = "$Revision: 1.43 $"; +const char *copyright = "2000-2004"; +const char *email = "nagiosplug-devel@lists.sourceforge.net"; + +#include "common.h" +#include "netutils.h" +#include "utils.h" + +#ifdef HAVE_SSL_H +# include +# include +# include +# include +# include +# include +#else +# ifdef HAVE_OPENSSL_SSL_H +# include +# include +# include +# include +# include +# include +# endif +#endif + +#ifdef HAVE_SSL + +int check_cert = FALSE; +int days_till_exp; +SSL_CTX *ctx; +SSL *ssl; +X509 *server_cert; +int connect_STARTTLS (void); +int check_certificate (X509 **); +#endif + +enum { + SMTP_PORT = 25 +}; +const char *SMTP_EXPECT = "220"; +const char *SMTP_HELO = "HELO "; +const char *SMTP_QUIT = "QUIT\r\n"; +const char *SMTP_STARTTLS = "STARTTLS\r\n"; + +int process_arguments (int, char **); +int validate_arguments (void); +void print_help (void); +void print_usage (void); +int myrecv(void); +int my_close(void); + +#ifdef HAVE_REGEX_H +#include +char regex_expect[MAX_INPUT_BUFFER] = ""; +regex_t preg; +regmatch_t pmatch[10]; +char timestamp[10] = ""; +char errbuf[MAX_INPUT_BUFFER]; +int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; +int eflags = 0; +int errcode, excode; +#endif + +int server_port = SMTP_PORT; +char *server_address = NULL; +char *server_expect = NULL; +int smtp_use_dummycmd = 0; +char *mail_command = NULL; +char *from_arg = NULL; +int ncommands=0; +int command_size=0; +int nresponses=0; +int response_size=0; +char **commands = NULL; +char **responses = NULL; +int warning_time = 0; +int check_warning_time = FALSE; +int critical_time = 0; +int check_critical_time = FALSE; +int verbose = 0; +int use_ssl = FALSE; +int sd; +char buffer[MAX_INPUT_BUFFER]; +enum { + TCP_PROTOCOL = 1, + UDP_PROTOCOL = 2, + MAXBUF = 1024 +}; + +int +main (int argc, char **argv) +{ + + int n = 0; + double elapsed_time; + long microsec; + int result = STATE_UNKNOWN; + char *cmd_str = NULL; + char *helocmd = NULL; + struct timeval tv; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); + + /* initialize the HELO command with the localhostname */ +#ifndef HOST_MAX_BYTES +#define HOST_MAX_BYTES 255 +#endif + helocmd = malloc (HOST_MAX_BYTES); + gethostname(helocmd, HOST_MAX_BYTES); + asprintf (&helocmd, "%s%s%s", SMTP_HELO, helocmd, "\r\n"); + + /* initialize the MAIL command with optional FROM command */ + asprintf (&cmd_str, "%sFROM: %s%s", mail_command, from_arg, "\r\n"); + + if (verbose && smtp_use_dummycmd) + printf ("FROM CMD: %s", cmd_str); + + /* initialize alarm signal handling */ + (void) signal (SIGALRM, socket_timeout_alarm_handler); + + /* set socket timeout */ + (void) alarm (socket_timeout); + + /* start timer */ + gettimeofday (&tv, NULL); + + /* try to connect to the host at the given port number */ + result = my_tcp_connect (server_address, server_port, &sd); + + if (result == STATE_OK) { /* we connected */ + + /* watch for the SMTP connection string and */ + /* return a WARNING status if we couldn't read any data */ + if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) { + printf (_("recv() failed\n")); + result = STATE_WARNING; + } + else { + if (verbose) + printf ("%s", buffer); + /* strip the buffer of carriage returns */ + strip (buffer); + /* make sure we find the response we are looking for */ + if (!strstr (buffer, server_expect)) { + if (server_port == SMTP_PORT) + printf (_("Invalid SMTP response received from host\n")); + else + printf (_("Invalid SMTP response received from host on port %d\n"), + server_port); + result = STATE_WARNING; + } + } +#ifdef HAVE_SSL + if(use_ssl) { + + send(sd, helocmd, strlen(helocmd), 0); + recv(sd,buffer, MAX_INPUT_BUFFER-1, 0); // wait for it + /* send the STARTTLS command */ + send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0); + + recv(sd,buffer, MAX_INPUT_BUFFER-1, 0); // wait for it + if (!strstr (buffer, server_expect)) { + printf (_("Server does not support STARTTLS : %s \n"),buffer); + return STATE_UNKNOWN; + } + if(connect_STARTTLS() != OK) { + printf (_("CRITICAL - Cannot create SSL context.: %s \n"),buffer); + return STATE_CRITICAL; + } + if ( check_cert ) { + if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) { + result = check_certificate (&server_cert); + X509_free(server_cert); + } + else { + printf (_("CRITICAL - Cannot retrieve server certificate.: %s \n"),buffer); + result = STATE_CRITICAL; + + } + my_close(); + return result; + } + } +#endif + /* send the HELO command */ +#ifdef HAVE_SSL + if (use_ssl) + SSL_write(ssl, helocmd, strlen(helocmd)); + else +#endif + send(sd, helocmd, strlen(helocmd), 0); + + /* allow for response to helo command to reach us */ + myrecv(); + + /* sendmail will syslog a "NOQUEUE" error if session does not attempt + * to do something useful. This can be prevented by giving a command + * even if syntax is illegal (MAIL requires a FROM:<...> argument) + * + * According to rfc821 you can include a null reversepath in the from command + * - but a log message is generated on the smtp server. + * + * You can disable sending mail_command with '--nocommand' + * Use the -f option to provide a FROM address + */ + if (smtp_use_dummycmd) { +#ifdef HAVE_SSL + if (use_ssl) + SSL_write(ssl, cmd_str, strlen(cmd_str)); + else +#endif + send(sd, cmd_str, strlen(cmd_str), 0); + myrecv(); + if (verbose) + printf("%s", buffer); + } + + while (n < ncommands) { + asprintf (&cmd_str, "%s%s", commands[n], "\r\n"); +#ifdef HAVE_SSL + if (use_ssl) + SSL_write(ssl,cmd_str, strlen(cmd_str)); + else +#endif + send(sd, cmd_str, strlen(cmd_str), 0); + myrecv(); + if (verbose) + printf("%s", buffer); + strip (buffer); + if (n < nresponses) { +#ifdef HAVE_REGEX_H + cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; + //strncpy (regex_expect, responses[n], sizeof (regex_expect) - 1); + //regex_expect[sizeof (regex_expect) - 1] = '\0'; + errcode = regcomp (&preg, responses[n], cflags); + if (errcode != 0) { + regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); + printf (_("Could Not Compile Regular Expression")); + return ERROR; + } + excode = regexec (&preg, buffer, 10, pmatch, eflags); + if (excode == 0) { + result = STATE_OK; + } + else if (excode == REG_NOMATCH) { + result = STATE_WARNING; + printf (_("SMTP %s - Invalid response '%s' to command '%s'\n"), state_text (result), buffer, commands[n]); + } + else { + regerror (excode, &preg, errbuf, MAX_INPUT_BUFFER); + printf (_("Execute Error: %s\n"), errbuf); + result = STATE_UNKNOWN; + } +#else + if (strstr(buffer, responses[n])!=buffer) { + result = STATE_WARNING; + printf (_("SMTP %s - Invalid response '%s' to command '%s'\n"), state_text (result), buffer, commands[n]); + } +#endif + } + n++; + } + + /* tell the server we're done */ +#ifdef HAVE_SSL + if (use_ssl) + SSL_write(ssl,SMTP_QUIT, strlen (SMTP_QUIT)); + else +#endif + send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0); + + /* finally close the connection */ + close (sd); + } + + /* reset the alarm */ + alarm (0); + + microsec = deltime (tv); + elapsed_time = (double)microsec / 1.0e6; + + if (result == STATE_OK) { + if (check_critical_time && elapsed_time > (double) critical_time) + result = STATE_CRITICAL; + else if (check_warning_time && elapsed_time > (double) warning_time) + result = STATE_WARNING; + } + + printf (_("SMTP %s - %.3f sec. response time%s%s|%s\n"), + state_text (result), elapsed_time, + verbose?", ":"", verbose?buffer:"", + fperfdata ("time", elapsed_time, "s", + (int)check_warning_time, warning_time, + (int)check_critical_time, critical_time, + TRUE, 0, FALSE, 0)); + + return result; +} + + + +/* process command-line arguments */ +int +process_arguments (int argc, char **argv) +{ + int c; + + int option = 0; + static struct option longopts[] = { + {"hostname", required_argument, 0, 'H'}, + {"expect", required_argument, 0, 'e'}, + {"critical", required_argument, 0, 'c'}, + {"warning", required_argument, 0, 'w'}, + {"timeout", required_argument, 0, 't'}, + {"port", required_argument, 0, 'p'}, + {"from", required_argument, 0, 'f'}, + {"command", required_argument, 0, 'C'}, + {"response", required_argument, 0, 'R'}, + {"nocommand", required_argument, 0, 'n'}, + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"use-ipv4", no_argument, 0, '4'}, + {"use-ipv6", no_argument, 0, '6'}, + {"help", no_argument, 0, 'h'}, + {"starttls",no_argument,0,'S'}, + {"certificate",required_argument,0,'D'}, + {0, 0, 0, 0} + }; + + if (argc < 2) + return ERROR; + + for (c = 1; c < argc; c++) { + if (strcmp ("-to", argv[c]) == 0) + strcpy (argv[c], "-t"); + else if (strcmp ("-wt", argv[c]) == 0) + strcpy (argv[c], "-w"); + else if (strcmp ("-ct", argv[c]) == 0) + strcpy (argv[c], "-c"); + } + + while (1) { + c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:", + longopts, &option); + + if (c == -1 || c == EOF) + break; + + switch (c) { + case 'H': /* hostname */ + if (is_host (optarg)) { + server_address = optarg; + } + else { + usage2 (_("Invalid hostname/address"), optarg); + } + break; + case 'p': /* port */ + if (is_intpos (optarg)) + server_port = atoi (optarg); + else + usage4 (_("Port must be a positive integer")); + break; + case 'f': /* from argument */ + from_arg = optarg; + smtp_use_dummycmd = 1; + break; + case 'e': /* server expect string on 220 */ + server_expect = optarg; + break; + case 'C': /* commands */ + if (ncommands >= command_size) { + commands = realloc (commands, command_size+8); + if (commands == NULL) + die (STATE_UNKNOWN, + _("Could not realloc() units [%d]\n"), ncommands); + } + commands[ncommands] = optarg; + ncommands++; + break; + case 'R': /* server responses */ + if (nresponses >= response_size) { + responses = realloc (responses, response_size+8); + if (responses == NULL) + die (STATE_UNKNOWN, + _("Could not realloc() units [%d]\n"), nresponses); + } + responses[nresponses] = optarg; + nresponses++; + break; + case 'c': /* critical time threshold */ + if (is_intnonneg (optarg)) { + critical_time = atoi (optarg); + check_critical_time = TRUE; + } + else { + usage4 (_("Critical time must be a positive integer")); + } + break; + case 'w': /* warning time threshold */ + if (is_intnonneg (optarg)) { + warning_time = atoi (optarg); + check_warning_time = TRUE; + } + else { + usage4 (_("Warning time must be a positive integer")); + } + break; + case 'v': /* verbose */ + verbose++; + break; + case 't': /* timeout */ + if (is_intnonneg (optarg)) { + socket_timeout = atoi (optarg); + } + else { + usage4 (_("Timeout interval must be a positive integer")); + } + break; + case 'S': + /* starttls */ + use_ssl = TRUE; + break; + case 'D': + /* Check SSL cert validity */ +#ifdef HAVE_SSL + if (!is_intnonneg (optarg)) + usage2 ("Invalid certificate expiration period",optarg); + days_till_exp = atoi (optarg); + check_cert = TRUE; +#else + usage (_("SSL support not available - install OpenSSL and recompile")); +#endif + break; + case '4': + address_family = AF_INET; + break; + case '6': +#ifdef USE_IPV6 + address_family = AF_INET6; +#else + usage4 (_("IPv6 support not available")); +#endif + break; + case 'V': /* version */ + print_revision (progname, revision); + exit (STATE_OK); + case 'h': /* help */ + print_help (); + exit (STATE_OK); + case '?': /* help */ + usage2 (_("Unknown argument"), optarg); + } + } + + c = optind; + if (server_address == NULL) { + if (argv[c]) { + if (is_host (argv[c])) + server_address = argv[c]; + else + usage2 (_("Invalid hostname/address"), argv[c]); + } + else { + asprintf (&server_address, "127.0.0.1"); + } + } + + if (server_expect == NULL) + server_expect = strdup (SMTP_EXPECT); + + if (mail_command == NULL) + mail_command = strdup("MAIL "); + + if (from_arg==NULL) + from_arg = strdup(" "); + + return validate_arguments (); +} + + + +int +validate_arguments (void) +{ + return OK; +} + + + +void +print_help (void) +{ + char *myport; + asprintf (&myport, "%d", SMTP_PORT); + + print_revision (progname, revision); + + printf ("Copyright (c) 1999-2001 Ethan Galstad \n"); + printf (COPYRIGHT, copyright, email); + + printf(_("This plugin will attempt to open an SMTP connection with the host.\n\n")); + + print_usage (); + + printf (_(UT_HELP_VRSN)); + + printf (_(UT_HOST_PORT), 'p', myport); + + printf (_(UT_IPv46)); + + printf (_("\ + -e, --expect=STRING\n\ + String to expect in first line of server response (default: '%s')\n\ + -n, nocommand\n\ + Suppress SMTP command\n\ + -C, --command=STRING\n\ + SMTP command (may be used repeatedly)\n\ + -R, --command=STRING\n\ + Expected response to command (may be used repeatedly)\n\ + -f, --from=STRING\n\ + FROM-address to include in MAIL command, required by Exchange 2000\n"), + SMTP_EXPECT); +#ifdef HAVE_SSL + printf (_("\ + -D, --certificate=INTEGER\n\ + Minimum number of days a certificate has to be valid.\n\ + -S, --starttls\n\ + Use STARTTLS for the connection.\n")); +#endif + + printf (_(UT_WARN_CRIT)); + + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); + + printf(_("\n\ +Successul connects return STATE_OK, refusals and timeouts return\n\ +STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful\n\ +connects, but incorrect reponse messages from the host result in\n\ +STATE_WARNING return values.\n")); + + printf (_(UT_SUPPORT)); +} + + + +void +print_usage (void) +{ + printf ("\ +Usage: %s -H host [-p port] [-e expect] [-C command] [-f from addr]\n\ + [-w warn] [-c crit] [-t timeout] [-S] [-D days] [-n] [-v] [-4|-6]\n", progname); +} + +#ifdef HAVE_SSL +int +connect_STARTTLS (void) +{ + SSL_METHOD *meth; + + /* Initialize SSL context */ + SSLeay_add_ssl_algorithms (); + meth = SSLv2_client_method (); + SSL_load_error_strings (); + if ((ctx = SSL_CTX_new (meth)) == NULL) + { + printf(_("CRITICAL - Cannot create SSL context.\n")); + return STATE_CRITICAL; + } + /* do the SSL handshake */ + if ((ssl = SSL_new (ctx)) != NULL) + { + SSL_set_fd (ssl, sd); + /* original version checked for -1 + I look for success instead (1) */ + if (SSL_connect (ssl) == 1) + return OK; + ERR_print_errors_fp (stderr); + } + else + { + printf (_("CRITICAL - Cannot initiate SSL handshake.\n")); + } + /* this causes a seg faul + not sure why, being sloppy + and commenting it out */ + // SSL_free (ssl); + SSL_CTX_free(ctx); + my_close(); + + return STATE_CRITICAL; +} + +int +check_certificate (X509 ** certificate) +{ + ASN1_STRING *tm; + int offset; + struct tm stamp; + int days_left; + + /* Retrieve timestamp of certificate */ + tm = X509_get_notAfter (*certificate); + + /* Generate tm structure to process timestamp */ + if (tm->type == V_ASN1_UTCTIME) { + if (tm->length < 10) { + printf (_("CRITICAL - Wrong time format in certificate.\n")); + return STATE_CRITICAL; + } + else { + stamp.tm_year = (tm->data[0] - '0') * 10 + (tm->data[1] - '0'); + if (stamp.tm_year < 50) + stamp.tm_year += 100; + offset = 0; + } + } + else { + if (tm->length < 12) { + printf (_("CRITICAL - Wrong time format in certificate.\n")); + return STATE_CRITICAL; + } + else { + stamp.tm_year = + (tm->data[0] - '0') * 1000 + (tm->data[1] - '0') * 100 + + (tm->data[2] - '0') * 10 + (tm->data[3] - '0'); + stamp.tm_year -= 1900; + offset = 2; + } + } + stamp.tm_mon = + (tm->data[2 + offset] - '0') * 10 + (tm->data[3 + offset] - '0') - 1; + stamp.tm_mday = + (tm->data[4 + offset] - '0') * 10 + (tm->data[5 + offset] - '0'); + stamp.tm_hour = + (tm->data[6 + offset] - '0') * 10 + (tm->data[7 + offset] - '0'); + stamp.tm_min = + (tm->data[8 + offset] - '0') * 10 + (tm->data[9 + offset] - '0'); + stamp.tm_sec = 0; + stamp.tm_isdst = -1; + + days_left = (mktime (&stamp) - time (NULL)) / 86400; + snprintf + (timestamp, 16, "%02d/%02d/%04d %02d:%02d", + stamp.tm_mon + 1, + stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min); + + if (days_left > 0 && days_left <= days_till_exp) { + printf ("Certificate expires in %d day(s) (%s).\n", days_left, timestamp); + return STATE_WARNING; + } + if (days_left < 0) { + printf ("Certificate expired on %s.\n", timestamp); + return STATE_CRITICAL; + } + + if (days_left == 0) { + printf ("Certificate expires today (%s).\n", timestamp); + return STATE_WARNING; + } + + printf ("Certificate will expire on %s.\n", timestamp); + + return STATE_OK; +} +#endif + +int +myrecv (void) +{ + int i; + +#ifdef HAVE_SSL + if (use_ssl) { + i = SSL_read (ssl, buffer, MAXBUF - 1); + } + else { +#endif + i = read (sd, buffer, MAXBUF - 1); +#ifdef HAVE_SSL + } +#endif + return i; +} + +int +myrecv_norm (void) +{ + int i; + i = read (sd, buffer, MAXBUF - 1); + return i; +} + +int +my_close (void) +{ +#ifdef HAVE_SSL + if (use_ssl == TRUE) { + SSL_shutdown (ssl); + SSL_free (ssl); + SSL_CTX_free (ctx); + return 0; + } + else { +#endif + return close(sd); +#ifdef HAVE_SSL + } +#endif +} diff --git a/web/attachments/129978-allow_empty_passwords b/web/attachments/129978-allow_empty_passwords new file mode 100644 index 0000000..f78f247 --- /dev/null +++ b/web/attachments/129978-allow_empty_passwords @@ -0,0 +1,24 @@ +--- plugins-scripts/check_disk_smb.pl.old 2005-04-15 16:22:18.000000000 +0200 ++++ plugins-scripts/check_disk_smb.pl 2005-04-15 16:25:44.000000000 +0200 +@@ -76,7 +76,7 @@ + my $user = $1 if ($opt_u =~ /^([-_.A-Za-z0-9\\]+)$/); + ($user) || usage("Invalid user: $opt_u\n"); + +-($opt_p) || ($opt_p = shift) || ($opt_p = "guest"); ++($opt_p) || ($opt_p = shift) || ($opt_p = ""); + my $pass = $1 if ($opt_p =~ /(.*)/); + + ($opt_w) || ($opt_w = shift) || ($opt_w = 85); +@@ -123,10 +123,10 @@ + # Execute an "ls" on the share using smbclient program + # get the results into $res + if (defined($workgroup)) { +- $res = qx/$smbclient \/\/$host\/$share $pass -W $workgroup -U $user $smbclientoptions -c ls/; ++ $res = qx/$smbclient \/\/$host\/$share -W $workgroup -U $user%$pass $smbclientoptions -c ls/; + } else { + print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose); +- $res = qx/$smbclient \/\/$host\/$share $pass -U $user $smbclientoptions -c ls/; ++ $res = qx/$smbclient \/\/$host\/$share -U $user%$pass $smbclientoptions -c ls/; + } + #Turn off alarm + alarm(0); diff --git a/web/attachments/130855-NPTest-Final.tar.gz b/web/attachments/130855-NPTest-Final.tar.gz new file mode 100644 index 0000000..1426e4f Binary files /dev/null and b/web/attachments/130855-NPTest-Final.tar.gz differ diff --git a/web/attachments/130858-check_time.c.patch b/web/attachments/130858-check_time.c.patch new file mode 100644 index 0000000..a00fb3d --- /dev/null +++ b/web/attachments/130858-check_time.c.patch @@ -0,0 +1,15 @@ +*** nagios-plugins-1.4/plugins/check_time.c Sat Dec 25 23:17:44 2004 +--- nagios-plugins-1.4-fixed/plugins/check_time.c Fri Apr 8 08:15:56 2005 +*************** +*** 34,38 **** + #define UNIX_EPOCH 2208988800UL + +! unsigned long server_time, raw_server_time; + time_t diff_time; + int warning_time = 0; +--- 34,38 ---- + #define UNIX_EPOCH 2208988800UL + +! uint32_t server_time, raw_server_time; + time_t diff_time; + int warning_time = 0; diff --git a/web/attachments/130868-test.pl b/web/attachments/130868-test.pl new file mode 100644 index 0000000..22d0576 --- /dev/null +++ b/web/attachments/130868-test.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl -w -I .. -I ../.. +# +# Wrapper for running the test harnesses +# +# $Id$ +# + +use strict; + +use Getopt::Long; + +use NPTest qw(DetermineTestHarnessDirectory TestsFrom); + +my $tstdir; + +if ( ! GetOptions( "testdir:s" => \$tstdir ) ) +{ + print "Usage: ${0} [--testdir=] [ ...]\n"; + exit 1; +} + +my @tests; + +if ( scalar( @ARGV ) ) +{ + @tests = @ARGV; +} +else +{ + my $directory = DetermineTestHarnessDirectory( $tstdir ); + + if ( !defined( $directory ) ) + { + print STDERR "$0: Unable to determine the test harness directory - ABORTING\n"; + exit 2; + } + + @tests = TestsFrom( $directory, 1 ); +} + +if ( ! scalar( @tests ) ) +{ + print STDERR "$0: Unable to determine the test harnesses to run - ABORTING\n"; + exit 3; +} + +use Test::Harness; + +#$Test::Harness::verbose=1; + +runtests( @tests ); diff --git a/web/attachments/131422-diff_check_nt b/web/attachments/131422-diff_check_nt new file mode 100644 index 0000000..6d0865d --- /dev/null +++ b/web/attachments/131422-diff_check_nt @@ -0,0 +1,230 @@ +--- check_nt.c.original 2005-03-05 04:45:05.000000000 -0500 ++++ check_nt.c 2005-04-23 08:35:43.000000000 -0400 +@@ -282,111 +282,74 @@ + break; + + case CHECK_COUNTER: +- +- +- /* +- CHECK_COUNTER has been modified to provide extensive perfdata information. +- In order to do this, some modifications have been done to the code +- and some constraints have been introduced. +- +- 1) For the sake of simplicity of the code, perfdata information will only be +- provided when the "description" field is added. +- +- 2) If the counter you're going to measure is percent-based, the code will detect +- the percent sign in its name and will attribute minimum (0%) and maximum (100%) +- values automagically, as well the %" sign to graph units. +- +- 3) OTOH, if the counter is "absolute", you'll have to provide the following +- the counter unit - that is, the dimensions of the counter you're getting. Examples: +- pages/s, packets transferred, etc. +- +- 4) If you want, you may provide the minimum and maximum values to expect. They aren't mandatory, +- but once specified they MUST have the same order of magnitude and units of -w and -c; otherwise. +- strange things will happen when you make graphs of your data. +- */ +- +- if (value_list == NULL) +- output_message = strdup (_("No counter specified")); +- else +- { +- preparelist (value_list); /* replace , between services with & to send the request */ +- isPercent = (strchr (value_list, '%') != NULL); +- +- strtok (value_list, "&"); /* burn the first parameters */ +- description = strtok (NULL, "&"); +- counter_unit = strtok (NULL, "&"); +- asprintf (&send_buffer, "%s&8&%s", req_password, value_list); +- fetch_data (server_address, server_port, send_buffer); +- counter_value = atof (recv_buffer); +- +- +- if (description == NULL) +- asprintf (&output_message, "%.f", counter_value); +- else if (isPercent) +- { +- counter_unit = strdup ("%"); +- allRight = TRUE; +- } +- +- if ((counter_unit != NULL) && (!allRight)) +- { +- minval = strtok (NULL, "&"); +- maxval = strtok (NULL, "&"); +- +- /* All parameters specified. Let's check the numbers */ +- +- fminval = (minval != NULL) ? strtod (minval, &errcvt) : -1; +- fmaxval = (minval != NULL) ? strtod (maxval, &errcvt) : -1; +- +- if ((fminval == 0) && (minval == errcvt)) +- output_message = strdup (_("Minimum value contains non-numbers")); +- else +- { +- if ((fmaxval == 0) && (maxval == errcvt)) +- output_message = strdup (_("Maximum value contains non-numbers")); +- else +- allRight = TRUE; /* Everything is OK. */ +- +- } +- } +- else if ((counter_unit == NULL) && (description != NULL)) +- output_message = strdup (_("No unit counter specified")); +- +- if (allRight) +- { +- /* Let's format the output string, finally... */ +- if (strstr(description, "%") == NULL) { +- asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit); +- } else { +- /* has formatting, will segv if wrong */ +- asprintf (&output_message, description, counter_value); +- } +- asprintf (&output_message, "%s |", output_message); +- asprintf (&output_message,"%s %s", output_message, +- fperfdata (description, counter_value, +- counter_unit, 1, warning_value, 1, critical_value, +- (!(isPercent) && (minval != NULL)), fminval, +- (!(isPercent) && (minval != NULL)), fmaxval)); +- } +- } +- +- if (critical_value > warning_value) +- { /* Normal thresholds */ +- if (check_critical_value == TRUE && counter_value >= critical_value) +- return_code = STATE_CRITICAL; +- else if (check_warning_value == TRUE && counter_value >= warning_value) +- return_code = STATE_WARNING; +- else +- return_code = STATE_OK; +- } +- else +- { /* inverse thresholds */ +- return_code = STATE_OK; +- if (check_critical_value == TRUE && counter_value <= critical_value) +- return_code = STATE_CRITICAL; +- else if (check_warning_value == TRUE && counter_value <= warning_value) +- return_code = STATE_WARNING; +- } ++ /* ++ * Check_Counter has been rewriten for NC_Net now it processes the pref data in ++ * a more consistent way to the Nagios plug-in development guidelines. ++ * 1) if no Units of mesurement use a 0 (zero) for the UOM in the check ++ * and the units will be omited from the output. ++ * 2) it will do MIN without a MAX ++ * 3) still processes custom min and max even if it is % ++ * 4) % has a default of min 0, max 100 ++ * 5) -w and -c are no longer causing a seg fault. old code said to always ++ * process both for perf data, but it should have checked that they were in use. ++ * 6) the description is only a label for perf data not a formatter... ++ ****************************************************************************/ ++ if (value_list == NULL) ++ output_message = strdup (_("No counter specified")); ++ else { ++ preparelist (value_list); /* replace , between services with & to send the request */ ++ ++ temp_string = strtok (value_list, "&"); ++ isPercent = (strchr (temp_string, '%') != NULL); ++ description = strtok (NULL, "&"); ++ counter_unit = strtok (NULL, "&"); ++ asprintf (&send_buffer, "%s&8&%s", req_password, value_list); ++ fetch_data (server_address, server_port, send_buffer); ++ counter_value = atof (recv_buffer); ++ if (isPercent) counter_unit = strdup ("%"); ++ if ( description != NULL && counter_unit == NULL ) ++ counter_unit = strdup ( "0" ); ++ if ( counter_unit != NULL && description != NULL) ++ { ++ if ( counter_unit[0] == '0' ) counter_unit[0] = '\0'; ++ minval = strtok (NULL, "&"); ++ maxval = strtok (NULL, "&"); ++ if ( minval == NULL && isPercent ) asprintf(&minval,"0"); ++ if ( minval != NULL ) fminval = strtod ( minval, NULL ) ; ++ if ( maxval == NULL && isPercent ) asprintf(&maxval,"100"); ++ if ( maxval != NULL ) fmaxval = strtod (maxval, NULL); ++ allRight = TRUE; ++ /* Let's format the output string, finally... */ ++ asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit); ++ asprintf (&output_message,"%s | %s", output_message, ++ fperfdata (description, counter_value, ++ counter_unit, check_warning_value, warning_value, ++ check_critical_value, critical_value, ++ (minval != NULL), fminval, ++ (maxval != NULL), fmaxval )); ++ } ++ else if (isPercent) ++ asprintf(&output_message, "%s = %.2f %%",temp_string,counter_value); ++ else ++ asprintf(&output_message, "%s = %.2f",temp_string,counter_value); ++ } ++ if (critical_value > warning_value) ++ { /* Normal thresholds */ ++ if (check_critical_value == TRUE && counter_value >= critical_value) ++ return_code = STATE_CRITICAL; ++ else if (check_warning_value == TRUE && counter_value >= warning_value) ++ return_code = STATE_WARNING; ++ else ++ return_code = STATE_OK; ++ } ++ else ++ { /* inverse thresholds */ ++ return_code = STATE_OK; ++ if (check_critical_value == TRUE && counter_value <= critical_value) ++ return_code = STATE_CRITICAL; ++ else if (check_warning_value == TRUE && counter_value <= warning_value) ++ return_code = STATE_WARNING; ++ } + break; + + case CHECK_FILEAGE: +@@ -394,7 +357,7 @@ + if (value_list==NULL) + output_message = strdup (_("No counter specified")); + else { +- preparelist(value_list); /* replace , between services with & to send the request */ ++ preparelist(value_list); /* replace , between services with & to send the request */ + asprintf(&send_buffer,"%s&9&%s", req_password,value_list); + fetch_data (server_address, server_port, send_buffer); + age_in_minutes = atoi(strtok(recv_buffer,"&")); +@@ -672,13 +635,32 @@ + printf (_("\ + COUNTER = Check any performance counter of Windows NT/2000.\n\ + Request a -l parameters with the following syntax:\n\ +- -l \"\\\\\\\\counter\",\"\n\ +- The parameter is optional and \n\ +- is given to a printf output command which requires a float parameter.\n\ +- If does not include \"%%\", it is used as a label.\n\ ++ -l \"\\\\\\\\counter\"[,\"