summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2023-01-09 16:55:10 +0100
committerGitHub <noreply@github.com>2023-01-09 16:55:10 +0100
commite0ada6f11a82ed6119836482b84c8ba5df491d8f (patch)
tree6ddcd5f7850169d82d88dca56a2e5c0dbda08b4e
parentc389aa4f918aab5cf181aa2cb9dec68b3bf34d4f (diff)
parent0899e41f5075d661153eb2c77ace1734a8f66bfa (diff)
downloadmonitoring-plugins-e0ada6f.tar.gz
Merge branch 'master' into rename_output_to_cmd_output
-rw-r--r--.github/dependabot.yml10
-rwxr-xr-x.github/prepare_debian.sh61
-rw-r--r--.github/workflows/codeql-analysis.yml4
-rw-r--r--.github/workflows/test.yml4
-rw-r--r--AUTHORS2
-rw-r--r--NEWS109
-rw-r--r--THANKS.in19
-rw-r--r--configure.ac126
-rw-r--r--doc/RELEASING.md6
-rw-r--r--lib/utils_disk.c6
-rwxr-xr-xpkg/solaris/solpkg2
-rw-r--r--plugins-root/check_icmp.c28
-rwxr-xr-xplugins-scripts/check_sensors.sh4
-rw-r--r--plugins/check_apt.c70
-rw-r--r--plugins/check_by_ssh.c18
-rw-r--r--plugins/check_curl.c29
-rw-r--r--plugins/check_disk.c67
-rw-r--r--plugins/check_http.c329
-rw-r--r--plugins/check_load.c122
-rw-r--r--plugins/check_ntp.c8
-rw-r--r--plugins/check_pgsql.c48
-rw-r--r--plugins/check_snmp.c90
-rw-r--r--plugins/check_swap.c33
-rw-r--r--plugins/t/check_curl.t44
-rw-r--r--plugins/t/check_http.t10
-rw-r--r--plugins/t/check_load.t15
-rwxr-xr-xplugins/tests/check_curl.t21
-rwxr-xr-xplugins/tests/check_http.t15
-rwxr-xr-xplugins/tests/check_snmp.t22
-rw-r--r--plugins/tests/check_snmp_agent.pl8
-rw-r--r--plugins/utils.c24
31 files changed, 857 insertions, 497 deletions
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..282063c4
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,10 @@
1version: 2
2updates:
3 - package-ecosystem: github-actions
4 directory: "/"
5 schedule:
6 interval: daily
7 time: "04:00"
8 pull-request-branch-name:
9 separator: "-"
10 open-pull-requests-limit: 10
diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh
index 4021c104..d8a76da6 100755
--- a/.github/prepare_debian.sh
+++ b/.github/prepare_debian.sh
@@ -11,21 +11,51 @@ if [ $(lsb_release -is) = "Debian" ]; then
11 apt-add-repository non-free 11 apt-add-repository non-free
12 apt-get update 12 apt-get update
13fi 13fi
14apt-get -y install perl autotools-dev libdbi-dev libldap2-dev libpq-dev libradcli-dev libnet-snmp-perl procps 14apt-get -y install perl \
15apt-get -y install libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd 15 autotools-dev \
16apt-get -y install fping snmp netcat-openbsd smbclient vsftpd apache2 ssl-cert postfix libhttp-daemon-ssl-perl 16 libdbi-dev \
17apt-get -y install libdbd-sybase-perl libnet-dns-perl 17 libldap2-dev \
18apt-get -y install slapd ldap-utils 18 libpq-dev \
19apt-get -y install gcc make autoconf automake gettext 19 libradcli-dev \
20apt-get -y install faketime 20 libnet-snmp-perl \
21apt-get -y install libmonitoring-plugin-perl 21 procps \
22apt-get -y install libcurl4-openssl-dev 22 libdbi0-dev \
23apt-get -y install liburiparser-dev 23 libdbd-sqlite3 \
24apt-get -y install squid 24 libssl-dev \
25apt-get -y install openssh-server 25 dnsutils \
26apt-get -y install mariadb-server mariadb-client libmariadb-dev 26 snmp-mibs-downloader \
27apt-get -y install cron iputils-ping 27 libsnmp-perl \
28apt-get -y install iproute2 28 snmpd \
29 fping \
30 snmp \
31 netcat-openbsd \
32 smbclient \
33 vsftpd \
34 apache2 \
35 ssl-cert \
36 postfix \
37 libhttp-daemon-ssl-perl \
38 libdbd-sybase-perl \
39 libnet-dns-perl \
40 slapd \
41 ldap-utils \
42 gcc \
43 make \
44 autoconf \
45 automake \
46 gettext \
47 faketime \
48 libmonitoring-plugin-perl \
49 libcurl4-openssl-dev \
50 liburiparser-dev \
51 squid \
52 openssh-server \
53 mariadb-server \
54 mariadb-client \
55 libmariadb-dev \
56 cron \
57 iputils-ping \
58 iproute2
29 59
30# remove ipv6 interface from hosts 60# remove ipv6 interface from hosts
31if [ $(ip addr show | grep "inet6 ::1" | wc -l) -eq "0" ]; then 61if [ $(ip addr show | grep "inet6 ::1" | wc -l) -eq "0" ]; then
@@ -37,7 +67,6 @@ ip addr show
37 67
38cat /etc/hosts 68cat /etc/hosts
39 69
40
41# apache 70# apache
42a2enmod ssl 71a2enmod ssl
43a2ensite default-ssl 72a2ensite default-ssl
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index afe6ab4f..ab8bfaae 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -39,11 +39,11 @@ jobs:
39 39
40 steps: 40 steps:
41 - name: Checkout repository 41 - name: Checkout repository
42 uses: actions/checkout@v2 42 uses: actions/checkout@v3
43 43
44 # Initializes the CodeQL tools for scanning. 44 # Initializes the CodeQL tools for scanning.
45 - name: Initialize CodeQL 45 - name: Initialize CodeQL
46 uses: github/codeql-action/init@v1 46 uses: github/codeql-action/init@v2
47 with: 47 with:
48 languages: ${{ matrix.language }} 48 languages: ${{ matrix.language }}
49 # If you wish to specify custom queries, you can do so here or in a config file. 49 # If you wish to specify custom queries, you can do so here or in a config file.
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0f93930a..80d49f7e 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -24,7 +24,7 @@ jobs:
24 #... 24 #...
25 steps: 25 steps:
26 - name: Git clone repository 26 - name: Git clone repository
27 uses: actions/checkout@v2 27 uses: actions/checkout@v3
28 #- name: Setup tmate session, see https://github.com/marketplace/actions/debugging-with-tmate 28 #- name: Setup tmate session, see https://github.com/marketplace/actions/debugging-with-tmate
29 # uses: mxschmitt/action-tmate@v3 29 # uses: mxschmitt/action-tmate@v3
30 - name: Run the tests on ${{ matrix.distro }} 30 - name: Run the tests on ${{ matrix.distro }}
@@ -40,7 +40,7 @@ jobs:
40 ${{ matrix.distro }} \ 40 ${{ matrix.distro }} \
41 /bin/sh -c '${{ matrix.prepare }} && \ 41 /bin/sh -c '${{ matrix.prepare }} && \
42 tools/setup && \ 42 tools/setup && \
43 ./configure --enable-libtap --with-ipv6=no && \ 43 ./configure --enable-libtap --with-ipv6=no && \
44 make && \ 44 make && \
45 make test' 45 make test'
46 docker container prune -f 46 docker container prune -f
diff --git a/AUTHORS b/AUTHORS
index 2d455be3..1b1a0366 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -22,3 +22,5 @@ Jan Wagner
22Holger Weiss 22Holger Weiss
23Michael Wirtgen 23Michael Wirtgen
24Oliver Skibbe 24Oliver Skibbe
25Andreas Baumann
26Lorenz Kästle
diff --git a/NEWS b/NEWS
index 3790e8a0..b674391b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,115 @@
1This file documents the major additions and syntax changes between releases. 1This file documents the major additions and syntax changes between releases.
2 2
32.4 [...] 32.3.2 20th Oct 2022
4 GENERAL
5 Use netcat-openbsd for debian explicitely (by @RincewindsHat #1704)
6 Replace egrep with grep -E (by @RincewindsHat #1791)
7 Use silent automake by default (by @RincewindsHat #1747)
8
9 SINGLE PLUGINS
10 check_by_ssh: added option to exit with an warning, if there is output on STDERR (by @nafets #1301)
11 check_by_ssh: Add "-U" flag (#1123). (by @archiecobbs #1774)
12 check_by_ssh: Let ssh decide if a host is valid, enables usage of ssh .config file (by @RincewindsHat #1691)
13 check_curl: Add an option to check_curl to verify the peer certificate & host using the system CA's (by @bazzisoft #1669)
14 check_curl: fixed -ffollow for HTTP/2.0 (Fixes #1685): added major_version parsing to PicoHTTPParser (by @andreasbaumann #1742)
15 check_curl: fixes check_curl: "CRITICAL - Cannot retrieve certificate subject." (by @andreasbaumann #1689)
16 check_curl: fix if http header contains leading spaces (by @sni #1666)
17 check_curl: Update check_curl.c to display a specific human-readable error message where possible (by @bazzisoft #1668)
18 check_curl: verify certificates option should not force SSL to be used (by @bazzisoft #1688)
19 check_disk: Description for -M was the wrong way around (by @RincewindsHat #1746)
20 check_disk: Fixing the stuff that is broken on btrfs (by @waja #1388)
21 check_disk: Fix perfdata for big values for check disk (by @RincewindsHat #1714)
22 check_disk_smb: Add configfile feature (by @Napsty #1402)
23 check_disk_smb: Add timeout (by @cdruee #1770)
24 check_dns: Add --expect-nxdomain (by @Jonny007-MKD #1623)
25 check_dns: split multiple IP addresses passed in one -a argument (by @DerDakon #1649)
26 check_file_age: Make size parameter a little bit more intelligible (by @RincewindsHat #1730)
27 check_fping: Implements 'host-alive' mode (Closes. #1027) (by @waja #1740)
28 check_game: Update Url to qstat (by @RincewindsHat #1725)
29 check_http: changed 'STATE_CRITICAL' to 'STATE_WARNING' for infinite loop (by @xFuture603 #1690)
30 check_http: Increase regexp limit (by @hydrapolic #1566)
31 check_http: Support http redirect (by @waja #1449)
32 check_icmp: buffer offerflow (by @RincewindsHat #1733)
33 check_icmp: delay set_source_ip() until address_family is detected (by @ghciv6 #1735)
34 check_icmp: Fix "Invalid Argument" from sendmsg() under FreeBSD 13.1 and "setsockopt failed" for TTL setting (by @eriksejr #1771)
35 check_icmp: Fix pkt perfdata in check_host mode (by @sjoegren #1721)
36 check_ldap: Allows check_ldap to read password from environment variable (by @mullumaus #1724)
37 check_load: add LOAD prefix to load plugin (by @haraldj #1694)
38 check_load: Display total and scaled load values if check_load scales the values (by number of CPUs by @RincewindsHat #1778)
39 check_log: Missing oldlog now aborts check_log (by @RincewindsHat #1732)
40 check_mailq: Add mailq -C option for config dir or config file (by @leeclemens #1490)
41 check_mailq: Check mailq domain specific warnings (by @RincewindsHat #1731)
42 check_mailq: Fix regexp for nullmailer "mailq" output (by @darksoul42 #1493)
43 check_mysql: fix segfaults with mysql-connector-c #1562 (by @ghciv6 #1644)
44 check_pgsql: add --queryname parameter to check_pgsql (by @datamuc #1741)
45 check_ping: Do not show RTA if no connection was possible (by @RincewindsHat #1697)
46 check_ping: understang ping6 output from iputils package (by @glensc #1412)
47 check_proc: Fix check proc ps detection (by @sni #1712)
48 check_procs: exchange needle and haystack in strstr() for proper st… (by @wolfgangkarall #1654)
49 check_smtp: add -L flag to support LMTP (LHLO instead of HELO/EHLO). (by @ghen2 #1715)
50 check_snmp: Added option for null zero length string exit codes (by @FracKenA #1496)
51 check_snmp: fix performance thresholds when using multiple oids (by @sni #1722)
52 check_snmp fix segfaults (by @adrb #1589)
53 check_snmp: put the "c" (to mark a counter) after the perfdata value (by @lausser #1465)
54 check_swap: fix parsing swap values (by @sni #1780)
55 check_swap: Fix perfdata for check swap (by @RincewindsHat #1707)
56 check_swap: Fix unit for total in perfdata (by @RincewindsHat #1779)
57 check_swap: Handle cached swap (by @mdavranche #1642)
58 check_swap: Small fix to threshold validation and style (indentation) fixes (by @RincewindsHat #1723)
59 check_ups: Fix possible overflow in check_ups (by @phibos #1727)
60 check_uptime: Add option to report uptime in days instead of seconds (by @amotl #1750)
61 check_uptime: Fix/improve output message "Uptime is ..." (by @amotl #1751)
62
63 MULTIPLE PLUGINS
64 check_http, check_curl: added --max-redirs=N option (feature #1684) (by @andreasbaumann #1744)
65 check_http, check_curl: Enhancement --continue-after-certificate (backport from nagios-plugins) (by @andreasbaumann #1762)
66 check_http, check_curl: Remove check_http and check_curl test which are somehow always failing (by @RincewindsHat #1777)
67 check_log, check_oracle, check_sensors: Several fixes shellcheck complaining about (by @waja #1459)
68 sslutils: use chain from client certificates (by @tobiaswiese #1664)
69
70 NON FUNCTIONAL CHANGES
71 Trivial source code whitespace formatting fixes to standard. (by @ziesemer #1424)
72 docs: fix simple typo, conspicuosly -> conspicuously (by @timgates42 #1652)
73 Migrate to GitHub actions (by @jacobbaungard #1686)
74 Point to Icinga Exchange instead of dead Monitoring Exchange (by @RincewindsHat #1737)
75 github actions: fix check_users test case (by @sni #1713)
76 Add CodeQL checks (by @phibos #1682)
77 Fix some QL problems (by @RincewindsHat #1729)
78 Update CodeQL and update runner before installing (by @RincewindsHat #1775)
79 check_disk: Check disk compiler warnings (by @RincewindsHat #1758)
80 check_disk: Trivial printf fix and a little bit of code style (by @RincewindsHat #1695)
81 check_http: Docs: make -C obvious (by @stblassitude #1554)
82 check_ifoperstatus: Re-attach a comment to where it actually belongs (by @peternewman #1699)
83 check_ircd: Restrict the nickname length of the test user for check_ircd (by @RincewindsHat #1710)
84 check_load: Check load compiler warnings (by @RincewindsHat #1759)
85 check_log: Modernize check log (by @RincewindsHat #1692)
86 check_mailq: remove duplicate W=i/C=i args in check_mailq.pl (by @ichdasich #1755)
87 check_ntp: Check ntp remove unused variables (by @RincewindsHat #1781)
88 check_pgsql: Using snprintf which honors the buffers size and guarantees null temination. (Closes: #1601) (by @waja #1663)
89 check_procs: Fix double percentage sign in usage (by @RincewindsHat #1743)
90 check_sensors.sh: Make shellcheck happier (by @RincewindsHat #1679)
91 check_snmp: Fixed option description authpassword -> authpasswd + whitespaces (by @RincewindsHat #1676)
92 check_swap: Check swap compiler warnings (by @RincewindsHat #1756)
93
942.3.1 10 April 2021
4 ENHANCEMENTS 95 ENHANCEMENTS
96 check_curl: Add an option to verify the peer certificate & host using the system CA's
5 97
6 FIXES 98 FIXES
99 check_icmp: fix simple typo, conspicuosly -> conspicuously
100 check_curl: fixed help, usage and errors for TLS 1.3
101 check_curl: fixed a potential buffer overflow in url buffer
102 check_dns: split multiple IP addresses passed in one -a argument
103 check_curl: added string_statuscode function for printing HTTP/1.1 and HTTP/2 correctly
104 check_curl: fix crash if http header contains leading spaces
105 check_curl: display a specific human-readable error message where possible
106 check_pgsql: Using snprintf which honors the buffers size and guarantees null termination.
107 check_snmp: put the "c" (to mark a counter) after the perfdata value
108 check_http: Increase regexp limit
109 check_http: make -C obvious
110 check_curl: Increase regexp limit (to 1024 as in check_http)
111 check_curl: make -C obvious (from check_http)
112 check_curl: backported --show-body/-B to print body (from check_http)
7 113
82.3 10th December 2020 1142.3 10th December 2020
9 ENHANCEMENTS 115 ENHANCEMENTS
@@ -529,4 +635,3 @@ This file documents the major additions and syntax changes between releases.
529 check_swap % thresholds changed to measure amount free, instead of amount used 635 check_swap % thresholds changed to measure amount free, instead of amount used
530 check_disk syntax changes for -p, -m/-M, defaults to MB instead of kB 636 check_disk syntax changes for -p, -m/-M, defaults to MB instead of kB
531 check_procs -C expects no path for the command name 637 check_procs -C expects no path for the command name
532
diff --git a/THANKS.in b/THANKS.in
index 7d1d1ff0..89201404 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -381,3 +381,22 @@ Michael Kraus
381Patrick Rauscher 381Patrick Rauscher
382Prathamesh Bhanuse 382Prathamesh Bhanuse
383Valentin Vidic 383Valentin Vidic
384Barak Shohat
385Florian Lohoff
386Stefan Bethke
387Tim Gates
388Tomas Mozes
389Aksel Sjögren
390Andreas Motl
391Claudio Kuenzler
392Daniel Uhlmann
393Eric Wunderlin
394Geert Hendrickx
395Ken D
396Klaus Ethgen
397Lee Clemens
398Linda Guo
399Peter Newman
400Tobias Fiebig
401Tobias Wiese
402Wolfgang Karall-Ahlborn
diff --git a/configure.ac b/configure.ac
index 8c5ca70a..87a84a0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -427,7 +427,7 @@ if test "$ac_cv_header_utmpx_h" = "no" -a "$ac_cv_header_wtsapi32_h" = "no"
427then 427then
428 AC_PATH_PROG(PATH_TO_WHO,who) 428 AC_PATH_PROG(PATH_TO_WHO,who)
429 429
430 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null] 430 if [$PATH_TO_WHO -q 2>/dev/null | grep -E -i "^# users=[0-9]+$" >/dev/null]
431 then 431 then
432 ac_cv_path_to_who="$PATH_TO_WHO -q" 432 ac_cv_path_to_who="$PATH_TO_WHO -q"
433 else 433 else
@@ -776,7 +776,7 @@ dnl Removing this for the moment - Ton
776dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation 776dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
777dnl Limitation that command name is not available 777dnl Limitation that command name is not available
778dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \ 778dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
779dnl egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null 779dnl grep -E -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
780dnl then 780dnl then
781dnl ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]" 781dnl ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
782dnl ac_cv_ps_command="/usr/ucb/ps -alxwwn" 782dnl ac_cv_ps_command="/usr/ucb/ps -alxwwn"
@@ -786,7 +786,7 @@ dnl AC_MSG_RESULT([$ac_cv_ps_command])
786 786
787dnl This one is the exact same test as the next one but includes etime 787dnl This one is the exact same test as the next one but includes etime
788elif ps axwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \ 788elif ps axwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
789 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +ELAPSED +COMMAND"] > /dev/null 789 grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +ELAPSED +COMMAND"] > /dev/null
790then 790then
791 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" 791 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
792 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu etime comm args'" 792 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu etime comm args'"
@@ -797,7 +797,7 @@ then
797dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. 797dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
798dnl so test for this first... 798dnl so test for this first...
799elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 799elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
800 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null 800 grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
801then 801then
802 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 802 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
803 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'" 803 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
@@ -809,7 +809,7 @@ dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
809dnl Should also work for FreeBSD 5.2.1 and 5.3 809dnl Should also work for FreeBSD 5.2.1 and 5.3
810dnl STAT UCOMM VSZ RSS USER PPID COMMAND 810dnl STAT UCOMM VSZ RSS USER PPID COMMAND
811elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 811elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
812 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null 812 grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
813then 813then
814 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 814 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
815 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'" 815 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
@@ -821,7 +821,7 @@ dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
821dnl Limitation: Only first 16 chars returned for ucomm field 821dnl Limitation: Only first 16 chars returned for ucomm field
822dnl Must come before ps -weo 822dnl Must come before ps -weo
823elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \ 823elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
824 egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null 824 grep -E -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
825then 825then
826 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 826 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
827 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'" 827 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
@@ -831,7 +831,7 @@ then
831 831
832dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND 832dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND
833elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \ 833elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
834 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null 834 grep -E -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
835then 835then
836 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" 836 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
837 ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'" 837 ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
@@ -841,7 +841,7 @@ then
841 841
842dnl FreeBSD 842dnl FreeBSD
843elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \ 843elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
844 egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null 844 grep -E -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
845then 845then
846 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 846 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
847 ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'" 847 ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
@@ -851,7 +851,7 @@ then
851 851
852dnl BSD-like mode in RH 6.1 852dnl BSD-like mode in RH 6.1
853elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ 853elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
854 egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 854 grep -E -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
855then 855then
856 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 856 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
857 ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'" 857 ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
@@ -863,7 +863,7 @@ dnl SunOS 4.1.3:
863dnl F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND 863dnl F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND
864dnl Need the head -1 otherwise test will work because arguments are found 864dnl Need the head -1 otherwise test will work because arguments are found
865elif ps -laxnwww 2>/dev/null | head -1 | \ 865elif ps -laxnwww 2>/dev/null | head -1 | \
866 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null 866 grep -E -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
867then 867then
868 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" 868 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
869 ac_cv_ps_command="$PATH_TO_PS -laxnwww" 869 ac_cv_ps_command="$PATH_TO_PS -laxnwww"
@@ -876,7 +876,7 @@ dnl FLAGS UID PID PPID PRI NI SIZE RSS WCHAN STA TTY TIME COMMA
876dnl 100 0 1 0 0 0 776 76 c0131c8c S ffff 0:11 init [2] 876dnl 100 0 1 0 0 0 776 76 c0131c8c S ffff 0:11 init [2]
877dnl 877dnl
878elif ps laxnwww 2>/dev/null | \ 878elif ps laxnwww 2>/dev/null | \
879 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null 879 grep -E -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
880then 880then
881 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]" 881 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
882 ac_cv_ps_command="$PATH_TO_PS laxnwww" 882 ac_cv_ps_command="$PATH_TO_PS laxnwww"
@@ -886,7 +886,7 @@ then
886 886
887dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs) 887dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
888elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 888elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
889 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null 889 grep -E -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
890then 890then
891 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 891 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
892 ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'" 892 ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
@@ -899,7 +899,7 @@ dnl Has /usr/bin/ps and /sbin/ps - force sbin version
899dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 899dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
900dnl of 1500). Will need big changes to check_procs to support 900dnl of 1500). Will need big changes to check_procs to support
901elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \ 901elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
902 egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null 902 grep -E -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
903then 903then
904 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]" 904 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
905 ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'" 905 ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
@@ -908,7 +908,7 @@ then
908 AC_MSG_RESULT([$ac_cv_ps_command]) 908 AC_MSG_RESULT([$ac_cv_ps_command])
909 909
910elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \ 910elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
911 egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null 911 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
912then 912then
913 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 913 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
914 ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'" 914 ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
@@ -918,7 +918,7 @@ then
918 918
919dnl AIX 4.3.3 and 5.1 do not have an rss field 919dnl AIX 4.3.3 and 5.1 do not have an rss field
920elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \ 920elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
921 egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null 921 grep -E -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
922then 922then
923 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]" 923 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
924 ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'" 924 ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
@@ -928,7 +928,7 @@ then
928 928
929dnl Solaris 2.6 929dnl Solaris 2.6
930elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \ 930elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
931 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 931 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
932then 932then
933 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 933 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
934 ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'" 934 ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
@@ -939,7 +939,7 @@ then
939 AC_MSG_RESULT([$ac_cv_ps_command]) 939 AC_MSG_RESULT([$ac_cv_ps_command])
940 940
941elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \ 941elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
942 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 942 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
943then 943then
944 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 944 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
945 ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'" 945 ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
@@ -948,7 +948,7 @@ then
948 AC_MSG_RESULT([$ac_cv_ps_command]) 948 AC_MSG_RESULT([$ac_cv_ps_command])
949 949
950elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ 950elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
951 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 951 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
952then 952then
953 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 953 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
954 ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'" 954 ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
@@ -958,7 +958,7 @@ then
958 958
959dnl wonder who takes state instead of stat 959dnl wonder who takes state instead of stat
960elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \ 960elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
961 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 961 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
962then 962then
963 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 963 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
964 ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'" 964 ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
@@ -968,7 +968,7 @@ then
968 968
969dnl IRIX 53 969dnl IRIX 53
970elif ps -el 2>/dev/null | \ 970elif ps -el 2>/dev/null | \
971 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null 971 grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
972then 972then
973 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]" 973 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
974 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)" 974 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
@@ -978,7 +978,7 @@ then
978 978
979dnl IRIX 63 979dnl IRIX 63
980elif ps -el 2>/dev/null | \ 980elif ps -el 2>/dev/null | \
981 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null 981 grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
982then 982then
983 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]" 983 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
984 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)" 984 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
@@ -991,7 +991,7 @@ dnl S UID RUID USER RUSER PID PPID VSZ %CPU COMMAND
991dnl S 0 400 root oracle 2805 1 12904 0.00 ora_dism_SEA1X ora_dism_SEA1X 991dnl S 0 400 root oracle 2805 1 12904 0.00 ora_dism_SEA1X ora_dism_SEA1X
992dnl S 400 400 oracle oracle 19261 1 126488 0.00 tnslsnr /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit 992dnl S 400 400 oracle oracle 19261 1 126488 0.00 tnslsnr /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit
993elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \ 993elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \
994 egrep -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null 994 grep -E -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
995then 995then
996 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]" 996 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
997 ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'" 997 ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'"
@@ -1003,7 +1003,7 @@ dnl AIX 4.1:
1003dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD 1003dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD
1004dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper 1004dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper
1005elif ps -el 2>/dev/null | \ 1005elif ps -el 2>/dev/null | \
1006 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null 1006 grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
1007then 1007then
1008 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]" 1008 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
1009 ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)" 1009 ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
@@ -1013,7 +1013,7 @@ then
1013 1013
1014dnl AIX? 1014dnl AIX?
1015elif ps glaxen 2>/dev/null | \ 1015elif ps glaxen 2>/dev/null | \
1016 egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null 1016 grep -E -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
1017then 1017then
1018 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" 1018 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
1019 ac_cv_ps_command="$PATH_TO_PS glaxen" 1019 ac_cv_ps_command="$PATH_TO_PS glaxen"
@@ -1027,7 +1027,7 @@ dnl Some truncation will happen in UCOMM column
1027dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND 1027dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND
1028dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon 1028dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon
1029elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \ 1029elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
1030 egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null 1030 grep -E -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
1031then 1031then
1032 ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'" 1032 ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
1033 ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]" 1033 ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
@@ -1037,7 +1037,7 @@ then
1037 1037
1038dnl UnixWare 1038dnl UnixWare
1039elif ps -Al 2>/dev/null | \ 1039elif ps -Al 2>/dev/null | \
1040 egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null 1040 grep -E -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
1041then 1041then
1042 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]" 1042 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
1043 ac_cv_ps_command="$PATH_TO_PS -Al" 1043 ac_cv_ps_command="$PATH_TO_PS -Al"
@@ -1105,14 +1105,14 @@ then
1105 1105
1106elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \ 1106elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1107 $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \ 1107 $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1108 egrep -i "^round-trip|^rtt" >/dev/null 1108 grep -E -i "^round-trip|^rtt" >/dev/null
1109then 1109then
1110 with_ping_command="$PATH_TO_PING -n -U -c %d %s" 1110 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1111 ac_cv_ping_packets_first=yes 1111 ac_cv_ping_packets_first=yes
1112 AC_MSG_RESULT([$with_ping_command]) 1112 AC_MSG_RESULT([$with_ping_command])
1113 1113
1114elif $PATH_TO_PING -4 -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \ 1114elif $PATH_TO_PING -4 -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1115 egrep -i "^round-trip|^rtt" >/dev/null 1115 grep -E -i "^round-trip|^rtt" >/dev/null
1116then 1116then
1117 # check if -4 is supported - issue #1550 1117 # check if -4 is supported - issue #1550
1118 with_ping_command="$PATH_TO_PING -4 -n -U -w %d -c %d %s" 1118 with_ping_command="$PATH_TO_PING -4 -n -U -w %d -c %d %s"
@@ -1120,7 +1120,7 @@ then
1120 ac_cv_ping_has_timeout=yes 1120 ac_cv_ping_has_timeout=yes
1121 AC_MSG_RESULT([$with_ping_command]) 1121 AC_MSG_RESULT([$with_ping_command])
1122elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \ 1122elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1123 egrep -i "^round-trip|^rtt" >/dev/null 1123 grep -E -i "^round-trip|^rtt" >/dev/null
1124then 1124then
1125 with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s" 1125 with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
1126 ac_cv_ping_packets_first=yes 1126 ac_cv_ping_packets_first=yes
@@ -1128,52 +1128,52 @@ then
1128 AC_MSG_RESULT([$with_ping_command]) 1128 AC_MSG_RESULT([$with_ping_command])
1129 1129
1130elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \ 1130elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1131 egrep -i "^round-trip|^rtt" >/dev/null 1131 grep -E -i "^round-trip|^rtt" >/dev/null
1132then 1132then
1133 with_ping_command="$PATH_TO_PING -n -U -c %d %s" 1133 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1134 ac_cv_ping_packets_first=yes 1134 ac_cv_ping_packets_first=yes
1135 AC_MSG_RESULT([$with_ping_command]) 1135 AC_MSG_RESULT([$with_ping_command])
1136 1136
1137elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \ 1137elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1138 egrep -i "^round-trip|^rtt" >/dev/null 1138 grep -E -i "^round-trip|^rtt" >/dev/null
1139then 1139then
1140 with_ping_command="$PATH_TO_PING -n -c %d %s" 1140 with_ping_command="$PATH_TO_PING -n -c %d %s"
1141 ac_cv_ping_packets_first=yes 1141 ac_cv_ping_packets_first=yes
1142 AC_MSG_RESULT([$with_ping_command]) 1142 AC_MSG_RESULT([$with_ping_command])
1143 1143
1144elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \ 1144elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1145 egrep -i "^round-trip|^rtt" >/dev/null 1145 grep -E -i "^round-trip|^rtt" >/dev/null
1146then 1146then
1147 with_ping_command="$PATH_TO_PING -n %s -c %d" 1147 with_ping_command="$PATH_TO_PING -n %s -c %d"
1148 AC_MSG_RESULT([$with_ping_command]) 1148 AC_MSG_RESULT([$with_ping_command])
1149 1149
1150elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \ 1150elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1151 egrep -i "^round-trip|^rtt" >/dev/null 1151 grep -E -i "^round-trip|^rtt" >/dev/null
1152then 1152then
1153 with_ping_command="$PATH_TO_PING %s -n %d" 1153 with_ping_command="$PATH_TO_PING %s -n %d"
1154 AC_MSG_RESULT([$with_ping_command]) 1154 AC_MSG_RESULT([$with_ping_command])
1155 1155
1156elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \ 1156elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1157 egrep -i "^round-trip|^rtt" >/dev/null 1157 grep -E -i "^round-trip|^rtt" >/dev/null
1158then 1158then
1159 with_ping_command="$PATH_TO_PING -n -s %s 56 %d" 1159 with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1160 AC_MSG_RESULT([$with_ping_command]) 1160 AC_MSG_RESULT([$with_ping_command])
1161 1161
1162elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \ 1162elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1163 egrep -i "^round-trip|^rtt" >/dev/null 1163 grep -E -i "^round-trip|^rtt" >/dev/null
1164then 1164then
1165 with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d" 1165 with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1166 AC_MSG_RESULT([$with_ping_command]) 1166 AC_MSG_RESULT([$with_ping_command])
1167 1167
1168elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \ 1168elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1169 egrep -i "^round-trip|^rtt" >/dev/null 1169 grep -E -i "^round-trip|^rtt" >/dev/null
1170then 1170then
1171 with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s" 1171 with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1172 ac_cv_ping_packets_first=yes 1172 ac_cv_ping_packets_first=yes
1173 AC_MSG_RESULT([$with_ping_command]) 1173 AC_MSG_RESULT([$with_ping_command])
1174 1174
1175elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \ 1175elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1176 egrep -i "^round-trip|^rtt" >/dev/null 1176 grep -E -i "^round-trip|^rtt" >/dev/null
1177then 1177then
1178 with_ping_command="$PATH_TO_PING -n -c %d %s" 1178 with_ping_command="$PATH_TO_PING -n -c %d %s"
1179 ac_cv_ping_packets_first=yes 1179 ac_cv_ping_packets_first=yes
@@ -1229,14 +1229,14 @@ elif [[ "z$ac_cv_uname_o" = "zCygwin" -a "x$PATH_TO_PING" != "x" ]]; then
1229elif test "x$PATH_TO_PING6" != "x"; then 1229elif test "x$PATH_TO_PING6" != "x"; then
1230 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \ 1230 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1231 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \ 1231 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1232 egrep -i "^round-trip|^rtt" >/dev/null 1232 grep -E -i "^round-trip|^rtt" >/dev/null
1233 then 1233 then
1234 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s" 1234 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1235 ac_cv_ping6_packets_first=yes 1235 ac_cv_ping6_packets_first=yes
1236 AC_MSG_RESULT([$with_ping6_command]) 1236 AC_MSG_RESULT([$with_ping6_command])
1237 1237
1238 elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \ 1238 elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1239 egrep -i "^round-trip|^rtt" >/dev/null 1239 grep -E -i "^round-trip|^rtt" >/dev/null
1240 then 1240 then
1241 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s" 1241 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1242 ac_cv_ping6_packets_first=yes 1242 ac_cv_ping6_packets_first=yes
@@ -1244,52 +1244,52 @@ elif test "x$PATH_TO_PING6" != "x"; then
1244 AC_MSG_RESULT([$with_ping6_command]) 1244 AC_MSG_RESULT([$with_ping6_command])
1245 1245
1246 elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \ 1246 elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1247 egrep -i "^round-trip|^rtt" >/dev/null 1247 grep -E -i "^round-trip|^rtt" >/dev/null
1248 then 1248 then
1249 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s" 1249 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1250 ac_cv_ping6_packets_first=yes 1250 ac_cv_ping6_packets_first=yes
1251 AC_MSG_RESULT([$with_ping6_command]) 1251 AC_MSG_RESULT([$with_ping6_command])
1252 1252
1253 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \ 1253 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1254 egrep -i "^round-trip|^rtt" >/dev/null 1254 grep -E -i "^round-trip|^rtt" >/dev/null
1255 then 1255 then
1256 with_ping6_command="$PATH_TO_PING6 -n -c %d %s" 1256 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1257 ac_cv_ping6_packets_first=yes 1257 ac_cv_ping6_packets_first=yes
1258 AC_MSG_RESULT([$with_ping6_command]) 1258 AC_MSG_RESULT([$with_ping6_command])
1259 1259
1260 elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \ 1260 elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1261 egrep -i "^round-trip|^rtt" >/dev/null 1261 grep -E -i "^round-trip|^rtt" >/dev/null
1262 then 1262 then
1263 with_ping6_command="$PATH_TO_PING6 -n %s -c %d" 1263 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1264 AC_MSG_RESULT([$with_ping6_command]) 1264 AC_MSG_RESULT([$with_ping6_command])
1265 1265
1266 elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \ 1266 elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1267 egrep -i "^round-trip|^rtt" >/dev/null 1267 grep -E -i "^round-trip|^rtt" >/dev/null
1268 then 1268 then
1269 with_ping6_command="$PATH_TO_PING6 %s -n %d" 1269 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1270 AC_MSG_RESULT([$with_ping6_command]) 1270 AC_MSG_RESULT([$with_ping6_command])
1271 1271
1272 elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \ 1272 elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1273 egrep -i "^round-trip|^rtt" >/dev/null 1273 grep -E -i "^round-trip|^rtt" >/dev/null
1274 then 1274 then
1275 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d" 1275 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1276 AC_MSG_RESULT([$with_ping6_command]) 1276 AC_MSG_RESULT([$with_ping6_command])
1277 1277
1278 elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \ 1278 elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1279 egrep -i "^round-trip|^rtt" >/dev/null 1279 grep -E -i "^round-trip|^rtt" >/dev/null
1280 then 1280 then
1281 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d" 1281 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1282 AC_MSG_RESULT([$with_ping6_command]) 1282 AC_MSG_RESULT([$with_ping6_command])
1283 1283
1284 elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \ 1284 elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1285 egrep -i "^round-trip|^rtt" >/dev/null 1285 grep -E -i "^round-trip|^rtt" >/dev/null
1286 then 1286 then
1287 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s" 1287 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1288 ac_cv_ping6_packets_first=yes 1288 ac_cv_ping6_packets_first=yes
1289 AC_MSG_RESULT([$with_ping_command]) 1289 AC_MSG_RESULT([$with_ping_command])
1290 1290
1291 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \ 1291 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1292 egrep -i "^round-trip|^rtt" >/dev/null 1292 grep -E -i "^round-trip|^rtt" >/dev/null
1293 then 1293 then
1294 with_ping6_command="$PATH_TO_PING6 -n -c %d %s" 1294 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1295 ac_cv_ping6_packets_first=yes 1295 ac_cv_ping6_packets_first=yes
@@ -1300,59 +1300,59 @@ elif test "x$PATH_TO_PING6" != "x"; then
1300elif test "x$PATH_TO_PING" != "x"; then 1300elif test "x$PATH_TO_PING" != "x"; then
1301 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \ 1301 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1302 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \ 1302 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1303 egrep -i "^round-trip|^rtt" >/dev/null 1303 grep -E -i "^round-trip|^rtt" >/dev/null
1304 then 1304 then
1305 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s" 1305 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1306 ac_cv_ping6_packets_first=yes 1306 ac_cv_ping6_packets_first=yes
1307 AC_MSG_RESULT([$with_ping6_command]) 1307 AC_MSG_RESULT([$with_ping6_command])
1308 1308
1309 elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \ 1309 elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1310 egrep -i "^round-trip|^rtt" >/dev/null 1310 grep -E -i "^round-trip|^rtt" >/dev/null
1311 then 1311 then
1312 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s" 1312 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1313 ac_cv_ping6_packets_first=yes 1313 ac_cv_ping6_packets_first=yes
1314 AC_MSG_RESULT([$with_ping6_command]) 1314 AC_MSG_RESULT([$with_ping6_command])
1315 1315
1316 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \ 1316 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1317 egrep -i "^round-trip|^rtt" >/dev/null 1317 grep -E -i "^round-trip|^rtt" >/dev/null
1318 then 1318 then
1319 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s" 1319 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1320 ac_cv_ping6_packets_first=yes 1320 ac_cv_ping6_packets_first=yes
1321 AC_MSG_RESULT([$with_ping6_command]) 1321 AC_MSG_RESULT([$with_ping6_command])
1322 1322
1323 elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \ 1323 elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1324 egrep -i "^round-trip|^rtt" >/dev/null 1324 grep -E -i "^round-trip|^rtt" >/dev/null
1325 then 1325 then
1326 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d" 1326 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1327 AC_MSG_RESULT([$with_ping6_command]) 1327 AC_MSG_RESULT([$with_ping6_command])
1328 1328
1329 elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \ 1329 elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1330 egrep -i "^round-trip|^rtt" >/dev/null 1330 grep -E -i "^round-trip|^rtt" >/dev/null
1331 then 1331 then
1332 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d" 1332 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1333 AC_MSG_RESULT([$with_ping6_command]) 1333 AC_MSG_RESULT([$with_ping6_command])
1334 1334
1335 elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \ 1335 elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1336 egrep -i "^round-trip|^rtt" >/dev/null 1336 grep -E -i "^round-trip|^rtt" >/dev/null
1337 then 1337 then
1338 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d" 1338 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1339 AC_MSG_RESULT([$with_ping6_command]) 1339 AC_MSG_RESULT([$with_ping6_command])
1340 1340
1341 elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \ 1341 elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1342 egrep -i "^round-trip|^rtt" >/dev/null 1342 grep -E -i "^round-trip|^rtt" >/dev/null
1343 then 1343 then
1344 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d" 1344 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1345 AC_MSG_RESULT([$with_ping6_command]) 1345 AC_MSG_RESULT([$with_ping6_command])
1346 1346
1347 elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \ 1347 elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1348 egrep -i "^round-trip|^rtt" >/dev/null 1348 grep -E -i "^round-trip|^rtt" >/dev/null
1349 then 1349 then
1350 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s" 1350 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1351 ac_cv_ping6_packets_first=yes 1351 ac_cv_ping6_packets_first=yes
1352 AC_MSG_RESULT([$with_ping_command]) 1352 AC_MSG_RESULT([$with_ping_command])
1353 1353
1354 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \ 1354 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1355 egrep -i "^round-trip|^rtt" >/dev/null 1355 grep -E -i "^round-trip|^rtt" >/dev/null
1356 then 1356 then
1357 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s" 1357 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1358 ac_cv_ping6_packets_first=yes 1358 ac_cv_ping6_packets_first=yes
@@ -1589,14 +1589,14 @@ then
1589 ac_cv_have_swap=yes 1589 ac_cv_have_swap=yes
1590 ac_cv_swap_command="$PATH_TO_SWAP -l" 1590 ac_cv_swap_command="$PATH_TO_SWAP -l"
1591 if [$PATH_TO_SWAP -l 2>/dev/null | \ 1591 if [$PATH_TO_SWAP -l 2>/dev/null | \
1592 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \ 1592 grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1593 >/dev/null] 1593 >/dev/null]
1594 then 1594 then
1595 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"] 1595 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
1596 ac_cv_swap_conv=2048 1596 ac_cv_swap_conv=2048
1597 AC_MSG_RESULT([using IRIX format swap]) 1597 AC_MSG_RESULT([using IRIX format swap])
1598 1598
1599 elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null] 1599 elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null]
1600 then 1600 then
1601 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"] 1601 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
1602 ac_cv_swap_conv=2048 1602 ac_cv_swap_conv=2048
@@ -1615,19 +1615,19 @@ AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1615if (test -n "$PATH_TO_SWAPINFO") 1615if (test -n "$PATH_TO_SWAPINFO")
1616then 1616then
1617AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format]) 1617AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1618if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null] 1618if [$PATH_TO_SWAPINFO -k 2>&1 | grep -E -i "^Device" >/dev/null]
1619then 1619then
1620 ac_cv_have_swap=yes 1620 ac_cv_have_swap=yes
1621 ac_cv_swap_command="$PATH_TO_SWAPINFO -k" 1621 ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1622 1622
1623 if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null] 1623 if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1624 then 1624 then
1625 ac_cv_swap_format=["%*s %f %*d %f"] 1625 ac_cv_swap_format=["%*s %f %*d %f"]
1626 ac_cv_swap_conv=1024 1626 ac_cv_swap_conv=1024
1627 AC_MSG_RESULT([using FreeBSD format swapinfo]) 1627 AC_MSG_RESULT([using FreeBSD format swapinfo])
1628 fi 1628 fi
1629 1629
1630elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null] 1630elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | grep -E -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1631then 1631then
1632 ac_cv_have_swap=yes 1632 ac_cv_have_swap=yes
1633 ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM" 1633 ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
@@ -1642,7 +1642,7 @@ AC_PATH_PROG(PATH_TO_LSPS,lsps)
1642if (test -n "$PATH_TO_LSPS") 1642if (test -n "$PATH_TO_LSPS")
1643then 1643then
1644AC_MSG_CHECKING([for $PATH_TO_LSPS format]) 1644AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1645if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null] 1645if [$PATH_TO_LSPS -a 2>/dev/null | grep -E -i "^Page Space" > /dev/null]
1646then 1646then
1647 ac_cv_have_swap=yes 1647 ac_cv_have_swap=yes
1648 ac_cv_swap_command="$PATH_TO_LSPS -a" 1648 ac_cv_swap_command="$PATH_TO_LSPS -a"
@@ -1844,7 +1844,7 @@ AC_ARG_ENABLE(redhat-pthread-workaround,
1844 [ac_cv_enable_redhat_pthread_workaround=$enableval], 1844 [ac_cv_enable_redhat_pthread_workaround=$enableval],
1845 [ac_cv_enable_redhat_pthread_workaround=test]) 1845 [ac_cv_enable_redhat_pthread_workaround=test])
1846if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then 1846if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1847 if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then 1847 if echo $ac_cv_uname_r | grep -E "\.EL(smp)?$" >/dev/null 2>&1 ; then
1848 AC_MSG_NOTICE([See https://www.monitoring-plugins.org/doc/faq/configure-hangs.html if this next part takes a long time]) 1848 AC_MSG_NOTICE([See https://www.monitoring-plugins.org/doc/faq/configure-hangs.html if this next part takes a long time])
1849 AC_MSG_CHECKING(for redhat spopen problem) 1849 AC_MSG_CHECKING(for redhat spopen problem)
1850 ( cd config_test && make && make test ) > /dev/null 2>&1 1850 ( cd config_test && make && make test ) > /dev/null 2>&1
diff --git a/doc/RELEASING.md b/doc/RELEASING.md
index bcd2c5ac..58ec3e16 100644
--- a/doc/RELEASING.md
+++ b/doc/RELEASING.md
@@ -2,14 +2,14 @@ Releasing a New Monitoring Plugins Version
2========================================== 2==========================================
3 3
4Throughout this document, it is assumed that the current Monitoring 4Throughout this document, it is assumed that the current Monitoring
5Plugins version is 2.2.1, and that we're about to publish version 2.3. 5Plugins version is 2.3.2, and that we're about to publish version 2.4.
6It is also assumed that the official repository on GitHub is tracked 6It is also assumed that the official repository on GitHub is tracked
7using the remote name `monitoring-plugins` (rather than `origin`). 7using the remote name `monitoring-plugins` (rather than `origin`).
8 8
9Before you start 9Before you start
10---------------- 10----------------
11 11
12- Check Travis CI status. 12- Check Github Actions status.
13- Update local Git repository to the current `master` tip. For a 13- Update local Git repository to the current `master` tip. For a
14 maintenance release (e.g., version 2.3.2), update to the current 14 maintenance release (e.g., version 2.3.2), update to the current
15 `maint-2.3` tip, instead. 15 `maint-2.3` tip, instead.
@@ -55,7 +55,7 @@ Build the tarball
55----------------- 55-----------------
56 56
57 cd /tmp/plugins 57 cd /tmp/plugins
58 tools/setup 58 tools/setup # requires docbook to be installed
59 ./configure 59 ./configure
60 make dist 60 make dist
61 61
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index c7c9126e..4f16068a 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -28,6 +28,7 @@
28 28
29#include "common.h" 29#include "common.h"
30#include "utils_disk.h" 30#include "utils_disk.h"
31#include "gl/fsusage.h"
31 32
32void 33void
33np_add_name (struct name_list **list, const char *name) 34np_add_name (struct name_list **list, const char *name)
@@ -127,9 +128,12 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
127 size_t name_len = strlen(d->name); 128 size_t name_len = strlen(d->name);
128 size_t best_match_len = 0; 129 size_t best_match_len = 0;
129 struct mount_entry *best_match = NULL; 130 struct mount_entry *best_match = NULL;
131 struct fs_usage fsp;
130 132
131 /* set best match if path name exactly matches a mounted device name */ 133 /* set best match if path name exactly matches a mounted device name */
132 for (me = mount_list; me; me = me->me_next) { 134 for (me = mount_list; me; me = me->me_next) {
135 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
136 continue; /* skip if permissions do not suffice for accessing device */
133 if (strcmp(me->me_devname, d->name)==0) 137 if (strcmp(me->me_devname, d->name)==0)
134 best_match = me; 138 best_match = me;
135 } 139 }
@@ -137,6 +141,8 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
137 /* set best match by directory name if no match was found by devname */ 141 /* set best match by directory name if no match was found by devname */
138 if (! best_match) { 142 if (! best_match) {
139 for (me = mount_list; me; me = me->me_next) { 143 for (me = mount_list; me; me = me->me_next) {
144 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
145 continue; /* skip if permissions do not suffice for accessing device */
140 size_t len = strlen (me->me_mountdir); 146 size_t len = strlen (me->me_mountdir);
141 if ((exact == FALSE && (best_match_len <= len && len <= name_len && 147 if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
142 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) 148 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
diff --git a/pkg/solaris/solpkg b/pkg/solaris/solpkg
index a21176e4..73b3c647 100755
--- a/pkg/solaris/solpkg
+++ b/pkg/solaris/solpkg
@@ -9,7 +9,7 @@ $pkgtrans = "/usr/bin/pkgtrans";
9$prototype = "prototype"; 9$prototype = "prototype";
10$pkginfo = "pkginfo"; 10$pkginfo = "pkginfo";
11$preinstall = "preinstall"; 11$preinstall = "preinstall";
12$egrep = "/usr/bin/egrep"; 12$egrep = "/usr/bin/grep -E";
13 13
14# Sanity check 14# Sanity check
15 15
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 61198237..1f87b75f 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -213,7 +213,7 @@ static int mode, protocols, sockets, debug = 0, timeout = 10;
213static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE; 213static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE;
214static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN; 214static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN;
215 215
216static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0; 216static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0, ttl = 0;
217#define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost)) 217#define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost))
218static unsigned short targets_down = 0, targets = 0, packets = 0; 218static unsigned short targets_down = 0, targets = 0, packets = 0;
219#define targets_alive (targets - targets_down) 219#define targets_alive (targets - targets_down)
@@ -223,7 +223,6 @@ static pid_t pid;
223static struct timezone tz; 223static struct timezone tz;
224static struct timeval prog_start; 224static struct timeval prog_start;
225static unsigned long long max_completion_time = 0; 225static unsigned long long max_completion_time = 0;
226static unsigned char ttl = 0; /* outgoing ttl */
227static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */ 226static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */
228static int min_hosts_alive = -1; 227static int min_hosts_alive = -1;
229float pkt_backoff_factor = 1.5; 228float pkt_backoff_factor = 1.5;
@@ -452,6 +451,14 @@ main(int argc, char **argv)
452 packets = 5; 451 packets = 5;
453 } 452 }
454 453
454 /* support "--help" and "--version" */
455 if(argc == 2) {
456 if(!strcmp(argv[1], "--help"))
457 strcpy(argv[1], "-h");
458 if(!strcmp(argv[1], "--version"))
459 strcpy(argv[1], "-V");
460 }
461
455 /* Parse protocol arguments first */ 462 /* Parse protocol arguments first */
456 for(i = 1; i < argc; i++) { 463 for(i = 1; i < argc; i++) {
457 while((arg = getopt(argc, argv, opts_str)) != EOF) { 464 while((arg = getopt(argc, argv, opts_str)) != EOF) {
@@ -520,7 +527,7 @@ main(int argc, char **argv)
520 add_target(optarg); 527 add_target(optarg);
521 break; 528 break;
522 case 'l': 529 case 'l':
523 ttl = (unsigned char)strtoul(optarg, NULL, 0); 530 ttl = (int)strtoul(optarg, NULL, 0);
524 break; 531 break;
525 case 'm': 532 case 'm':
526 min_hosts_alive = (int)strtoul(optarg, NULL, 0); 533 min_hosts_alive = (int)strtoul(optarg, NULL, 0);
@@ -556,14 +563,6 @@ main(int argc, char **argv)
556 /* Parse extra opts if any */ 563 /* Parse extra opts if any */
557 argv=np_extra_opts(&argc, argv, progname); 564 argv=np_extra_opts(&argc, argv, progname);
558 565
559 /* support "--help" and "--version" */
560 if(argc == 2) {
561 if(!strcmp(argv[1], "--help"))
562 strcpy(argv[1], "-h");
563 if(!strcmp(argv[1], "--version"))
564 strcpy(argv[1], "-V");
565 }
566
567 argv = &argv[optind]; 566 argv = &argv[optind];
568 while(*argv) { 567 while(*argv) {
569 add_target(*argv); 568 add_target(*argv);
@@ -948,6 +947,7 @@ static int
948send_icmp_ping(int sock, struct rta_host *host) 947send_icmp_ping(int sock, struct rta_host *host)
949{ 948{
950 long int len; 949 long int len;
950 size_t addrlen;
951 struct icmp_ping_data data; 951 struct icmp_ping_data data;
952 struct msghdr hdr; 952 struct msghdr hdr;
953 struct iovec iov; 953 struct iovec iov;
@@ -979,6 +979,7 @@ send_icmp_ping(int sock, struct rta_host *host)
979 979
980 if (address_family == AF_INET) { 980 if (address_family == AF_INET) {
981 struct icmp *icp = (struct icmp*)buf; 981 struct icmp *icp = (struct icmp*)buf;
982 addrlen = sizeof(struct sockaddr_in);
982 983
983 memcpy(&icp->icmp_data, &data, sizeof(data)); 984 memcpy(&icp->icmp_data, &data, sizeof(data));
984 985
@@ -995,7 +996,10 @@ send_icmp_ping(int sock, struct rta_host *host)
995 } 996 }
996 else { 997 else {
997 struct icmp6_hdr *icp6 = (struct icmp6_hdr*)buf; 998 struct icmp6_hdr *icp6 = (struct icmp6_hdr*)buf;
999 addrlen = sizeof(struct sockaddr_in6);
1000
998 memcpy(&icp6->icmp6_dataun.icmp6_un_data8[4], &data, sizeof(data)); 1001 memcpy(&icp6->icmp6_dataun.icmp6_un_data8[4], &data, sizeof(data));
1002
999 icp6->icmp6_type = ICMP6_ECHO_REQUEST; 1003 icp6->icmp6_type = ICMP6_ECHO_REQUEST;
1000 icp6->icmp6_code = 0; 1004 icp6->icmp6_code = 0;
1001 icp6->icmp6_cksum = 0; 1005 icp6->icmp6_cksum = 0;
@@ -1016,7 +1020,7 @@ send_icmp_ping(int sock, struct rta_host *host)
1016 1020
1017 memset(&hdr, 0, sizeof(hdr)); 1021 memset(&hdr, 0, sizeof(hdr));
1018 hdr.msg_name = (struct sockaddr *)&host->saddr_in; 1022 hdr.msg_name = (struct sockaddr *)&host->saddr_in;
1019 hdr.msg_namelen = sizeof(struct sockaddr_storage); 1023 hdr.msg_namelen = addrlen;
1020 hdr.msg_iov = &iov; 1024 hdr.msg_iov = &iov;
1021 hdr.msg_iovlen = 1; 1025 hdr.msg_iovlen = 1;
1022 1026
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh
index ab4e726e..921e7b36 100755
--- a/plugins-scripts/check_sensors.sh
+++ b/plugins-scripts/check_sensors.sh
@@ -49,10 +49,10 @@ case "$1" in
49 elif test "${status}" -ne 0; then 49 elif test "${status}" -ne 0; then
50 text="WARNING - sensors returned state $status" 50 text="WARNING - sensors returned state $status"
51 exit=$STATE_WARNING 51 exit=$STATE_WARNING
52 elif echo "${sensordata}" | egrep ALARM > /dev/null; then 52 elif echo "${sensordata}" | grep -E ALARM > /dev/null; then
53 text="SENSOR CRITICAL - Sensor alarm detected!" 53 text="SENSOR CRITICAL - Sensor alarm detected!"
54 exit=$STATE_CRITICAL 54 exit=$STATE_CRITICAL
55 elif echo "${sensordata}" | egrep FAULT > /dev/null \ 55 elif echo "${sensordata}" | grep -E FAULT > /dev/null \
56 && test "$1" != "-i" -a "$1" != "--ignore-fault"; then 56 && test "$1" != "-i" -a "$1" != "--ignore-fault"; then
57 text="SENSOR UNKNOWN - Sensor reported fault" 57 text="SENSOR UNKNOWN - Sensor reported fault"
58 exit=$STATE_UNKNOWN 58 exit=$STATE_UNKNOWN
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index 731aab82..d41e2a6c 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -1,32 +1,32 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_apt plugin 3* Monitoring check_apt plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2006-2008 Monitoring Plugins Development Team 6* Copyright (c) 2006-2008 Monitoring Plugins Development Team
7* 7*
8* Original author: Sean Finney 8* Original author: Sean Finney
9* 9*
10* Description: 10* Description:
11* 11*
12* This file contains the check_apt plugin 12* This file contains the check_apt plugin
13* 13*
14* Check for available updates in apt package management systems 14* Check for available updates in apt package management systems
15* 15*
16* 16*
17* This program is free software: you can redistribute it and/or modify 17* This program is free software: you can redistribute it and/or modify
18* it under the terms of the GNU General Public License as published by 18* it under the terms of the GNU General Public License as published by
19* the Free Software Foundation, either version 3 of the License, or 19* the Free Software Foundation, either version 3 of the License, or
20* (at your option) any later version. 20* (at your option) any later version.
21* 21*
22* This program is distributed in the hope that it will be useful, 22* This program is distributed in the hope that it will be useful,
23* but WITHOUT ANY WARRANTY; without even the implied warranty of 23* but WITHOUT ANY WARRANTY; without even the implied warranty of
24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25* GNU General Public License for more details. 25* GNU General Public License for more details.
26* 26*
27* You should have received a copy of the GNU General Public License 27* You should have received a copy of the GNU General Public License
28* along with this program. If not, see <http://www.gnu.org/licenses/>. 28* along with this program. If not, see <http://www.gnu.org/licenses/>.
29* 29*
30*****************************************************************************/ 30*****************************************************************************/
31 31
32const char *progname = "check_apt"; 32const char *progname = "check_apt";
@@ -76,9 +76,9 @@ int cmpstringp(const void *p1, const void *p2);
76 76
77/* configuration variables */ 77/* configuration variables */
78static int verbose = 0; /* -v */ 78static int verbose = 0; /* -v */
79static int list = 0; /* list packages available for upgrade */ 79static bool list = false; /* list packages available for upgrade */
80static int do_update = 0; /* whether to call apt-get update */ 80static bool do_update = false; /* whether to call apt-get update */
81static int only_critical = 0; /* whether to warn about non-critical updates */ 81static bool only_critical = false; /* whether to warn about non-critical updates */
82static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */ 82static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */
83static char *upgrade_opts = NULL; /* options to override defaults for upgrade */ 83static char *upgrade_opts = NULL; /* options to override defaults for upgrade */
84static char *update_opts = NULL; /* options to override defaults for update */ 84static char *update_opts = NULL; /* options to override defaults for update */
@@ -119,7 +119,7 @@ int main (int argc, char **argv) {
119 119
120 if(sec_count > 0){ 120 if(sec_count > 0){
121 result = max_state(result, STATE_CRITICAL); 121 result = max_state(result, STATE_CRITICAL);
122 } else if(packages_available >= packages_warning && only_critical == 0){ 122 } else if(packages_available >= packages_warning && only_critical == false){
123 result = max_state(result, STATE_WARNING); 123 result = max_state(result, STATE_WARNING);
124 } else if(result > STATE_UNKNOWN){ 124 } else if(result > STATE_UNKNOWN){
125 result = STATE_UNKNOWN; 125 result = STATE_UNKNOWN;
@@ -144,7 +144,7 @@ int main (int argc, char **argv) {
144 144
145 for(i = 0; i < sec_count; i++) 145 for(i = 0; i < sec_count; i++)
146 printf("%s (security)\n", secpackages_list[i]); 146 printf("%s (security)\n", secpackages_list[i]);
147 if (only_critical == 0) { 147 if (only_critical == false) {
148 for(i = 0; i < packages_available - sec_count; i++) 148 for(i = 0; i < packages_available - sec_count; i++)
149 printf("%s\n", packages_list[i]); 149 printf("%s\n", packages_list[i]);
150 } 150 }
@@ -166,7 +166,7 @@ int process_arguments (int argc, char **argv) {
166 {"upgrade", optional_argument, 0, 'U'}, 166 {"upgrade", optional_argument, 0, 'U'},
167 {"no-upgrade", no_argument, 0, 'n'}, 167 {"no-upgrade", no_argument, 0, 'n'},
168 {"dist-upgrade", optional_argument, 0, 'd'}, 168 {"dist-upgrade", optional_argument, 0, 'd'},
169 {"list", no_argument, 0, 'l'}, 169 {"list", no_argument, false, 'l'},
170 {"include", required_argument, 0, 'i'}, 170 {"include", required_argument, 0, 'i'},
171 {"exclude", required_argument, 0, 'e'}, 171 {"exclude", required_argument, 0, 'e'},
172 {"critical", required_argument, 0, 'c'}, 172 {"critical", required_argument, 0, 'c'},
@@ -212,14 +212,14 @@ int process_arguments (int argc, char **argv) {
212 upgrade=NO_UPGRADE; 212 upgrade=NO_UPGRADE;
213 break; 213 break;
214 case 'u': 214 case 'u':
215 do_update=1; 215 do_update=true;
216 if(optarg!=NULL){ 216 if(optarg!=NULL){
217 update_opts=strdup(optarg); 217 update_opts=strdup(optarg);
218 if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed"); 218 if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed");
219 } 219 }
220 break; 220 break;
221 case 'l': 221 case 'l':
222 list=1; 222 list=true;
223 break; 223 break;
224 case 'i': 224 case 'i':
225 do_include=add_to_regexp(do_include, optarg); 225 do_include=add_to_regexp(do_include, optarg);
@@ -231,7 +231,7 @@ int process_arguments (int argc, char **argv) {
231 do_critical=add_to_regexp(do_critical, optarg); 231 do_critical=add_to_regexp(do_critical, optarg);
232 break; 232 break;
233 case 'o': 233 case 'o':
234 only_critical=1; 234 only_critical=true;
235 break; 235 break;
236 case INPUT_FILE_OPT: 236 case INPUT_FILE_OPT:
237 input_filename = optarg; 237 input_filename = optarg;
@@ -269,7 +269,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
269 die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); 269 die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf);
270 } 270 }
271 } 271 }
272 272
273 if(do_exclude!=NULL){ 273 if(do_exclude!=NULL){
274 regres=regcomp(&ereg, do_exclude, REG_EXTENDED); 274 regres=regcomp(&ereg, do_exclude, REG_EXTENDED);
275 if(regres!=0) { 275 if(regres!=0) {
@@ -278,7 +278,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
278 progname, rerrbuf); 278 progname, rerrbuf);
279 } 279 }
280 } 280 }
281 281
282 const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE; 282 const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE;
283 regres=regcomp(&sreg, crit_ptr, REG_EXTENDED); 283 regres=regcomp(&sreg, crit_ptr, REG_EXTENDED);
284 if(regres!=0) { 284 if(regres!=0) {
@@ -295,7 +295,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
295 /* run the upgrade */ 295 /* run the upgrade */
296 result = np_runcmd(cmdline, &chld_out, &chld_err, 0); 296 result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
297 } 297 }
298 298
299 /* apt-get upgrade only changes exit status if there is an 299 /* apt-get upgrade only changes exit status if there is an
300 * internal error when run in dry-run mode. therefore we will 300 * internal error when run in dry-run mode. therefore we will
301 * treat such an error as UNKNOWN */ 301 * treat such an error as UNKNOWN */
@@ -371,7 +371,7 @@ int run_update(void){
371 struct cmd_output chld_out, chld_err; 371 struct cmd_output chld_out, chld_err;
372 char *cmdline; 372 char *cmdline;
373 373
374 /* run the upgrade */ 374 /* run the update */
375 cmdline = construct_cmdline(NO_UPGRADE, update_opts); 375 cmdline = construct_cmdline(NO_UPGRADE, update_opts);
376 result = np_runcmd(cmdline, &chld_out, &chld_err, 0); 376 result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
377 /* apt-get update changes exit status if it can't fetch packages. 377 /* apt-get update changes exit status if it can't fetch packages.
@@ -501,16 +501,6 @@ print_help (void)
501 501
502 printf(UT_PLUG_TIMEOUT, timeout_interval); 502 printf(UT_PLUG_TIMEOUT, timeout_interval);
503 503
504 printf (" %s\n", "-U, --upgrade=OPTS");
505 printf (" %s\n", _("[Default] Perform an upgrade. If an optional OPTS argument is provided,"));
506 printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
507 printf (" %s", _("default "));
508 printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
509 printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
510 printf (" %s\n", _("the default options."));
511 printf (" %s\n", "-d, --dist-upgrade=OPTS");
512 printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
513 printf (" %s\n", _("can be provided to override the default options."));
514 printf (" %s\n", "-n, --no-upgrade"); 504 printf (" %s\n", "-n, --no-upgrade");
515 printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least).")); 505 printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least)."));
516 printf (" %s\n", "-l, --list"); 506 printf (" %s\n", "-l, --list");
@@ -530,7 +520,7 @@ print_help (void)
530 printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified")); 520 printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified"));
531 printf (" %s\n", _("multiple times like above. Default is a regexp matching security")); 521 printf (" %s\n", _("multiple times like above. Default is a regexp matching security"));
532 printf (" %s\n", _("upgrades for Debian and Ubuntu:")); 522 printf (" %s\n", _("upgrades for Debian and Ubuntu:"));
533 printf (" \t\%s\n", SECURITY_RE); 523 printf (" \t%s\n", SECURITY_RE);
534 printf (" %s\n", _("Note that the package must first match the include list before its")); 524 printf (" %s\n", _("Note that the package must first match the include list before its"));
535 printf (" %s\n", _("information is compared against the critical list.")); 525 printf (" %s\n", _("information is compared against the critical list."));
536 printf (" %s\n", "-o, --only-critical"); 526 printf (" %s\n", "-o, --only-critical");
@@ -547,6 +537,16 @@ print_help (void)
547 printf (" %s\n", _("the default options. Note: you may also need to adjust the global")); 537 printf (" %s\n", _("the default options. Note: you may also need to adjust the global"));
548 printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get")); 538 printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get"));
549 printf (" %s\n", _("upgrade is expected to take longer than the default timeout.")); 539 printf (" %s\n", _("upgrade is expected to take longer than the default timeout."));
540 printf (" %s\n", "-U, --upgrade=OPTS");
541 printf (" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,"));
542 printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
543 printf (" %s", _("default "));
544 printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
545 printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
546 printf (" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade"));
547 printf (" %s\n", "-d, --dist-upgrade=OPTS");
548 printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
549 printf (" %s\n", _("can be provided to override the default options."));
550 550
551 printf(UT_SUPPORT); 551 printf(UT_SUPPORT);
552} 552}
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 193657c3..4ea721b2 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -50,6 +50,7 @@ unsigned int services = 0;
50int skip_stdout = 0; 50int skip_stdout = 0;
51int skip_stderr = 0; 51int skip_stderr = 0;
52int warn_on_stderr = 0; 52int warn_on_stderr = 0;
53bool unknown_timeout = FALSE;
53char *remotecmd = NULL; 54char *remotecmd = NULL;
54char **commargv = NULL; 55char **commargv = NULL;
55int commargc = 0; 56int commargc = 0;
@@ -101,6 +102,13 @@ main (int argc, char **argv)
101 102
102 result = cmd_run_array (commargv, &chld_out, &chld_err, 0); 103 result = cmd_run_array (commargv, &chld_out, &chld_err, 0);
103 104
105 /* SSH returns 255 if connection attempt fails; include the first line of error output */
106 if (result == 255 && unknown_timeout) {
107 printf (_("SSH connection failed: %s\n"),
108 chld_err.lines > 0 ? chld_err.line[0] : "(no error output)");
109 return STATE_UNKNOWN;
110 }
111
104 if (verbose) { 112 if (verbose) {
105 for(i = 0; i < chld_out.lines; i++) 113 for(i = 0; i < chld_out.lines; i++)
106 printf("stdout: %s\n", chld_out.line[i]); 114 printf("stdout: %s\n", chld_out.line[i]);
@@ -180,6 +188,7 @@ process_arguments (int argc, char **argv)
180 {"verbose", no_argument, 0, 'v'}, 188 {"verbose", no_argument, 0, 'v'},
181 {"fork", no_argument, 0, 'f'}, 189 {"fork", no_argument, 0, 'f'},
182 {"timeout", required_argument, 0, 't'}, 190 {"timeout", required_argument, 0, 't'},
191 {"unknown-timeout", no_argument, 0, 'U'},
183 {"host", required_argument, 0, 'H'}, /* backward compatibility */ 192 {"host", required_argument, 0, 'H'}, /* backward compatibility */
184 {"hostname", required_argument, 0, 'H'}, 193 {"hostname", required_argument, 0, 'H'},
185 {"port", required_argument,0,'p'}, 194 {"port", required_argument,0,'p'},
@@ -212,7 +221,7 @@ process_arguments (int argc, char **argv)
212 strcpy (argv[c], "-t"); 221 strcpy (argv[c], "-t");
213 222
214 while (1) { 223 while (1) {
215 c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts, 224 c = getopt_long (argc, argv, "Vvh1246fqt:UH:O:p:i:u:l:C:S::E::n:s:o:F:", longopts,
216 &option); 225 &option);
217 226
218 if (c == -1 || c == EOF) 227 if (c == -1 || c == EOF)
@@ -234,6 +243,9 @@ process_arguments (int argc, char **argv)
234 else 243 else
235 timeout_interval = atoi (optarg); 244 timeout_interval = atoi (optarg);
236 break; 245 break;
246 case 'U':
247 unknown_timeout = TRUE;
248 break;
237 case 'H': /* host */ 249 case 'H': /* host */
238 hostname = optarg; 250 hostname = optarg;
239 break; 251 break;
@@ -445,6 +457,8 @@ print_help (void)
445 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]")); 457 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]"));
446 printf (UT_WARN_CRIT); 458 printf (UT_WARN_CRIT);
447 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 459 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
460 printf (" %s\n","-U, --unknown-timeout");
461 printf (" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL"));
448 printf (UT_VERBOSE); 462 printf (UT_VERBOSE);
449 printf("\n"); 463 printf("\n");
450 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with")); 464 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with"));
@@ -474,7 +488,7 @@ void
474print_usage (void) 488print_usage (void)
475{ 489{
476 printf ("%s\n", _("Usage:")); 490 printf ("%s\n", _("Usage:"));
477 printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" 491 printf (" %s -H <host> -C <command> [-fqvU] [-1|-2] [-4|-6]\n"
478 " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n" 492 " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n"
479 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" 493 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n"
480 " [-p port] [-o ssh-option] [-F configfile]\n", 494 " [-p port] [-o ssh-option] [-F configfile]\n",
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index a69854a8..55de22fd 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -476,6 +476,18 @@ check_http (void)
476 printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache); 476 printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache);
477 } 477 }
478 478
479 // If server_address is an IPv6 address it must be surround by square brackets
480 struct in6_addr tmp_in_addr;
481 if (inet_pton(AF_INET6, server_address, &tmp_in_addr) == 1) {
482 char *new_server_address = malloc(strlen(server_address) + 3);
483 if (new_server_address == NULL) {
484 die(STATE_UNKNOWN, "HTTP UNKNOWN - Unable to allocate memory\n");
485 }
486 snprintf(new_server_address, strlen(server_address)+3, "[%s]", server_address);
487 free(server_address);
488 server_address = new_server_address;
489 }
490
479 /* compose URL: use the address we want to connect to, set Host: header later */ 491 /* compose URL: use the address we want to connect to, set Host: header later */
480 snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s", 492 snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s",
481 use_ssl ? "https" : "http", 493 use_ssl ? "https" : "http",
@@ -999,10 +1011,12 @@ GOT_FIRST_CERT:
999 result = max_state_alt(get_status(total_time, thlds), result); 1011 result = max_state_alt(get_status(total_time, thlds), result);
1000 1012
1001 /* Cut-off trailing characters */ 1013 /* Cut-off trailing characters */
1002 if(msg[strlen(msg)-2] == ',') 1014 if (strlen(msg) >= 2) {
1003 msg[strlen(msg)-2] = '\0'; 1015 if(msg[strlen(msg)-2] == ',')
1004 else 1016 msg[strlen(msg)-2] = '\0';
1005 msg[strlen(msg)-3] = '\0'; 1017 else
1018 msg[strlen(msg)-3] = '\0';
1019 }
1006 1020
1007 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */ 1021 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
1008 die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s", 1022 die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
@@ -2010,9 +2024,12 @@ curlhelp_buffer_write_callback (void *buffer, size_t size, size_t nmemb, void *s
2010 curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream; 2024 curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream;
2011 2025
2012 while (buf->bufsize < buf->buflen + size * nmemb + 1) { 2026 while (buf->bufsize < buf->buflen + size * nmemb + 1) {
2013 buf->bufsize *= buf->bufsize * 2; 2027 buf->bufsize = buf->bufsize * 2;
2014 buf->buf = (char *)realloc (buf->buf, buf->bufsize); 2028 buf->buf = (char *)realloc (buf->buf, buf->bufsize);
2015 if (buf->buf == NULL) return -1; 2029 if (buf->buf == NULL) {
2030 fprintf(stderr, "malloc failed (%d) %s\n", errno, strerror(errno));
2031 return -1;
2032 }
2016 } 2033 }
2017 2034
2018 memcpy (buf->buf + buf->buflen, buffer, size * nmemb); 2035 memcpy (buf->buf + buf->buflen, buffer, size * nmemb);
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 66c5dd39..7018c6fd 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -171,7 +171,6 @@ main (int argc, char **argv)
171 char *perf_ilabel; 171 char *perf_ilabel;
172 char *preamble; 172 char *preamble;
173 char *flag_header; 173 char *flag_header;
174 double inode_space_pct;
175 int temp_result; 174 int temp_result;
176 175
177 struct mount_entry *me; 176 struct mount_entry *me;
@@ -288,7 +287,7 @@ main (int argc, char **argv)
288 get_stats (path, &fsp); 287 get_stats (path, &fsp);
289 288
290 if (verbose >= 3) { 289 if (verbose >= 3) {
291 printf ("For %s, used_pct=%g free_pct=%g used_units=%llu free_units=%llu total_units=%llu used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n", 290 printf ("For %s, used_pct=%g free_pct=%g used_units=%lu free_units=%lu total_units=%lu used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%lu mult=%lu\n",
292 me->me_mountdir, 291 me->me_mountdir,
293 path->dused_pct, 292 path->dused_pct,
294 path->dfree_pct, 293 path->dfree_pct,
@@ -369,10 +368,10 @@ main (int argc, char **argv)
369 critical_high_tide = UINT64_MAX; 368 critical_high_tide = UINT64_MAX;
370 369
371 if (path->freeinodes_percent->warning != NULL) { 370 if (path->freeinodes_percent->warning != NULL) {
372 warning_high_tide = llabs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total )); 371 warning_high_tide = (uint64_t) fabs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total ));
373 } 372 }
374 if (path->freeinodes_percent->critical != NULL) { 373 if (path->freeinodes_percent->critical != NULL) {
375 critical_high_tide = llabs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total )); 374 critical_high_tide = (uint64_t) fabs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total ));
376 } 375 }
377 376
378 xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir); 377 xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
@@ -406,15 +405,7 @@ main (int argc, char **argv)
406 xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : "")); 405 xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : ""));
407 } 406 }
408 free(flag_header); 407 free(flag_header);
409 /* TODO: Need to do a similar debug line
410 xasprintf (&details, _("%s\n\%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
411 details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct,
412 me->me_devname, me->me_type, me->me_mountdir,
413 (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp);
414 */
415
416 } 408 }
417
418 } 409 }
419 410
420 if (verbose >= 2) 411 if (verbose >= 2)
@@ -689,6 +680,7 @@ process_arguments (int argc, char **argv)
689 break; 680 break;
690 case 'I': 681 case 'I':
691 cflags |= REG_ICASE; 682 cflags |= REG_ICASE;
683 // Intentional fallthrough
692 case 'i': 684 case 'i':
693 if (!path_selected) 685 if (!path_selected)
694 die (STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly")); 686 die (STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly"));
@@ -728,8 +720,10 @@ process_arguments (int argc, char **argv)
728 720
729 case 'A': 721 case 'A':
730 optarg = strdup(".*"); 722 optarg = strdup(".*");
723 // Intentional fallthrough
731 case 'R': 724 case 'R':
732 cflags |= REG_ICASE; 725 cflags |= REG_ICASE;
726 // Intentional fallthrough
733 case 'r': 727 case 'r':
734 if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent || 728 if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent ||
735 crit_freespace_percent || warn_usedspace_units || crit_usedspace_units || 729 crit_freespace_percent || warn_usedspace_units || crit_usedspace_units ||
@@ -862,51 +856,6 @@ set_all_thresholds (struct parameter_list *path)
862 set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); 856 set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent);
863} 857}
864 858
865/* TODO: Remove?
866
867int
868validate_arguments (uintmax_t w, uintmax_t c, double wp, double cp, double iwp, double icp, char *mypath)
869{
870 if (w < 0 && c < 0 && wp < 0.0 && cp < 0.0) {
871 printf (_("INPUT ERROR: No thresholds specified"));
872 print_path (mypath);
873 return ERROR;
874 }
875 else if ((wp >= 0.0 || cp >= 0.0) &&
876 (wp < 0.0 || cp < 0.0 || wp > 100.0 || cp > 100.0 || cp > wp)) {
877 printf (_("\
878INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"),
879 cp, wp);
880 print_path (mypath);
881 return ERROR;
882 }
883 else if ((iwp >= 0.0 || icp >= 0.0) &&
884 (iwp < 0.0 || icp < 0.0 || iwp > 100.0 || icp > 100.0 || icp > iwp)) {
885 printf (_("\
886INPUT ERROR: C_IDFP (%f) should be less than W_IDFP (%.1f) and both should be between zero and 100 percent, inclusive"),
887 icp, iwp);
888 print_path (mypath);
889 return ERROR;
890 }
891 else if ((w > 0 || c > 0) && (w == 0 || c == 0 || c > w)) {
892 printf (_("\
893INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"),
894 (unsigned long)c, (unsigned long)w);
895 print_path (mypath);
896 return ERROR;
897 }
898
899 return OK;
900}
901
902*/
903
904
905
906
907
908
909
910void 859void
911print_help (void) 860print_help (void)
912{ 861{
@@ -1042,7 +991,7 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
1042 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); 991 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp);
1043 get_path_stats(p_list, &tmpfsp); 992 get_path_stats(p_list, &tmpfsp);
1044 if (verbose >= 3) 993 if (verbose >= 3)
1045 printf("Group %s: adding %llu blocks sized %llu, (%s) used_units=%lu free_units=%llu total_units=%llu mult=%llu\n", 994 printf("Group %s: adding %lu blocks sized %lu, (%s) used_units=%lu free_units=%lu total_units=%lu mult=%lu\n",
1046 p_list->group, 995 p_list->group,
1047 tmpfsp.fsu_blocks, 996 tmpfsp.fsu_blocks,
1048 tmpfsp.fsu_blocksize, 997 tmpfsp.fsu_blocksize,
@@ -1071,7 +1020,7 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
1071 first = 0; 1020 first = 0;
1072 } 1021 }
1073 if (verbose >= 3) 1022 if (verbose >= 3)
1074 printf("Group %s now has: used_units=%llu free_units=%llu total_units=%llu fsu_blocksize=%llu mult=%llu\n", 1023 printf("Group %s now has: used_units=%lu free_units=%lu total_units=%lu fsu_blocksize=%lu mult=%lu\n",
1075 p->group, 1024 p->group,
1076 p->dused_units, 1025 p->dused_units,
1077 p->dfree_units, 1026 p->dfree_units,
diff --git a/plugins/check_http.c b/plugins/check_http.c
index f8ec853b..a9c22389 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -31,13 +31,14 @@
31* 31*
32*****************************************************************************/ 32*****************************************************************************/
33 33
34/* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */
35
36const char *progname = "check_http"; 34const char *progname = "check_http";
37const char *copyright = "1999-2013"; 35const char *copyright = "1999-2022";
38const char *email = "devel@monitoring-plugins.org"; 36const char *email = "devel@monitoring-plugins.org";
39 37
38// Do NOT sort those headers, it will break the build
39// TODO: Fix this
40#include "common.h" 40#include "common.h"
41#include "base64.h"
41#include "netutils.h" 42#include "netutils.h"
42#include "utils.h" 43#include "utils.h"
43#include "base64.h" 44#include "base64.h"
@@ -57,8 +58,8 @@ enum {
57}; 58};
58 59
59#ifdef HAVE_SSL 60#ifdef HAVE_SSL
60int check_cert = FALSE; 61bool check_cert = false;
61int continue_after_check_cert = FALSE; 62bool continue_after_check_cert = false;
62int ssl_version = 0; 63int ssl_version = 0;
63int days_till_exp_warn, days_till_exp_crit; 64int days_till_exp_warn, days_till_exp_crit;
64char *randbuff; 65char *randbuff;
@@ -69,7 +70,7 @@ X509 *server_cert;
69# define my_recv(buf, len) read(sd, buf, len) 70# define my_recv(buf, len) read(sd, buf, len)
70# define my_send(buf, len) send(sd, buf, len, 0) 71# define my_send(buf, len) send(sd, buf, len, 0)
71#endif /* HAVE_SSL */ 72#endif /* HAVE_SSL */
72int no_body = FALSE; 73bool no_body = false;
73int maximum_age = -1; 74int maximum_age = -1;
74 75
75enum { 76enum {
@@ -91,7 +92,7 @@ struct timeval tv_temp;
91#define HTTP_URL "/" 92#define HTTP_URL "/"
92#define CRLF "\r\n" 93#define CRLF "\r\n"
93 94
94int specify_port = FALSE; 95bool specify_port = false;
95int server_port = HTTP_PORT; 96int server_port = HTTP_PORT;
96int virtual_port = 0; 97int virtual_port = 0;
97char server_port_text[6] = ""; 98char server_port_text[6] = "";
@@ -106,23 +107,21 @@ int server_expect_yn = 0;
106char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; 107char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
107char header_expect[MAX_INPUT_BUFFER] = ""; 108char header_expect[MAX_INPUT_BUFFER] = "";
108char string_expect[MAX_INPUT_BUFFER] = ""; 109char string_expect[MAX_INPUT_BUFFER] = "";
109char output_header_search[30] = "";
110char output_string_search[30] = "";
111char *warning_thresholds = NULL; 110char *warning_thresholds = NULL;
112char *critical_thresholds = NULL; 111char *critical_thresholds = NULL;
113thresholds *thlds; 112thresholds *thlds;
114char user_auth[MAX_INPUT_BUFFER] = ""; 113char user_auth[MAX_INPUT_BUFFER] = "";
115char proxy_auth[MAX_INPUT_BUFFER] = ""; 114char proxy_auth[MAX_INPUT_BUFFER] = "";
116int display_html = FALSE; 115bool display_html = false;
117char **http_opt_headers; 116char **http_opt_headers;
118int http_opt_headers_count = 0; 117int http_opt_headers_count = 0;
119int onredirect = STATE_OK; 118int onredirect = STATE_OK;
120int followsticky = STICKY_NONE; 119int followsticky = STICKY_NONE;
121int use_ssl = FALSE; 120bool use_ssl = false;
122int use_sni = FALSE; 121bool use_sni = false;
123int verbose = FALSE; 122bool verbose = false;
124int show_extended_perfdata = FALSE; 123bool show_extended_perfdata = false;
125int show_body = FALSE; 124bool show_body = false;
126int sd; 125int sd;
127int min_page_len = 0; 126int min_page_len = 0;
128int max_page_len = 0; 127int max_page_len = 0;
@@ -136,10 +135,11 @@ char buffer[MAX_INPUT_BUFFER];
136char *client_cert = NULL; 135char *client_cert = NULL;
137char *client_privkey = NULL; 136char *client_privkey = NULL;
138 137
139int process_arguments (int, char **); 138// Forward function declarations
139bool process_arguments (int, char **);
140int check_http (void); 140int check_http (void);
141void redir (char *pos, char *status_line); 141void redir (char *pos, char *status_line);
142int server_type_check(const char *type); 142bool server_type_check(const char *type);
143int server_port_check(int ssl_flag); 143int server_port_check(int ssl_flag);
144char *perfd_time (double microsec); 144char *perfd_time (double microsec);
145char *perfd_time_connect (double microsec); 145char *perfd_time_connect (double microsec);
@@ -150,6 +150,7 @@ char *perfd_time_transfer (double microsec);
150char *perfd_size (int page_len); 150char *perfd_size (int page_len);
151void print_help (void); 151void print_help (void);
152void print_usage (void); 152void print_usage (void);
153char *unchunk_content(const char *content);
153 154
154int 155int
155main (int argc, char **argv) 156main (int argc, char **argv)
@@ -169,10 +170,10 @@ main (int argc, char **argv)
169 /* Parse extra opts if any */ 170 /* Parse extra opts if any */
170 argv=np_extra_opts (&argc, argv, progname); 171 argv=np_extra_opts (&argc, argv, progname);
171 172
172 if (process_arguments (argc, argv) == ERROR) 173 if (process_arguments (argc, argv) == false)
173 usage4 (_("Could not parse arguments")); 174 usage4 (_("Could not parse arguments"));
174 175
175 if (display_html == TRUE) 176 if (display_html == true)
176 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">", 177 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">",
177 use_ssl ? "https" : "http", host_name ? host_name : server_address, 178 use_ssl ? "https" : "http", host_name ? host_name : server_address,
178 server_port, server_url); 179 server_port, server_url);
@@ -195,9 +196,11 @@ test_file (char *path)
195 usage2 (_("file does not exist or is not readable"), path); 196 usage2 (_("file does not exist or is not readable"), path);
196} 197}
197 198
198/* process command-line arguments */ 199/*
199int 200 * process command-line arguments
200process_arguments (int argc, char **argv) 201 * returns true on succes, false otherwise
202 */
203bool process_arguments (int argc, char **argv)
201{ 204{
202 int c = 1; 205 int c = 1;
203 char *p; 206 char *p;
@@ -252,7 +255,7 @@ process_arguments (int argc, char **argv)
252 }; 255 };
253 256
254 if (argc < 2) 257 if (argc < 2)
255 return ERROR; 258 return false;
256 259
257 for (c = 1; c < argc; c++) { 260 for (c = 1; c < argc; c++) {
258 if (strcmp ("-to", argv[c]) == 0) 261 if (strcmp ("-to", argv[c]) == 0)
@@ -308,10 +311,10 @@ process_arguments (int argc, char **argv)
308 /* xasprintf (&http_opt_headers, "%s", optarg); */ 311 /* xasprintf (&http_opt_headers, "%s", optarg); */
309 break; 312 break;
310 case 'L': /* show html link */ 313 case 'L': /* show html link */
311 display_html = TRUE; 314 display_html = true;
312 break; 315 break;
313 case 'n': /* do not show html link */ 316 case 'n': /* do not show html link */
314 display_html = FALSE; 317 display_html = false;
315 break; 318 break;
316 case 'C': /* Check SSL cert validity */ 319 case 'C': /* Check SSL cert validity */
317#ifdef HAVE_SSL 320#ifdef HAVE_SSL
@@ -332,12 +335,12 @@ process_arguments (int argc, char **argv)
332 usage2 (_("Invalid certificate expiration period"), optarg); 335 usage2 (_("Invalid certificate expiration period"), optarg);
333 days_till_exp_warn = atoi (optarg); 336 days_till_exp_warn = atoi (optarg);
334 } 337 }
335 check_cert = TRUE; 338 check_cert = true;
336 goto enable_ssl; 339 goto enable_ssl;
337#endif 340#endif
338 case CONTINUE_AFTER_CHECK_CERT: /* don't stop after the certificate is checked */ 341 case CONTINUE_AFTER_CHECK_CERT: /* don't stop after the certificate is checked */
339#ifdef HAVE_SSL 342#ifdef HAVE_SSL
340 continue_after_check_cert = TRUE; 343 continue_after_check_cert = true;
341 break; 344 break;
342#endif 345#endif
343 case 'J': /* use client certificate */ 346 case 'J': /* use client certificate */
@@ -357,7 +360,7 @@ process_arguments (int argc, char **argv)
357 enable_ssl: 360 enable_ssl:
358 /* ssl_version initialized to 0 as a default. Only set if it's non-zero. This helps when we include multiple 361 /* ssl_version initialized to 0 as a default. Only set if it's non-zero. This helps when we include multiple
359 parameters, like -S and -C combinations */ 362 parameters, like -S and -C combinations */
360 use_ssl = TRUE; 363 use_ssl = true;
361 if (c=='S' && optarg != NULL) { 364 if (c=='S' && optarg != NULL) {
362 int got_plus = strchr(optarg, '+') != NULL; 365 int got_plus = strchr(optarg, '+') != NULL;
363 366
@@ -374,7 +377,7 @@ process_arguments (int argc, char **argv)
374 else 377 else
375 usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)")); 378 usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)"));
376 } 379 }
377 if (specify_port == FALSE) 380 if (specify_port == false)
378 server_port = HTTPS_PORT; 381 server_port = HTTPS_PORT;
379#else 382#else
380 /* -C -J and -K fall through to here without SSL */ 383 /* -C -J and -K fall through to here without SSL */
@@ -382,7 +385,7 @@ process_arguments (int argc, char **argv)
382#endif 385#endif
383 break; 386 break;
384 case SNI_OPTION: 387 case SNI_OPTION:
385 use_sni = TRUE; 388 use_sni = true;
386 break; 389 break;
387 case MAX_REDIRS_OPTION: 390 case MAX_REDIRS_OPTION:
388 if (!is_intnonneg (optarg)) 391 if (!is_intnonneg (optarg))
@@ -420,7 +423,7 @@ process_arguments (int argc, char **argv)
420 host_name_length = strlen (host_name) - strlen (p) - 1; 423 host_name_length = strlen (host_name) - strlen (p) - 1;
421 free (host_name); 424 free (host_name);
422 host_name = strndup (optarg, host_name_length); 425 host_name = strndup (optarg, host_name_length);
423 if (specify_port == FALSE) 426 if (specify_port == false)
424 server_port = virtual_port; 427 server_port = virtual_port;
425 } 428 }
426 } else if ((p = strchr (host_name, ':')) != NULL 429 } else if ((p = strchr (host_name, ':')) != NULL
@@ -430,7 +433,7 @@ process_arguments (int argc, char **argv)
430 host_name_length = strlen (host_name) - strlen (p) - 1; 433 host_name_length = strlen (host_name) - strlen (p) - 1;
431 free (host_name); 434 free (host_name);
432 host_name = strndup (optarg, host_name_length); 435 host_name = strndup (optarg, host_name_length);
433 if (specify_port == FALSE) 436 if (specify_port == false)
434 server_port = virtual_port; 437 server_port = virtual_port;
435 } 438 }
436 break; 439 break;
@@ -446,7 +449,7 @@ process_arguments (int argc, char **argv)
446 usage2 (_("Invalid port number"), optarg); 449 usage2 (_("Invalid port number"), optarg);
447 else { 450 else {
448 server_port = atoi (optarg); 451 server_port = atoi (optarg);
449 specify_port = TRUE; 452 specify_port = true;
450 } 453 }
451 break; 454 break;
452 case 'a': /* authorization info */ 455 case 'a': /* authorization info */
@@ -502,7 +505,7 @@ process_arguments (int argc, char **argv)
502 if (errcode != 0) { 505 if (errcode != 0) {
503 (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); 506 (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
504 printf (_("Could Not Compile Regular Expression: %s"), errbuf); 507 printf (_("Could Not Compile Regular Expression: %s"), errbuf);
505 return ERROR; 508 return false;
506 } 509 }
507 break; 510 break;
508 case INVERT_REGEX: 511 case INVERT_REGEX:
@@ -519,7 +522,7 @@ process_arguments (int argc, char **argv)
519#endif 522#endif
520 break; 523 break;
521 case 'v': /* verbose */ 524 case 'v': /* verbose */
522 verbose = TRUE; 525 verbose = true;
523 break; 526 break;
524 case 'm': /* min_page_length */ 527 case 'm': /* min_page_length */
525 { 528 {
@@ -544,7 +547,7 @@ process_arguments (int argc, char **argv)
544 break; 547 break;
545 } 548 }
546 case 'N': /* no-body */ 549 case 'N': /* no-body */
547 no_body = TRUE; 550 no_body = true;
548 break; 551 break;
549 case 'M': /* max-age */ 552 case 'M': /* max-age */
550 { 553 {
@@ -565,10 +568,10 @@ process_arguments (int argc, char **argv)
565 } 568 }
566 break; 569 break;
567 case 'E': /* show extended perfdata */ 570 case 'E': /* show extended perfdata */
568 show_extended_perfdata = TRUE; 571 show_extended_perfdata = true;
569 break; 572 break;
570 case 'B': /* print body content after status line */ 573 case 'B': /* print body content after status line */
571 show_body = TRUE; 574 show_body = true;
572 break; 575 break;
573 } 576 }
574 } 577 }
@@ -605,7 +608,7 @@ process_arguments (int argc, char **argv)
605 if (virtual_port == 0) 608 if (virtual_port == 0)
606 virtual_port = server_port; 609 virtual_port = server_port;
607 610
608 return TRUE; 611 return true;
609} 612}
610 613
611 614
@@ -945,7 +948,7 @@ check_http (void)
945 /* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */ 948 /* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */
946 949
947 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 950 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
948 && host_name != NULL && use_ssl == TRUE) { 951 && host_name != NULL && use_ssl == true) {
949 952
950 if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT); 953 if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT);
951 asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent); 954 asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent);
@@ -979,7 +982,7 @@ check_http (void)
979 } 982 }
980#ifdef HAVE_SSL 983#ifdef HAVE_SSL
981 elapsed_time_connect = (double)microsec_connect / 1.0e6; 984 elapsed_time_connect = (double)microsec_connect / 1.0e6;
982 if (use_ssl == TRUE) { 985 if (use_ssl == true) {
983 gettimeofday (&tv_temp, NULL); 986 gettimeofday (&tv_temp, NULL);
984 result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey); 987 result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey);
985 if (verbose) printf ("SSL initialized\n"); 988 if (verbose) printf ("SSL initialized\n");
@@ -987,9 +990,9 @@ check_http (void)
987 die (STATE_CRITICAL, NULL); 990 die (STATE_CRITICAL, NULL);
988 microsec_ssl = deltime (tv_temp); 991 microsec_ssl = deltime (tv_temp);
989 elapsed_time_ssl = (double)microsec_ssl / 1.0e6; 992 elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
990 if (check_cert == TRUE) { 993 if (check_cert == true) {
991 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); 994 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
992 if (continue_after_check_cert == FALSE) { 995 if (continue_after_check_cert == false) {
993 if (sd) close(sd); 996 if (sd) close(sd);
994 np_net_ssl_cleanup(); 997 np_net_ssl_cleanup();
995 return result; 998 return result;
@@ -999,7 +1002,7 @@ check_http (void)
999#endif /* HAVE_SSL */ 1002#endif /* HAVE_SSL */
1000 1003
1001 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 1004 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
1002 && host_name != NULL && use_ssl == TRUE) 1005 && host_name != NULL && use_ssl == true)
1003 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method_proxy, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); 1006 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method_proxy, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
1004 else 1007 else
1005 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); 1008 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
@@ -1027,10 +1030,10 @@ check_http (void)
1027 * 14.23). Some server applications/configurations cause trouble if the 1030 * 14.23). Some server applications/configurations cause trouble if the
1028 * (default) port is explicitly specified in the "Host:" header line. 1031 * (default) port is explicitly specified in the "Host:" header line.
1029 */ 1032 */
1030 if ((use_ssl == FALSE && virtual_port == HTTP_PORT) || 1033 if ((use_ssl == false && virtual_port == HTTP_PORT) ||
1031 (use_ssl == TRUE && virtual_port == HTTPS_PORT) || 1034 (use_ssl == true && virtual_port == HTTPS_PORT) ||
1032 (server_address != NULL && strcmp(http_method, "CONNECT") == 0 1035 (server_address != NULL && strcmp(http_method, "CONNECT") == 0
1033 && host_name != NULL && use_ssl == TRUE)) 1036 && host_name != NULL && use_ssl == true))
1034 xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); 1037 xasprintf (&buf, "%sHost: %s\r\n", buf, host_name);
1035 else 1038 else
1036 xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port); 1039 xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port);
@@ -1070,9 +1073,8 @@ check_http (void)
1070 } 1073 }
1071 1074
1072 xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data)); 1075 xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
1073 xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); 1076 xasprintf (&buf, "%s%s", buf, http_post_data);
1074 } 1077 } else {
1075 else {
1076 /* or just a newline so the server knows we're done with the request */ 1078 /* or just a newline so the server knows we're done with the request */
1077 xasprintf (&buf, "%s%s", buf, CRLF); 1079 xasprintf (&buf, "%s%s", buf, CRLF);
1078 } 1080 }
@@ -1096,9 +1098,14 @@ check_http (void)
1096 *pos = ' '; 1098 *pos = ' ';
1097 } 1099 }
1098 buffer[i] = '\0'; 1100 buffer[i] = '\0';
1099 xasprintf (&full_page_new, "%s%s", full_page, buffer); 1101
1100 free (full_page); 1102 if ((full_page_new = realloc(full_page, pagesize + i + 1)) == NULL)
1103 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate memory for full_page\n"));
1104
1105 memmove(&full_page_new[pagesize], buffer, i + 1);
1106
1101 full_page = full_page_new; 1107 full_page = full_page_new;
1108
1102 pagesize += i; 1109 pagesize += i;
1103 1110
1104 if (no_body && document_headers_done (full_page)) { 1111 if (no_body && document_headers_done (full_page)) {
@@ -1110,25 +1117,7 @@ check_http (void)
1110 elapsed_time_transfer = (double)microsec_transfer / 1.0e6; 1117 elapsed_time_transfer = (double)microsec_transfer / 1.0e6;
1111 1118
1112 if (i < 0 && errno != ECONNRESET) { 1119 if (i < 0 && errno != ECONNRESET) {
1113#ifdef HAVE_SSL 1120 die(STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
1114 /*
1115 if (use_ssl) {
1116 sslerr=SSL_get_error(ssl, i);
1117 if ( sslerr == SSL_ERROR_SSL ) {
1118 die (STATE_WARNING, _("HTTP WARNING - Client Certificate Required\n"));
1119 } else {
1120 die (STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
1121 }
1122 }
1123 else {
1124 */
1125#endif
1126 die (STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
1127#ifdef HAVE_SSL
1128 /* XXX
1129 }
1130 */
1131#endif
1132 } 1121 }
1133 1122
1134 /* return a CRITICAL status if we couldn't read any data */ 1123 /* return a CRITICAL status if we couldn't read any data */
@@ -1253,32 +1242,73 @@ check_http (void)
1253 } 1242 }
1254 1243
1255 /* Page and Header content checks go here */ 1244 /* Page and Header content checks go here */
1256 if (strlen (header_expect)) { 1245 if (strlen(header_expect) > 0) {
1257 if (!strstr (header, header_expect)) { 1246 if (strstr(header, header_expect) == NULL) {
1258 strncpy(&output_header_search[0],header_expect,sizeof(output_header_search)); 1247 // We did not find the header, the rest is for building the output and setting the state
1259 if(output_header_search[sizeof(output_header_search)-1]!='\0') { 1248 char output_header_search[30] = "";
1260 bcopy("...",&output_header_search[sizeof(output_header_search)-4],4); 1249
1250 strncpy(&output_header_search[0], header_expect,
1251 sizeof(output_header_search));
1252
1253 if (output_header_search[sizeof(output_header_search) - 1] != '\0') {
1254 bcopy("...",
1255 &output_header_search[sizeof(output_header_search) - 4],
1256 4);
1261 } 1257 }
1262 xasprintf (&msg, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); 1258
1259 xasprintf (&msg,
1260 _("%sheader '%s' not found on '%s://%s:%d%s', "),
1261 msg,
1262 output_header_search, use_ssl ? "https" : "http",
1263 host_name ? host_name : server_address, server_port,
1264 server_url);
1265
1263 result = STATE_CRITICAL; 1266 result = STATE_CRITICAL;
1264 } 1267 }
1265 } 1268 }
1266 1269
1270 // At this point we should test if the content is chunked and unchunk it, so
1271 // it can be searched (and possibly printed)
1272 const char *chunked_header_regex_string = "Transfer-Encoding: *chunked *";
1273 regex_t chunked_header_regex;
1274
1275 if (regcomp(&chunked_header_regex, chunked_header_regex_string, REG_ICASE)) {
1276 die(STATE_UNKNOWN, "HTTP %s: %s\n", state_text(STATE_UNKNOWN), "Failed to compile chunked_header_regex regex");
1277 }
1278
1279 regmatch_t chre_pmatch[1]; // We actually do not care about this, since we only want to know IF it was found
1280
1281 if (regexec(&chunked_header_regex, header, 1, chre_pmatch, 0) == 0) {
1282 if (verbose) {
1283 printf("Found chunked content\n");
1284 }
1285 // We actually found the chunked header
1286 char *tmp = unchunk_content(page);
1287 if (tmp == NULL) {
1288 die(STATE_UNKNOWN, "HTTP %s: %s\n", state_text(STATE_UNKNOWN), "Failed to unchunk message body");
1289 }
1290 page = tmp;
1291 }
1267 1292
1268 if (strlen (string_expect)) { 1293 if (strlen(string_expect) > 0) {
1269 if (!strstr (page, string_expect)) { 1294 if (!strstr(page, string_expect)) {
1270 strncpy(&output_string_search[0],string_expect,sizeof(output_string_search)); 1295 // We found the string the body, the rest is for building the output
1271 if(output_string_search[sizeof(output_string_search)-1]!='\0') { 1296 char output_string_search[30] = "";
1272 bcopy("...",&output_string_search[sizeof(output_string_search)-4],4); 1297 strncpy(&output_string_search[0], string_expect,
1298 sizeof(output_string_search));
1299 if (output_string_search[sizeof(output_string_search) - 1] != '\0') {
1300 bcopy("...", &output_string_search[sizeof(output_string_search) - 4],
1301 4);
1273 } 1302 }
1274 xasprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); 1303 xasprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
1275 result = STATE_CRITICAL; 1304 result = STATE_CRITICAL;
1276 } 1305 }
1277 } 1306 }
1278 1307
1279 if (strlen (regexp)) { 1308 if (strlen(regexp) > 0) {
1280 errcode = regexec (&preg, page, REGS, pmatch, 0); 1309 errcode = regexec(&preg, page, REGS, pmatch, 0);
1281 if ((errcode == 0 && invert_regex == 0) || (errcode == REG_NOMATCH && invert_regex == 1)) { 1310 if ((errcode == 0 && invert_regex == 0) ||
1311 (errcode == REG_NOMATCH && invert_regex == 1)) {
1282 /* OK - No-op to avoid changing the logic around it */ 1312 /* OK - No-op to avoid changing the logic around it */
1283 result = max_state_alt(STATE_OK, result); 1313 result = max_state_alt(STATE_OK, result);
1284 } 1314 }
@@ -1330,7 +1360,7 @@ check_http (void)
1330 perfd_time (elapsed_time), 1360 perfd_time (elapsed_time),
1331 perfd_size (page_len), 1361 perfd_size (page_len),
1332 perfd_time_connect (elapsed_time_connect), 1362 perfd_time_connect (elapsed_time_connect),
1333 use_ssl == TRUE ? perfd_time_ssl (elapsed_time_ssl) : "", 1363 use_ssl == true ? perfd_time_ssl (elapsed_time_ssl) : "",
1334 perfd_time_headers (elapsed_time_headers), 1364 perfd_time_headers (elapsed_time_headers),
1335 perfd_time_firstbyte (elapsed_time_firstbyte), 1365 perfd_time_firstbyte (elapsed_time_firstbyte),
1336 perfd_time_transfer (elapsed_time_transfer)); 1366 perfd_time_transfer (elapsed_time_transfer));
@@ -1352,7 +1382,88 @@ check_http (void)
1352 return STATE_UNKNOWN; 1382 return STATE_UNKNOWN;
1353} 1383}
1354 1384
1385/* Receivces a pointer to the beginning of the body of a HTTP message
1386 * which is chunked and returns a pointer to a freshly allocated memory
1387 * region containing the unchunked body or NULL if something failed.
1388 * The result must be freed by the caller.
1389 */
1390char *unchunk_content(const char *content) {
1391 // https://en.wikipedia.org/wiki/Chunked_transfer_encoding
1392 // https://www.rfc-editor.org/rfc/rfc7230#section-4.1
1393 char *result = NULL;
1394 size_t content_length = strlen(content);
1395 char *start_of_chunk;
1396 char* end_of_chunk;
1397 long size_of_chunk;
1398 const char *pointer = content;
1399 char *endptr;
1400 long length_of_chunk = 0;
1401 size_t overall_size = 0;
1402 char *result_ptr;
1403
1404 while (true) {
1405 size_of_chunk = strtol(pointer, &endptr, 16);
1406 if (size_of_chunk == LONG_MIN || size_of_chunk == LONG_MAX) {
1407 // Apparently underflow or overflow, should not happen
1408 if (verbose) {
1409 printf("Got an underflow or overflow from strtol at: %u\n", __LINE__);
1410 }
1411 return NULL;
1412 }
1413 if (endptr == pointer) {
1414 // Apparently this was not a number
1415 if (verbose) {
1416 printf("Chunked content did not start with a number at all (Line: %u)\n", __LINE__);
1417 }
1418 return NULL;
1419 }
1420
1421 // So, we got the length of the chunk
1422 if (*endptr == ';') {
1423 // Chunk extension starts here
1424 while (*endptr != '\r') {
1425 endptr++;
1426 }
1427 }
1428
1429 start_of_chunk = endptr + 2;
1430 end_of_chunk = start_of_chunk + size_of_chunk;
1431 length_of_chunk = (long)(end_of_chunk - start_of_chunk);
1432 pointer = end_of_chunk + 2; //Next number should be here
1433
1434 if (length_of_chunk == 0) {
1435 // Chunk length is 0, so this is the last one
1436 break;
1437 }
1355 1438
1439 overall_size += length_of_chunk;
1440
1441 if (result == NULL) {
1442 result = (char *)calloc(length_of_chunk, sizeof(char));
1443 if (result == NULL) {
1444 if (verbose) {
1445 printf("Failed to allocate memory for unchunked body\n");
1446 }
1447 return NULL;
1448 }
1449 result_ptr = result;
1450 } else {
1451 void *tmp = realloc(result, overall_size);
1452 if (tmp == NULL) {
1453 if (verbose) {
1454 printf("Failed to allocate memory for unchunked body\n");
1455 }
1456 return NULL;
1457 }
1458 }
1459
1460 memcpy(result_ptr, start_of_chunk, size_of_chunk);
1461 result_ptr = result_ptr + size_of_chunk;
1462 }
1463
1464 result[overall_size] = '\0';
1465 return result;
1466}
1356 1467
1357/* per RFC 2396 */ 1468/* per RFC 2396 */
1358#define URI_HTTP "%5[HTPShtps]" 1469#define URI_HTTP "%5[HTPShtps]"
@@ -1363,7 +1474,9 @@ check_http (void)
1363#define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH 1474#define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH
1364#define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT 1475#define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT
1365#define HD4 URI_HTTP "://" URI_HOST 1476#define HD4 URI_HTTP "://" URI_HOST
1366#define HD5 URI_PATH 1477/* relative reference redirect like //www.site.org/test https://tools.ietf.org/html/rfc3986 */
1478#define HD5 "//" URI_HOST "/" URI_PATH
1479#define HD6 URI_PATH
1367 1480
1368void 1481void
1369redir (char *pos, char *status_line) 1482redir (char *pos, char *status_line)
@@ -1440,9 +1553,21 @@ redir (char *pos, char *status_line)
1440 use_ssl = server_type_check (type); 1553 use_ssl = server_type_check (type);
1441 i = server_port_check (use_ssl); 1554 i = server_port_check (use_ssl);
1442 } 1555 }
1556 /* URI_HTTP, URI_HOST, URI_PATH */
1557 else if (sscanf (pos, HD5, addr, url) == 2) {
1558 if(use_ssl){
1559 strcpy (type,"https");
1560 }
1561 else{
1562 strcpy (type, server_type);
1563 }
1564 xasprintf (&url, "/%s", url);
1565 use_ssl = server_type_check (type);
1566 i = server_port_check (use_ssl);
1567 }
1443 1568
1444 /* URI_PATH */ 1569 /* URI_PATH */
1445 else if (sscanf (pos, HD5, url) == 1) { 1570 else if (sscanf (pos, HD6, url) == 1) {
1446 /* relative url */ 1571 /* relative url */
1447 if ((url[0] != '/')) { 1572 if ((url[0] != '/')) {
1448 if ((x = strrchr(server_url, '/'))) 1573 if ((x = strrchr(server_url, '/')))
@@ -1511,13 +1636,13 @@ redir (char *pos, char *status_line)
1511} 1636}
1512 1637
1513 1638
1514int 1639bool
1515server_type_check (const char *type) 1640server_type_check (const char *type)
1516{ 1641{
1517 if (strcmp (type, "https")) 1642 if (strcmp (type, "https"))
1518 return FALSE; 1643 return false;
1519 else 1644 else
1520 return TRUE; 1645 return true;
1521} 1646}
1522 1647
1523int 1648int
@@ -1532,42 +1657,42 @@ server_port_check (int ssl_flag)
1532char *perfd_time (double elapsed_time) 1657char *perfd_time (double elapsed_time)
1533{ 1658{
1534 return fperfdata ("time", elapsed_time, "s", 1659 return fperfdata ("time", elapsed_time, "s",
1535 thlds->warning?TRUE:FALSE, thlds->warning?thlds->warning->end:0, 1660 thlds->warning?true:false, thlds->warning?thlds->warning->end:0,
1536 thlds->critical?TRUE:FALSE, thlds->critical?thlds->critical->end:0, 1661 thlds->critical?true:false, thlds->critical?thlds->critical->end:0,
1537 TRUE, 0, TRUE, socket_timeout); 1662 true, 0, true, socket_timeout);
1538} 1663}
1539 1664
1540char *perfd_time_connect (double elapsed_time_connect) 1665char *perfd_time_connect (double elapsed_time_connect)
1541{ 1666{
1542 return fperfdata ("time_connect", elapsed_time_connect, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1667 return fperfdata ("time_connect", elapsed_time_connect, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1543} 1668}
1544 1669
1545char *perfd_time_ssl (double elapsed_time_ssl) 1670char *perfd_time_ssl (double elapsed_time_ssl)
1546{ 1671{
1547 return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1672 return fperfdata ("time_ssl", elapsed_time_ssl, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1548} 1673}
1549 1674
1550char *perfd_time_headers (double elapsed_time_headers) 1675char *perfd_time_headers (double elapsed_time_headers)
1551{ 1676{
1552 return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1677 return fperfdata ("time_headers", elapsed_time_headers, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1553} 1678}
1554 1679
1555char *perfd_time_firstbyte (double elapsed_time_firstbyte) 1680char *perfd_time_firstbyte (double elapsed_time_firstbyte)
1556{ 1681{
1557 return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1682 return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1558} 1683}
1559 1684
1560char *perfd_time_transfer (double elapsed_time_transfer) 1685char *perfd_time_transfer (double elapsed_time_transfer)
1561{ 1686{
1562 return fperfdata ("time_transfer", elapsed_time_transfer, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1687 return fperfdata ("time_transfer", elapsed_time_transfer, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1563} 1688}
1564 1689
1565char *perfd_size (int page_len) 1690char *perfd_size (int page_len)
1566{ 1691{
1567 return perfdata ("size", page_len, "B", 1692 return perfdata ("size", page_len, "B",
1568 (min_page_len>0?TRUE:FALSE), min_page_len, 1693 (min_page_len>0?true:false), min_page_len,
1569 (min_page_len>0?TRUE:FALSE), 0, 1694 (min_page_len>0?true:false), 0,
1570 TRUE, 0, FALSE, 0); 1695 true, 0, false, 0);
1571} 1696}
1572 1697
1573void 1698void
diff --git a/plugins/check_load.c b/plugins/check_load.c
index fdfa1da8..388714f2 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -1,41 +1,43 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_load plugin 3* Monitoring check_load plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Monitoring Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_load plugin 10* This file contains the check_load plugin
11* 11*
12* This plugin tests the current system load average. 12* This plugin tests the current system load average.
13* 13*
14* 14*
15* This program is free software: you can redistribute it and/or modify 15* This program is free software: you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by 16* it under the terms of the GNU General Public License as published by
17* the Free Software Foundation, either version 3 of the License, or 17* the Free Software Foundation, either version 3 of the License, or
18* (at your option) any later version. 18* (at your option) any later version.
19* 19*
20* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details. 23* GNU General Public License for more details.
24* 24*
25* You should have received a copy of the GNU General Public License 25* You should have received a copy of the GNU General Public License
26* along with this program. If not, see <http://www.gnu.org/licenses/>. 26* along with this program. If not, see <http://www.gnu.org/licenses/>.
27* 27*
28* 28*
29*****************************************************************************/ 29*****************************************************************************/
30 30
31const char *progname = "check_load"; 31const char *progname = "check_load";
32const char *copyright = "1999-2007"; 32const char *copyright = "1999-2022";
33const char *email = "devel@monitoring-plugins.org"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "./common.h"
36#include "runcmd.h" 36#include "./runcmd.h"
37#include "utils.h" 37#include "./utils.h"
38#include "popen.h" 38#include "./popen.h"
39
40#include <string.h>
39 41
40#ifdef HAVE_SYS_LOADAVG_H 42#ifdef HAVE_SYS_LOADAVG_H
41#include <sys/loadavg.h> 43#include <sys/loadavg.h>
@@ -68,7 +70,7 @@ double cload[3] = { 0.0, 0.0, 0.0 };
68#define la15 la[2] 70#define la15 la[2]
69 71
70char *status_line; 72char *status_line;
71int take_into_account_cpus = 0; 73bool take_into_account_cpus = false;
72 74
73static void 75static void
74get_threshold(char *arg, double *th) 76get_threshold(char *arg, double *th)
@@ -101,7 +103,7 @@ get_threshold(char *arg, double *th)
101int 103int
102main (int argc, char **argv) 104main (int argc, char **argv)
103{ 105{
104 int result; 106 int result = -1;
105 int i; 107 int i;
106 long numcpus; 108 long numcpus;
107 109
@@ -164,7 +166,7 @@ main (int argc, char **argv)
164 sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15); 166 sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15);
165 } 167 }
166 else { 168 else {
167 printf (_("could not parse load from uptime %s: %s\n"), PATH_TO_UPTIME, result); 169 printf (_("could not parse load from uptime %s: %d\n"), PATH_TO_UPTIME, result);
168 return STATE_UNKNOWN; 170 return STATE_UNKNOWN;
169 } 171 }
170 172
@@ -176,13 +178,6 @@ main (int argc, char **argv)
176# endif 178# endif
177#endif 179#endif
178 180
179 if (take_into_account_cpus == 1) {
180 if ((numcpus = GET_NUMBER_OF_CPUS()) > 0) {
181 la[0] = la[0] / numcpus;
182 la[1] = la[1] / numcpus;
183 la[2] = la[2] / numcpus;
184 }
185 }
186 if ((la[0] < 0.0) || (la[1] < 0.0) || (la[2] < 0.0)) { 181 if ((la[0] < 0.0) || (la[1] < 0.0) || (la[2] < 0.0)) {
187#ifdef HAVE_GETLOADAVG 182#ifdef HAVE_GETLOADAVG
188 printf (_("Error in getloadavg()\n")); 183 printf (_("Error in getloadavg()\n"));
@@ -200,18 +195,49 @@ main (int argc, char **argv)
200 result = STATE_OK; 195 result = STATE_OK;
201 196
202 xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15); 197 xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
198 xasprintf(&status_line, ("total %s"), status_line);
199
200
201 double scaled_la[3] = { 0.0, 0.0, 0.0 };
202 bool is_using_scaled_load_values = false;
203
204 if (take_into_account_cpus == true && (numcpus = GET_NUMBER_OF_CPUS()) > 0) {
205 is_using_scaled_load_values = true;
206
207 scaled_la[0] = la[0] / numcpus;
208 scaled_la[1] = la[1] / numcpus;
209 scaled_la[2] = la[2] / numcpus;
210
211 char *tmp = NULL;
212 xasprintf(&tmp, _("load average: %.2f, %.2f, %.2f"), scaled_la[0], scaled_la[1], scaled_la[2]);
213 xasprintf(&status_line, "scaled %s - %s", tmp, status_line);
214 }
203 215
204 for(i = 0; i < 3; i++) { 216 for(i = 0; i < 3; i++) {
205 if(la[i] > cload[i]) { 217 if (is_using_scaled_load_values) {
206 result = STATE_CRITICAL; 218 if(scaled_la[i] > cload[i]) {
207 break; 219 result = STATE_CRITICAL;
220 break;
221 }
222 else if(scaled_la[i] > wload[i]) result = STATE_WARNING;
223 } else {
224 if(la[i] > cload[i]) {
225 result = STATE_CRITICAL;
226 break;
227 }
228 else if(la[i] > wload[i]) result = STATE_WARNING;
208 } 229 }
209 else if(la[i] > wload[i]) result = STATE_WARNING;
210 } 230 }
211 231
212 printf("LOAD %s - %s|", state_text(result), status_line); 232 printf("LOAD %s - %s|", state_text(result), status_line);
213 for(i = 0; i < 3; i++) 233 for(i = 0; i < 3; i++) {
214 printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]); 234 if (is_using_scaled_load_values) {
235 printf("load%d=%.3f;;;0; ", nums[i], la[i]);
236 printf("scaled_load%d=%.3f;%.3f;%.3f;0; ", nums[i], scaled_la[i], wload[i], cload[i]);
237 } else {
238 printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]);
239 }
240 }
215 241
216 putchar('\n'); 242 putchar('\n');
217 if (n_procs_to_show > 0) { 243 if (n_procs_to_show > 0) {
@@ -255,7 +281,7 @@ process_arguments (int argc, char **argv)
255 get_threshold(optarg, cload); 281 get_threshold(optarg, cload);
256 break; 282 break;
257 case 'r': /* Divide load average by number of CPUs */ 283 case 'r': /* Divide load average by number of CPUs */
258 take_into_account_cpus = 1; 284 take_into_account_cpus = true;
259 break; 285 break;
260 case 'V': /* version */ 286 case 'V': /* version */
261 print_revision (progname, NP_VERSION); 287 print_revision (progname, NP_VERSION);
@@ -289,7 +315,6 @@ process_arguments (int argc, char **argv)
289} 315}
290 316
291 317
292
293static int 318static int
294validate_arguments (void) 319validate_arguments (void)
295{ 320{
@@ -310,7 +335,6 @@ validate_arguments (void)
310} 335}
311 336
312 337
313
314void 338void
315print_help (void) 339print_help (void)
316{ 340{
@@ -321,7 +345,7 @@ print_help (void)
321 345
322 printf (_("This plugin tests the current system load average.")); 346 printf (_("This plugin tests the current system load average."));
323 347
324 printf ("\n\n"); 348 printf ("\n\n");
325 349
326 print_usage (); 350 print_usage ();
327 351
@@ -329,15 +353,15 @@ print_help (void)
329 printf (UT_EXTRA_OPTS); 353 printf (UT_EXTRA_OPTS);
330 354
331 printf (" %s\n", "-w, --warning=WLOAD1,WLOAD5,WLOAD15"); 355 printf (" %s\n", "-w, --warning=WLOAD1,WLOAD5,WLOAD15");
332 printf (" %s\n", _("Exit with WARNING status if load average exceeds WLOADn")); 356 printf (" %s\n", _("Exit with WARNING status if load average exceeds WLOADn"));
333 printf (" %s\n", "-c, --critical=CLOAD1,CLOAD5,CLOAD15"); 357 printf (" %s\n", "-c, --critical=CLOAD1,CLOAD5,CLOAD15");
334 printf (" %s\n", _("Exit with CRITICAL status if load average exceed CLOADn")); 358 printf (" %s\n", _("Exit with CRITICAL status if load average exceed CLOADn"));
335 printf (" %s\n", _("the load average format is the same used by \"uptime\" and \"w\"")); 359 printf (" %s\n", _("the load average format is the same used by \"uptime\" and \"w\""));
336 printf (" %s\n", "-r, --percpu"); 360 printf (" %s\n", "-r, --percpu");
337 printf (" %s\n", _("Divide the load averages by the number of CPUs (when possible)")); 361 printf (" %s\n", _("Divide the load averages by the number of CPUs (when possible)"));
338 printf (" %s\n", "-n, --procs-to-show=NUMBER_OF_PROCS"); 362 printf (" %s\n", "-n, --procs-to-show=NUMBER_OF_PROCS");
339 printf (" %s\n", _("Number of processes to show when printing the top consuming processes.")); 363 printf (" %s\n", _("Number of processes to show when printing the top consuming processes."));
340 printf (" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0")); 364 printf (" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0"));
341 365
342 printf (UT_SUPPORT); 366 printf (UT_SUPPORT);
343} 367}
@@ -345,8 +369,8 @@ print_help (void)
345void 369void
346print_usage (void) 370print_usage (void)
347{ 371{
348 printf ("%s\n", _("Usage:")); 372 printf ("%s\n", _("Usage:"));
349 printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 [-n NUMBER_OF_PROCS]\n", progname); 373 printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 [-n NUMBER_OF_PROCS]\n", progname);
350} 374}
351 375
352#ifdef PS_USES_PROCPCPU 376#ifdef PS_USES_PROCPCPU
@@ -384,8 +408,8 @@ static int print_top_consuming_processes() {
384#ifdef PS_USES_PROCPCPU 408#ifdef PS_USES_PROCPCPU
385 qsort(chld_out.line + 1, chld_out.lines - 1, sizeof(char*), cmpstringp); 409 qsort(chld_out.line + 1, chld_out.lines - 1, sizeof(char*), cmpstringp);
386#endif /* PS_USES_PROCPCPU */ 410#endif /* PS_USES_PROCPCPU */
387 int lines_to_show = chld_out.lines < (n_procs_to_show + 1) 411 int lines_to_show = chld_out.lines < (size_t)(n_procs_to_show + 1)
388 ? chld_out.lines : n_procs_to_show + 1; 412 ? (int)chld_out.lines : n_procs_to_show + 1;
389 for (i = 0; i < lines_to_show; i += 1) { 413 for (i = 0; i < lines_to_show; i += 1) {
390 printf("%s\n", chld_out.line[i]); 414 printf("%s\n", chld_out.line[i]);
391 } 415 }
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 914b40ce..8b776ba1 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -355,7 +355,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
355 * - we also "manually" handle resolving host names and connecting, because 355 * - we also "manually" handle resolving host names and connecting, because
356 * we have to do it in a way that our lazy macros don't handle currently :( */ 356 * we have to do it in a way that our lazy macros don't handle currently :( */
357double offset_request(const char *host, int *status){ 357double offset_request(const char *host, int *status){
358 int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0; 358 int i=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
359 int servers_completed=0, one_read=0, servers_readable=0, best_index=-1; 359 int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
360 time_t now_time=0, start_ts=0; 360 time_t now_time=0, start_ts=0;
361 ntp_message *req=NULL; 361 ntp_message *req=NULL;
@@ -488,7 +488,7 @@ double offset_request(const char *host, int *status){
488 /* cleanup */ 488 /* cleanup */
489 /* FIXME: Not closing the socket to avoid re-use of the local port 489 /* FIXME: Not closing the socket to avoid re-use of the local port
490 * which can cause old NTP packets to be read instead of NTP control 490 * which can cause old NTP packets to be read instead of NTP control
491 * pactets in jitter_request(). THERE MUST BE ANOTHER WAY... 491 * packets in jitter_request(). THERE MUST BE ANOTHER WAY...
492 * for(j=0; j<num_hosts; j++){ close(socklist[j]); } */ 492 * for(j=0; j<num_hosts; j++){ close(socklist[j]); } */
493 free(socklist); 493 free(socklist);
494 free(ufds); 494 free(ufds);
@@ -512,7 +512,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
512} 512}
513 513
514/* XXX handle responses with the error bit set */ 514/* XXX handle responses with the error bit set */
515double jitter_request(const char *host, int *status){ 515double jitter_request(int *status){
516 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0; 516 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0;
517 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0; 517 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0;
518 int peers_size=0, peer_offset=0; 518 int peers_size=0, peer_offset=0;
@@ -803,7 +803,7 @@ int main(int argc, char *argv[]){
803 * (for example) will result in an error 803 * (for example) will result in an error
804 */ 804 */
805 if(do_jitter){ 805 if(do_jitter){
806 jitter=jitter_request(server_address, &jitter_result); 806 jitter=jitter_request(&jitter_result);
807 result = max_state_alt(result, get_status(jitter, jitter_thresholds)); 807 result = max_state_alt(result, get_status(jitter, jitter_thresholds));
808 /* -1 indicates that we couldn't calculate the jitter 808 /* -1 indicates that we couldn't calculate the jitter
809 * Only overrides STATE_OK from the offset */ 809 * Only overrides STATE_OK from the offset */
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index c893386c..c26cd439 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -69,7 +69,6 @@ int process_arguments (int, char **);
69int validate_arguments (void); 69int validate_arguments (void);
70void print_usage (void); 70void print_usage (void);
71void print_help (void); 71void print_help (void);
72int is_pg_dbname (char *);
73int is_pg_logname (char *); 72int is_pg_logname (char *);
74int do_query (PGconn *, char *); 73int do_query (PGconn *, char *);
75 74
@@ -347,10 +346,10 @@ process_arguments (int argc, char **argv)
347 pgport = optarg; 346 pgport = optarg;
348 break; 347 break;
349 case 'd': /* database name */ 348 case 'd': /* database name */
350 if (!is_pg_dbname (optarg)) /* checks length and valid chars */ 349 if (strlen(optarg) >= NAMEDATALEN) {
351 usage2 (_("Database name is not valid"), optarg); 350 usage2 (_("Database name exceeds the maximum length"), optarg);
352 else /* we know length, and know optarg is terminated, so us strcpy */ 351 }
353 snprintf(dbName, NAMEDATALEN, "%s", optarg); 352 snprintf(dbName, NAMEDATALEN, "%s", optarg);
354 break; 353 break;
355 case 'l': /* login name */ 354 case 'l': /* login name */
356 if (!is_pg_logname (optarg)) 355 if (!is_pg_logname (optarg))
@@ -414,45 +413,6 @@ validate_arguments ()
414 return OK; 413 return OK;
415} 414}
416 415
417
418/******************************************************************************
419
420@@-
421<sect3>
422<title>is_pg_dbname</title>
423
424<para>&PROTO_is_pg_dbname;</para>
425
426<para>Given a database name, this function returns TRUE if the string
427is a valid PostgreSQL database name, and returns false if it is
428not.</para>
429
430<para>Valid PostgreSQL database names are less than &NAMEDATALEN;
431characters long and consist of letters, numbers, and underscores. The
432first character cannot be a number, however.</para>
433
434</sect3>
435-@@
436******************************************************************************/
437
438
439
440int
441is_pg_dbname (char *dbname)
442{
443 char txt[NAMEDATALEN];
444 char tmp[NAMEDATALEN];
445 if (strlen (dbname) > NAMEDATALEN - 1)
446 return (FALSE);
447 strncpy (txt, dbname, NAMEDATALEN - 1);
448 txt[NAMEDATALEN - 1] = 0;
449 if (sscanf (txt, "%[_a-zA-Z]%[^_a-zA-Z0-9-]", tmp, tmp) == 1)
450 return (TRUE);
451 if (sscanf (txt, "%[_a-zA-Z]%[_a-zA-Z0-9-]%[^_a-zA-Z0-9-]", tmp, tmp, tmp) ==
452 2) return (TRUE);
453 return (FALSE);
454}
455
456/** 416/**
457 417
458the tango program should eventually create an entity here based on the 418the tango program should eventually create an entity here based on the
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 205f7ee8..67aa6be1 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -1,31 +1,31 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_snmp plugin 3* Monitoring check_snmp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Monitoring Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_snmp plugin 10* This file contains the check_snmp plugin
11* 11*
12* Check status of remote machines and obtain system information via SNMP 12* Check status of remote machines and obtain system information via SNMP
13* 13*
14* 14*
15* This program is free software: you can redistribute it and/or modify 15* This program is free software: you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by 16* it under the terms of the GNU General Public License as published by
17* the Free Software Foundation, either version 3 of the License, or 17* the Free Software Foundation, either version 3 of the License, or
18* (at your option) any later version. 18* (at your option) any later version.
19* 19*
20* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details. 23* GNU General Public License for more details.
24* 24*
25* You should have received a copy of the GNU General Public License 25* You should have received a copy of the GNU General Public License
26* along with this program. If not, see <http://www.gnu.org/licenses/>. 26* along with this program. If not, see <http://www.gnu.org/licenses/>.
27* 27*
28* 28*
29*****************************************************************************/ 29*****************************************************************************/
30 30
31const char *progname = "check_snmp"; 31const char *progname = "check_snmp";
@@ -90,6 +90,7 @@ char *thisarg (char *str);
90char *nextarg (char *str); 90char *nextarg (char *str);
91void print_usage (void); 91void print_usage (void);
92void print_help (void); 92void print_help (void);
93char *multiply (char *str);
93 94
94#include "regex.h" 95#include "regex.h"
95char regex_expect[MAX_INPUT_BUFFER] = ""; 96char regex_expect[MAX_INPUT_BUFFER] = "";
@@ -154,6 +155,8 @@ double *previous_value;
154size_t previous_size = OID_COUNT_STEP; 155size_t previous_size = OID_COUNT_STEP;
155int perf_labels = 1; 156int perf_labels = 1;
156char* ip_version = ""; 157char* ip_version = "";
158double multiplier = 1.0;
159char *fmtstr = "";
157 160
158static char *fix_snmp_range(char *th) 161static char *fix_snmp_range(char *th)
159{ 162{
@@ -316,7 +319,7 @@ main (int argc, char **argv)
316 for (i = 0; i < numcontext; i++) { 319 for (i = 0; i < numcontext; i++) {
317 command_line[10 + i] = contextargs[i]; 320 command_line[10 + i] = contextargs[i];
318 } 321 }
319 322
320 for (i = 0; i < numauthpriv; i++) { 323 for (i = 0; i < numauthpriv; i++) {
321 command_line[10 + numcontext + i] = authpriv[i]; 324 command_line[10 + numcontext + i] = authpriv[i];
322 } 325 }
@@ -330,7 +333,7 @@ main (int argc, char **argv)
330 333
331 for (i = 0; i < numoids; i++) { 334 for (i = 0; i < numoids; i++) {
332 command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i]; 335 command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i];
333 xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]); 336 xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
334 } 337 }
335 338
336 command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL; 339 command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL;
@@ -376,7 +379,7 @@ main (int argc, char **argv)
376 } 379 }
377 } 380 }
378 381
379 for (line=0, i=0; line < chld_out.lines; line++, i++) { 382 for (line=0, i=0; line < chld_out.lines && i < numoids ; line++, i++) {
380 if(calculate_rate) 383 if(calculate_rate)
381 conv = "%.10g"; 384 conv = "%.10g";
382 else 385 else
@@ -398,15 +401,15 @@ main (int argc, char **argv)
398 is_counter=0; 401 is_counter=0;
399 /* We strip out the datatype indicator for PHBs */ 402 /* We strip out the datatype indicator for PHBs */
400 if (strstr (response, "Gauge: ")) { 403 if (strstr (response, "Gauge: ")) {
401 show = strstr (response, "Gauge: ") + 7; 404 show = multiply (strstr (response, "Gauge: ") + 7);
402 } 405 }
403 else if (strstr (response, "Gauge32: ")) { 406 else if (strstr (response, "Gauge32: ")) {
404 show = strstr (response, "Gauge32: ") + 9; 407 show = multiply (strstr (response, "Gauge32: ") + 9);
405 } 408 }
406 else if (strstr (response, "Counter32: ")) { 409 else if (strstr (response, "Counter32: ")) {
407 show = strstr (response, "Counter32: ") + 11; 410 show = strstr (response, "Counter32: ") + 11;
408 is_counter=1; 411 is_counter=1;
409 if(!calculate_rate) 412 if(!calculate_rate)
410 strcpy(type, "c"); 413 strcpy(type, "c");
411 } 414 }
412 else if (strstr (response, "Counter64: ")) { 415 else if (strstr (response, "Counter64: ")) {
@@ -416,7 +419,10 @@ main (int argc, char **argv)
416 strcpy(type, "c"); 419 strcpy(type, "c");
417 } 420 }
418 else if (strstr (response, "INTEGER: ")) { 421 else if (strstr (response, "INTEGER: ")) {
419 show = strstr (response, "INTEGER: ") + 9; 422 show = multiply (strstr (response, "INTEGER: ") + 9);
423 if (fmtstr != "") {
424 conv = fmtstr;
425 }
420 } 426 }
421 else if (strstr (response, "OID: ")) { 427 else if (strstr (response, "OID: ")) {
422 show = strstr (response, "OID: ") + 5; 428 show = strstr (response, "OID: ") + 5;
@@ -616,7 +622,7 @@ main (int argc, char **argv)
616 state_string=malloc(string_length); 622 state_string=malloc(string_length);
617 if(state_string==NULL) 623 if(state_string==NULL)
618 die(STATE_UNKNOWN, _("Cannot malloc")); 624 die(STATE_UNKNOWN, _("Cannot malloc"));
619 625
620 current_length=0; 626 current_length=0;
621 for(i=0; i<total_oids; i++) { 627 for(i=0; i<total_oids; i++) {
622 xasprintf(&temp_string,"%.0f",response_value[i]); 628 xasprintf(&temp_string,"%.0f",response_value[i]);
@@ -638,7 +644,7 @@ main (int argc, char **argv)
638 state_string[--current_length]='\0'; 644 state_string[--current_length]='\0';
639 if (verbose > 2) 645 if (verbose > 2)
640 printf("State string=%s\n",state_string); 646 printf("State string=%s\n",state_string);
641 647
642 /* This is not strictly the same as time now, but any subtle variations will cancel out */ 648 /* This is not strictly the same as time now, but any subtle variations will cancel out */
643 np_state_write_string(current_time, state_string ); 649 np_state_write_string(current_time, state_string );
644 if(previous_state==NULL) { 650 if(previous_state==NULL) {
@@ -698,6 +704,8 @@ process_arguments (int argc, char **argv)
698 {"perf-oids", no_argument, 0, 'O'}, 704 {"perf-oids", no_argument, 0, 'O'},
699 {"ipv4", no_argument, 0, '4'}, 705 {"ipv4", no_argument, 0, '4'},
700 {"ipv6", no_argument, 0, '6'}, 706 {"ipv6", no_argument, 0, '6'},
707 {"multiplier", required_argument, 0, 'M'},
708 {"fmtstr", required_argument, 0, 'f'},
701 {0, 0, 0, 0} 709 {0, 0, 0, 0}
702 }; 710 };
703 711
@@ -715,7 +723,7 @@ process_arguments (int argc, char **argv)
715 } 723 }
716 724
717 while (1) { 725 while (1) {
718 c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:z:", 726 c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:M:f:z:",
719 longopts, &option); 727 longopts, &option);
720 728
721 if (c == -1 || c == EOF) 729 if (c == -1 || c == EOF)
@@ -953,6 +961,16 @@ process_arguments (int argc, char **argv)
953 if(verbose>2) 961 if(verbose>2)
954 printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n"); 962 printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n");
955 break; 963 break;
964 case 'M':
965 if ( strspn( optarg, "0123456789.," ) == strlen( optarg ) ) {
966 multiplier=strtod(optarg,NULL);
967 }
968 break;
969 case 'f':
970 if (multiplier != 1.0) {
971 fmtstr=optarg;
972 }
973 break;
956 } 974 }
957 } 975 }
958 976
@@ -1022,7 +1040,7 @@ validate_arguments ()
1022 contextargs[0] = strdup ("-n"); 1040 contextargs[0] = strdup ("-n");
1023 contextargs[1] = strdup (context); 1041 contextargs[1] = strdup (context);
1024 } 1042 }
1025 1043
1026 if (seclevel == NULL) 1044 if (seclevel == NULL)
1027 xasprintf(&seclevel, "noAuthNoPriv"); 1045 xasprintf(&seclevel, "noAuthNoPriv");
1028 1046
@@ -1143,6 +1161,25 @@ nextarg (char *str)
1143 1161
1144 1162
1145 1163
1164/* multiply result (values 0 < n < 1 work as divider) */
1165char *
1166multiply (char *str)
1167{
1168 double val = strtod (str, NULL);
1169 val *= multiplier;
1170 char *conv = "%f";
1171 if (fmtstr != "") {
1172 conv = fmtstr;
1173 }
1174 if (val == (int)val) {
1175 sprintf(str, "%.0f", val);
1176 } else {
1177 sprintf(str, conv, val);
1178 }
1179 return str;
1180}
1181
1182
1146void 1183void
1147print_help (void) 1184print_help (void)
1148{ 1185{
@@ -1235,6 +1272,10 @@ print_help (void)
1235 printf (" %s\n", _("Units label(s) for output data (e.g., 'sec.').")); 1272 printf (" %s\n", _("Units label(s) for output data (e.g., 'sec.')."));
1236 printf (" %s\n", "-D, --output-delimiter=STRING"); 1273 printf (" %s\n", "-D, --output-delimiter=STRING");
1237 printf (" %s\n", _("Separates output on multiple OID requests")); 1274 printf (" %s\n", _("Separates output on multiple OID requests"));
1275 printf (" %s\n", "-M, --multiplier=FLOAT");
1276 printf (" %s\n", _("Multiplies current value, 0 < n < 1 works as divider, defaults to 1"));
1277 printf (" %s\n", "-f, --fmtstr=STRING");
1278 printf (" %s\n", _("C-style format string for float values (see option -M)"));
1238 1279
1239 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1280 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1240 printf (" %s\n", _("NOTE the final timeout value is calculated using this formula: timeout_interval * retries + 5")); 1281 printf (" %s\n", _("NOTE the final timeout value is calculated using this formula: timeout_interval * retries + 5"));
@@ -1287,4 +1328,5 @@ print_usage (void)
1287 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); 1328 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
1288 printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); 1329 printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n");
1289 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n"); 1330 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n");
1331 printf ("[-M multiplier [-f format]]\n");
1290} 1332}
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index bb854beb..a607da1e 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -1,30 +1,30 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_swap plugin 3* Monitoring check_swap plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) 6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
7* Copyright (c) 2000-2007 Monitoring Plugins Development Team 7* Copyright (c) 2000-2007 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
11* This file contains the check_swap plugin 11* This file contains the check_swap plugin
12* 12*
13* 13*
14* This program is free software: you can redistribute it and/or modify 14* This program is free software: you can redistribute it and/or modify
15* it under the terms of the GNU General Public License as published by 15* it under the terms of the GNU General Public License as published by
16* the Free Software Foundation, either version 3 of the License, or 16* the Free Software Foundation, either version 3 of the License, or
17* (at your option) any later version. 17* (at your option) any later version.
18* 18*
19* This program is distributed in the hope that it will be useful, 19* This program is distributed in the hope that it will be useful,
20* but WITHOUT ANY WARRANTY; without even the implied warranty of 20* but WITHOUT ANY WARRANTY; without even the implied warranty of
21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22* GNU General Public License for more details. 22* GNU General Public License for more details.
23* 23*
24* You should have received a copy of the GNU General Public License 24* You should have received a copy of the GNU General Public License
25* along with this program. If not, see <http://www.gnu.org/licenses/>. 25* along with this program. If not, see <http://www.gnu.org/licenses/>.
26* 26*
27* 27*
28*****************************************************************************/ 28*****************************************************************************/
29 29
30const char *progname = "check_swap"; 30const char *progname = "check_swap";
@@ -150,7 +150,7 @@ main (int argc, char **argv)
150 * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123" 150 * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123"
151 * This format exists at least on Debian Linux with a 5.* kernel 151 * This format exists at least on Debian Linux with a 5.* kernel
152 */ 152 */
153 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %f %*[k]%*[B]", str, &tmp_KB)) { 153 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %lu %*[k]%*[B]", str, &tmp_KB)) {
154 if (verbose >= 3) { 154 if (verbose >= 3) {
155 printf("Got %s with %lu\n", str, tmp_KB); 155 printf("Got %s with %lu\n", str, tmp_KB);
156 } 156 }
@@ -389,7 +389,7 @@ main (int argc, char **argv)
389 TRUE, warn_print, 389 TRUE, warn_print,
390 TRUE, crit_print, 390 TRUE, crit_print,
391 TRUE, 0, 391 TRUE, 0,
392 TRUE, (long) total_swap_mb)); 392 TRUE, (long) total_swap_mb * 1024 * 1024));
393 393
394 return result; 394 return result;
395} 395}
@@ -410,7 +410,6 @@ check_swap(float free_swap_mb, float total_swap_mb)
410 uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100; 410 uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100;
411 411
412 if (crit.is_percentage && 412 if (crit.is_percentage &&
413 usage_percentage >= 0 &&
414 crit.value != 0 && 413 crit.value != 0 &&
415 usage_percentage >= (100 - crit.value)) 414 usage_percentage >= (100 - crit.value))
416 { 415 {
@@ -418,7 +417,6 @@ check_swap(float free_swap_mb, float total_swap_mb)
418 } 417 }
419 418
420 if (warn.is_percentage && 419 if (warn.is_percentage &&
421 usage_percentage >= 0 &&
422 warn.value != 0 && 420 warn.value != 0 &&
423 usage_percentage >= (100 - warn.value)) 421 usage_percentage >= (100 - warn.value))
424 { 422 {
@@ -475,10 +473,9 @@ process_arguments (int argc, char **argv)
475 if (is_uint64(optarg, &warn.value)) { 473 if (is_uint64(optarg, &warn.value)) {
476 if (warn.value > 100) { 474 if (warn.value > 100) {
477 usage4 (_("Warning threshold percentage must be <= 100!")); 475 usage4 (_("Warning threshold percentage must be <= 100!"));
478 } else {
479 break;
480 } 476 }
481 } 477 }
478 break;
482 } else { 479 } else {
483 /* It's Bytes */ 480 /* It's Bytes */
484 warn.is_percentage = 0; 481 warn.is_percentage = 0;
@@ -506,10 +503,9 @@ process_arguments (int argc, char **argv)
506 if (is_uint64(optarg, &crit.value)) { 503 if (is_uint64(optarg, &crit.value)) {
507 if (crit.value> 100) { 504 if (crit.value> 100) {
508 usage4 (_("Critical threshold percentage must be <= 100!")); 505 usage4 (_("Critical threshold percentage must be <= 100!"));
509 } else {
510 break;
511 } 506 }
512 } 507 }
508 break;
513 } else { 509 } else {
514 /* It's Bytes */ 510 /* It's Bytes */
515 crit.is_percentage = 0; 511 crit.is_percentage = 0;
@@ -527,6 +523,7 @@ process_arguments (int argc, char **argv)
527 if ((no_swap_state = mp_translate_state(optarg)) == ERROR) { 523 if ((no_swap_state = mp_translate_state(optarg)) == ERROR) {
528 usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 524 usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
529 } 525 }
526 break;
530 case 'v': /* verbose */ 527 case 'v': /* verbose */
531 verbose++; 528 verbose++;
532 break; 529 break;
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t
index ada6a045..eae98cc1 100644
--- a/plugins/t/check_curl.t
+++ b/plugins/t/check_curl.t
@@ -1,15 +1,22 @@
1#! /usr/bin/perl -w -I .. 1#! /usr/bin/perl -w -I ..
2# 2#
3# HyperText Transfer Protocol (HTTP) Test via check_http 3# HyperText Transfer Protocol (HTTP) Test via check_curl
4# 4#
5# 5#
6 6
7use strict; 7use strict;
8use Test::More; 8use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest;
11 10
12plan tests => 58; 11use vars qw($tests $has_ipv6);
12
13BEGIN {
14 use NPTest;
15 $has_ipv6 = NPTest::has_ipv6();
16 $tests = $has_ipv6 ? 59 : 57;
17 plan tests => $tests;
18}
19
13 20
14my $successOutput = '/OK.*HTTP.*second/'; 21my $successOutput = '/OK.*HTTP.*second/';
15 22
@@ -18,6 +25,7 @@ my $plugin = 'check_http';
18$plugin = 'check_curl' if $0 =~ m/check_curl/mx; 25$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
19 26
20my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost"); 27my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
28my $host_tcp_http_ipv6 = getTestParameter("NP_HOST_TCP_HTTP_IPV6", "An IPv6 address providing a HTTP Service (a web server)", "::1");
21my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost"); 29my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
22my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost"); 30my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost");
23my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); 31my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
@@ -31,26 +39,35 @@ my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
31 39
32 40
33$res = NPTest->testCmd( 41$res = NPTest->testCmd(
34 "./$plugin $host_tcp_http -wt 300 -ct 600" 42 "./$plugin $host_tcp_http -wt 300 -ct 600"
35 ); 43 );
36cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); 44cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
37like( $res->output, $successOutput, "Output OK" ); 45like( $res->output, $successOutput, "Output OK" );
38 46
47if ($has_ipv6) {
48 # Test for IPv6 formatting
49 $res = NPTest->testCmd(
50 "./$plugin -I $host_tcp_http_ipv6 -wt 300 -ct 600"
51 );
52 cmp_ok( $res->return_code, '==', 0, "IPv6 URL formatting is working" );
53 like( $res->output, $successOutput, "Output OK" );
54}
55
39$res = NPTest->testCmd( 56$res = NPTest->testCmd(
40 "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'" 57 "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
41 ); 58 );
42like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); 59like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
43 60
44$res = NPTest->testCmd( 61$res = NPTest->testCmd(
45 "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3" 62 "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
46 ); 63 );
47cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); 64cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
48# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!) 65# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!)
49like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK"); 66like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK");
50 67
51$res = NPTest->testCmd( 68$res = NPTest->testCmd(
52 "./$plugin $hostname_invalid -wt 1 -ct 2" 69 "./$plugin $hostname_invalid -wt 1 -ct 2"
53 ); 70 );
54cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); 71cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
55# The first part of the message comes from the OS catalogue, so cannot check this. 72# The first part of the message comes from the OS catalogue, so cannot check this.
56# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename 73# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename
@@ -188,11 +205,6 @@ SKIP: {
188 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); 205 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
189 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); 206 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
190 207
191 $res = NPTest->testCmd(
192 "./$plugin --ssl -H www.e-paycobalt.com"
193 );
194 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
195
196 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); 208 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" );
197 is( $res->return_code, 0, "Redirection based on location is okay"); 209 is( $res->return_code, 0, "Redirection based on location is okay");
198 210
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index c137f7b4..1ca52f61 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -9,7 +9,7 @@ use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest; 10use NPTest;
11 11
12plan tests => 50; 12plan tests => 49;
13 13
14my $successOutput = '/OK.*HTTP.*second/'; 14my $successOutput = '/OK.*HTTP.*second/';
15 15
@@ -103,7 +103,7 @@ SKIP: {
103 cmp_ok( $res->return_code, "==", 0, "And also when not found"); 103 cmp_ok( $res->return_code, "==", 0, "And also when not found");
104} 104}
105SKIP: { 105SKIP: {
106 skip "No internet access", 23 if $internet_access eq "no"; 106 skip "No internet access", 22 if $internet_access eq "no";
107 107
108 $res = NPTest->testCmd( 108 $res = NPTest->testCmd(
109 "./$plugin --ssl $host_tls_http" 109 "./$plugin --ssl $host_tls_http"
@@ -166,12 +166,6 @@ SKIP: {
166 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); 166 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
167 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); 167 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
168 168
169 $res = NPTest->testCmd(
170 "./$plugin --ssl -H www.e-paycobalt.com"
171 );
172 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
173
174
175 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); 169 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
176 is( $res->return_code, 0, "Redirection based on location is okay"); 170 is( $res->return_code, 0, "Redirection based on location is okay");
177 171
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t
index 60837ef6..bba8947c 100644
--- a/plugins/t/check_load.t
+++ b/plugins/t/check_load.t
@@ -11,10 +11,12 @@ use NPTest;
11my $res; 11my $res;
12 12
13my $loadValue = "[0-9]+\.?[0-9]+"; 13my $loadValue = "[0-9]+\.?[0-9]+";
14my $successOutput = "/^LOAD OK - load average: $loadValue, $loadValue, $loadValue/"; 14my $successOutput = "/^LOAD OK - total load average: $loadValue, $loadValue, $loadValue/";
15my $failureOutput = "/^LOAD CRITICAL - load average: $loadValue, $loadValue, $loadValue/"; 15my $successScaledOutput = "/^LOAD OK - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/";
16my $failureOutput = "/^LOAD CRITICAL - total load average: $loadValue, $loadValue, $loadValue/";
17my $failurScaledOutput = "/^LOAD CRITICAL - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/";
16 18
17plan tests => 11; 19plan tests => 13;
18 20
19$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" ); 21$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
20cmp_ok( $res->return_code, 'eq', 0, "load not over 100"); 22cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
@@ -26,7 +28,7 @@ like( $res->output, $failureOutput, "Output OK");
26 28
27$res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" ); 29$res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" );
28cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division"); 30cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
29like( $res->output, $failureOutput, "Output OK"); 31like( $res->output, $failurScaledOutput, "Output OK");
30 32
31$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" ); 33$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
32cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments"); 34cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
@@ -34,3 +36,8 @@ like( $res->output, $successOutput, "Output OK");
34like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)"); 36like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
35like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)"); 37like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
36like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)"); 38like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");
39
40
41$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100 -r" );
42cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
43like( $res->output, $successScaledOutput, "Output OK");
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
index aa72ef67..72f2b7c2 100755
--- a/plugins/tests/check_curl.t
+++ b/plugins/tests/check_curl.t
@@ -21,7 +21,7 @@ use FindBin qw($Bin);
21 21
22$ENV{'LC_TIME'} = "C"; 22$ENV{'LC_TIME'} = "C";
23 23
24my $common_tests = 72; 24my $common_tests = 73;
25my $ssl_only_tests = 8; 25my $ssl_only_tests = 8;
26# Check that all dependent modules are available 26# Check that all dependent modules are available
27eval "use HTTP::Daemon 6.01;"; 27eval "use HTTP::Daemon 6.01;";
@@ -200,6 +200,14 @@ sub run_server {
200 $c->send_basic_header; 200 $c->send_basic_header;
201 $c->send_crlf; 201 $c->send_crlf;
202 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); 202 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
203 } elsif ($r->url->path eq "/chunked") {
204 my $chunks = ["chunked", "encoding", "test\n"];
205 $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
206 my $chunk = shift @{$chunks};
207 return unless $chunk;
208 sleep(1);
209 return($chunk);
210 }));
203 } else { 211 } else {
204 $c->send_error(HTTP::Status->RC_FORBIDDEN); 212 $c->send_error(HTTP::Status->RC_FORBIDDEN);
205 } 213 }
@@ -472,7 +480,8 @@ sub run_common_tests {
472 local $SIG{ALRM} = sub { die "alarm\n" }; 480 local $SIG{ALRM} = sub { die "alarm\n" };
473 alarm(2); 481 alarm(2);
474 $result = NPTest->testCmd( $cmd ); 482 $result = NPTest->testCmd( $cmd );
475 alarm(0); }; 483 };
484 alarm(0);
476 isnt( $@, "alarm\n", $cmd ); 485 isnt( $@, "alarm\n", $cmd );
477 is( $result->return_code, 0, $cmd ); 486 is( $result->return_code, 0, $cmd );
478 487
@@ -482,7 +491,8 @@ sub run_common_tests {
482 local $SIG{ALRM} = sub { die "alarm\n" }; 491 local $SIG{ALRM} = sub { die "alarm\n" };
483 alarm(2); 492 alarm(2);
484 $result = NPTest->testCmd( $cmd ); 493 $result = NPTest->testCmd( $cmd );
485 alarm(0); }; 494 };
495 alarm(0);
486 isnt( $@, "alarm\n", $cmd ); 496 isnt( $@, "alarm\n", $cmd );
487 isnt( $result->return_code, 0, $cmd ); 497 isnt( $result->return_code, 0, $cmd );
488 498
@@ -508,4 +518,9 @@ sub run_common_tests {
508 }; 518 };
509 is( $@, "", $cmd ); 519 is( $@, "", $cmd );
510 520
521 $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
522 eval {
523 $result = NPTest->testCmd( $cmd, 5 );
524 };
525 is( $@, "", $cmd );
511} 526}
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index ea11b2ac..d766ac37 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -12,7 +12,7 @@ use FindBin qw($Bin);
12 12
13$ENV{'LC_TIME'} = "C"; 13$ENV{'LC_TIME'} = "C";
14 14
15my $common_tests = 70; 15my $common_tests = 71;
16my $virtual_port_tests = 8; 16my $virtual_port_tests = 8;
17my $ssl_only_tests = 12; 17my $ssl_only_tests = 12;
18# Check that all dependent modules are available 18# Check that all dependent modules are available
@@ -190,6 +190,14 @@ sub run_server {
190 $c->send_basic_header; 190 $c->send_basic_header;
191 $c->send_crlf; 191 $c->send_crlf;
192 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); 192 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
193 } elsif ($r->url->path eq "/chunked") {
194 my $chunks = ["chunked", "encoding", "test\n"];
195 $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
196 my $chunk = shift @{$chunks};
197 return unless $chunk;
198 sleep(1);
199 return($chunk);
200 }));
193 } else { 201 } else {
194 $c->send_error(HTTP::Status->RC_FORBIDDEN); 202 $c->send_error(HTTP::Status->RC_FORBIDDEN);
195 } 203 }
@@ -497,4 +505,9 @@ sub run_common_tests {
497 }; 505 };
498 is( $@, "", $cmd ); 506 is( $@, "", $cmd );
499 507
508 $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
509 eval {
510 $result = NPTest->testCmd( $cmd, 5 );
511 };
512 is( $@, "", $cmd );
500} 513}
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index 0a77fa8a..bc03ec60 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -9,7 +9,7 @@ use NPTest;
9use FindBin qw($Bin); 9use FindBin qw($Bin);
10use POSIX qw/strftime/; 10use POSIX qw/strftime/;
11 11
12my $tests = 73; 12my $tests = 81;
13# Check that all dependent modules are available 13# Check that all dependent modules are available
14eval { 14eval {
15 require NetSNMP::OID; 15 require NetSNMP::OID;
@@ -57,9 +57,9 @@ if ($pid) {
57 exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp"); 57 exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp");
58} 58}
59 59
60END { 60END {
61 foreach my $pid (@pids) { 61 foreach my $pid (@pids) {
62 if ($pid) { print "Killing $pid\n"; kill "INT", $pid } 62 if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
63 } 63 }
64}; 64};
65 65
@@ -268,3 +268,19 @@ like($res->output, '/SNMP WARNING - \d+ \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d
268$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w 1,2 -c 1" ); 268$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w 1,2 -c 1" );
269is($res->return_code, 2, "Multiple OIDs with some thresholds" ); 269is($res->return_code, 2, "Multiple OIDs with some thresholds" );
270like($res->output, '/SNMP CRITICAL - \*\d+\* \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1;2 iso.3.6.1.4.1.8072.3.2.67.17=-4;;/', "Multiple OIDs with thresholds output" ); 270like($res->output, '/SNMP CRITICAL - \*\d+\* \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1;2 iso.3.6.1.4.1.8072.3.2.67.17=-4;;/', "Multiple OIDs with thresholds output" );
271
272$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19");
273is($res->return_code, 0, "Test plain .1.3.6.1.4.1.8072.3.2.67.6 RC" );
274is($res->output,'SNMP OK - 42 | iso.3.6.1.4.1.8072.3.2.67.19=42 ', "Test plain value of .1.3.6.1.4.1.8072.3.2.67.1" );
275
276$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 -M .1");
277is($res->return_code, 0, "Test multiply RC" );
278is($res->output,'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ' , "Test multiply .1 output" );
279
280$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' ");
281is($res->return_code, 0, "Test multiply RC + format" );
282is($res->output, 'SNMP OK - 4.20 | iso.3.6.1.4.1.8072.3.2.67.19=4.20 ', "Test multiply .1 output + format" );
283
284$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' -w 1");
285is($res->return_code, 1, "Test multiply RC + format + thresholds" );
286is($res->output, 'SNMP WARNING - *4.20* | iso.3.6.1.4.1.8072.3.2.67.19=4.20;1 ', "Test multiply .1 output + format + thresholds" );
diff --git a/plugins/tests/check_snmp_agent.pl b/plugins/tests/check_snmp_agent.pl
index 0e41d575..38912e98 100644
--- a/plugins/tests/check_snmp_agent.pl
+++ b/plugins/tests/check_snmp_agent.pl
@@ -32,11 +32,11 @@ my $multilin5 = 'And now have fun with with this: "C:\\"
32because we\'re not done yet!'; 32because we\'re not done yet!';
33 33
34# Next are arrays of indexes (Type, initial value and increments) 34# Next are arrays of indexes (Type, initial value and increments)
35# 0..16 <---- please update comment when adding/removing fields 35# 0..19 <---- please update comment when adding/removing fields
36my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR ); 36my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER );
37my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' ); 37my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6', 42 );
38# undef increments are randomized 38# undef increments are randomized
39my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef ); 39my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef, 0 );
40 40
41# Number of elements in our OID 41# Number of elements in our OID
42my $oidelts; 42my $oidelts;
diff --git a/plugins/utils.c b/plugins/utils.c
index 17dd5814..b4214c61 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -615,27 +615,27 @@ char *perfdata_uint64 (const char *label,
615 char *data = NULL; 615 char *data = NULL;
616 616
617 if (strpbrk (label, "'= ")) 617 if (strpbrk (label, "'= "))
618 xasprintf (&data, "'%s'=%ld%s;", label, val, uom); 618 xasprintf (&data, "'%s'=%" PRIu64 "%s;", label, val, uom);
619 else 619 else
620 xasprintf (&data, "%s=%ld%s;", label, val, uom); 620 xasprintf (&data, "%s=%" PRIu64 "%s;", label, val, uom);
621 621
622 if (warnp) 622 if (warnp)
623 xasprintf (&data, "%s%lu;", data, warn); 623 xasprintf (&data, "%s%" PRIu64 ";", data, warn);
624 else 624 else
625 xasprintf (&data, "%s;", data); 625 xasprintf (&data, "%s;", data);
626 626
627 if (critp) 627 if (critp)
628 xasprintf (&data, "%s%lu;", data, crit); 628 xasprintf (&data, "%s%" PRIu64 ";", data, crit);
629 else 629 else
630 xasprintf (&data, "%s;", data); 630 xasprintf (&data, "%s;", data);
631 631
632 if (minp) 632 if (minp)
633 xasprintf (&data, "%s%lu;", data, minv); 633 xasprintf (&data, "%s%" PRIu64 ";", data, minv);
634 else 634 else
635 xasprintf (&data, "%s;", data); 635 xasprintf (&data, "%s;", data);
636 636
637 if (maxp) 637 if (maxp)
638 xasprintf (&data, "%s%lu", data, maxv); 638 xasprintf (&data, "%s%" PRIu64, data, maxv);
639 639
640 return data; 640 return data;
641} 641}
@@ -656,27 +656,27 @@ char *perfdata_int64 (const char *label,
656 char *data = NULL; 656 char *data = NULL;
657 657
658 if (strpbrk (label, "'= ")) 658 if (strpbrk (label, "'= "))
659 xasprintf (&data, "'%s'=%ld%s;", label, val, uom); 659 xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
660 else 660 else
661 xasprintf (&data, "%s=%ld%s;", label, val, uom); 661 xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
662 662
663 if (warnp) 663 if (warnp)
664 xasprintf (&data, "%s%ld;", data, warn); 664 xasprintf (&data, "%s%" PRId64 ";", data, warn);
665 else 665 else
666 xasprintf (&data, "%s;", data); 666 xasprintf (&data, "%s;", data);
667 667
668 if (critp) 668 if (critp)
669 xasprintf (&data, "%s%ld;", data, crit); 669 xasprintf (&data, "%s%" PRId64 ";", data, crit);
670 else 670 else
671 xasprintf (&data, "%s;", data); 671 xasprintf (&data, "%s;", data);
672 672
673 if (minp) 673 if (minp)
674 xasprintf (&data, "%s%ld;", data, minv); 674 xasprintf (&data, "%s%" PRId64 ";", data, minv);
675 else 675 else
676 xasprintf (&data, "%s;", data); 676 xasprintf (&data, "%s;", data);
677 677
678 if (maxp) 678 if (maxp)
679 xasprintf (&data, "%s%ld", data, maxv); 679 xasprintf (&data, "%s%" PRId64, data, maxv);
680 680
681 return data; 681 return data;
682} 682}