summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.github/prepare_debian.sh2
-rw-r--r--.github/workflows/codeql-analysis.yml71
-rw-r--r--.github/workflows/test.yml1
-rw-r--r--NEWS1
-rw-r--r--configure.ac10
-rw-r--r--lib/utils_base.c2
-rw-r--r--lib/utils_base.h1
-rw-r--r--lib/utils_disk.h2
-rw-r--r--plugins-root/check_icmp.c6
-rwxr-xr-xplugins-scripts/check_ifoperstatus.pl2
-rwxr-xr-xplugins-scripts/check_ircd.pl4
-rw-r--r--plugins/check_by_ssh.c2
-rw-r--r--plugins/check_curl.c87
-rw-r--r--plugins/check_disk.c203
-rw-r--r--plugins/check_dns.c61
-rw-r--r--plugins/check_hpjd.c17
-rw-r--r--plugins/check_http.c4
-rw-r--r--plugins/check_ldap.c5
-rw-r--r--plugins/check_load.c2
-rw-r--r--plugins/check_ping.c14
-rw-r--r--plugins/check_procs.c52
-rw-r--r--plugins/check_smtp.c18
-rw-r--r--plugins/check_snmp.c11
-rw-r--r--plugins/check_swap.c278
-rw-r--r--plugins/check_ups.c5
-rw-r--r--plugins/t/check_curl.t2
-rw-r--r--plugins/t/check_disk.t7
-rw-r--r--plugins/t/check_dns.t10
-rw-r--r--plugins/t/check_load.t4
-rw-r--r--plugins/t/check_swap.t6
-rwxr-xr-xplugins/tests/check_procs.t26
-rwxr-xr-xplugins/tests/check_snmp.t17
-rw-r--r--plugins/tests/var/ps-axwo.debian219
-rw-r--r--plugins/tests/var/ps_axwo.debian84
-rw-r--r--plugins/utils.c130
-rw-r--r--plugins/utils.h9
36 files changed, 972 insertions, 403 deletions
diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh
index c68b9f5..4021c10 100755
--- a/.github/prepare_debian.sh
+++ b/.github/prepare_debian.sh
@@ -13,7 +13,7 @@ if [ $(lsb_release -is) = "Debian" ]; then
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 autotools-dev libdbi-dev libldap2-dev libpq-dev libradcli-dev libnet-snmp-perl procps
15apt-get -y install libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd 15apt-get -y install libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd
16apt-get -y install fping snmp netcat smbclient vsftpd apache2 ssl-cert postfix libhttp-daemon-ssl-perl 16apt-get -y install fping snmp netcat-openbsd smbclient vsftpd apache2 ssl-cert postfix libhttp-daemon-ssl-perl
17apt-get -y install libdbd-sybase-perl libnet-dns-perl 17apt-get -y install libdbd-sybase-perl libnet-dns-perl
18apt-get -y install slapd ldap-utils 18apt-get -y install slapd ldap-utils
19apt-get -y install gcc make autoconf automake gettext 19apt-get -y install gcc make autoconf automake gettext
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 0000000..9de367e
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,71 @@
1# For most projects, this workflow file will not need changing; you simply need
2# to commit it to your repository.
3#
4# You may wish to alter this file to override the set of languages analyzed,
5# or to provide custom queries or build logic.
6#
7# ******** NOTE ********
8# We have attempted to detect the languages in your repository. Please check
9# the `language` matrix defined below to confirm you have the correct set of
10# supported CodeQL languages.
11#
12name: "CodeQL"
13
14on:
15 push:
16 branches: [ master ]
17 pull_request:
18 # The branches below must be a subset of the branches above
19 branches: [ master ]
20 schedule:
21 - cron: '15 18 * * 0'
22
23jobs:
24 analyze:
25 name: Analyze
26 runs-on: ubuntu-latest
27 permissions:
28 actions: read
29 contents: read
30 security-events: write
31
32 strategy:
33 fail-fast: false
34 matrix:
35 language: [ 'cpp' ]
36 # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37 # Learn more:
38 # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39
40 steps:
41 - name: Checkout repository
42 uses: actions/checkout@v2
43
44 # Initializes the CodeQL tools for scanning.
45 - name: Initialize CodeQL
46 uses: github/codeql-action/init@v1
47 with:
48 languages: ${{ matrix.language }}
49 # If you wish to specify custom queries, you can do so here or in a config file.
50 # By default, queries listed here will override any specified in a config file.
51 # Prefix the list here with "+" to use these queries and those in the config file.
52 # queries: ./path/to/local/query, your-org/your-repo/queries@main
53
54 - name: Install packages
55 run: |
56 sudo apt-get install -y --no-install-recommends m4 gettext automake autoconf make build-essential
57 sudo apt-get install -y --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev \
58 libmysqlclient-dev libradcli-dev libkrb5-dev libdbi0-dev \
59 libdbd-sqlite3 libssl-dev libcurl4-openssl-dev liburiparser-dev
60
61 - name: Configure build
62 run: |
63 ./tools/setup
64 ./configure --enable-libtap
65
66 - name: Build
67 run: |
68 make
69
70 - name: Perform CodeQL Analysis
71 uses: github/codeql-action/analyze@v1
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 512d28e..0f93930 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -35,6 +35,7 @@ jobs:
35 -e NPTEST_CACHE="/src/.github/NPTest.cache" \ 35 -e NPTEST_CACHE="/src/.github/NPTest.cache" \
36 -w /src -v ${PWD}:/src \ 36 -w /src -v ${PWD}:/src \
37 --tmpfs /media/ramdisk1 \ 37 --tmpfs /media/ramdisk1 \
38 -v /var/run/utmp:/var/run/utmp \
38 --mount source=tmp-vol,destination=/src,target=/media/ramdisk2 \ 39 --mount source=tmp-vol,destination=/src,target=/media/ramdisk2 \
39 ${{ matrix.distro }} \ 40 ${{ matrix.distro }} \
40 /bin/sh -c '${{ matrix.prepare }} && \ 41 /bin/sh -c '${{ matrix.prepare }} && \
diff --git a/NEWS b/NEWS
index 4061c03..3790e8a 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ This file documents the major additions and syntax changes between releases.
13 check_dns: Accept CIDR 13 check_dns: Accept CIDR
14 check_dns: allow unsorted addresses 14 check_dns: allow unsorted addresses
15 check_dns: allow forcing complete match of all addresses 15 check_dns: allow forcing complete match of all addresses
16 check_dns: option to expect NXDOMAIN
16 check_apt: add --only-critical switch 17 check_apt: add --only-critical switch
17 check_apt: add -l/--list option to print packages 18 check_apt: add -l/--list option to print packages
18 check_file_age: add range checking 19 check_file_age: add range checking
diff --git a/configure.ac b/configure.ac
index 7c17dcd..dfc37b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -783,6 +783,16 @@ dnl ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT
783dnl ac_cv_ps_cols=8 783dnl ac_cv_ps_cols=8
784dnl AC_MSG_RESULT([$ac_cv_ps_command]) 784dnl AC_MSG_RESULT([$ac_cv_ps_command])
785 785
786dnl This one is the exact same test as the next one but includes etime
787elif ps axwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
788 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +ELAPSED +COMMAND"] > /dev/null
789then
790 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
791 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu etime comm args'"
792 ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
793 ac_cv_ps_cols=10
794 AC_MSG_RESULT([$ac_cv_ps_command])
795
786dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. 796dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
787dnl so test for this first... 797dnl so test for this first...
788elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 798elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
diff --git a/lib/utils_base.c b/lib/utils_base.c
index fd7058d..08fa215 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -128,6 +128,7 @@ range
128 temp_range->end = 0; 128 temp_range->end = 0;
129 temp_range->end_infinity = TRUE; 129 temp_range->end_infinity = TRUE;
130 temp_range->alert_on = OUTSIDE; 130 temp_range->alert_on = OUTSIDE;
131 temp_range->text = strdup(str);
131 132
132 if (str[0] == '@') { 133 if (str[0] == '@') {
133 temp_range->alert_on = INSIDE; 134 temp_range->alert_on = INSIDE;
@@ -706,4 +707,3 @@ void np_state_write_string(time_t data_time, char *data_string) {
706 707
707 np_free(temp_file); 708 np_free(temp_file);
708} 709}
709
diff --git a/lib/utils_base.h b/lib/utils_base.h
index d7e7dff..9482f23 100644
--- a/lib/utils_base.h
+++ b/lib/utils_base.h
@@ -23,6 +23,7 @@ typedef struct range_struct {
23 double end; 23 double end;
24 int end_infinity; 24 int end_infinity;
25 int alert_on; /* OUTSIDE (default) or INSIDE */ 25 int alert_on; /* OUTSIDE (default) or INSIDE */
26 char* text; /* original unparsed text input */
26 } range; 27 } range;
27 28
28typedef struct thresholds_struct { 29typedef struct thresholds_struct {
diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index 999270c..bf52e4c 100644
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
@@ -27,7 +27,7 @@ struct parameter_list
27 uintmax_t total, available, available_to_root, used, 27 uintmax_t total, available, available_to_root, used,
28 inodes_free, inodes_free_to_root, inodes_used, inodes_total; 28 inodes_free, inodes_free_to_root, inodes_used, inodes_total;
29 double dfree_pct, dused_pct; 29 double dfree_pct, dused_pct;
30 double dused_units, dfree_units, dtotal_units; 30 uint64_t dused_units, dfree_units, dtotal_units;
31 double dused_inodes_percent, dfree_inodes_percent; 31 double dused_inodes_percent, dfree_inodes_percent;
32}; 32};
33 33
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 31eb4c6..01ae174 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -502,7 +502,7 @@ main(int argc, char **argv)
502 icmp_data_size = size; 502 icmp_data_size = size;
503 icmp_pkt_size = size + ICMP_MINLEN; 503 icmp_pkt_size = size + ICMP_MINLEN;
504 } else 504 } else
505 usage_va("ICMP data length must be between: %d and %d", 505 usage_va("ICMP data length must be between: %lu and %lu",
506 sizeof(struct icmp) + sizeof(struct icmp_ping_data), 506 sizeof(struct icmp) + sizeof(struct icmp_ping_data),
507 MAX_PING_DATA - 1); 507 MAX_PING_DATA - 1);
508 break; 508 break;
@@ -921,7 +921,7 @@ wait_for_reply(int sock, u_int t)
921 /* if we're in hostcheck mode, exit with limited printouts */ 921 /* if we're in hostcheck mode, exit with limited printouts */
922 if(mode == MODE_HOSTCHECK) { 922 if(mode == MODE_HOSTCHECK) {
923 printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|" 923 printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|"
924 "pkt=%u;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n", 924 "pkt=%u;;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n",
925 host->name, icmp_recv, (float)tdiff / 1000, 925 host->name, icmp_recv, (float)tdiff / 1000,
926 icmp_recv, packets, (float)tdiff / 1000, 926 icmp_recv, packets, (float)tdiff / 1000,
927 (float)warn.rta / 1000, (float)crit.rta / 1000); 927 (float)warn.rta / 1000, (float)crit.rta / 1000);
@@ -1293,7 +1293,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in)
1293 if(!host) { 1293 if(!host) {
1294 char straddr[INET6_ADDRSTRLEN]; 1294 char straddr[INET6_ADDRSTRLEN];
1295 parse_address((struct sockaddr_storage*)&in, straddr, sizeof(straddr)); 1295 parse_address((struct sockaddr_storage*)&in, straddr, sizeof(straddr));
1296 crash("add_target_ip(%s, %s): malloc(%d) failed", 1296 crash("add_target_ip(%s, %s): malloc(%lu) failed",
1297 arg, straddr, sizeof(struct rta_host)); 1297 arg, straddr, sizeof(struct rta_host));
1298 } 1298 }
1299 memset(host, 0, sizeof(struct rta_host)); 1299 memset(host, 0, sizeof(struct rta_host));
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl
index 9ede163..c190ce9 100755
--- a/plugins-scripts/check_ifoperstatus.pl
+++ b/plugins-scripts/check_ifoperstatus.pl
@@ -124,10 +124,10 @@ if (!defined($session)) {
124## map ifdescr to ifindex - should look at being able to cache this value 124## map ifdescr to ifindex - should look at being able to cache this value
125 125
126if (defined $ifdescr || defined $iftype) { 126if (defined $ifdescr || defined $iftype) {
127 # escape "/" in ifdescr - very common in the Cisco world
128 if (defined $iftype) { 127 if (defined $iftype) {
129 $status=fetch_ifindex($snmpIfType, $iftype); 128 $status=fetch_ifindex($snmpIfType, $iftype);
130 } else { 129 } else {
130 # escape "/" in ifdescr - very common in the Cisco world
131 $ifdescr =~ s/\//\\\//g; 131 $ifdescr =~ s/\//\\\//g;
132 $status=fetch_ifindex($snmpIfDescr, $ifdescr); # if using on device with large number of interfaces 132 $status=fetch_ifindex($snmpIfDescr, $ifdescr); # if using on device with large number of interfaces
133 # recommend use of SNMP v2 (get-bulk) 133 # recommend use of SNMP v2 (get-bulk)
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl
index 22d21c2..d869ae7 100755
--- a/plugins-scripts/check_ircd.pl
+++ b/plugins-scripts/check_ircd.pl
@@ -69,7 +69,9 @@ $ENV{'ENV'}='';
69# -----------------------------------------------------------------[ Global ]-- 69# -----------------------------------------------------------------[ Global ]--
70 70
71$PROGNAME = "check_ircd"; 71$PROGNAME = "check_ircd";
72my $NICK="ircd$$"; 72# nickname shouldn't be longer than 9 chars, this might happen with large PIDs
73# To prevent this, we cut of the part over 10000
74my $NICK="ircd" . $$ % 10000;
73my $USER_INFO="monitor localhost localhost : "; 75my $USER_INFO="monitor localhost localhost : ";
74 76
75# -------------------------------------------------------------[ connection ]-- 77# -------------------------------------------------------------[ connection ]--
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 13d8bc3..485bf3b 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -230,7 +230,6 @@ process_arguments (int argc, char **argv)
230 timeout_interval = atoi (optarg); 230 timeout_interval = atoi (optarg);
231 break; 231 break;
232 case 'H': /* host */ 232 case 'H': /* host */
233 host_or_die(optarg);
234 hostname = optarg; 233 hostname = optarg;
235 break; 234 break;
236 case 'p': /* port number */ 235 case 'p': /* port number */
@@ -329,7 +328,6 @@ process_arguments (int argc, char **argv)
329 if (c <= argc) { 328 if (c <= argc) {
330 die (STATE_UNKNOWN, _("%s: You must provide a host name\n"), progname); 329 die (STATE_UNKNOWN, _("%s: You must provide a host name\n"), progname);
331 } 330 }
332 host_or_die(argv[c]);
333 hostname = argv[c++]; 331 hostname = argv[c++];
334 } 332 }
335 333
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 59e398b..14cc846 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -55,6 +55,12 @@ const char *email = "devel@monitoring-plugins.org";
55 55
56#include <arpa/inet.h> 56#include <arpa/inet.h>
57 57
58#if defined(HAVE_SSL) && defined(USE_OPENSSL)
59#include <openssl/opensslv.h>
60#endif
61
62#include <netdb.h>
63
58#define MAKE_LIBCURL_VERSION(major, minor, patch) ((major)*0x10000 + (minor)*0x100 + (patch)) 64#define MAKE_LIBCURL_VERSION(major, minor, patch) ((major)*0x10000 + (minor)*0x100 + (patch))
59 65
60#define DEFAULT_BUFFER_SIZE 2048 66#define DEFAULT_BUFFER_SIZE 2048
@@ -206,6 +212,7 @@ int maximum_age = -1;
206int address_family = AF_UNSPEC; 212int address_family = AF_UNSPEC;
207curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN; 213curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN;
208int curl_http_version = CURL_HTTP_VERSION_NONE; 214int curl_http_version = CURL_HTTP_VERSION_NONE;
215int automatic_decompression = FALSE;
209 216
210int process_arguments (int, char**); 217int process_arguments (int, char**);
211void handle_curl_option_return_code (CURLcode res, const char* option); 218void handle_curl_option_return_code (CURLcode res, const char* option);
@@ -285,7 +292,9 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
285 * TODO: is the last certificate always the server certificate? 292 * TODO: is the last certificate always the server certificate?
286 */ 293 */
287 cert = X509_STORE_CTX_get_current_cert(x509_ctx); 294 cert = X509_STORE_CTX_get_current_cert(x509_ctx);
295#if OPENSSL_VERSION_NUMBER >= 0x10100000L
288 X509_up_ref(cert); 296 X509_up_ref(cert);
297#endif
289 if (verbose>=2) { 298 if (verbose>=2) {
290 puts("* SSL verify callback with certificate:"); 299 puts("* SSL verify callback with certificate:");
291 X509_NAME *subject, *issuer; 300 X509_NAME *subject, *issuer;
@@ -363,12 +372,55 @@ handle_curl_option_return_code (CURLcode res, const char* option)
363} 372}
364 373
365int 374int
375lookup_host (const char *host, char *buf, size_t buflen)
376{
377 struct addrinfo hints, *res, *result;
378 int errcode;
379 void *ptr;
380
381 memset (&hints, 0, sizeof (hints));
382 hints.ai_family = address_family;
383 hints.ai_socktype = SOCK_STREAM;
384 hints.ai_flags |= AI_CANONNAME;
385
386 errcode = getaddrinfo (host, NULL, &hints, &result);
387 if (errcode != 0)
388 return errcode;
389
390 res = result;
391
392 while (res) {
393 inet_ntop (res->ai_family, res->ai_addr->sa_data, buf, buflen);
394 switch (res->ai_family) {
395 case AF_INET:
396 ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
397 break;
398 case AF_INET6:
399 ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
400 break;
401 }
402 inet_ntop (res->ai_family, ptr, buf, buflen);
403 if (verbose >= 1)
404 printf ("* getaddrinfo IPv%d address: %s\n",
405 res->ai_family == PF_INET6 ? 6 : 4, buf);
406 res = res->ai_next;
407 }
408
409 freeaddrinfo(result);
410
411 return 0;
412}
413
414int
366check_http (void) 415check_http (void)
367{ 416{
368 int result = STATE_OK; 417 int result = STATE_OK;
369 int page_len = 0; 418 int page_len = 0;
370 int i; 419 int i;
371 char *force_host_header = NULL; 420 char *force_host_header = NULL;
421 struct curl_slist *host = NULL;
422 char addrstr[100];
423 char dnscache[DEFAULT_BUFFER_SIZE];
372 424
373 /* initialize curl */ 425 /* initialize curl */
374 if (curl_global_init (CURL_GLOBAL_DEFAULT) != CURLE_OK) 426 if (curl_global_init (CURL_GLOBAL_DEFAULT) != CURLE_OK)
@@ -383,6 +435,13 @@ check_http (void)
383 /* print everything on stdout like check_http would do */ 435 /* print everything on stdout like check_http would do */
384 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_STDERR, stdout), "CURLOPT_STDERR"); 436 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_STDERR, stdout), "CURLOPT_STDERR");
385 437
438 if (automatic_decompression)
439#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 21, 6)
440 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""), "CURLOPT_ACCEPT_ENCODING");
441#else
442 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_ENCODING, ""), "CURLOPT_ENCODING");
443#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 21, 6) */
444
386 /* initialize buffer for body of the answer */ 445 /* initialize buffer for body of the answer */
387 if (curlhelp_initwritebuffer(&body_buf) < 0) 446 if (curlhelp_initwritebuffer(&body_buf) < 0)
388 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for body\n"); 447 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for body\n");
@@ -404,9 +463,12 @@ check_http (void)
404 463
405 // fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy 464 // fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy
406 if(use_ssl && host_name != NULL) { 465 if(use_ssl && host_name != NULL) {
407 struct curl_slist *host = NULL; 466 if ( (res=lookup_host (server_address, addrstr, 100)) != 0) {
408 char dnscache[DEFAULT_BUFFER_SIZE]; 467 snprintf (msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"),
409 snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, server_address); 468 server_address, res, gai_strerror (res));
469 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
470 }
471 snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, addrstr);
410 host = curl_slist_append(NULL, dnscache); 472 host = curl_slist_append(NULL, dnscache);
411 curl_easy_setopt(curl, CURLOPT_RESOLVE, host); 473 curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
412 if (verbose>=1) 474 if (verbose>=1)
@@ -971,8 +1033,8 @@ char*
971uri_string (const UriTextRangeA range, char* buf, size_t buflen) 1033uri_string (const UriTextRangeA range, char* buf, size_t buflen)
972{ 1034{
973 if (!range.first) return "(null)"; 1035 if (!range.first) return "(null)";
974 strncpy (buf, range.first, max (buflen, range.afterLast - range.first)); 1036 strncpy (buf, range.first, max (buflen-1, range.afterLast - range.first));
975 buf[max (buflen, range.afterLast - range.first)] = '\0'; 1037 buf[max (buflen-1, range.afterLast - range.first)] = '\0';
976 buf[range.afterLast - range.first] = '\0'; 1038 buf[range.afterLast - range.first] = '\0';
977 return buf; 1039 return buf;
978} 1040}
@@ -1092,8 +1154,8 @@ redir (curlhelp_write_curlbuf* header_buf)
1092 !strncmp(server_address, new_host, MAX_IPV4_HOSTLENGTH) && 1154 !strncmp(server_address, new_host, MAX_IPV4_HOSTLENGTH) &&
1093 (host_name && !strncmp(host_name, new_host, MAX_IPV4_HOSTLENGTH)) && 1155 (host_name && !strncmp(host_name, new_host, MAX_IPV4_HOSTLENGTH)) &&
1094 !strcmp(server_url, new_url)) 1156 !strcmp(server_url, new_url))
1095 die (STATE_WARNING, 1157 die (STATE_CRITICAL,
1096 _("HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"), 1158 _("HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"),
1097 use_ssl ? "https" : "http", new_host, new_port, new_url, (display_html ? "</A>" : "")); 1159 use_ssl ? "https" : "http", new_host, new_port, new_url, (display_html ? "</A>" : ""));
1098 1160
1099 /* set new values for redirected request */ 1161 /* set new values for redirected request */
@@ -1149,7 +1211,8 @@ process_arguments (int argc, char **argv)
1149 INVERT_REGEX = CHAR_MAX + 1, 1211 INVERT_REGEX = CHAR_MAX + 1,
1150 SNI_OPTION, 1212 SNI_OPTION,
1151 CA_CERT_OPTION, 1213 CA_CERT_OPTION,
1152 HTTP_VERSION_OPTION 1214 HTTP_VERSION_OPTION,
1215 AUTOMATIC_DECOMPRESSION
1153 }; 1216 };
1154 1217
1155 int option = 0; 1218 int option = 0;
@@ -1192,6 +1255,7 @@ process_arguments (int argc, char **argv)
1192 {"extended-perfdata", no_argument, 0, 'E'}, 1255 {"extended-perfdata", no_argument, 0, 'E'},
1193 {"show-body", no_argument, 0, 'B'}, 1256 {"show-body", no_argument, 0, 'B'},
1194 {"http-version", required_argument, 0, HTTP_VERSION_OPTION}, 1257 {"http-version", required_argument, 0, HTTP_VERSION_OPTION},
1258 {"enable-automatic-decompression", no_argument, 0, AUTOMATIC_DECOMPRESSION},
1195 {0, 0, 0, 0} 1259 {0, 0, 0, 0}
1196 }; 1260 };
1197 1261
@@ -1358,7 +1422,7 @@ process_arguments (int argc, char **argv)
1358#ifdef LIBCURL_FEATURE_SSL 1422#ifdef LIBCURL_FEATURE_SSL
1359 case 'D': /* verify peer certificate & host */ 1423 case 'D': /* verify peer certificate & host */
1360 verify_peer_and_host = TRUE; 1424 verify_peer_and_host = TRUE;
1361 goto enable_ssl; 1425 break;
1362#endif 1426#endif
1363 case 'S': /* use SSL */ 1427 case 'S': /* use SSL */
1364#ifdef LIBCURL_FEATURE_SSL 1428#ifdef LIBCURL_FEATURE_SSL
@@ -1583,6 +1647,9 @@ process_arguments (int argc, char **argv)
1583 exit (STATE_WARNING); 1647 exit (STATE_WARNING);
1584 } 1648 }
1585 break; 1649 break;
1650 case AUTOMATIC_DECOMPRESSION:
1651 automatic_decompression = TRUE;
1652 break;
1586 case '?': 1653 case '?':
1587 /* print short usage statement if args not parsable */ 1654 /* print short usage statement if args not parsable */
1588 usage5 (); 1655 usage5 ();
@@ -1793,6 +1860,8 @@ print_help (void)
1793 printf (" %s\n", "--http-version=VERSION"); 1860 printf (" %s\n", "--http-version=VERSION");
1794 printf (" %s\n", _("Connect via specific HTTP protocol.")); 1861 printf (" %s\n", _("Connect via specific HTTP protocol."));
1795 printf (" %s\n", _("1.0 = HTTP/1.0, 1.1 = HTTP/1.1, 2.0 = HTTP/2 (HTTP/2 will fail without -S)")); 1862 printf (" %s\n", _("1.0 = HTTP/1.0, 1.1 = HTTP/1.1, 2.0 = HTTP/2 (HTTP/2 will fail without -S)"));
1863 printf (" %s\n", "--enable-automatic-decompression");
1864 printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING)."));
1796 printf ("\n"); 1865 printf ("\n");
1797 1866
1798 printf (UT_WARN_CRIT); 1867 printf (UT_WARN_CRIT);
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 844e625..54befca 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1,29 +1,29 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_disk plugin 3* Monitoring check_disk plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2008 Monitoring Plugins Development Team 6* Copyright (c) 1999-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_disk plugin 10* This file contains the check_disk plugin
11* 11*
12* 12*
13* This program is free software: you can redistribute it and/or modify 13* This program is free software: you can redistribute it and/or modify
14* it under the terms of the GNU General Public License as published by 14* it under the terms of the GNU General Public License as published by
15* the Free Software Foundation, either version 3 of the License, or 15* the Free Software Foundation, either version 3 of the License, or
16* (at your option) any later version. 16* (at your option) any later version.
17* 17*
18* This program is distributed in the hope that it will be useful, 18* This program is distributed in the hope that it will be useful,
19* but WITHOUT ANY WARRANTY; without even the implied warranty of 19* but WITHOUT ANY WARRANTY; without even the implied warranty of
20* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21* GNU General Public License for more details. 21* GNU General Public License for more details.
22* 22*
23* You should have received a copy of the GNU General Public License 23* You should have received a copy of the GNU General Public License
24* along with this program. If not, see <http://www.gnu.org/licenses/>. 24* along with this program. If not, see <http://www.gnu.org/licenses/>.
25* 25*
26* 26*
27*****************************************************************************/ 27*****************************************************************************/
28 28
29const char *progname = "check_disk"; 29const char *progname = "check_disk";
@@ -46,7 +46,7 @@ const char *email = "devel@monitoring-plugins.org";
46#include <stdarg.h> 46#include <stdarg.h>
47#include "fsusage.h" 47#include "fsusage.h"
48#include "mountlist.h" 48#include "mountlist.h"
49#include "intprops.h" /* necessary for TYPE_MAXIMUM */ 49#include "intprops.h" /* necessary for TYPE_MAXIMUM */
50#if HAVE_LIMITS_H 50#if HAVE_LIMITS_H
51# include <limits.h> 51# include <limits.h>
52#endif 52#endif
@@ -172,8 +172,6 @@ main (int argc, char **argv)
172 char *preamble; 172 char *preamble;
173 char *flag_header; 173 char *flag_header;
174 double inode_space_pct; 174 double inode_space_pct;
175 double warning_high_tide;
176 double critical_high_tide;
177 int temp_result; 175 int temp_result;
178 176
179 struct mount_entry *me; 177 struct mount_entry *me;
@@ -245,17 +243,17 @@ main (int argc, char **argv)
245 243
246#ifdef __CYGWIN__ 244#ifdef __CYGWIN__
247 if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11) 245 if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11)
248 continue; 246 continue;
249 snprintf(mountdir, sizeof(mountdir), "%s:\\", me->me_mountdir + 10); 247 snprintf(mountdir, sizeof(mountdir), "%s:\\", me->me_mountdir + 10);
250 if (GetDriveType(mountdir) != DRIVE_FIXED) 248 if (GetDriveType(mountdir) != DRIVE_FIXED)
251 me->me_remote = 1; 249 me->me_remote = 1;
252#endif 250#endif
253 /* Filters */ 251 /* Filters */
254 252
255 /* Remove filesystems already seen */ 253 /* Remove filesystems already seen */
256 if (np_seen_name(seen, me->me_mountdir)) { 254 if (np_seen_name(seen, me->me_mountdir)) {
257 continue; 255 continue;
258 } 256 }
259 np_add_name(&seen, me->me_mountdir); 257 np_add_name(&seen, me->me_mountdir);
260 258
261 if (path->group == NULL) { 259 if (path->group == NULL) {
@@ -288,8 +286,17 @@ main (int argc, char **argv)
288 get_stats (path, &fsp); 286 get_stats (path, &fsp);
289 287
290 if (verbose >= 3) { 288 if (verbose >= 3) {
291 printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n", 289 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",
292 me->me_mountdir, path->dused_pct, path->dfree_pct, path->dused_units, path->dfree_units, path->dtotal_units, path->dused_inodes_percent, path->dfree_inodes_percent, fsp.fsu_blocksize, mult); 290 me->me_mountdir,
291 path->dused_pct,
292 path->dfree_pct,
293 path->dused_units,
294 path->dfree_units,
295 path->dtotal_units,
296 path->dused_inodes_percent,
297 path->dfree_inodes_percent,
298 fsp.fsu_blocksize,
299 mult);
293 } 300 }
294 301
295 /* Threshold comparisons */ 302 /* Threshold comparisons */
@@ -326,77 +333,79 @@ main (int argc, char **argv)
326 */ 333 */
327 334
328 /* *_high_tide must be reinitialized at each run */ 335 /* *_high_tide must be reinitialized at each run */
329 warning_high_tide = UINT_MAX; 336 uint64_t warning_high_tide = UINT64_MAX;
330 critical_high_tide = UINT_MAX;
331 337
332 if (path->freespace_units->warning != NULL) { 338 if (path->freespace_units->warning != NULL) {
333 warning_high_tide = path->dtotal_units - path->freespace_units->warning->end; 339 warning_high_tide = (path->dtotal_units - path->freespace_units->warning->end) * mult;
334 } 340 }
335 if (path->freespace_percent->warning != NULL) { 341 if (path->freespace_percent->warning != NULL) {
336 warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*path->dtotal_units )); 342 warning_high_tide = min( warning_high_tide, (uint64_t)((1.0 - path->freespace_percent->warning->end/100) * (path->dtotal_units * mult)) );
337 } 343 }
344
345 uint64_t critical_high_tide = UINT64_MAX;
346
338 if (path->freespace_units->critical != NULL) { 347 if (path->freespace_units->critical != NULL) {
339 critical_high_tide = path->dtotal_units - path->freespace_units->critical->end; 348 critical_high_tide = (path->dtotal_units - path->freespace_units->critical->end) * mult;
340 } 349 }
341 if (path->freespace_percent->critical != NULL) { 350 if (path->freespace_percent->critical != NULL) {
342 critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*path->dtotal_units )); 351 critical_high_tide = min( critical_high_tide, (uint64_t)((1.0 - path->freespace_percent->critical->end/100) * (path->dtotal_units * mult)) );
343 } 352 }
344 353
345 /* Nb: *_high_tide are unset when == UINT_MAX */ 354 /* Nb: *_high_tide are unset when == UINT64_MAX */
346 xasprintf (&perf, "%s %s", perf, 355 xasprintf (&perf, "%s %s", perf,
347 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 356 perfdata_uint64 (
348 path->dused_units, units, 357 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
349 (warning_high_tide != UINT_MAX ? TRUE : FALSE), warning_high_tide, 358 path->dused_units * mult, "B",
350 (critical_high_tide != UINT_MAX ? TRUE : FALSE), critical_high_tide, 359 (warning_high_tide == UINT64_MAX ? FALSE : TRUE), warning_high_tide,
351 TRUE, 0, 360 (critical_high_tide == UINT64_MAX ? FALSE : TRUE), critical_high_tide,
352 TRUE, path->dtotal_units)); 361 TRUE, 0,
362 TRUE, path->dtotal_units * mult));
353 363
354 if (display_inodes_perfdata) { 364 if (display_inodes_perfdata) {
355 /* *_high_tide must be reinitialized at each run */ 365 /* *_high_tide must be reinitialized at each run */
356 warning_high_tide = UINT_MAX; 366 warning_high_tide = UINT64_MAX;
357 critical_high_tide = UINT_MAX; 367 critical_high_tide = UINT64_MAX;
358 368
359 if (path->freeinodes_percent->warning != NULL) { 369 if (path->freeinodes_percent->warning != NULL) {
360 warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total )); 370 warning_high_tide = llabs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total ));
361 } 371 }
362 if (path->freeinodes_percent->critical != NULL) { 372 if (path->freeinodes_percent->critical != NULL) {
363 critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total )); 373 critical_high_tide = llabs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total ));
364 } 374 }
365 375
366 xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir); 376 xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
367 /* Nb: *_high_tide are unset when == UINT_MAX */ 377 /* Nb: *_high_tide are unset when == UINT64_MAX */
368 xasprintf (&perf, "%s %s", perf, 378 xasprintf (&perf, "%s %s", perf,
369 perfdata (perf_ilabel, 379 perfdata_uint64 (perf_ilabel,
370 path->inodes_used, "", 380 path->inodes_used, "",
371 (warning_high_tide != UINT_MAX ? TRUE : FALSE), warning_high_tide, 381 (warning_high_tide != UINT64_MAX ? TRUE : FALSE), warning_high_tide,
372 (critical_high_tide != UINT_MAX ? TRUE : FALSE), critical_high_tide, 382 (critical_high_tide != UINT64_MAX ? TRUE : FALSE), critical_high_tide,
373 TRUE, 0, 383 TRUE, 0,
374 TRUE, path->inodes_total)); 384 TRUE, path->inodes_total));
375 } 385 }
376 386
377 if (disk_result==STATE_OK && erronly && !verbose) 387 if (disk_result==STATE_OK && erronly && !verbose)
378 continue; 388 continue;
379 389
380 if(disk_result && verbose >= 1) { 390 if(disk_result && verbose >= 1) {
381 xasprintf(&flag_header, " %s [", state_text (disk_result)); 391 xasprintf(&flag_header, " %s [", state_text (disk_result));
382 } else { 392 } else {
383 xasprintf(&flag_header, ""); 393 xasprintf(&flag_header, "");
384 } 394 }
385 xasprintf (&output, "%s%s %s %.0f %s (%.0f%%", 395 xasprintf (&output, "%s%s %s %llu%s (%.0f%%",
386 output, flag_header, 396 output, flag_header,
387 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 397 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
388 path->dfree_units, 398 path->dfree_units,
389 units, 399 units,
390 path->dfree_pct); 400 path->dfree_pct);
391 if (path->dused_inodes_percent < 0) { 401 if (path->dused_inodes_percent < 0) {
392 xasprintf(&output, "%s inode=-)%s;", output, (disk_result ? "]" : "")); 402 xasprintf(&output, "%s inode=-)%s;", output, (disk_result ? "]" : ""));
393 } else { 403 } else {
394 xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : "")); 404 xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : ""));
395 } 405 }
396 free(flag_header); 406 free(flag_header);
397 /* TODO: Need to do a similar debug line 407 /* TODO: Need to do a similar debug line
398 xasprintf (&details, _("%s\n\ 408 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%%"),
399%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
400 details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct, 409 details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct,
401 me->me_devname, me->me_type, me->me_mountdir, 410 me->me_devname, me->me_type, me->me_mountdir,
402 (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp); 411 (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp);
@@ -557,14 +566,14 @@ process_arguments (int argc, char **argv)
557 } 566 }
558 break; 567 break;
559 568
560 case 'W': /* warning inode threshold */ 569 case 'W': /* warning inode threshold */
561 if (*optarg == '@') { 570 if (*optarg == '@') {
562 warn_freeinodes_percent = optarg; 571 warn_freeinodes_percent = optarg;
563 } else { 572 } else {
564 xasprintf(&warn_freeinodes_percent, "@%s", optarg); 573 xasprintf(&warn_freeinodes_percent, "@%s", optarg);
565 } 574 }
566 break; 575 break;
567 case 'K': /* critical inode threshold */ 576 case 'K': /* critical inode threshold */
568 if (*optarg == '@') { 577 if (*optarg == '@') {
569 crit_freeinodes_percent = optarg; 578 crit_freeinodes_percent = optarg;
570 } else { 579 } else {
@@ -574,21 +583,24 @@ process_arguments (int argc, char **argv)
574 case 'u': 583 case 'u':
575 if (units) 584 if (units)
576 free(units); 585 free(units);
577 if (! strcmp (optarg, "bytes")) { 586 if (! strcasecmp (optarg, "bytes")) {
578 mult = (uintmax_t)1; 587 mult = (uintmax_t)1;
579 units = strdup ("B"); 588 units = strdup ("B");
580 } else if (! strcmp (optarg, "kB")) { 589 } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) {
581 mult = (uintmax_t)1024; 590 mult = (uintmax_t)1024;
582 units = strdup ("kB"); 591 units = strdup ("kiB");
583 } else if (! strcmp (optarg, "MB")) { 592 } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) {
584 mult = (uintmax_t)1024 * 1024; 593 mult = (uintmax_t)1024 * 1024;
585 units = strdup ("MB"); 594 units = strdup ("MiB");
586 } else if (! strcmp (optarg, "GB")) { 595 } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) {
587 mult = (uintmax_t)1024 * 1024 * 1024; 596 mult = (uintmax_t)1024 * 1024 * 1024;
588 units = strdup ("GB"); 597 units = strdup ("GiB");
589 } else if (! strcmp (optarg, "TB")) { 598 } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) {
590 mult = (uintmax_t)1024 * 1024 * 1024 * 1024; 599 mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
591 units = strdup ("TB"); 600 units = strdup ("TiB");
601 } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) {
602 mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024;
603 units = strdup ("PiB");
592 } else { 604 } else {
593 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); 605 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
594 } 606 }
@@ -599,13 +611,13 @@ process_arguments (int argc, char **argv)
599 mult = 1024; 611 mult = 1024;
600 if (units) 612 if (units)
601 free(units); 613 free(units);
602 units = strdup ("kB"); 614 units = strdup ("kiB");
603 break; 615 break;
604 case 'm': /* display mountpoint */ 616 case 'm': /* display mountpoint */
605 mult = 1024 * 1024; 617 mult = 1024 * 1024;
606 if (units) 618 if (units)
607 free(units); 619 free(units);
608 units = strdup ("MB"); 620 units = strdup ("MiB");
609 break; 621 break;
610 case 'L': 622 case 'L':
611 stat_remote_fs = 1; 623 stat_remote_fs = 1;
@@ -812,7 +824,7 @@ process_arguments (int argc, char **argv)
812 } 824 }
813 825
814 if (units == NULL) { 826 if (units == NULL) {
815 units = strdup ("MB"); 827 units = strdup ("MiB");
816 mult = (uintmax_t)1024 * 1024; 828 mult = (uintmax_t)1024 * 1024;
817 } 829 }
818 830
@@ -1026,20 +1038,26 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
1026 if (p_list->group && ! (strcmp(p_list->group, p->group))) { 1038 if (p_list->group && ! (strcmp(p_list->group, p->group))) {
1027 stat_path(p_list); 1039 stat_path(p_list);
1028 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); 1040 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp);
1029 get_path_stats(p_list, &tmpfsp); 1041 get_path_stats(p_list, &tmpfsp);
1030 if (verbose >= 3) 1042 if (verbose >= 3)
1031 printf("Group %s: adding %llu blocks sized %llu, (%s) used_units=%g free_units=%g total_units=%g fsu_blocksize=%llu mult=%llu\n", 1043 printf("Group %s: adding %llu blocks sized %llu, (%s) used_units=%lu free_units=%llu total_units=%llu mult=%llu\n",
1032 p_list->group, tmpfsp.fsu_bavail, tmpfsp.fsu_blocksize, p_list->best_match->me_mountdir, p_list->dused_units, p_list->dfree_units, 1044 p_list->group,
1033 p_list->dtotal_units, mult); 1045 tmpfsp.fsu_blocks,
1034 1046 tmpfsp.fsu_blocksize,
1035 /* prevent counting the first FS of a group twice since its parameter_list entry 1047 p_list->best_match->me_mountdir,
1048 p_list->dused_units,
1049 p_list->dfree_units,
1050 p_list->dtotal_units,
1051 mult);
1052
1053 /* prevent counting the first FS of a group twice since its parameter_list entry
1036 * is used to carry the information of all file systems of the entire group */ 1054 * is used to carry the information of all file systems of the entire group */
1037 if (! first) { 1055 if (! first) {
1038 p->total += p_list->total; 1056 p->total += p_list->total;
1039 p->available += p_list->available; 1057 p->available += p_list->available;
1040 p->available_to_root += p_list->available_to_root; 1058 p->available_to_root += p_list->available_to_root;
1041 p->used += p_list->used; 1059 p->used += p_list->used;
1042 1060
1043 p->dused_units += p_list->dused_units; 1061 p->dused_units += p_list->dused_units;
1044 p->dfree_units += p_list->dfree_units; 1062 p->dfree_units += p_list->dfree_units;
1045 p->dtotal_units += p_list->dtotal_units; 1063 p->dtotal_units += p_list->dtotal_units;
@@ -1050,28 +1068,29 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
1050 } 1068 }
1051 first = 0; 1069 first = 0;
1052 } 1070 }
1053 if (verbose >= 3) 1071 if (verbose >= 3)
1054 printf("Group %s now has: used_units=%g free_units=%g total_units=%g fsu_blocksize=%llu mult=%llu\n", 1072 printf("Group %s now has: used_units=%llu free_units=%llu total_units=%llu fsu_blocksize=%llu mult=%llu\n",
1055 p->group, tmpfsp.fsu_bavail, tmpfsp.fsu_blocksize, p->best_match->me_mountdir, p->dused_units, 1073 p->group,
1056 p->dfree_units, p->dtotal_units, mult); 1074 p->dused_units,
1075 p->dfree_units,
1076 p->dtotal_units,
1077 tmpfsp.fsu_blocksize,
1078 mult);
1057 } 1079 }
1058 /* modify devname and mountdir for output */ 1080 /* modify devname and mountdir for output */
1059 p->best_match->me_mountdir = p->best_match->me_devname = p->group; 1081 p->best_match->me_mountdir = p->best_match->me_devname = p->group;
1060 } 1082 }
1061 /* finally calculate percentages for either plain FS or summed up group */ 1083 /* finally calculate percentages for either plain FS or summed up group */
1062 p->dused_pct = calculate_percent( p->used, p->used + p->available ); /* used + available can never be > uintmax */ 1084 p->dused_pct = calculate_percent( p->used, p->used + p->available ); /* used + available can never be > uintmax */
1063 p->dfree_pct = 100 - p->dused_pct; 1085 p->dfree_pct = 100 - p->dused_pct;
1064 p->dused_inodes_percent = calculate_percent(p->inodes_total - p->inodes_free, p->inodes_total); 1086 p->dused_inodes_percent = calculate_percent(p->inodes_total - p->inodes_free, p->inodes_total);
1065 p->dfree_inodes_percent = 100 - p->dused_inodes_percent; 1087 p->dfree_inodes_percent = 100 - p->dused_inodes_percent;
1066 1088
1067} 1089}
1068 1090
1069void 1091void
1070get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { 1092get_path_stats (struct parameter_list *p, struct fs_usage *fsp) {
1071 /* 2007-12-08 - Workaround for Gnulib reporting insanely high available 1093 p->available = fsp->fsu_bavail;
1072 * space on BSD (the actual value should be negative but fsp->fsu_bavail
1073 * is unsigned) */
1074 p->available = fsp->fsu_bavail > fsp->fsu_bfree ? 0 : fsp->fsu_bavail;
1075 p->available_to_root = fsp->fsu_bfree; 1094 p->available_to_root = fsp->fsu_bfree;
1076 p->used = fsp->fsu_blocks - fsp->fsu_bfree; 1095 p->used = fsp->fsu_blocks - fsp->fsu_bfree;
1077 if (freespace_ignore_reserved) { 1096 if (freespace_ignore_reserved) {
@@ -1081,7 +1100,7 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) {
1081 /* default behaviour : take all the blocks into account */ 1100 /* default behaviour : take all the blocks into account */
1082 p->total = fsp->fsu_blocks; 1101 p->total = fsp->fsu_blocks;
1083 } 1102 }
1084 1103
1085 p->dused_units = p->used*fsp->fsu_blocksize/mult; 1104 p->dused_units = p->used*fsp->fsu_blocksize/mult;
1086 p->dfree_units = p->available*fsp->fsu_blocksize/mult; 1105 p->dfree_units = p->available*fsp->fsu_blocksize/mult;
1087 p->dtotal_units = p->total*fsp->fsu_blocksize/mult; 1106 p->dtotal_units = p->total*fsp->fsu_blocksize/mult;
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 0f2e654..9de6caf 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -41,7 +41,7 @@ const char *email = "devel@monitoring-plugins.org";
41 41
42int process_arguments (int, char **); 42int process_arguments (int, char **);
43int validate_arguments (void); 43int validate_arguments (void);
44int error_scan (char *); 44int error_scan (char *, int *);
45int ip_match_cidr(const char *, const char *); 45int ip_match_cidr(const char *, const char *);
46unsigned long ip2long(const char *); 46unsigned long ip2long(const char *);
47void print_help (void); 47void print_help (void);
@@ -54,6 +54,7 @@ char ptr_server[ADDRESS_LENGTH] = "";
54int verbose = FALSE; 54int verbose = FALSE;
55char **expected_address = NULL; 55char **expected_address = NULL;
56int expected_address_cnt = 0; 56int expected_address_cnt = 0;
57int expect_nxdomain = FALSE;
57 58
58int expect_authority = FALSE; 59int expect_authority = FALSE;
59int all_match = FALSE; 60int all_match = FALSE;
@@ -87,6 +88,7 @@ main (int argc, char **argv)
87 int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ 88 int parse_address = FALSE; /* This flag scans for Address: but only after Name: */
88 output chld_out, chld_err; 89 output chld_out, chld_err;
89 size_t i; 90 size_t i;
91 int is_nxdomain = FALSE;
90 92
91 setlocale (LC_ALL, ""); 93 setlocale (LC_ALL, "");
92 bindtextdomain (PACKAGE, LOCALEDIR); 94 bindtextdomain (PACKAGE, LOCALEDIR);
@@ -186,7 +188,7 @@ main (int argc, char **argv)
186 } 188 }
187 189
188 190
189 result = error_scan (chld_out.line[i]); 191 result = error_scan (chld_out.line[i], &is_nxdomain);
190 if (result != STATE_OK) { 192 if (result != STATE_OK) {
191 msg = strchr (chld_out.line[i], ':'); 193 msg = strchr (chld_out.line[i], ':');
192 if(msg) msg++; 194 if(msg) msg++;
@@ -199,8 +201,8 @@ main (int argc, char **argv)
199 if (verbose) 201 if (verbose)
200 puts(chld_err.line[i]); 202 puts(chld_err.line[i]);
201 203
202 if (error_scan (chld_err.line[i]) != STATE_OK) { 204 if (error_scan (chld_err.line[i], &is_nxdomain) != STATE_OK) {
203 result = max_state (result, error_scan (chld_err.line[i])); 205 result = max_state (result, error_scan (chld_err.line[i], &is_nxdomain));
204 msg = strchr(input_buffer, ':'); 206 msg = strchr(input_buffer, ':');
205 if(msg) 207 if(msg)
206 msg++; 208 msg++;
@@ -209,6 +211,10 @@ main (int argc, char **argv)
209 } 211 }
210 } 212 }
211 213
214 if (is_nxdomain && !expect_nxdomain) {
215 die (STATE_CRITICAL, _("Domain '%s' was not found by the server\n"), query_address);
216 }
217
212 if (addresses) { 218 if (addresses) {
213 int i,slen; 219 int i,slen;
214 char *adrp; 220 char *adrp;
@@ -260,6 +266,16 @@ main (int argc, char **argv)
260 } 266 }
261 } 267 }
262 268
269 if (expect_nxdomain) {
270 if (!is_nxdomain) {
271 result = STATE_CRITICAL;
272 xasprintf(&msg, _("Domain '%s' was found by the server: '%s'\n"), query_address, address);
273 } else {
274 if (address != NULL) free(address);
275 address = "NXDOMAIN";
276 }
277 }
278
263 /* check if authoritative */ 279 /* check if authoritative */
264 if (result == STATE_OK && expect_authority && non_authoritative) { 280 if (result == STATE_OK && expect_authority && non_authoritative) {
265 result = STATE_CRITICAL; 281 result = STATE_CRITICAL;
@@ -339,9 +355,15 @@ ip2long(const char* src) {
339} 355}
340 356
341int 357int
342error_scan (char *input_buffer) 358error_scan (char *input_buffer, int *is_nxdomain)
343{ 359{
344 360
361 const int nxdomain = strstr (input_buffer, "Non-existent") ||
362 strstr (input_buffer, "** server can't find") ||
363 strstr (input_buffer, "** Can't find") ||
364 strstr (input_buffer, "NXDOMAIN");
365 if (nxdomain) *is_nxdomain = TRUE;
366
345 /* the DNS lookup timed out */ 367 /* the DNS lookup timed out */
346 if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) || 368 if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) ||
347 strstr (input_buffer, _("Consider using the `dig' or `host' programs instead. Run nslookup with")) || 369 strstr (input_buffer, _("Consider using the `dig' or `host' programs instead. Run nslookup with")) ||
@@ -360,7 +382,7 @@ error_scan (char *input_buffer)
360 382
361 /* Connection was refused */ 383 /* Connection was refused */
362 else if (strstr (input_buffer, "Connection refused") || 384 else if (strstr (input_buffer, "Connection refused") ||
363 strstr (input_buffer, "Couldn't find server") || 385 strstr (input_buffer, "Couldn't find server") ||
364 strstr (input_buffer, "Refused") || 386 strstr (input_buffer, "Refused") ||
365 (strstr (input_buffer, "** server can't find") && 387 (strstr (input_buffer, "** server can't find") &&
366 strstr (input_buffer, ": REFUSED"))) 388 strstr (input_buffer, ": REFUSED")))
@@ -374,13 +396,6 @@ error_scan (char *input_buffer)
374 else if (strstr (input_buffer, "No information")) 396 else if (strstr (input_buffer, "No information"))
375 die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server); 397 die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server);
376 398
377 /* Host or domain name does not exist */
378 else if (strstr (input_buffer, "Non-existent") ||
379 strstr (input_buffer, "** server can't find") ||
380 strstr (input_buffer, "** Can't find") ||
381 strstr (input_buffer,"NXDOMAIN"))
382 die (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address);
383
384 /* Network is unreachable */ 399 /* Network is unreachable */
385 else if (strstr (input_buffer, "Network is unreachable")) 400 else if (strstr (input_buffer, "Network is unreachable"))
386 die (STATE_CRITICAL, _("Network is unreachable\n")); 401 die (STATE_CRITICAL, _("Network is unreachable\n"));
@@ -417,6 +432,7 @@ process_arguments (int argc, char **argv)
417 {"server", required_argument, 0, 's'}, 432 {"server", required_argument, 0, 's'},
418 {"reverse-server", required_argument, 0, 'r'}, 433 {"reverse-server", required_argument, 0, 'r'},
419 {"expected-address", required_argument, 0, 'a'}, 434 {"expected-address", required_argument, 0, 'a'},
435 {"expect-nxdomain", no_argument, 0, 'n'},
420 {"expect-authority", no_argument, 0, 'A'}, 436 {"expect-authority", no_argument, 0, 'A'},
421 {"all", no_argument, 0, 'L'}, 437 {"all", no_argument, 0, 'L'},
422 {"warning", required_argument, 0, 'w'}, 438 {"warning", required_argument, 0, 'w'},
@@ -432,7 +448,7 @@ process_arguments (int argc, char **argv)
432 strcpy (argv[c], "-t"); 448 strcpy (argv[c], "-t");
433 449
434 while (1) { 450 while (1) {
435 c = getopt_long (argc, argv, "hVvALt:H:s:r:a:w:c:", long_opts, &opt_index); 451 c = getopt_long (argc, argv, "hVvALnt:H:s:r:a:w:c:", long_opts, &opt_index);
436 452
437 if (c == -1 || c == EOF) 453 if (c == -1 || c == EOF)
438 break; 454 break;
@@ -491,6 +507,9 @@ process_arguments (int argc, char **argv)
491 expected_address_cnt++; 507 expected_address_cnt++;
492 } 508 }
493 break; 509 break;
510 case 'n': /* expect NXDOMAIN */
511 expect_nxdomain = TRUE;
512 break;
494 case 'A': /* expect authority */ 513 case 'A': /* expect authority */
495 expect_authority = TRUE; 514 expect_authority = TRUE;
496 break; 515 break;
@@ -532,8 +551,15 @@ process_arguments (int argc, char **argv)
532int 551int
533validate_arguments () 552validate_arguments ()
534{ 553{
535 if (query_address[0] == 0) 554 if (query_address[0] == 0) {
555 printf ("missing --host argument\n");
556 return ERROR;
557 }
558
559 if (expected_address_cnt > 0 && expect_nxdomain) {
560 printf ("--expected-address and --expect-nxdomain cannot be combined\n");
536 return ERROR; 561 return ERROR;
562 }
537 563
538 return OK; 564 return OK;
539} 565}
@@ -566,6 +592,9 @@ print_help (void)
566 printf (" %s\n", _("Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end")); 592 printf (" %s\n", _("Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end"));
567 printf (" %s\n", _("with a dot (.). This option can be repeated multiple times (Returns OK if any")); 593 printf (" %s\n", _("with a dot (.). This option can be repeated multiple times (Returns OK if any"));
568 printf (" %s\n", _("value matches).")); 594 printf (" %s\n", _("value matches)."));
595 printf (" -n, --expect-nxdomain\n");
596 printf (" %s\n", _("Expect the DNS server to return NXDOMAIN (i.e. the domain was not found)"));
597 printf (" %s\n", _("Cannot be used together with -a"));
569 printf (" -A, --expect-authority\n"); 598 printf (" -A, --expect-authority\n");
570 printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup")); 599 printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup"));
571 printf (" -w, --warning=seconds\n"); 600 printf (" -w, --warning=seconds\n");
@@ -586,5 +615,5 @@ void
586print_usage (void) 615print_usage (void)
587{ 616{
588 printf ("%s\n", _("Usage:")); 617 printf ("%s\n", _("Usage:"));
589 printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit] [-L]\n", progname); 618 printf ("%s -H host [-s server] [-a expected-address] [-n] [-A] [-t timeout] [-w warn] [-c crit] [-L]\n", progname);
590} 619}
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 6546556..c4b4417 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -66,7 +66,7 @@ void print_usage (void);
66 66
67char *community = NULL; 67char *community = NULL;
68char *address = NULL; 68char *address = NULL;
69char *port = NULL; 69unsigned int port = 0;
70int check_paper_out = 1; 70int check_paper_out = 1;
71 71
72int 72int
@@ -121,8 +121,12 @@ main (int argc, char **argv)
121 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); 121 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY);
122 122
123 /* get the command to run */ 123 /* get the command to run */
124 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%hd %s", PATH_TO_SNMPGET, community, 124 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%u %s",
125 address, port, query_string); 125 PATH_TO_SNMPGET,
126 community,
127 address,
128 port,
129 query_string);
126 130
127 /* run the command */ 131 /* run the command */
128 child_process = spopen (command_line); 132 child_process = spopen (command_line);
@@ -380,11 +384,8 @@ process_arguments (int argc, char **argv)
380 community = strdup (DEFAULT_COMMUNITY); 384 community = strdup (DEFAULT_COMMUNITY);
381 } 385 }
382 386
383 if (port == NULL) { 387 if (port == 0) {
384 if (argv[c] != NULL ) 388 port = atoi(DEFAULT_PORT);
385 port = argv[c];
386 else
387 port = atoi (DEFAULT_PORT);
388 } 389 }
389 390
390 return validate_arguments (); 391 return validate_arguments ();
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 0b71266..34fb4f0 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1453,8 +1453,8 @@ redir (char *pos, char *status_line)
1453 !strncmp(server_address, addr, MAX_IPV4_HOSTLENGTH) && 1453 !strncmp(server_address, addr, MAX_IPV4_HOSTLENGTH) &&
1454 (host_name && !strncmp(host_name, addr, MAX_IPV4_HOSTLENGTH)) && 1454 (host_name && !strncmp(host_name, addr, MAX_IPV4_HOSTLENGTH)) &&
1455 !strcmp(server_url, url)) 1455 !strcmp(server_url, url))
1456 die (STATE_WARNING, 1456 die (STATE_CRITICAL,
1457 _("HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"), 1457 _("HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"),
1458 type, addr, i, url, (display_html ? "</A>" : "")); 1458 type, addr, i, url, (display_html ? "</A>" : ""));
1459 1459
1460 strcpy (server_type, type); 1460 strcpy (server_type, type);
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index bc7bd44..845a4f5 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -432,6 +432,9 @@ validate_arguments ()
432 set_thresholds(&entries_thresholds, 432 set_thresholds(&entries_thresholds,
433 warn_entries, crit_entries); 433 warn_entries, crit_entries);
434 } 434 }
435 if (ld_passwd==NULL)
436 ld_passwd = getenv("LDAP_PASSWORD");
437
435 return OK; 438 return OK;
436} 439}
437 440
@@ -465,7 +468,7 @@ print_help (void)
465 printf (" %s\n", "-D [--bind]"); 468 printf (" %s\n", "-D [--bind]");
466 printf (" %s\n", _("ldap bind DN (if required)")); 469 printf (" %s\n", _("ldap bind DN (if required)"));
467 printf (" %s\n", "-P [--pass]"); 470 printf (" %s\n", "-P [--pass]");
468 printf (" %s\n", _("ldap password (if required)")); 471 printf (" %s\n", _("ldap password (if required, or set the password through environment variable 'LDAP_PASSWORD')"));
469 printf (" %s\n", "-T [--starttls]"); 472 printf (" %s\n", "-T [--starttls]");
470 printf (" %s\n", _("use starttls mechanism introduced in protocol version 3")); 473 printf (" %s\n", _("use starttls mechanism introduced in protocol version 3"));
471 printf (" %s\n", "-S [--ssl]"); 474 printf (" %s\n", "-S [--ssl]");
diff --git a/plugins/check_load.c b/plugins/check_load.c
index bf7b94b..0e4de54 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -209,7 +209,7 @@ main (int argc, char **argv)
209 else if(la[i] > wload[i]) result = STATE_WARNING; 209 else if(la[i] > wload[i]) result = STATE_WARNING;
210 } 210 }
211 211
212 printf("%s - %s|", state_text(result), status_line); 212 printf("LOAD %s - %s|", state_text(result), status_line);
213 for(i = 0; i < 3; i++) 213 for(i = 0; i < 3; i++)
214 printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]); 214 printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]);
215 215
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 423ecbe..ba7af37 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -37,6 +37,8 @@ const char *email = "devel@monitoring-plugins.org";
37#include "popen.h" 37#include "popen.h"
38#include "utils.h" 38#include "utils.h"
39 39
40#include <signal.h>
41
40#define WARN_DUPLICATES "DUPLICATES FOUND! " 42#define WARN_DUPLICATES "DUPLICATES FOUND! "
41#define UNKNOWN_TRIP_TIME -1.0 /* -1 seconds */ 43#define UNKNOWN_TRIP_TIME -1.0 /* -1 seconds */
42 44
@@ -163,10 +165,14 @@ main (int argc, char **argv)
163 printf ("</A>"); 165 printf ("</A>");
164 166
165 /* Print performance data */ 167 /* Print performance data */
166 printf("|%s", fperfdata ("rta", (double) rta, "ms", 168 if (pl != 100) {
167 wrta>0?TRUE:FALSE, wrta, 169 printf("|%s", fperfdata ("rta", (double) rta, "ms",
168 crta>0?TRUE:FALSE, crta, 170 wrta>0?TRUE:FALSE, wrta,
169 TRUE, 0, FALSE, 0)); 171 crta>0?TRUE:FALSE, crta,
172 TRUE, 0, FALSE, 0));
173 } else {
174 printf("| rta=U;%f;%f;;", wrta, crta);
175 }
170 printf(" %s\n", perfdata ("pl", (long) pl, "%", 176 printf(" %s\n", perfdata ("pl", (long) pl, "%",
171 wpl>0?TRUE:FALSE, wpl, 177 wpl>0?TRUE:FALSE, wpl,
172 cpl>0?TRUE:FALSE, cpl, 178 cpl>0?TRUE:FALSE, cpl,
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index f7917c3..4872340 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -1,34 +1,34 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_procs plugin 3* Monitoring check_procs plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2008 Monitoring Plugins Development Team 6* Copyright (c) 2000-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_procs plugin 10* This file contains the check_procs plugin
11* 11*
12* Checks all processes and generates WARNING or CRITICAL states if the 12* Checks all processes and generates WARNING or CRITICAL states if the
13* specified metric is outside the required threshold ranges. The metric 13* specified metric is outside the required threshold ranges. The metric
14* defaults to number of processes. Search filters can be applied to limit 14* defaults to number of processes. Search filters can be applied to limit
15* the processes to check. 15* the processes to check.
16* 16*
17* 17*
18* This program is free software: you can redistribute it and/or modify 18* This program is free software: you can redistribute it and/or modify
19* it under the terms of the GNU General Public License as published by 19* it under the terms of the GNU General Public License as published by
20* the Free Software Foundation, either version 3 of the License, or 20* the Free Software Foundation, either version 3 of the License, or
21* (at your option) any later version. 21* (at your option) any later version.
22* 22*
23* This program is distributed in the hope that it will be useful, 23* This program is distributed in the hope that it will be useful,
24* but WITHOUT ANY WARRANTY; without even the implied warranty of 24* but WITHOUT ANY WARRANTY; without even the implied warranty of
25* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26* GNU General Public License for more details. 26* GNU General Public License for more details.
27* 27*
28* You should have received a copy of the GNU General Public License 28* You should have received a copy of the GNU General Public License
29* along with this program. If not, see <http://www.gnu.org/licenses/>. 29* along with this program. If not, see <http://www.gnu.org/licenses/>.
30* 30*
31* 31*
32*****************************************************************************/ 32*****************************************************************************/
33 33
34const char *progname = "check_procs"; 34const char *progname = "check_procs";
@@ -50,7 +50,7 @@ const char *email = "devel@monitoring-plugins.org";
50 50
51int process_arguments (int, char **); 51int process_arguments (int, char **);
52int validate_arguments (void); 52int validate_arguments (void);
53int convert_to_seconds (char *); 53int convert_to_seconds (char *);
54void print_help (void); 54void print_help (void);
55void print_usage (void); 55void print_usage (void);
56 56
@@ -230,9 +230,9 @@ main (int argc, char **argv)
230 procseconds = convert_to_seconds(procetime); 230 procseconds = convert_to_seconds(procetime);
231 231
232 if (verbose >= 3) 232 if (verbose >= 3)
233 printf ("proc#=%d uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n", 233 printf ("proc#=%d uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n",
234 procs, procuid, procvsz, procrss, 234 procs, procuid, procvsz, procrss,
235 procpid, procppid, procpcpu, procstat, 235 procpid, procppid, procpcpu, procstat,
236 procetime, procprog, procargs); 236 procetime, procprog, procargs);
237 237
238 /* Ignore self */ 238 /* Ignore self */
@@ -265,7 +265,7 @@ main (int argc, char **argv)
265 } 265 }
266 } 266 }
267 267
268 if ((options & STAT) && (strstr (statopts, procstat))) 268 if ((options & STAT) && (strstr (procstat, statopts)))
269 resultsum |= STAT; 269 resultsum |= STAT;
270 if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL)) 270 if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL))
271 resultsum |= ARGS; 271 resultsum |= ARGS;
@@ -292,9 +292,9 @@ main (int argc, char **argv)
292 292
293 procs++; 293 procs++;
294 if (verbose >= 2) { 294 if (verbose >= 2) {
295 printf ("Matched: uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n", 295 printf ("Matched: uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n",
296 procuid, procvsz, procrss, 296 procuid, procvsz, procrss,
297 procpid, procppid, procpcpu, procstat, 297 procpid, procppid, procpcpu, procstat,
298 procetime, procprog, procargs); 298 procetime, procprog, procargs);
299 } 299 }
300 300
@@ -320,7 +320,7 @@ main (int argc, char **argv)
320 result = max_state (result, i); 320 result = max_state (result, i);
321 } 321 }
322 } 322 }
323 } 323 }
324 /* This should not happen */ 324 /* This should not happen */
325 else if (verbose) { 325 else if (verbose) {
326 printf(_("Not parseable: %s"), input_buffer); 326 printf(_("Not parseable: %s"), input_buffer);
@@ -332,7 +332,7 @@ main (int argc, char **argv)
332 return STATE_UNKNOWN; 332 return STATE_UNKNOWN;
333 } 333 }
334 334
335 if ( result == STATE_UNKNOWN ) 335 if ( result == STATE_UNKNOWN )
336 result = STATE_OK; 336 result = STATE_OK;
337 337
338 /* Needed if procs found, but none match filter */ 338 /* Needed if procs found, but none match filter */
@@ -352,9 +352,9 @@ main (int argc, char **argv)
352 if (metric != METRIC_PROCS) { 352 if (metric != METRIC_PROCS) {
353 printf (_("%d crit, %d warn out of "), crit, warn); 353 printf (_("%d crit, %d warn out of "), crit, warn);
354 } 354 }
355 } 355 }
356 printf (ngettext ("%d process", "%d processes", (unsigned long) procs), procs); 356 printf (ngettext ("%d process", "%d processes", (unsigned long) procs), procs);
357 357
358 if (strcmp(fmt,"") != 0) { 358 if (strcmp(fmt,"") != 0) {
359 printf (_(" with %s"), fmt); 359 printf (_(" with %s"), fmt);
360 } 360 }
@@ -440,7 +440,7 @@ process_arguments (int argc, char **argv)
440 break; 440 break;
441 case 'c': /* critical threshold */ 441 case 'c': /* critical threshold */
442 critical_range = optarg; 442 critical_range = optarg;
443 break; 443 break;
444 case 'w': /* warning threshold */ 444 case 'w': /* warning threshold */
445 warning_range = optarg; 445 warning_range = optarg;
446 break; 446 break;
@@ -542,11 +542,11 @@ process_arguments (int argc, char **argv)
542 if ( strcmp(optarg, "PROCS") == 0) { 542 if ( strcmp(optarg, "PROCS") == 0) {
543 metric = METRIC_PROCS; 543 metric = METRIC_PROCS;
544 break; 544 break;
545 } 545 }
546 else if ( strcmp(optarg, "VSZ") == 0) { 546 else if ( strcmp(optarg, "VSZ") == 0) {
547 metric = METRIC_VSZ; 547 metric = METRIC_VSZ;
548 break; 548 break;
549 } 549 }
550 else if ( strcmp(optarg, "RSS") == 0 ) { 550 else if ( strcmp(optarg, "RSS") == 0 ) {
551 metric = METRIC_RSS; 551 metric = METRIC_RSS;
552 break; 552 break;
@@ -559,7 +559,7 @@ process_arguments (int argc, char **argv)
559 metric = METRIC_ELAPSED; 559 metric = METRIC_ELAPSED;
560 break; 560 break;
561 } 561 }
562 562
563 usage4 (_("Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!")); 563 usage4 (_("Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"));
564 case 'k': /* linux kernel thread filter */ 564 case 'k': /* linux kernel thread filter */
565 kthread_filter = 1; 565 kthread_filter = 1;
@@ -642,7 +642,7 @@ convert_to_seconds(char *etime) {
642 seconds = 0; 642 seconds = 0;
643 643
644 for (ptr = etime; *ptr != '\0'; ptr++) { 644 for (ptr = etime; *ptr != '\0'; ptr++) {
645 645
646 if (*ptr == '-') { 646 if (*ptr == '-') {
647 hyphcnt++; 647 hyphcnt++;
648 continue; 648 continue;
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index d37c57c..c1e92df 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -55,6 +55,7 @@ enum {
55#define SMTP_EXPECT "220" 55#define SMTP_EXPECT "220"
56#define SMTP_HELO "HELO " 56#define SMTP_HELO "HELO "
57#define SMTP_EHLO "EHLO " 57#define SMTP_EHLO "EHLO "
58#define SMTP_LHLO "LHLO "
58#define SMTP_QUIT "QUIT\r\n" 59#define SMTP_QUIT "QUIT\r\n"
59#define SMTP_STARTTLS "STARTTLS\r\n" 60#define SMTP_STARTTLS "STARTTLS\r\n"
60#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" 61#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
@@ -102,6 +103,7 @@ int check_critical_time = FALSE;
102int verbose = 0; 103int verbose = 0;
103int use_ssl = FALSE; 104int use_ssl = FALSE;
104short use_ehlo = FALSE; 105short use_ehlo = FALSE;
106short use_lhlo = FALSE;
105short ssl_established = 0; 107short ssl_established = 0;
106char *localhostname = NULL; 108char *localhostname = NULL;
107int sd; 109int sd;
@@ -152,7 +154,9 @@ main (int argc, char **argv)
152 return STATE_CRITICAL; 154 return STATE_CRITICAL;
153 } 155 }
154 } 156 }
155 if(use_ehlo) 157 if(use_lhlo)
158 xasprintf (&helocmd, "%s%s%s", SMTP_LHLO, localhostname, "\r\n");
159 else if(use_ehlo)
156 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n"); 160 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
157 else 161 else
158 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n"); 162 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
@@ -197,7 +201,7 @@ main (int argc, char **argv)
197 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) { 201 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
198 printf (_("recv() failed\n")); 202 printf (_("recv() failed\n"));
199 return STATE_WARNING; 203 return STATE_WARNING;
200 } else if(use_ehlo){ 204 } else if(use_ehlo || use_lhlo){
201 if(strstr(buffer, "250 STARTTLS") != NULL || 205 if(strstr(buffer, "250 STARTTLS") != NULL ||
202 strstr(buffer, "250-STARTTLS") != NULL){ 206 strstr(buffer, "250-STARTTLS") != NULL){
203 supports_tls=TRUE; 207 supports_tls=TRUE;
@@ -470,6 +474,7 @@ process_arguments (int argc, char **argv)
470 {"use-ipv4", no_argument, 0, '4'}, 474 {"use-ipv4", no_argument, 0, '4'},
471 {"use-ipv6", no_argument, 0, '6'}, 475 {"use-ipv6", no_argument, 0, '6'},
472 {"help", no_argument, 0, 'h'}, 476 {"help", no_argument, 0, 'h'},
477 {"lmtp", no_argument, 0, 'L'},
473 {"starttls",no_argument,0,'S'}, 478 {"starttls",no_argument,0,'S'},
474 {"certificate",required_argument,0,'D'}, 479 {"certificate",required_argument,0,'D'},
475 {"ignore-quit-failure",no_argument,0,'q'}, 480 {"ignore-quit-failure",no_argument,0,'q'},
@@ -489,7 +494,7 @@ process_arguments (int argc, char **argv)
489 } 494 }
490 495
491 while (1) { 496 while (1) {
492 c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", 497 c = getopt_long (argc, argv, "+hVv46Lt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q",
493 longopts, &option); 498 longopts, &option);
494 499
495 if (c == -1 || c == EOF) 500 if (c == -1 || c == EOF)
@@ -616,6 +621,9 @@ process_arguments (int argc, char **argv)
616 use_ssl = TRUE; 621 use_ssl = TRUE;
617 use_ehlo = TRUE; 622 use_ehlo = TRUE;
618 break; 623 break;
624 case 'L':
625 use_lhlo = TRUE;
626 break;
619 case '4': 627 case '4':
620 address_family = AF_INET; 628 address_family = AF_INET;
621 break; 629 break;
@@ -824,6 +832,8 @@ print_help (void)
824 printf (" %s\n", _("SMTP AUTH username")); 832 printf (" %s\n", _("SMTP AUTH username"));
825 printf (" %s\n", "-P, --authpass=STRING"); 833 printf (" %s\n", "-P, --authpass=STRING");
826 printf (" %s\n", _("SMTP AUTH password")); 834 printf (" %s\n", _("SMTP AUTH password"));
835 printf (" %s\n", "-L, --lmtp");
836 printf (" %s\n", _("Send LHLO instead of HELO/EHLO"));
827 printf (" %s\n", "-q, --ignore-quit-failure"); 837 printf (" %s\n", "-q, --ignore-quit-failure");
828 printf (" %s\n", _("Ignore failure when sending QUIT command to server")); 838 printf (" %s\n", _("Ignore failure when sending QUIT command to server"));
829 839
@@ -850,6 +860,6 @@ print_usage (void)
850 printf ("%s\n", _("Usage:")); 860 printf ("%s\n", _("Usage:"));
851 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname); 861 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname);
852 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n"); 862 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
853 printf ("[-F fqdn] [-S] [-D warn days cert expire[,crit days cert expire]] [-v] \n"); 863 printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-v] \n");
854} 864}
855 865
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index afc568b..abe54cf 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -468,6 +468,9 @@ main (int argc, char **argv)
468 /* Process this block for numeric comparisons */ 468 /* Process this block for numeric comparisons */
469 /* Make some special values,like Timeticks numeric only if a threshold is defined */ 469 /* Make some special values,like Timeticks numeric only if a threshold is defined */
470 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) { 470 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) {
471 if (verbose > 2) {
472 print_thresholds(" thresholds", thlds[i]);
473 }
471 ptr = strpbrk (show, "-0123456789"); 474 ptr = strpbrk (show, "-0123456789");
472 if (ptr == NULL) 475 if (ptr == NULL)
473 die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); 476 die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show);
@@ -581,14 +584,16 @@ main (int argc, char **argv)
581 584
582 if (warning_thresholds) { 585 if (warning_thresholds) {
583 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 586 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
584 strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1); 587 if(thlds[i]->warning && thlds[i]->warning->text)
588 strncat(perfstr, thlds[i]->warning->text, sizeof(perfstr)-strlen(perfstr)-1);
585 } 589 }
586 590
587 if (critical_thresholds) { 591 if (critical_thresholds) {
588 if (!warning_thresholds) 592 if (!warning_thresholds)
589 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 593 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
590 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 594 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
591 strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1); 595 if(thlds[i]->critical && thlds[i]->critical->text)
596 strncat(perfstr, thlds[i]->critical->text, sizeof(perfstr)-strlen(perfstr)-1);
592 } 597 }
593 598
594 strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1); 599 strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
@@ -1161,7 +1166,7 @@ print_help (void)
1161 printf ("(%s \"%s\")\n", _("default is") ,DEFAULT_COMMUNITY); 1166 printf ("(%s \"%s\")\n", _("default is") ,DEFAULT_COMMUNITY);
1162 printf (" %s\n", "-U, --secname=USERNAME"); 1167 printf (" %s\n", "-U, --secname=USERNAME");
1163 printf (" %s\n", _("SNMPv3 username")); 1168 printf (" %s\n", _("SNMPv3 username"));
1164 printf (" %s\n", "-A, --authpassword=PASSWORD"); 1169 printf (" %s\n", "-A, --authpasswd=PASSWORD");
1165 printf (" %s\n", _("SNMPv3 authentication password")); 1170 printf (" %s\n", _("SNMPv3 authentication password"));
1166 printf (" %s\n", "-X, --privpasswd=PASSWORD"); 1171 printf (" %s\n", "-X, --privpasswd=PASSWORD");
1167 printf (" %s\n", _("SNMPv3 privacy password")); 1172 printf (" %s\n", _("SNMPv3 privacy password"));
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 0ff0c77..7da26cf 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -34,6 +34,9 @@ const char *email = "devel@monitoring-plugins.org";
34#include "common.h" 34#include "common.h"
35#include "popen.h" 35#include "popen.h"
36#include "utils.h" 36#include "utils.h"
37#include <string.h>
38#include <math.h>
39#include <libintl.h>
37 40
38#ifdef HAVE_DECL_SWAPCTL 41#ifdef HAVE_DECL_SWAPCTL
39# ifdef HAVE_SYS_PARAM_H 42# ifdef HAVE_SYS_PARAM_H
@@ -51,16 +54,19 @@ const char *email = "devel@monitoring-plugins.org";
51# define SWAP_CONVERSION 1 54# define SWAP_CONVERSION 1
52#endif 55#endif
53 56
54int check_swap (int usp, float free_swap_mb, float total_swap_mb); 57typedef struct {
58 int is_percentage;
59 uint64_t value;
60} threshold_t;
61
62int check_swap (float free_swap_mb, float total_swap_mb);
55int process_arguments (int argc, char **argv); 63int process_arguments (int argc, char **argv);
56int validate_arguments (void); 64int validate_arguments (void);
57void print_usage (void); 65void print_usage (void);
58void print_help (void); 66void print_help (void);
59 67
60int warn_percent = 0; 68threshold_t warn;
61int crit_percent = 0; 69threshold_t crit;
62float warn_size_bytes = 0;
63float crit_size_bytes = 0;
64int verbose; 70int verbose;
65int allswaps; 71int allswaps;
66int no_swap_state = STATE_CRITICAL; 72int no_swap_state = STATE_CRITICAL;
@@ -68,9 +74,10 @@ int no_swap_state = STATE_CRITICAL;
68int 74int
69main (int argc, char **argv) 75main (int argc, char **argv)
70{ 76{
71 int percent_used, percent; 77 unsigned int percent_used, percent;
72 float total_swap_mb = 0, used_swap_mb = 0, free_swap_mb = 0; 78 uint64_t total_swap_mb = 0, used_swap_mb = 0, free_swap_mb = 0;
73 float dsktotal_mb = 0, dskused_mb = 0, dskfree_mb = 0, tmp_mb = 0; 79 uint64_t dsktotal_mb = 0, dskused_mb = 0, dskfree_mb = 0;
80 uint64_t tmp_KB = 0;
74 int result = STATE_UNKNOWN; 81 int result = STATE_UNKNOWN;
75 char input_buffer[MAX_INPUT_BUFFER]; 82 char input_buffer[MAX_INPUT_BUFFER];
76#ifdef HAVE_PROC_MEMINFO 83#ifdef HAVE_PROC_MEMINFO
@@ -116,10 +123,15 @@ main (int argc, char **argv)
116 } 123 }
117 fp = fopen (PROC_MEMINFO, "r"); 124 fp = fopen (PROC_MEMINFO, "r");
118 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { 125 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
119 if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %f %f %f", &dsktotal_mb, &dskused_mb, &dskfree_mb) == 3) { 126 /*
120 dsktotal_mb = dsktotal_mb / 1048576; /* Apply conversion */ 127 * The following sscanf call looks for a line looking like: "Swap: 123 123 123"
121 dskused_mb = dskused_mb / 1048576; 128 * On which kind of system this format exists, I can not say, but I wanted to
122 dskfree_mb = dskfree_mb / 1048576; 129 * document this for people who are not adapt with sscanf anymore, like me
130 */
131 if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %lu %lu %lu", &dsktotal_mb, &dskused_mb, &dskfree_mb) == 3) {
132 dsktotal_mb = dsktotal_mb / (1024 * 1024); /* Apply conversion */
133 dskused_mb = dskused_mb / (1024 * 1024);
134 dskfree_mb = dskfree_mb / (1024 * 1024);
123 total_swap_mb += dsktotal_mb; 135 total_swap_mb += dsktotal_mb;
124 used_swap_mb += dskused_mb; 136 used_swap_mb += dskused_mb;
125 free_swap_mb += dskfree_mb; 137 free_swap_mb += dskfree_mb;
@@ -128,21 +140,25 @@ main (int argc, char **argv)
128 percent=100.0; 140 percent=100.0;
129 else 141 else
130 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 142 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
131 result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb)); 143 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb));
132 if (verbose) 144 if (verbose)
133 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 145 xasprintf (&status, "%s [%lu (%d%%)]", status, dskfree_mb, 100 - percent);
134 } 146 }
135 } 147 }
136 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) { 148 /*
149 * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123"
150 * This format exists at least on Debian Linux with a 5.* kernel
151 */
152 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %lu %*[k]%*[B]", str, &tmp_KB)) {
137 if (verbose >= 3) { 153 if (verbose >= 3) {
138 printf("Got %s with %f\n", str, tmp_mb); 154 printf("Got %s with %lu\n", str, tmp_KB);
139 } 155 }
140 /* I think this part is always in Kb, so convert to mb */ 156 /* I think this part is always in Kb, so convert to mb */
141 if (strcmp ("Total", str) == 0) { 157 if (strcmp ("Total", str) == 0) {
142 dsktotal_mb = tmp_mb / 1024; 158 dsktotal_mb = tmp_KB / 1024;
143 } 159 }
144 else if (strcmp ("Free", str) == 0) { 160 else if (strcmp ("Free", str) == 0) {
145 dskfree_mb = tmp_mb / 1024; 161 dskfree_mb = tmp_KB / 1024;
146 } 162 }
147 } 163 }
148 } 164 }
@@ -227,7 +243,7 @@ main (int argc, char **argv)
227 free_swap_mb += dskfree_mb; 243 free_swap_mb += dskfree_mb;
228 if (allswaps) { 244 if (allswaps) {
229 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 245 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
230 result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb)); 246 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb));
231 if (verbose) 247 if (verbose)
232 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 248 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
233 } 249 }
@@ -289,7 +305,7 @@ main (int argc, char **argv)
289 305
290 if(allswaps && dsktotal_mb > 0){ 306 if(allswaps && dsktotal_mb > 0){
291 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 307 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
292 result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb)); 308 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb));
293 if (verbose) { 309 if (verbose) {
294 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 310 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
295 } 311 }
@@ -328,7 +344,7 @@ main (int argc, char **argv)
328 344
329 if(allswaps && dsktotal_mb > 0){ 345 if(allswaps && dsktotal_mb > 0){
330 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 346 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
331 result = max_state (result, check_swap (percent, dskfree_mb, dsktotal_mb)); 347 result = max_state (result, check_swap(dskfree_mb, dsktotal_mb));
332 if (verbose) { 348 if (verbose) {
333 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 349 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
334 } 350 }
@@ -355,14 +371,19 @@ main (int argc, char **argv)
355 status = "- Swap is either disabled, not present, or of zero size. "; 371 status = "- Swap is either disabled, not present, or of zero size. ";
356 } 372 }
357 373
358 result = max_state (result, check_swap (percent_used, free_swap_mb, total_swap_mb)); 374 result = max_state (result, check_swap(free_swap_mb, total_swap_mb));
359 printf (_("SWAP %s - %d%% free (%d MB out of %d MB) %s|"), 375 printf (_("SWAP %s - %d%% free (%dMB out of %dMB) %s|"),
360 state_text (result), 376 state_text (result),
361 (100 - percent_used), (int) free_swap_mb, (int) total_swap_mb, status); 377 (100 - percent_used), (int) free_swap_mb, (int) total_swap_mb, status);
362 378
363 puts (perfdata ("swap", (long) free_swap_mb, "MB", 379 uint64_t warn_print = warn.value;
364 TRUE, (long) max (warn_size_bytes/(1024 * 1024), warn_percent/100.0*total_swap_mb), 380 if (warn.is_percentage) warn_print = warn.value * (total_swap_mb *1024 *1024/100);
365 TRUE, (long) max (crit_size_bytes/(1024 * 1024), crit_percent/100.0*total_swap_mb), 381 uint64_t crit_print = crit.value;
382 if (crit.is_percentage) crit_print = crit.value * (total_swap_mb *1024 *1024/100);
383
384 puts (perfdata_uint64 ("swap", free_swap_mb *1024 *1024, "B",
385 TRUE, warn_print,
386 TRUE, crit_print,
366 TRUE, 0, 387 TRUE, 0,
367 TRUE, (long) total_swap_mb)); 388 TRUE, (long) total_swap_mb));
368 389
@@ -370,26 +391,37 @@ main (int argc, char **argv)
370} 391}
371 392
372 393
373
374int 394int
375check_swap (int usp, float free_swap_mb, float total_swap_mb) 395check_swap(float free_swap_mb, float total_swap_mb)
376{ 396{
377 397
378 if (!total_swap_mb) return no_swap_state; 398 if (!total_swap_mb) return no_swap_state;
379 399
380 int result = STATE_UNKNOWN; 400 uint64_t free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */
381 float free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */ 401
382 if (usp >= 0 && crit_percent != 0 && usp >= (100.0 - crit_percent)) 402 if (!crit.is_percentage && crit.value >= free_swap) return STATE_CRITICAL;
383 result = STATE_CRITICAL; 403 if (!warn.is_percentage && warn.value >= free_swap) return STATE_WARNING;
384 else if (crit_size_bytes > 0 && free_swap <= crit_size_bytes) 404
385 result = STATE_CRITICAL; 405
386 else if (usp >= 0 && warn_percent != 0 && usp >= (100.0 - warn_percent)) 406 uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100;
387 result = STATE_WARNING; 407
388 else if (warn_size_bytes > 0 && free_swap <= warn_size_bytes) 408 if (crit.is_percentage &&
389 result = STATE_WARNING; 409 usage_percentage >= 0 &&
390 else if (usp >= 0.0) 410 crit.value != 0 &&
391 result = STATE_OK; 411 usage_percentage >= (100 - crit.value))
392 return result; 412 {
413 return STATE_CRITICAL;
414 }
415
416 if (warn.is_percentage &&
417 usage_percentage >= 0 &&
418 warn.value != 0 &&
419 usage_percentage >= (100 - warn.value))
420 {
421 return STATE_WARNING;
422 }
423
424 return STATE_OK;
393} 425}
394 426
395 427
@@ -422,42 +454,68 @@ process_arguments (int argc, char **argv)
422 break; 454 break;
423 455
424 switch (c) { 456 switch (c) {
425 case 'w': /* warning size threshold */ 457 case 'w': /* warning size threshold */
426 if (is_intnonneg (optarg)) { 458 {
427 warn_size_bytes = (float) atoi (optarg); 459 /*
428 break; 460 * We expect either a positive integer value without a unit, which means
429 } 461 * the unit is Bytes or a positive integer value and a percentage sign (%),
430 else if (strstr (optarg, ",") && 462 * which means the value must be with 0 and 100 and is relative to the total swap
431 strstr (optarg, "%") && 463 */
432 sscanf (optarg, "%f,%d%%", &warn_size_bytes, &warn_percent) == 2) { 464 size_t length;
433 warn_size_bytes = floorf(warn_size_bytes); 465 length = strlen(optarg);
434 break; 466
435 } 467 if (optarg[length - 1] == '%') {
436 else if (strstr (optarg, "%") && 468 /* It's percentage */
437 sscanf (optarg, "%d%%", &warn_percent) == 1) { 469 warn.is_percentage = 1;
438 break; 470 optarg[length - 1] = '\0';
439 } 471 if (is_uint64(optarg, &warn.value)) {
440 else { 472 if (warn.value > 100) {
441 usage4 (_("Warning threshold must be integer or percentage!")); 473 usage4 (_("Warning threshold percentage must be <= 100!"));
442 } 474 } else {
443 case 'c': /* critical size threshold */ 475 break;
444 if (is_intnonneg (optarg)) { 476 }
445 crit_size_bytes = (float) atoi (optarg); 477 }
446 break; 478 } else {
447 } 479 /* It's Bytes */
448 else if (strstr (optarg, ",") && 480 warn.is_percentage = 0;
449 strstr (optarg, "%") && 481 if (is_uint64(optarg, &warn.value)) {
450 sscanf (optarg, "%f,%d%%", &crit_size_bytes, &crit_percent) == 2) { 482 break;
451 crit_size_bytes = floorf(crit_size_bytes); 483 } else {
452 break; 484 usage4 (_("Warning threshold be positive integer or percentage!"));
453 } 485 }
454 else if (strstr (optarg, "%") && 486 }
455 sscanf (optarg, "%d%%", &crit_percent) == 1) {
456 break;
457 }
458 else {
459 usage4 (_("Critical threshold must be integer or percentage!"));
460 } 487 }
488 case 'c': /* critical size threshold */
489 {
490 /*
491 * We expect either a positive integer value without a unit, which means
492 * the unit is Bytes or a positive integer value and a percentage sign (%),
493 * which means the value must be with 0 and 100 and is relative to the total swap
494 */
495 size_t length;
496 length = strlen(optarg);
497
498 if (optarg[length - 1] == '%') {
499 /* It's percentage */
500 crit.is_percentage = 1;
501 optarg[length - 1] = '\0';
502 if (is_uint64(optarg, &crit.value)) {
503 if (crit.value> 100) {
504 usage4 (_("Critical threshold percentage must be <= 100!"));
505 } else {
506 break;
507 }
508 }
509 } else {
510 /* It's Bytes */
511 crit.is_percentage = 0;
512 if (is_uint64(optarg, &crit.value)) {
513 break;
514 } else {
515 usage4 (_("Critical threshold be positive integer or percentage!"));
516 }
517 }
518 }
461 case 'a': /* all swap */ 519 case 'a': /* all swap */
462 allswaps = TRUE; 520 allswaps = TRUE;
463 break; 521 break;
@@ -482,23 +540,6 @@ process_arguments (int argc, char **argv)
482 c = optind; 540 c = optind;
483 if (c == argc) 541 if (c == argc)
484 return validate_arguments (); 542 return validate_arguments ();
485 if (warn_percent == 0 && is_intnonneg (argv[c]))
486 warn_percent = atoi (argv[c++]);
487
488 if (c == argc)
489 return validate_arguments ();
490 if (crit_percent == 0 && is_intnonneg (argv[c]))
491 crit_percent = atoi (argv[c++]);
492
493 if (c == argc)
494 return validate_arguments ();
495 if (warn_size_bytes == 0 && is_intnonneg (argv[c]))
496 warn_size_bytes = (float) atoi (argv[c++]);
497
498 if (c == argc)
499 return validate_arguments ();
500 if (crit_size_bytes == 0 && is_intnonneg (argv[c]))
501 crit_size_bytes = (float) atoi (argv[c++]);
502 543
503 return validate_arguments (); 544 return validate_arguments ();
504} 545}
@@ -508,17 +549,15 @@ process_arguments (int argc, char **argv)
508int 549int
509validate_arguments (void) 550validate_arguments (void)
510{ 551{
511 if (warn_percent == 0 && crit_percent == 0 && warn_size_bytes == 0 552 if (warn.value == 0 && crit.value == 0) {
512 && crit_size_bytes == 0) {
513 return ERROR; 553 return ERROR;
514 } 554 }
515 else if (warn_percent < crit_percent) { 555 else if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
516 usage4 556 /* This is NOT triggered if warn and crit are different units, e.g warn is percentage
517 (_("Warning percentage should be more than critical percentage")); 557 * and crit is absolut. We cannot determine the condition at this point since we
518 } 558 * dont know the value of total swap yet
519 else if (warn_size_bytes < crit_size_bytes) { 559 */
520 usage4 560 usage4(_("Warning should be more than critical"));
521 (_("Warning free space should be more than critical free space"));
522 } 561 }
523 return OK; 562 return OK;
524} 563}
@@ -534,7 +573,7 @@ print_help (void)
534 573
535 printf ("%s\n", _("Check swap space on local machine.")); 574 printf ("%s\n", _("Check swap space on local machine."));
536 575
537 printf ("\n\n"); 576 printf ("\n\n");
538 577
539 print_usage (); 578 print_usage ();
540 579
@@ -542,33 +581,32 @@ print_help (void)
542 printf (UT_EXTRA_OPTS); 581 printf (UT_EXTRA_OPTS);
543 582
544 printf (" %s\n", "-w, --warning=INTEGER"); 583 printf (" %s\n", "-w, --warning=INTEGER");
545 printf (" %s\n", _("Exit with WARNING status if less than INTEGER bytes of swap space are free")); 584 printf (" %s\n", _("Exit with WARNING status if less than INTEGER bytes of swap space are free"));
546 printf (" %s\n", "-w, --warning=PERCENT%%"); 585 printf (" %s\n", "-w, --warning=PERCENT%");
547 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of swap space is free")); 586 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of swap space is free"));
548 printf (" %s\n", "-c, --critical=INTEGER"); 587 printf (" %s\n", "-c, --critical=INTEGER");
549 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free")); 588 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free"));
550 printf (" %s\n", "-c, --critical=PERCENT%%"); 589 printf (" %s\n", "-c, --critical=PERCENT%");
551 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of swap space is free")); 590 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of swap space is free"));
552 printf (" %s\n", "-a, --allswaps"); 591 printf (" %s\n", "-a, --allswaps");
553 printf (" %s\n", _("Conduct comparisons for all swap partitions, one by one")); 592 printf (" %s\n", _("Conduct comparisons for all swap partitions, one by one"));
554 printf (" %s\n", "-n, --no-swap=<ok|warning|critical|unknown>"); 593 printf (" %s\n", "-n, --no-swap=<ok|warning|critical|unknown>");
555 printf (" %s %s\n", _("Resulting state when there is no swap regardless of thresholds. Default:"), state_text(no_swap_state)); 594 printf (" %s %s\n", _("Resulting state when there is no swap regardless of thresholds. Default:"), state_text(no_swap_state));
556 printf (UT_VERBOSE); 595 printf (UT_VERBOSE);
557 596
558 printf ("\n"); 597 printf ("\n");
559 printf ("%s\n", _("Notes:")); 598 printf ("%s\n", _("Notes:"));
560 printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked.")); 599 printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked."));
561 printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.")); 600 printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."));
562 601
563 printf (UT_SUPPORT); 602 printf (UT_SUPPORT);
564} 603}
565 604
566 605
567
568void 606void
569print_usage (void) 607print_usage (void)
570{ 608{
571 printf ("%s\n", _("Usage:")); 609 printf ("%s\n", _("Usage:"));
572 printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname); 610 printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
573 printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n"); 611 printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n");
574} 612}
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index e9e56a5..0de37a2 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -402,7 +402,10 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
402 402
403 /* create the command string to send to the UPS daemon */ 403 /* create the command string to send to the UPS daemon */
404 /* Add LOGOUT to avoid read failure logs */ 404 /* Add LOGOUT to avoid read failure logs */
405 sprintf (send_buffer, "GET VAR %s %s\nLOGOUT\n", ups_name, varname); 405 if (snprintf (send_buffer, sizeof(send_buffer), "GET VAR %s %s\nLOGOUT\n", ups_name, varname) >= sizeof(send_buffer)) {
406 printf("%s\n", _("UPS name to long for buffer"));
407 return ERROR;
408 }
406 409
407 /* send the command to the daemon and get a response back */ 410 /* send the command to the daemon and get a response back */
408 if (process_tcp_request 411 if (process_tcp_request
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t
index 45ee533..ada6a04 100644
--- a/plugins/t/check_curl.t
+++ b/plugins/t/check_curl.t
@@ -95,7 +95,7 @@ SKIP: {
95 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443"); 95 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443");
96 like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); 96 like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
97 97
98 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -D -p 443"); 98 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -D -S -p 443");
99 like( $res->output, '/(^Host: '.$host_tls_http.'\s*$)|(cURL returned 60)/ms', "Host Header OK" ); 99 like( $res->output, '/(^Host: '.$host_tls_http.'\s*$)|(cURL returned 60)/ms', "Host Header OK" );
100}; 100};
101 101
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index fdd8769..ec527e7 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -88,8 +88,9 @@ $result = NPTest->testCmd(
88 ); 88 );
89$_ = $result->perf_output; 89$_ = $result->perf_output;
90my ($warn_absth_data, $crit_absth_data, $total_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/); 90my ($warn_absth_data, $crit_absth_data, $total_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/);
91is ($warn_absth_data, $total_absth_data - 20, "Wrong warning in perf data using absolute thresholds"); 91# default unit is MiB, but perfdata is always bytes
92is ($crit_absth_data, $total_absth_data - 10, "Wrong critical in perf data using absolute thresholds"); 92is ($warn_absth_data, $total_absth_data - (20 * (2 ** 20)), "Wrong warning in perf data using absolute thresholds");
93is ($crit_absth_data, $total_absth_data - (10 * (2 ** 20)), "Wrong critical in perf data using absolute thresholds");
93 94
94# Then check percent thresholds. 95# Then check percent thresholds.
95$result = NPTest->testCmd( 96$result = NPTest->testCmd(
@@ -119,7 +120,7 @@ like ( $result->only_output, qr/$more_free/, "Have disk name in text");
119$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" ); 120$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" );
120cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free"); 121cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free");
121$_ = $result->output; 122$_ = $result->output;
122my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+) MB .* (\d+) MB /g); 123my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+)MiB .* (\d+)MiB /g);
123my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2; 124my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2;
124 125
125 126
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index cdfbe60..afb2062 100644
--- a/plugins/t/check_dns.t
+++ b/plugins/t/check_dns.t
@@ -10,7 +10,7 @@ use NPTest;
10 10
11plan skip_all => "check_dns not compiled" unless (-x "check_dns"); 11plan skip_all => "check_dns not compiled" unless (-x "check_dns");
12 12
13plan tests => 19; 13plan tests => 23;
14 14
15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; 15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
16 16
@@ -105,3 +105,11 @@ cmp_ok( $res->return_code, '==', 0, "Got expected address");
105$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5"); 105$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5");
106cmp_ok( $res->return_code, '==', 2, "Got wrong address"); 106cmp_ok( $res->return_code, '==', 2, "Got wrong address");
107like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK"); 107like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK");
108
109$res = NPTest->testCmd("./check_dns -H $hostname_valid -n");
110cmp_ok( $res->return_code, '==', 2, "Found $hostname_valid");
111like ( $res->output, "/^DNS CRITICAL.*Domain '$hostname_valid' was found by the server:/", "Output OK");
112
113$res = NPTest->testCmd("./check_dns -H $hostname_invalid -n");
114cmp_ok( $res->return_code, '==', 0, "Did not find $hostname_invalid");
115like ( $res->output, $successOutput, "Output OK" );
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t
index 55f6f75..60837ef 100644
--- a/plugins/t/check_load.t
+++ b/plugins/t/check_load.t
@@ -11,8 +11,8 @@ use NPTest;
11my $res; 11my $res;
12 12
13my $loadValue = "[0-9]+\.?[0-9]+"; 13my $loadValue = "[0-9]+\.?[0-9]+";
14my $successOutput = "/^OK - load average: $loadValue, $loadValue, $loadValue/"; 14my $successOutput = "/^LOAD OK - load average: $loadValue, $loadValue, $loadValue/";
15my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/"; 15my $failureOutput = "/^LOAD CRITICAL - load average: $loadValue, $loadValue, $loadValue/";
16 16
17plan tests => 11; 17plan tests => 11;
18 18
diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t
index e44adc9..de9e0f0 100644
--- a/plugins/t/check_swap.t
+++ b/plugins/t/check_swap.t
@@ -8,9 +8,9 @@ use strict;
8use Test::More tests => 8; 8use Test::More tests => 8;
9use NPTest; 9use NPTest;
10 10
11my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; 11my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
12my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; 12my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
13my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; 13my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
14 14
15my $result; 15my $result;
16 16
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index 54d43d9..3af218f 100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -8,13 +8,14 @@ use Test::More;
8use NPTest; 8use NPTest;
9 9
10if (-x "./check_procs") { 10if (-x "./check_procs") {
11 plan tests => 50; 11 plan tests => 52;
12} else { 12} else {
13 plan skip_all => "No check_procs compiled"; 13 plan skip_all => "No check_procs compiled";
14} 14}
15 15
16my $result; 16my $result;
17my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin"; 17my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin";
18my $cmd_etime = "./check_procs --input-file=tests/var/ps-axwo.debian";
18 19
19$result = NPTest->testCmd( "$command" ); 20$result = NPTest->testCmd( "$command" );
20is( $result->return_code, 0, "Run with no options" ); 21is( $result->return_code, 0, "Run with no options" );
@@ -69,9 +70,21 @@ SKIP: {
69 like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); 70 like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
70}; 71};
71 72
72$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); 73SKIP: {
73is( $result->return_code, 0, "Checking regexp search of arguments" ); 74 skip 'check_procs is compiled with etime format support', 2 if `$command -vvv` =~ m/etime/mx;
74is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); 75
76 $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
77 is( $result->return_code, 0, "Checking regexp search of arguments" );
78 is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" );
79}
80
81SKIP: {
82 skip 'check_procs is compiled without etime format support', 2 if `$cmd_etime -vvv` !~ m/etime/mx;
83
84 $result = NPTest->testCmd( "$cmd_etime -m ELAPSED -C apache2 -w 1000 -c 2000" );
85 is( $result->return_code, 2, "Checking elapsed time threshold" );
86 is( $result->output, "ELAPSED CRITICAL: 10 crit, 0 warn out of 10 processes with command name 'apache2' | procs=10;;;0; procs_warn=0;;;0; procs_crit=10;;;0;", "Output correct" );
87}
75 88
76$result = NPTest->testCmd( "$command --vsz 1000000" ); 89$result = NPTest->testCmd( "$command --vsz 1000000" );
77is( $result->return_code, 0, "Checking filter by VSZ" ); 90is( $result->return_code, 0, "Checking filter by VSZ" );
@@ -83,7 +96,7 @@ is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;',
83 96
84$result = NPTest->testCmd( "$command -s S" ); 97$result = NPTest->testCmd( "$command -s S" );
85is( $result->return_code, 0, "Checking filter for sleeping processes" ); 98is( $result->return_code, 0, "Checking filter for sleeping processes" );
86like( $result->output, '/^PROCS OK: 44 processes with STATE = S/', "Output correct" ); 99like( $result->output, '/^PROCS OK: 88 processes with STATE = S/', "Output correct" );
87 100
88$result = NPTest->testCmd( "$command -s Z" ); 101$result = NPTest->testCmd( "$command -s Z" );
89is( $result->return_code, 0, "Checking filter for zombies" ); 102is( $result->return_code, 0, "Checking filter for zombies" );
@@ -129,4 +142,3 @@ is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowSe
129$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); 142$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" );
130is( $result->return_code, 0, "Checking no pipe symbol in output" ); 143is( $result->return_code, 0, "Checking no pipe symbol in output" );
131is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" ); 144is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" );
132
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index 85d6bf5..0a77fa8 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 = 67; 12my $tests = 73;
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;
@@ -251,9 +251,20 @@ is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4;-2:;-3:
251 251
252$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.18 -c '~:-6.5'" ); 252$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.18 -c '~:-6.5'" );
253is($res->return_code, 0, "Negative float OK" ); 253is($res->return_code, 0, "Negative float OK" );
254is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;;~:-6.5 ', "Negative float OK output" ); 254is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;;@-6.5:~ ', "Negative float OK output" );
255 255
256$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.18 -w '~:-6.65' -c '~:-6.55'" ); 256$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.18 -w '~:-6.65' -c '~:-6.55'" );
257is($res->return_code, 1, "Negative float WARNING" ); 257is($res->return_code, 1, "Negative float WARNING" );
258is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;~:-6.65;~:-6.55 ', "Negative float WARNING output" ); 258is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;@-6.65:~;@-6.55:~ ', "Negative float WARNING output" );
259 259
260$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:100000,-10:20' -c '2:200000,-20:30'" );
261is($res->return_code, 0, "Multiple OIDs with thresholds" );
262like($res->output, '/SNMP OK - \d+ -4 | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1:100000;2:200000 iso.3.6.1.4.1.8072.3.2.67.17=-4;-10:20;-20:30/', "Multiple OIDs with thresholds output" );
263
264$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:100000,-1:2' -c '2:200000,-20:30'" );
265is($res->return_code, 1, "Multiple OIDs with thresholds" );
266like($res->output, '/SNMP WARNING - \d+ \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1:100000;2:200000 iso.3.6.1.4.1.8072.3.2.67.17=-4;-10:20;-20:30/', "Multiple OIDs with thresholds output" );
267
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" );
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" );
diff --git a/plugins/tests/var/ps-axwo.debian b/plugins/tests/var/ps-axwo.debian
new file mode 100644
index 0000000..5889e9a
--- /dev/null
+++ b/plugins/tests/var/ps-axwo.debian
@@ -0,0 +1,219 @@
1STAT UID PID PPID VSZ RSS %CPU ELAPSED COMMAND COMMAND
2Ss 0 1 0 167244 7144 0.1 26-03:07:26 systemd /lib/systemd/systemd --system --deserialize 17
3S 0 2 0 0 0 0.0 26-03:07:26 kthreadd [kthreadd]
4I< 0 3 2 0 0 0.0 26-03:07:26 rcu_gp [rcu_gp]
5I< 0 4 2 0 0 0.0 26-03:07:26 rcu_par_gp [rcu_par_gp]
6I< 0 6 2 0 0 0.0 26-03:07:26 kworker/0:0H-ev [kworker/0:0H-events_highpri]
7I< 0 9 2 0 0 0.0 26-03:07:26 mm_percpu_wq [mm_percpu_wq]
8S 0 10 2 0 0 0.0 26-03:07:26 rcu_tasks_rude_ [rcu_tasks_rude_]
9S 0 11 2 0 0 0.0 26-03:07:26 rcu_tasks_trace [rcu_tasks_trace]
10S 0 12 2 0 0 0.0 26-03:07:26 ksoftirqd/0 [ksoftirqd/0]
11I 0 13 2 0 0 0.0 26-03:07:26 rcu_sched [rcu_sched]
12S 0 14 2 0 0 0.0 26-03:07:26 migration/0 [migration/0]
13S 0 15 2 0 0 0.0 26-03:07:26 cpuhp/0 [cpuhp/0]
14S 0 16 2 0 0 0.0 26-03:07:26 cpuhp/1 [cpuhp/1]
15S 0 17 2 0 0 0.0 26-03:07:26 migration/1 [migration/1]
16S 0 18 2 0 0 0.0 26-03:07:26 ksoftirqd/1 [ksoftirqd/1]
17I< 0 20 2 0 0 0.0 26-03:07:26 kworker/1:0H-ev [kworker/1:0H-events_highpri]
18S 0 21 2 0 0 0.0 26-03:07:26 cpuhp/2 [cpuhp/2]
19S 0 22 2 0 0 0.0 26-03:07:26 migration/2 [migration/2]
20S 0 23 2 0 0 0.0 26-03:07:26 ksoftirqd/2 [ksoftirqd/2]
21I< 0 25 2 0 0 0.0 26-03:07:26 kworker/2:0H-ev [kworker/2:0H-events_highpri]
22S 0 26 2 0 0 0.0 26-03:07:26 cpuhp/3 [cpuhp/3]
23S 0 27 2 0 0 0.0 26-03:07:26 migration/3 [migration/3]
24S 0 28 2 0 0 0.0 26-03:07:26 ksoftirqd/3 [ksoftirqd/3]
25I< 0 30 2 0 0 0.0 26-03:07:26 kworker/3:0H-ev [kworker/3:0H-events_highpri]
26S 0 35 2 0 0 0.0 26-03:07:26 kdevtmpfs [kdevtmpfs]
27I< 0 36 2 0 0 0.0 26-03:07:26 netns [netns]
28S 0 37 2 0 0 0.0 26-03:07:26 kauditd [kauditd]
29S 0 38 2 0 0 0.0 26-03:07:26 khungtaskd [khungtaskd]
30S 0 39 2 0 0 0.0 26-03:07:26 oom_reaper [oom_reaper]
31I< 0 40 2 0 0 0.0 26-03:07:26 writeback [writeback]
32S 0 41 2 0 0 0.0 26-03:07:26 kcompactd0 [kcompactd0]
33SN 0 42 2 0 0 0.0 26-03:07:26 ksmd [ksmd]
34SN 0 43 2 0 0 0.0 26-03:07:26 khugepaged [khugepaged]
35I< 0 62 2 0 0 0.0 26-03:07:26 kintegrityd [kintegrityd]
36I< 0 63 2 0 0 0.0 26-03:07:26 kblockd [kblockd]
37I< 0 64 2 0 0 0.0 26-03:07:26 blkcg_punt_bio [blkcg_punt_bio]
38I< 0 65 2 0 0 0.0 26-03:07:26 edac-poller [edac-poller]
39I< 0 66 2 0 0 0.0 26-03:07:26 devfreq_wq [devfreq_wq]
40I< 0 67 2 0 0 0.0 26-03:07:26 kworker/2:1H-ev [kworker/2:1H-events_highpri]
41S 0 70 2 0 0 0.3 26-03:07:25 kswapd0 [kswapd0]
42I< 0 71 2 0 0 0.0 26-03:07:25 kthrotld [kthrotld]
43I< 0 72 2 0 0 0.0 26-03:07:25 acpi_thermal_pm [acpi_thermal_pm]
44I< 0 74 2 0 0 0.0 26-03:07:25 ipv6_addrconf [ipv6_addrconf]
45I< 0 80 2 0 0 0.0 26-03:07:25 kworker/3:1H-ev [kworker/3:1H-events_highpri]
46I< 0 84 2 0 0 0.0 26-03:07:25 kstrp [kstrp]
47I< 0 87 2 0 0 0.0 26-03:07:25 zswap-shrink [zswap-shrink]
48I< 0 110 2 0 0 0.0 26-03:07:25 kworker/0:1H-ev [kworker/0:1H-events_highpri]
49I< 0 141 2 0 0 0.0 26-03:07:25 ata_sff [ata_sff]
50S 0 143 2 0 0 0.0 26-03:07:25 scsi_eh_0 [scsi_eh_0]
51I< 0 144 2 0 0 0.0 26-03:07:25 scsi_tmf_0 [scsi_tmf_0]
52S 0 145 2 0 0 0.0 26-03:07:25 scsi_eh_1 [scsi_eh_1]
53I< 0 146 2 0 0 0.0 26-03:07:25 scsi_tmf_1 [scsi_tmf_1]
54S 0 147 2 0 0 0.0 26-03:07:25 scsi_eh_2 [scsi_eh_2]
55I< 0 148 2 0 0 0.0 26-03:07:25 scsi_tmf_2 [scsi_tmf_2]
56S 0 149 2 0 0 0.0 26-03:07:25 scsi_eh_3 [scsi_eh_3]
57I< 0 150 2 0 0 0.0 26-03:07:25 scsi_tmf_3 [scsi_tmf_3]
58S 0 151 2 0 0 0.0 26-03:07:25 scsi_eh_4 [scsi_eh_4]
59I< 0 152 2 0 0 0.0 26-03:07:25 scsi_tmf_4 [scsi_tmf_4]
60S 0 153 2 0 0 0.0 26-03:07:25 scsi_eh_5 [scsi_eh_5]
61I< 0 154 2 0 0 0.0 26-03:07:25 scsi_tmf_5 [scsi_tmf_5]
62S 0 158 2 0 0 0.0 26-03:07:25 card0-crtc0 [card0-crtc0]
63S 0 159 2 0 0 0.0 26-03:07:25 card0-crtc1 [card0-crtc1]
64S 0 160 2 0 0 0.0 26-03:07:25 card0-crtc2 [card0-crtc2]
65I< 0 162 2 0 0 0.0 26-03:07:25 kworker/1:1H-ev [kworker/1:1H-events_highpri]
66S 0 163 2 0 0 0.0 26-03:07:25 scsi_eh_6 [scsi_eh_6]
67I< 0 164 2 0 0 0.0 26-03:07:25 scsi_tmf_6 [scsi_tmf_6]
68S 0 165 2 0 0 0.0 26-03:07:25 usb-storage [usb-storage]
69I< 0 167 2 0 0 0.0 26-03:07:25 uas [uas]
70I< 0 176 2 0 0 0.0 26-03:07:25 kdmflush [kdmflush]
71I< 0 177 2 0 0 0.0 26-03:07:25 kdmflush [kdmflush]
72S 0 202 2 0 0 0.0 26-03:07:24 scsi_eh_7 [scsi_eh_7]
73I< 0 203 2 0 0 0.0 26-03:07:24 scsi_tmf_7 [scsi_tmf_7]
74S 0 204 2 0 0 0.0 26-03:07:24 usb-storage [usb-storage]
75I< 0 232 2 0 0 0.0 26-03:07:23 btrfs-worker [btrfs-worker]
76I< 0 233 2 0 0 0.0 26-03:07:23 btrfs-worker-hi [btrfs-worker-hi]
77I< 0 234 2 0 0 0.0 26-03:07:23 btrfs-delalloc [btrfs-delalloc]
78I< 0 235 2 0 0 0.0 26-03:07:23 btrfs-flush_del [btrfs-flush_del]
79I< 0 236 2 0 0 0.0 26-03:07:23 btrfs-cache [btrfs-cache]
80I< 0 237 2 0 0 0.0 26-03:07:23 btrfs-fixup [btrfs-fixup]
81I< 0 238 2 0 0 0.0 26-03:07:23 btrfs-endio [btrfs-endio]
82I< 0 239 2 0 0 0.0 26-03:07:23 btrfs-endio-met [btrfs-endio-met]
83I< 0 240 2 0 0 0.0 26-03:07:23 btrfs-endio-met [btrfs-endio-met]
84I< 0 241 2 0 0 0.0 26-03:07:23 btrfs-endio-rai [btrfs-endio-rai]
85I< 0 242 2 0 0 0.0 26-03:07:23 btrfs-rmw [btrfs-rmw]
86I< 0 243 2 0 0 0.0 26-03:07:23 btrfs-endio-wri [btrfs-endio-wri]
87I< 0 244 2 0 0 0.0 26-03:07:23 btrfs-freespace [btrfs-freespace]
88I< 0 245 2 0 0 0.0 26-03:07:23 btrfs-delayed-m [btrfs-delayed-m]
89I< 0 246 2 0 0 0.0 26-03:07:23 btrfs-readahead [btrfs-readahead]
90I< 0 247 2 0 0 0.0 26-03:07:23 btrfs-qgroup-re [btrfs-qgroup-re]
91S 0 248 2 0 0 0.0 26-03:07:23 btrfs-cleaner [btrfs-cleaner]
92S 0 249 2 0 0 0.2 26-03:07:23 btrfs-transacti [btrfs-transacti]
93I< 0 317 2 0 0 0.0 26-03:07:22 rpciod [rpciod]
94I< 0 322 2 0 0 0.0 26-03:07:22 xprtiod [xprtiod]
95S 0 381 2 0 0 0.0 26-03:07:22 irq/133-mei_me [irq/133-mei_me]
96S 0 422 2 0 0 0.0 26-03:07:22 watchdogd [watchdogd]
97I< 0 523 2 0 0 0.0 26-03:07:22 led_workqueue [led_workqueue]
98I< 0 583 2 0 0 0.0 26-03:07:22 cryptd [cryptd]
99I< 0 590 2 0 0 0.0 26-03:07:22 ext4-rsv-conver [ext4-rsv-conver]
100Ss 104 693 1 12324 4292 0.5 26-03:07:21 dbus-daemon /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
101Ss 0 731 1 575120 1368 0.0 26-03:07:21 systemd-logind /lib/systemd/systemd-logind
102Ssl 0 1111 1 121248 732 0.0 26-03:07:18 unattended-upgr /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
103S 0 1141 2 0 0 0.0 26-03:07:18 lockd [lockd]
104I< 0 1459 2 0 0 0.0 26-03:07:16 nfsiod [nfsiod]
105S 0 1621 2 0 0 0.0 26-03:07:15 NFSv4 callback [NFSv4 callback]
106Ssl 0 1771 1 1548340 676 0.0 26-03:07:13 libvirtd /usr/sbin/libvirtd
107I< 0 24315 2 0 0 0.0 26-02:49:02 cifsiod [cifsiod]
108I< 0 24316 2 0 0 0.0 26-02:49:02 smb3decryptd [smb3decryptd]
109I< 0 24317 2 0 0 0.0 26-02:49:02 cifsfileinfoput [cifsfileinfoput]
110I< 0 24318 2 0 0 0.0 26-02:49:02 cifsoplockd [cifsoplockd]
111I< 0 24319 2 0 0 0.0 26-02:49:02 cifs-dfscache [cifs-dfscache]
112S 0 24322 2 0 0 0.0 26-02:49:02 cifsd [cifsd]
113I< 0 24413 2 0 0 0.0 26-02:48:57 btrfs-worker [btrfs-worker]
114I< 0 24414 2 0 0 0.0 26-02:48:57 btrfs-worker-hi [btrfs-worker-hi]
115I< 0 24415 2 0 0 0.0 26-02:48:57 btrfs-delalloc [btrfs-delalloc]
116I< 0 24416 2 0 0 0.0 26-02:48:57 btrfs-flush_del [btrfs-flush_del]
117I< 0 24418 2 0 0 0.0 26-02:48:57 btrfs-cache [btrfs-cache]
118I< 0 24419 2 0 0 0.0 26-02:48:57 btrfs-fixup [btrfs-fixup]
119I< 0 24420 2 0 0 0.0 26-02:48:57 btrfs-endio [btrfs-endio]
120I< 0 24421 2 0 0 0.0 26-02:48:57 btrfs-endio-met [btrfs-endio-met]
121I< 0 24422 2 0 0 0.0 26-02:48:57 btrfs-endio-met [btrfs-endio-met]
122I< 0 24423 2 0 0 0.0 26-02:48:57 btrfs-endio-rai [btrfs-endio-rai]
123I< 0 24424 2 0 0 0.0 26-02:48:57 btrfs-rmw [btrfs-rmw]
124I< 0 24425 2 0 0 0.0 26-02:48:57 btrfs-endio-wri [btrfs-endio-wri]
125I< 0 24426 2 0 0 0.0 26-02:48:57 btrfs-freespace [btrfs-freespace]
126I< 0 24427 2 0 0 0.0 26-02:48:57 btrfs-delayed-m [btrfs-delayed-m]
127I< 0 24428 2 0 0 0.0 26-02:48:57 btrfs-readahead [btrfs-readahead]
128I< 0 24429 2 0 0 0.0 26-02:48:57 btrfs-qgroup-re [btrfs-qgroup-re]
129S 0 24450 2 0 0 0.0 26-02:48:53 btrfs-cleaner [btrfs-cleaner]
130S 0 24451 2 0 0 0.0 26-02:48:53 btrfs-transacti [btrfs-transacti]
131I< 0 747708 2 0 0 0.0 16-21:06:20 xfsalloc [xfsalloc]
132I< 0 747709 2 0 0 0.0 16-21:06:20 xfs_mru_cache [xfs_mru_cache]
133S 0 747713 2 0 0 0.0 16-21:06:20 jfsIO [jfsIO]
134S 0 747714 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
135S 0 747715 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
136S 0 747716 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
137S 0 747717 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
138S 0 747718 2 0 0 0.0 16-21:06:20 jfsSync [jfsSync]
139Ss 0 1071687 1 105976 28304 0.0 3-03:12:31 systemd-journal /lib/systemd/systemd-journald
140Ss 0 1934146 1 25672 4704 0.0 11:19:31 cupsd /usr/sbin/cupsd -l
141Ssl 0 1934148 1 182868 8540 0.0 11:19:31 cups-browsed /usr/sbin/cups-browsed
142S 13 1934155 3392655 5752 88 0.0 11:19:31 pinger (pinger)
143S< 33 1934166 3393034 57996 5460 0.0 11:19:31 apache2 /usr/sbin/apache2 -k start
144S< 33 1934167 3393034 216944 13892 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
145S< 33 1934168 3393034 216944 13756 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
146S< 33 1934169 3393034 216936 13732 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
147S< 33 1934170 3393034 216944 13888 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
148S< 33 1934172 3393034 216944 15388 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
149S< 33 1934701 3393034 216936 13736 0.0 11:19:29 apache2 /usr/sbin/apache2 -k start
150S< 33 1935056 3393034 216920 13724 0.0 11:19:28 apache2 /usr/sbin/apache2 -k start
151S 7 1936834 1934146 16652 832 0.0 11:18:12 dbus /usr/lib/cups/notifier/dbus dbus://
152S< 33 1955909 3393034 216928 13792 0.0 11:00:25 apache2 /usr/sbin/apache2 -k start
153I< 0 2531464 2 0 0 0.0 06:35:47 kworker/u9:0-i9 [kworker/u9:0-i915_flip]
154I 0 2570506 2 0 0 0.0 06:27:41 kworker/1:0-cgr [kworker/1:0-cgroup_destroy]
155I 0 2596195 2 0 0 0.0 06:21:52 kworker/1:1-eve [kworker/1:1-events]
156I 0 2785341 2 0 0 0.0 03:34:16 kworker/u8:8-bt [kworker/u8:8-btrfs-endio-write]
157I 0 2785520 2 0 0 0.0 03:33:50 kworker/3:0-eve [kworker/3:0-events]
158I 0 2798669 2 0 0 0.0 03:21:09 kworker/u8:5-bt [kworker/u8:5-btrfs-endio-write]
159Ss 0 2803015 1 5616 3108 0.0 03:17:54 cron /usr/sbin/cron -f
160I 0 2845483 2 0 0 0.0 02:38:11 kworker/0:3-eve [kworker/0:3-events]
161I 0 2939490 2 0 0 0.1 01:10:32 kworker/0:0-eve [kworker/0:0-events]
162I 0 2939754 2 0 0 0.0 01:10:26 kworker/u8:1-i9 [kworker/u8:1-i915]
163I 0 2942040 2 0 0 0.0 01:08:02 kworker/u8:7-bt [kworker/u8:7-btrfs-endio-meta]
164S 117 2954268 3392551 40044 5772 0.0 56:37 pickup pickup -l -t unix -u -c
165I 0 2965195 2 0 0 0.0 46:00 kworker/u8:0-bt [kworker/u8:0-btrfs-worker]
166I 0 2977972 2 0 0 0.0 33:54 kworker/u8:2-bt [kworker/u8:2-btrfs-endio-write]
167I 0 2985488 2 0 0 0.0 27:02 kworker/u8:3-bl [kworker/u8:3-blkcg_punt_bio]
168I 0 2987519 2 0 0 1.0 25:15 kworker/2:1-eve [kworker/2:1-events]
169I 0 2987601 2 0 0 0.0 25:03 kworker/u8:9-i9 [kworker/u8:9-i915]
170I< 0 2995218 2 0 0 0.0 18:41 kworker/u9:2-xp [kworker/u9:2-xprtiod]
171I 0 2997170 2 0 0 0.0 16:41 kworker/3:1-rcu [kworker/3:1-rcu_gp]
172I 0 3001264 2 0 0 0.0 13:01 kworker/u8:4-bt [kworker/u8:4-btrfs-endio-write]
173I 0 3004697 2 0 0 0.7 09:41 kworker/2:0-eve [kworker/2:0-events]
174I 0 3010619 2 0 0 1.0 04:29 kworker/2:2-eve [kworker/2:2-events]
175I 0 3014612 2 0 0 0.0 00:41 kworker/3:2-eve [kworker/3:2-events]
176S 0 3015082 2803015 6716 3028 0.0 00:30 cron /usr/sbin/CRON -f
177I 0 3015382 2 0 0 0.0 00:00 kworker/u8:6-bt [kworker/u8:6-btrfs-endio-meta]
178Ss 1 3392068 1 5592 504 0.0 15-02:34:39 atd /usr/sbin/atd -f
179Ssl 0 3392072 1 235796 1740 0.0 15-02:34:39 accounts-daemon /usr/libexec/accounts-daemon
180Ssl 106 3392076 1 315708 6128 0.0 15-02:34:39 colord /usr/libexec/colord
181Ss 0 3392083 1 8120 720 0.0 15-02:34:39 haveged /usr/sbin/haveged --Foreground --verbose=1
182Ss 0 3392090 1 5168 132 0.0 15-02:34:39 blkmapd /usr/sbin/blkmapd
183SNsl 111 3392094 1 155648 440 0.0 15-02:34:39 rtkit-daemon /usr/libexec/rtkit-daemon
184Ssl 0 3392097 1 290168 1352 0.0 15-02:34:39 packagekitd /usr/libexec/packagekitd
185Ss 128 3392100 1 7960 448 0.0 15-02:34:39 rpcbind /sbin/rpcbind -f -w
186Ss 0 3392114 1 13432 616 0.0 15-02:34:39 systemd-machine /lib/systemd/systemd-machined
187Ss 0 3392118 1 13316 848 0.0 15-02:34:39 sshd sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
188Ssl 0 3392124 1 244072 2456 0.0 15-02:34:39 upowerd /usr/libexec/upowerd
189Ssl 0 3392138 1 1634748 10684 0.0 15-02:34:39 containerd /usr/bin/containerd
190Ssl 0 3392139 1 222768 1784 0.0 15-02:34:39 rsyslogd /usr/sbin/rsyslogd -n -iNONE
191Ss 13 3392140 1 3344 152 0.0 15-02:34:39 polipo /usr/bin/polipo -c /etc/polipo/config pidFile=/var/run/polipo/polipo.pid daemonise=true
192Ssl 119 3392156 1 76472 1688 0.0 15-02:34:39 ntpd /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 119:126
193Ss 120 3392168 1 4656 276 0.0 15-02:34:39 rpc.statd /sbin/rpc.statd --no-notify
194Ss 0 3392171 1 5072 432 0.0 15-02:34:39 rpc.mountd /usr/sbin/rpc.mountd --manage-gids
195Ss 0 3392176 1 5008 288 0.0 15-02:34:39 rpc.idmapd /usr/sbin/rpc.idmapd
196Ss 105 3392184 1 15544 6816 3.5 15-02:34:39 avahi-daemon avahi-daemon: running [tsui.local]
197Ss 0 3392186 1 25288 3860 0.0 15-02:34:39 systemd-udevd /lib/systemd/systemd-udevd
198S 105 3392190 3392184 8788 52 0.0 15-02:34:39 avahi-daemon avahi-daemon: chroot helper
199Ssl 0 3392197 1 396120 4188 0.0 15-02:34:39 udisksd /usr/libexec/udisks2/udisksd
200Ssl 0 3392214 1 237504 6632 0.0 15-02:34:39 polkitd /usr/libexec/polkitd --no-debug
201Ss 0 3392284 1 9684 560 0.0 15-02:34:38 xinetd /usr/sbin/xinetd -pidfile /run/xinetd.pid -stayalive -inetd_compat -inetd_ipv6
202Ssl 0 3392285 1 314840 1352 0.0 15-02:34:38 ModemManager /usr/sbin/ModemManager
203Ss 0 3392317 1 2352 140 0.0 15-02:34:38 acpid /usr/sbin/acpid
204S 0 3392400 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
205S 0 3392401 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
206S 0 3392402 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
207S 0 3392403 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
208S 0 3392404 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
209S 0 3392405 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
210S 0 3392407 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
211S 0 3392410 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
212Ss 0 3392551 1 40092 1304 0.0 15-02:34:37 master /usr/lib/postfix/sbin/master -w
213S 117 3392553 3392551 40156 568 0.0 15-02:34:37 qmgr qmgr -l -t unix -u
214Ss 0 3392650 1 63652 4 0.0 15-02:34:36 squid /usr/sbin/squid --foreground -sYC
215Ssl 116 3392652 1 1675196 93848 0.0 15-02:34:36 mariadbd /usr/sbin/mariadbd
216S 13 3392655 3392650 81776 21232 0.0 15-02:34:36 squid (squid-1) --kid squid-1 --foreground -sYC
217S 13 3392657 3392655 5572 68 0.0 15-02:34:36 log_file_daemon (logfile-daemon) /var/log/squid/access.log
218S<s 0 3393034 1 216648 7560 0.0 15-02:34:34 apache2 /usr/sbin/apache2 -k start
219Ss 33 3393037 1 3432 180 0.0 15-02:34:34 htcacheclean /usr/bin/htcacheclean -d 120 -p /var/cache/apache2/mod_cache_disk -l 300M -n
diff --git a/plugins/tests/var/ps_axwo.debian b/plugins/tests/var/ps_axwo.debian
deleted file mode 100644
index 37a2d35..0000000
--- a/plugins/tests/var/ps_axwo.debian
+++ /dev/null
@@ -1,84 +0,0 @@
1STAT UID PID PPID VSZ RSS %CPU COMMAND COMMAND
2S 0 1 0 1504 428 0.0 init init [2]
3SN 0 2 1 0 0 0.0 ksoftirqd/0 [ksoftirqd/0]
4S< 0 3 1 0 0 0.0 events/0 [events/0]
5S< 0 4 3 0 0 0.0 khelper [khelper]
6S< 0 5 3 0 0 0.0 kacpid [kacpid]
7S< 0 38 3 0 0 0.0 kblockd/0 [kblockd/0]
8S 0 48 3 0 0 0.0 pdflush [pdflush]
9S< 0 51 3 0 0 0.0 aio/0 [aio/0]
10S 0 50 1 0 0 0.0 kswapd0 [kswapd0]
11S 0 193 1 0 0 0.0 kseriod [kseriod]
12S 0 214 1 0 0 0.0 scsi_eh_0 [scsi_eh_0]
13S 0 221 1 0 0 0.0 khubd [khubd]
14S 0 299 1 0 0 0.3 kjournald [kjournald]
15S 0 1148 1 0 0 0.0 pciehpd_event [pciehpd_event]
16S 0 1168 1 0 0 0.0 shpchpd_event [shpchpd_event]
17Ss 1 1795 1 1612 276 0.0 portmap /sbin/portmap
18Ss 0 2200 1 1652 568 0.0 vmware-guestd /usr/sbin/vmware-guestd --background /var/run/vmware-guestd.pid
19Ss 0 2209 1 2240 532 0.0 inetd /usr/sbin/inetd
20Ss 0 2319 1 3468 792 0.0 sshd /usr/sbin/sshd
21Ss 0 2323 1 2468 676 0.0 rpc.statd /sbin/rpc.statd
22Ss 1 2332 1 1684 488 0.0 atd /usr/sbin/atd
23Ss 0 2335 1 1764 636 0.0 cron /usr/sbin/cron
24Ss+ 0 2350 1 1500 348 0.0 getty /sbin/getty 38400 tty1
25Ss+ 0 2351 1 1500 348 0.0 getty /sbin/getty 38400 tty2
26Ss+ 0 2352 1 1500 348 0.0 getty /sbin/getty 38400 tty3
27Ss+ 0 2353 1 1500 348 0.0 getty /sbin/getty 38400 tty4
28Ss+ 0 2354 1 1500 348 0.0 getty /sbin/getty 38400 tty5
29Ss+ 0 2355 1 1500 348 0.0 getty /sbin/getty 38400 tty6
30S 0 6907 1 2308 892 0.0 mysqld_safe /bin/sh /usr/bin/mysqld_safe
31S 103 6944 6907 123220 27724 0.0 mysqld /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
32S 0 6945 6907 1488 420 0.0 logger logger -p daemon.err -t mysqld_safe -i -t mysqld
33S 1001 17778 1 6436 1588 0.0 snmpd /usr/sbin/snmpd -u nagios -Lsd -Lf /dev/null -p/var/run/snmpd.pid
34Ss 0 17789 1 9496 5556 0.0 snmptrapd /usr/sbin/snmptrapd -t -m ALL -M /usr/share/snmp/mibs:/usr/local/monitoring/snmp/load -p /var/run/snmptrapd.pid
35Ss 0 847 2319 14452 1752 0.0 sshd sshd: tonvoon [priv]
36S 1000 857 847 14616 1832 0.0 sshd sshd: tonvoon@pts/3
37Ss 1000 860 857 2984 1620 0.0 bash -bash
38S 0 868 860 2588 1428 0.0 bash -su
39S+ 1001 877 868 2652 1568 0.0 bash -su
40S 0 6086 3 0 0 0.0 pdflush [pdflush]
41Ss 0 17832 2319 14452 1752 0.0 sshd sshd: tonvoon [priv]
42S 1000 18155 17832 14620 1840 0.0 sshd sshd: tonvoon@pts/0
43Ss 1000 18156 18155 2984 1620 0.0 bash -bash
44S 0 18518 18156 2588 1428 0.0 bash -su
45S 1001 18955 18518 2672 1600 0.0 bash -su
46Ss 0 21683 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
47S 1000 21742 21683 14620 1896 0.0 sshd sshd: tonvoon@pts/1
48Ss 1000 21743 21742 2984 1620 0.0 bash -bash
49S 0 21748 21743 2592 1432 0.0 bash -su
50S 1001 21757 21748 2620 1540 0.0 bash -su
51Ss 0 2334 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
52S 1000 2343 2334 14620 1840 0.0 sshd sshd: tonvoon@pts/2
53Ss 1000 2344 2343 2984 1620 0.0 bash -bash
54S 0 2349 2344 2592 1432 0.0 bash -su
55S+ 1001 2364 2349 2620 1520 0.0 bash -su
56T 1001 2454 2364 2096 1032 0.0 vi vi configure.in.rej
57S+ 1001 8500 21757 69604 52576 0.0 opsview_web_ser /usr/bin/perl -w ./script/opsview_web_server.pl -f -d
58Ss 0 7609 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
59S 1000 7617 7609 14460 1828 0.0 sshd sshd: tonvoon@pts/4
60Ss 1000 7618 7617 2984 1620 0.0 bash -bash
61S 0 7623 7618 2592 1432 0.0 bash -su
62S+ 1001 7632 7623 2620 1528 0.0 bash -su
63Ss 1001 12678 1 20784 17728 0.0 opsviewd opsviewd
64Ss 0 832 1 14512 6360 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
65S 33 842 832 14648 6596 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
66S 33 843 832 14512 6504 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
67S 33 844 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
68S 33 845 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
69S 33 846 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
70Ss 7 4081 1 2464 884 0.0 lpd /usr/sbin/lpd -s
71S 33 26484 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
72Ss 1001 22324 1 20252 1612 0.1 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg
73Ss 0 23336 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
74S 1000 23339 23336 14620 1840 0.0 sshd sshd: tonvoon@pts/5
75Ss 1000 23340 23339 2996 1636 0.0 bash -bash
76S 0 23367 23340 3020 1628 0.0 bash bash
77S 1001 23370 23367 3064 1748 0.0 bash bash
78Ss 1001 23783 1 3220 764 0.0 ndo2db /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
79Ss 1001 23784 1 6428 4948 0.0 import_ndologsd import_ndologsd
80S+ 1001 9803 18955 4132 1936 0.0 ssh ssh altinity@cube02.lei.altinity
81S 1001 22505 22324 20256 1616 0.0 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg
82S 1001 22506 22505 1676 608 0.0 check_ping /usr/local/libexec/check_ping -H 192.168.10.23 -w 3000.0,80% -c 5000.0,100% -p 1
83S 1001 22507 22506 1660 492 0.0 ping /bin/ping -n -U -w 10 -c 1 192.168.10.23
84R+ 1001 22508 23370 2308 680 0.0 ps ps axwo stat uid pid ppid vsz rss pcpu comm args
diff --git a/plugins/utils.c b/plugins/utils.c
index 348ec02..17dd581 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -27,6 +27,8 @@
27#include "utils_base.h" 27#include "utils_base.h"
28#include <stdarg.h> 28#include <stdarg.h>
29#include <limits.h> 29#include <limits.h>
30#include <string.h>
31#include <errno.h>
30 32
31#include <arpa/inet.h> 33#include <arpa/inet.h>
32 34
@@ -239,6 +241,46 @@ is_intnonneg (char *number)
239 return FALSE; 241 return FALSE;
240} 242}
241 243
244/*
245 * Checks whether the number in the string _number_ can be put inside a int64_t
246 * On success the number will be written to the _target_ address, if _target_ is not set
247 * to NULL.
248 */
249int is_int64(char *number, int64_t *target) {
250 errno = 0;
251 uint64_t tmp = strtoll(number, NULL, 10);
252 if (errno != 0) {
253 return 0;
254 }
255 if (tmp < INT64_MIN || tmp > INT64_MAX) {
256 return 0;
257 }
258 if (target != NULL) {
259 *target = tmp;
260 }
261 return 1;
262}
263
264/*
265 * Checks whether the number in the string _number_ can be put inside a uint64_t
266 * On success the number will be written to the _target_ address, if _target_ is not set
267 * to NULL.
268 */
269int is_uint64(char *number, uint64_t *target) {
270 errno = 0;
271 uint64_t tmp = strtoll(number, NULL, 10);
272 if (errno != 0) {
273 return 0;
274 }
275 if (tmp < 0 || tmp > UINT64_MAX) {
276 return 0;
277 }
278 if (target != NULL) {
279 *target = tmp;
280 }
281 return 1;
282}
283
242int 284int
243is_intpercent (char *number) 285is_intpercent (char *number)
244{ 286{
@@ -547,10 +589,94 @@ char *perfdata (const char *label,
547 xasprintf (&data, "%s;", data); 589 xasprintf (&data, "%s;", data);
548 590
549 if (minp) 591 if (minp)
550 xasprintf (&data, "%s%ld", data, minv); 592 xasprintf (&data, "%s%ld;", data, minv);
593 else
594 xasprintf (&data, "%s;", data);
595
596 if (maxp)
597 xasprintf (&data, "%s%ld", data, maxv);
598
599 return data;
600}
601
602
603char *perfdata_uint64 (const char *label,
604 uint64_t val,
605 const char *uom,
606 int warnp, /* Warning present */
607 uint64_t warn,
608 int critp, /* Critical present */
609 uint64_t crit,
610 int minp, /* Minimum present */
611 uint64_t minv,
612 int maxp, /* Maximum present */
613 uint64_t maxv)
614{
615 char *data = NULL;
616
617 if (strpbrk (label, "'= "))
618 xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
619 else
620 xasprintf (&data, "%s=%ld%s;", label, val, uom);
621
622 if (warnp)
623 xasprintf (&data, "%s%lu;", data, warn);
624 else
625 xasprintf (&data, "%s;", data);
626
627 if (critp)
628 xasprintf (&data, "%s%lu;", data, crit);
629 else
630 xasprintf (&data, "%s;", data);
631
632 if (minp)
633 xasprintf (&data, "%s%lu;", data, minv);
634 else
635 xasprintf (&data, "%s;", data);
636
637 if (maxp)
638 xasprintf (&data, "%s%lu", data, maxv);
639
640 return data;
641}
642
643
644char *perfdata_int64 (const char *label,
645 int64_t val,
646 const char *uom,
647 int warnp, /* Warning present */
648 int64_t warn,
649 int critp, /* Critical present */
650 int64_t crit,
651 int minp, /* Minimum present */
652 int64_t minv,
653 int maxp, /* Maximum present */
654 int64_t maxv)
655{
656 char *data = NULL;
657
658 if (strpbrk (label, "'= "))
659 xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
660 else
661 xasprintf (&data, "%s=%ld%s;", label, val, uom);
662
663 if (warnp)
664 xasprintf (&data, "%s%ld;", data, warn);
665 else
666 xasprintf (&data, "%s;", data);
667
668 if (critp)
669 xasprintf (&data, "%s%ld;", data, crit);
670 else
671 xasprintf (&data, "%s;", data);
672
673 if (minp)
674 xasprintf (&data, "%s%ld;", data, minv);
675 else
676 xasprintf (&data, "%s;", data);
551 677
552 if (maxp) 678 if (maxp)
553 xasprintf (&data, "%s;%ld", data, maxv); 679 xasprintf (&data, "%s%ld", data, maxv);
554 680
555 return data; 681 return data;
556} 682}
diff --git a/plugins/utils.h b/plugins/utils.h
index 33a2054..5b54da3 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -16,6 +16,7 @@ suite of plugins. */
16/* now some functions etc are being defined in ../lib/utils_base.c */ 16/* now some functions etc are being defined in ../lib/utils_base.c */
17#include "utils_base.h" 17#include "utils_base.h"
18 18
19
19#ifdef NP_EXTRA_OPTS 20#ifdef NP_EXTRA_OPTS
20/* Include extra-opts functions if compiled in */ 21/* Include extra-opts functions if compiled in */
21#include "extra_opts.h" 22#include "extra_opts.h"
@@ -38,6 +39,8 @@ int is_intpos (char *);
38int is_intneg (char *); 39int is_intneg (char *);
39int is_intnonneg (char *); 40int is_intnonneg (char *);
40int is_intpercent (char *); 41int is_intpercent (char *);
42int is_uint64(char *number, uint64_t *target);
43int is_int64(char *number, int64_t *target);
41 44
42int is_numeric (char *); 45int is_numeric (char *);
43int is_positive (char *); 46int is_positive (char *);
@@ -88,6 +91,12 @@ void usage_va(const char *fmt, ...) __attribute__((noreturn));
88char *perfdata (const char *, long int, const char *, int, long int, 91char *perfdata (const char *, long int, const char *, int, long int,
89 int, long int, int, long int, int, long int); 92 int, long int, int, long int, int, long int);
90 93
94char *perfdata_uint64 (const char *, uint64_t , const char *, int, uint64_t,
95 int, uint64_t, int, uint64_t, int, uint64_t);
96
97char *perfdata_int64 (const char *, int64_t, const char *, int, int64_t,
98 int, int64_t, int, int64_t, int, int64_t);
99
91char *fperfdata (const char *, double, const char *, int, double, 100char *fperfdata (const char *, double, const char *, int, double,
92 int, double, int, double, int, double); 101 int, double, int, double, int, double);
93 102