summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/codeql-analysis.yml71
-rw-r--r--plugins-root/check_icmp.c4
-rwxr-xr-xplugins-scripts/check_file_age.pl2
-rwxr-xr-xplugins-scripts/check_log.sh138
-rwxr-xr-xplugins-scripts/check_mailq.pl26
-rwxr-xr-xplugins-scripts/check_oracle.sh240
-rwxr-xr-xplugins-scripts/check_sensors.sh32
-rw-r--r--plugins/check_disk.c18
-rw-r--r--plugins/check_hpjd.c17
-rw-r--r--plugins/check_swap.c2
-rw-r--r--plugins/check_ups.c5
11 files changed, 348 insertions, 207 deletions
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/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 519b93c..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;
@@ -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_file_age.pl b/plugins-scripts/check_file_age.pl
index 01b854a..26281dd 100755
--- a/plugins-scripts/check_file_age.pl
+++ b/plugins-scripts/check_file_age.pl
@@ -147,7 +147,7 @@ sub print_help () {
147 print "\n"; 147 print "\n";
148 print " -i | --ignore-missing : return OK if the file does not exist\n"; 148 print " -i | --ignore-missing : return OK if the file does not exist\n";
149 print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; 149 print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n";
150 print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n\n"; 150 print " <size> File must be at least this many bytes long (default: file size is ignored (0 bytes))\n\n";
151 print " Both <secs> and <size> can specify a range using the standard plugin syntax\n"; 151 print " Both <secs> and <size> can specify a range using the standard plugin syntax\n";
152 print " If any of the warning and critical arguments are in range syntax (not just bare numbers)\n"; 152 print " If any of the warning and critical arguments are in range syntax (not just bare numbers)\n";
153 print " then all warning and critical arguments will be interpreted as ranges.\n"; 153 print " then all warning and critical arguments will be interpreted as ranges.\n";
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh
index d28c8d0..6113123 100755
--- a/plugins-scripts/check_log.sh
+++ b/plugins-scripts/check_log.sh
@@ -1,8 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# Log file pattern detector plugin for monitoring 3# Log file pattern detector plugin for monitoring
4# Written by Ethan Galstad (nagios@nagios.org) 4# Written originally by Ethan Galstad (nagios@nagios.org)
5# Last Modified: 07-31-1999
6# 5#
7# Usage: ./check_log <log_file> <old_log_file> <pattern> 6# Usage: ./check_log <log_file> <old_log_file> <pattern>
8# 7#
@@ -60,20 +59,25 @@
60 59
61PATH="@TRUSTED_PATH@" 60PATH="@TRUSTED_PATH@"
62export PATH 61export PATH
63PROGNAME=`basename $0` 62PROGNAME=$(basename "$0")
64PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 63PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
65REVISION="@NP_VERSION@" 64REVISION="@NP_VERSION@"
66 65
67. $PROGPATH/utils.sh 66. "$PROGPATH"/utils.sh
68 67
69print_usage() { 68print_usage() {
70 echo "Usage: $PROGNAME -F logfile -O oldlog -q query" 69 echo "Usage: $PROGNAME -F logfile -O oldlog -q query"
71 echo "Usage: $PROGNAME --help" 70 echo "Usage: $PROGNAME --help"
72 echo "Usage: $PROGNAME --version" 71 echo "Usage: $PROGNAME --version"
72 echo ""
73 echo "Other parameters:"
74 echo " -a|--all : Print all matching lines"
75 echo " -p|--perl-regex : Use perl style regular expressions in the query"
76 echo " -e|--extended-regex : Use extended style regular expressions in the query (not necessary for GNU grep)"
73} 77}
74 78
75print_help() { 79print_help() {
76 print_revision $PROGNAME $REVISION 80 print_revision "$PROGNAME" "$REVISION"
77 echo "" 81 echo ""
78 print_usage 82 print_usage
79 echo "" 83 echo ""
@@ -87,7 +91,7 @@ print_help() {
87 91
88if [ $# -lt 1 ]; then 92if [ $# -lt 1 ]; then
89 print_usage 93 print_usage
90 exit $STATE_UNKNOWN 94 exit "$STATE_UNKNOWN"
91fi 95fi
92 96
93# Grab the command line arguments 97# Grab the command line arguments
@@ -100,79 +104,118 @@ while test -n "$1"; do
100 case "$1" in 104 case "$1" in
101 --help) 105 --help)
102 print_help 106 print_help
103 exit $STATE_OK 107 exit "$STATE_OK"
104 ;; 108 ;;
105 -h) 109 -h)
106 print_help 110 print_help
107 exit $STATE_OK 111 exit "$STATE_OK"
108 ;; 112 ;;
109 --version) 113 --version)
110 print_revision $PROGNAME $REVISION 114 print_revision "$PROGNAME" "$REVISION"
111 exit $STATE_OK 115 exit "$STATE_OK"
112 ;; 116 ;;
113 -V) 117 -V)
114 print_revision $PROGNAME $REVISION 118 print_revision "$PROGNAME" "$REVISION"
115 exit $STATE_OK 119 exit "$STATE_OK"
116 ;; 120 ;;
117 --filename) 121 --filename)
118 logfile=$2 122 logfile=$2
119 shift 123 shift 2
120 ;; 124 ;;
121 -F) 125 -F)
122 logfile=$2 126 logfile=$2
123 shift 127 shift 2
124 ;; 128 ;;
125 --oldlog) 129 --oldlog)
126 oldlog=$2 130 oldlog=$2
127 shift 131 shift 2
128 ;; 132 ;;
129 -O) 133 -O)
130 oldlog=$2 134 oldlog=$2
131 shift 135 shift 2
132 ;; 136 ;;
133 --query) 137 --query)
134 query=$2 138 query=$2
135 shift 139 shift 2
136 ;; 140 ;;
137 -q) 141 -q)
138 query=$2 142 query=$2
139 shift 143 shift 2
140 ;; 144 ;;
141 -x) 145 -x)
142 exitstatus=$2 146 exitstatus=$2
143 shift 147 shift 2
144 ;; 148 ;;
145 --exitstatus) 149 --exitstatus)
146 exitstatus=$2 150 exitstatus=$2
151 shift 2
152 ;;
153 --extended-regex)
154 ERE=1
155 shift
156 ;;
157 -e)
158 ERE=1
159 shift
160 ;;
161 --perl-regex)
162 PRE=1
163 shift
164 ;;
165 -p)
166 PRE=1
167 shift
168 ;;
169 --all)
170 ALL=1
171 shift
172 ;;
173 -a)
174 ALL=1
147 shift 175 shift
148 ;; 176 ;;
149 *) 177 *)
150 echo "Unknown argument: $1" 178 echo "Unknown argument: $1"
151 print_usage 179 print_usage
152 exit $STATE_UNKNOWN 180 exit "$STATE_UNKNOWN"
153 ;; 181 ;;
154 esac 182 esac
155 shift
156done 183done
157 184
185# Parameter sanity check
186if [ $ERE ] && [ $PRE ] ; then
187 echo "Can not use extended and perl regex at the same time"
188 exit "$STATE_UNKNOWN"
189fi
190
191GREP="grep"
192
193if [ $ERE ]; then
194 GREP="grep -E"
195fi
196
197if [ $PRE ]; then
198 GREP="grep -P"
199fi
200
158# If the source log file doesn't exist, exit 201# If the source log file doesn't exist, exit
159 202
160if [ ! -e $logfile ]; then 203if [ ! -e "$logfile" ]; then
161 echo "Log check error: Log file $logfile does not exist!" 204 echo "Log check error: Log file $logfile does not exist!"
162 exit $STATE_UNKNOWN 205 exit "$STATE_UNKNOWN"
163elif [ ! -r $logfile ] ; then 206elif [ ! -r "$logfile" ] ; then
164 echo "Log check error: Log file $logfile is not readable!" 207 echo "Log check error: Log file $logfile is not readable!"
165 exit $STATE_UNKNOWN 208 exit "$STATE_UNKNOWN"
166fi 209fi
167 210
168# If the old log file doesn't exist, this must be the first time 211# If the old log file doesn't exist, this must be the first time
169# we're running this test, so copy the original log file over to 212# we're running this test, so copy the original log file over to
170# the old diff file and exit 213# the old diff file and exit
171 214
172if [ ! -e $oldlog ]; then 215if [ ! -e "$oldlog" ]; then
173 cat $logfile > $oldlog 216 cat "$logfile" > "$oldlog"
174 echo "Log check data initialized..." 217 echo "Log check data initialized..."
175 exit $STATE_OK 218 exit "$STATE_OK"
176fi 219fi
177 220
178# The old log file exists, so compare it to the original log now 221# The old log file exists, so compare it to the original log now
@@ -180,31 +223,42 @@ fi
180# The temporary file that the script should use while 223# The temporary file that the script should use while
181# processing the log file. 224# processing the log file.
182if [ -x /bin/mktemp ]; then 225if [ -x /bin/mktemp ]; then
183 tempdiff=`/bin/mktemp /tmp/check_log.XXXXXXXXXX` 226
227 tempdiff=$(/bin/mktemp /tmp/check_log.XXXXXXXXXX)
184else 228else
185 tempdiff=`/bin/date '+%H%M%S'` 229 tempdiff=$(/bin/date '+%H%M%S')
186 tempdiff="/tmp/check_log.${tempdiff}" 230 tempdiff="/tmp/check_log.${tempdiff}"
187 touch $tempdiff 231 touch "$tempdiff"
188 chmod 600 $tempdiff 232 chmod 600 "$tempdiff"
189fi 233fi
190 234
191diff $logfile $oldlog | grep -v "^>" > $tempdiff 235diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff"
236
237
238if [ $ALL ]; then
239 # Get the last matching entry in the diff file
240 entry=$($GREP "$query" "$tempdiff")
192 241
193# Count the number of matching log entries we have 242 # Count the number of matching log entries we have
194count=`grep -c "$query" $tempdiff` 243 count=$(echo "$entry" | wc -l)
195 244
196# Get the last matching entry in the diff file 245else
197lastentry=`grep "$query" $tempdiff | tail -1` 246 # Count the number of matching log entries we have
247 count=$($GREP -c "$query" "$tempdiff")
248
249 # Get the last matching entry in the diff file
250 entry=$($GREP "$query" "$tempdiff" | tail -1)
251fi
198 252
199rm -f $tempdiff 253rm -f "$tempdiff"
200cat $logfile > $oldlog 254cat "$logfile" > "$oldlog"
201 255
202if [ "$count" = "0" ]; then # no matches, exit with no error 256if [ "$count" = "0" ]; then # no matches, exit with no error
203 echo "Log check ok - 0 pattern matches found" 257 echo "Log check ok - 0 pattern matches found"
204 exitstatus=$STATE_OK 258 exitstatus=$STATE_OK
205else # Print total matche count and the last entry we found 259else # Print total matche count and the last entry we found
206 echo "($count) $lastentry" 260 echo "($count) $entry"
207 exitstatus=$STATE_CRITICAL 261 exitstatus=$STATE_CRITICAL
208fi 262fi
209 263
210exit $exitstatus 264exit "$exitstatus"
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
index aac1310..3914f4a 100755
--- a/plugins-scripts/check_mailq.pl
+++ b/plugins-scripts/check_mailq.pl
@@ -28,9 +28,9 @@
28use POSIX; 28use POSIX;
29use strict; 29use strict;
30use Getopt::Long; 30use Getopt::Long;
31use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s 31use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s $opt_d
32 $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines 32 $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq $mailq_args
33 %srcdomains %dstdomains); 33 @lines %srcdomains %dstdomains);
34use FindBin; 34use FindBin;
35use lib "$FindBin::Bin"; 35use lib "$FindBin::Bin";
36use utils qw(%ERRORS &print_revision &support &usage ); 36use utils qw(%ERRORS &print_revision &support &usage );
@@ -48,6 +48,8 @@ $PROGNAME = "check_mailq";
48$mailq = 'sendmail'; # default 48$mailq = 'sendmail'; # default
49$msg_q = 0 ; 49$msg_q = 0 ;
50$msg_p = 0 ; 50$msg_p = 0 ;
51# If appended, must start with a space
52$mailq_args = '' ;
51$state = $ERRORS{'UNKNOWN'}; 53$state = $ERRORS{'UNKNOWN'};
52 54
53Getopt::Long::Configure('bundling'); 55Getopt::Long::Configure('bundling');
@@ -68,6 +70,10 @@ if ($opt_s) {
68 $sudo = ""; 70 $sudo = "";
69} 71}
70 72
73if ($opt_d) {
74 $mailq_args = $mailq_args . ' -C ' . $opt_d;
75}
76
71$SIG{'ALRM'} = sub { 77$SIG{'ALRM'} = sub {
72 print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n"); 78 print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n");
73 exit $ERRORS{"WARNING"}; 79 exit $ERRORS{"WARNING"};
@@ -309,8 +315,8 @@ elsif ( $mailq eq "postfix" ) {
309 315
310 ## open mailq 316 ## open mailq
311 if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { 317 if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
312 if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { 318 if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ$mailq_args | " ) ) {
313 print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; 319 print "ERROR: could not open $utils::PATH_TO_MAILQ$mailq_args \n";
314 exit $ERRORS{'UNKNOWN'}; 320 exit $ERRORS{'UNKNOWN'};
315 } 321 }
316 }elsif( defined $utils::PATH_TO_MAILQ){ 322 }elsif( defined $utils::PATH_TO_MAILQ){
@@ -330,7 +336,7 @@ elsif ( $mailq eq "postfix" ) {
330 close MAILQ; 336 close MAILQ;
331 337
332 if ( $? ) { 338 if ( $? ) {
333 print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/; 339 print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ$mailq_args",$/;
334 exit $ERRORS{CRITICAL}; 340 exit $ERRORS{CRITICAL};
335 } 341 }
336 342
@@ -343,7 +349,7 @@ elsif ( $mailq eq "postfix" ) {
343 }elsif ($lines[0]=~/Mail queue is empty/) { 349 }elsif ($lines[0]=~/Mail queue is empty/) {
344 $msg_q = 0; 350 $msg_q = 0;
345 }else{ 351 }else{
346 print "Couldn't match $utils::PATH_TO_MAILQ output\n"; 352 print "Couldn't match $utils::PATH_TO_MAILQ$mailq_args output\n";
347 exit $ERRORS{'UNKNOWN'}; 353 exit $ERRORS{'UNKNOWN'};
348 } 354 }
349 355
@@ -533,7 +539,7 @@ elsif ( $mailq eq "nullmailer" ) {
533 while (<MAILQ>) { 539 while (<MAILQ>) {
534 #2006-06-22 16:00:00 282 bytes 540 #2006-06-22 16:00:00 282 bytes
535 541
536 if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-2][0-9]\:[0-2][0-9]\s{2}[0-9]+\sbytes$/) { 542 if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-5][0-9]\:[0-5][0-9]\s+[0-9]+\sbytes/) {
537 $msg_q++ ; 543 $msg_q++ ;
538 } 544 }
539 } 545 }
@@ -569,6 +575,7 @@ sub process_arguments(){
569 "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number 575 "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number
570 "t=i" => \$opt_t, "timeout=i" => \$opt_t, 576 "t=i" => \$opt_t, "timeout=i" => \$opt_t,
571 "s" => \$opt_s, "sudo" => \$opt_s, 577 "s" => \$opt_s, "sudo" => \$opt_s,
578 "d:s" => \$opt_d, "configdir:s" => \$opt_d,
572 "W=i" => \$opt_W, # warning if above this number 579 "W=i" => \$opt_W, # warning if above this number
573 "C=i" => \$opt_C, # critical if above this number 580 "C=i" => \$opt_C, # critical if above this number
574 ); 581 );
@@ -651,7 +658,7 @@ sub process_arguments(){
651} 658}
652 659
653sub print_usage () { 660sub print_usage () {
654 print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-v]\n"; 661 print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-d <CONFIGDIR>] [-v]\n";
655} 662}
656 663
657sub print_help () { 664sub print_help () {
@@ -669,6 +676,7 @@ sub print_help () {
669 print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; 676 print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
670 print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; 677 print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n";
671 print "-s (--sudo) = Use sudo to call the mailq command\n"; 678 print "-s (--sudo) = Use sudo to call the mailq command\n";
679 print "-d (--configdir) = Config file or directory\n";
672 print "-h (--help)\n"; 680 print "-h (--help)\n";
673 print "-V (--version)\n"; 681 print "-V (--version)\n";
674 print "-v (--verbose) = debugging output\n"; 682 print "-v (--verbose) = debugging output\n";
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
index 96078ac..b14ec50 100755
--- a/plugins-scripts/check_oracle.sh
+++ b/plugins-scripts/check_oracle.sh
@@ -8,11 +8,11 @@
8 8
9PATH="@TRUSTED_PATH@" 9PATH="@TRUSTED_PATH@"
10export PATH 10export PATH
11PROGNAME=`basename $0` 11PROGNAME=$(basename "$0")
12PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 12PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
13REVISION="@NP_VERSION@" 13REVISION="@NP_VERSION@"
14 14
15. $PROGPATH/utils.sh 15. "$PROGPATH"/utils.sh
16 16
17 17
18print_usage() { 18print_usage() {
@@ -29,7 +29,7 @@ print_usage() {
29} 29}
30 30
31print_help() { 31print_help() {
32 print_revision $PROGNAME $REVISION 32 print_revision "$PROGNAME" "$REVISION"
33 echo "" 33 echo ""
34 print_usage 34 print_usage
35 echo "" 35 echo ""
@@ -87,47 +87,47 @@ esac
87case "$cmd" in 87case "$cmd" in
88--help) 88--help)
89 print_help 89 print_help
90 exit $STATE_OK 90 exit "$STATE_OK"
91 ;; 91 ;;
92-h) 92-h)
93 print_help 93 print_help
94 exit $STATE_OK 94 exit "$STATE_OK"
95 ;; 95 ;;
96--version) 96--version)
97 print_revision $PROGNAME $REVISION 97 print_revision "$PROGNAME" "$REVISION"
98 exit $STATE_OK 98 exit "$STATE_OK"
99 ;; 99 ;;
100-V) 100-V)
101 print_revision $PROGNAME $REVISION 101 print_revision "$PROGNAME" "$REVISION"
102 exit $STATE_OK 102 exit "$STATE_OK"
103 ;; 103 ;;
104esac 104esac
105 105
106# Hunt down a reasonable ORACLE_HOME 106# Hunt down a reasonable ORACLE_HOME
107if [ -z "$ORACLE_HOME" ] ; then 107if [ -z "$ORACLE_HOME" ] ; then
108 # Adjust to taste 108 # Adjust to taste
109 for oratab in /var/opt/oracle/oratab /etc/oratab 109 for oratab in /var/opt/oracle/oratab /etc/oratab
110 do 110 do
111 [ ! -f $oratab ] && continue 111 [ ! -f $oratab ] && continue
112 ORACLE_HOME=`IFS=: 112 ORACLE_HOME=`IFS=:
113 while read SID ORACLE_HOME junk; 113 while read -r SID ORACLE_HOME junk;
114 do 114 do
115 if [ "$SID" = "$2" -o "$SID" = "*" ] ; then 115 if [ "$SID" = "$2" ] || [ "$SID" = "*" ] ; then
116 echo $ORACLE_HOME; 116 echo "$ORACLE_HOME";
117 exit; 117 exit;
118 fi; 118 fi;
119 done < $oratab` 119 done < $oratab`
120 [ -n "$ORACLE_HOME" ] && break 120 [ -n "$ORACLE_HOME" ] && break
121 done 121 done
122fi 122fi
123# Last resort 123# Last resort
124[ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle 124[ -z "$ORACLE_HOME" ] && [ -d "$PROGPATH"/oracle ] && ORACLE_HOME=$PROGPATH/oracle
125 125
126if [ "$cmd" != "--db" ]; then 126if [ "$cmd" != "--db" ]; then
127 if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then 127 if [ -z "$ORACLE_HOME" ] || [ ! -d "$ORACLE_HOME" ] ; then
128 echo "Cannot determine ORACLE_HOME for sid $2" 128 echo "Cannot determine ORACLE_HOME for sid $2"
129 exit $STATE_UNKNOWN 129 exit "$STATE_UNKNOWN"
130 fi 130 fi
131fi 131fi
132PATH=$PATH:$ORACLE_HOME/bin 132PATH=$PATH:$ORACLE_HOME/bin
133LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib 133LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
@@ -135,81 +135,81 @@ export ORACLE_HOME PATH LD_LIBRARY_PATH
135 135
136case "$cmd" in 136case "$cmd" in
137--tns) 137--tns)
138 tnschk=` tnsping $2` 138 tnschk=$(tnsping "$2")
139 tnschk2=` echo $tnschk | grep -c OK` 139 tnschk2=$(echo "$tnschk" | grep -c OK)
140 if [ ${tnschk2} -eq 1 ] ; then 140 if [ "${tnschk2}" -eq 1 ] ; then
141 tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*} 141 tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*}
142 echo "OK - reply time ${tnschk3} from $2" 142 echo "OK - reply time ${tnschk3} from $2"
143 exit $STATE_OK 143 exit "$STATE_OK"
144 else 144 else
145 echo "No TNS Listener on $2" 145 echo "No TNS Listener on $2"
146 exit $STATE_CRITICAL 146 exit "$STATE_CRITICAL"
147 fi 147 fi
148 ;; 148 ;;
149--oranames) 149--oranames)
150 namesctl status $2 | awk ' 150 namesctl status "$2" | awk '
151 /Server has been running for:/ { 151 /Server has been running for:/ {
152 msg = "OK: Up" 152 msg = "OK: Up"
153 for (i = 6; i <= NF; i++) { 153 for (i = 6; i <= NF; i++) {
154 msg = msg " " $i 154 msg = msg " " $i
155 } 155 }
156 status = '$STATE_OK' 156 status = '"$STATE_OK"'
157 } 157 }
158 /error/ { 158 /error/ {
159 msg = "CRITICAL: " $0 159 msg = "CRITICAL: " $0
160 status = '$STATE_CRITICAL' 160 status = '"$STATE_CRITICAL"'
161 } 161 }
162 END { 162 END {
163 print msg 163 print msg
164 exit status 164 exit status
165 }' 165 }'
166 ;; 166 ;;
167--db) 167--db)
168 pmonchk=`ps -ef | grep -v grep | grep -E -c "(asm|ora)_pmon_${2}$"` 168 pmonchk=$(pgrep -f "(asm|ora)_pmon_${2}$")
169 if [ ${pmonchk} -ge 1 ] ; then 169 if [ "${pmonchk}" -ge 1 ] ; then
170 echo "${2} OK - ${pmonchk} PMON process(es) running" 170 echo "${2} OK - ${pmonchk} PMON process(es) running"
171 exit $STATE_OK 171 exit "$STATE_OK"
172 #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then 172 #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then
173 #if [ ${pmonchk} -eq 1 ] ; then 173 #if [ ${pmonchk} -eq 1 ] ; then
174 #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` 174 #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55`
175 #echo "${2} OK - running since ${utime}" 175 #echo "${2} OK - running since ${utime}"
176 #exit $STATE_OK 176 #exit $STATE_OK
177 #fi 177 #fi
178 else 178 else
179 echo "${2} Database is DOWN" 179 echo "${2} Database is DOWN"
180 exit $STATE_CRITICAL 180 exit "$STATE_CRITICAL"
181 fi 181 fi
182 ;; 182 ;;
183--login) 183--login)
184 loginchk=`sqlplus dummy/user@$2 < /dev/null` 184 loginchk=$(sqlplus dummy/user@"$2" < /dev/null)
185 loginchk2=` echo $loginchk | grep -c ORA-01017` 185 loginchk2=$(echo "$loginchk" | grep -c ORA-01017)
186 if [ ${loginchk2} -eq 1 ] ; then 186 if [ "${loginchk2}" -eq 1 ] ; then
187 echo "OK - dummy login connected" 187 echo "OK - dummy login connected"
188 exit $STATE_OK 188 exit "$STATE_OK"
189 else 189 else
190 loginchk3=` echo "$loginchk" | grep "ORA-" | head -1` 190 loginchk3=$(echo "$loginchk" | grep "ORA-" | head -1)
191 echo "CRITICAL - $loginchk3" 191 echo "CRITICAL - $loginchk3"
192 exit $STATE_CRITICAL 192 exit "$STATE_CRITICAL"
193 fi 193 fi
194 ;; 194 ;;
195--connect) 195--connect)
196 connectchk=`sqlplus $2 < /dev/null` 196 connectchk=$(sqlplus "$2" < /dev/null)
197 connectchk2=` echo $connectchk | grep -c ORA-` 197 connectchk2=$(echo "$connectchk" | grep -c ORA-)
198 if [ ${connectchk2} -eq 0 ] ; then 198 if [ "${connectchk2}" -eq 0 ] ; then
199 echo "OK - login successful" 199 echo "OK - login successful"
200 exit $STATE_OK 200 exit "$STATE_OK"
201 else 201 else
202 connectchk3=` echo "$connectchk" | grep "ORA-" | head -1` 202 connectchk3=$(echo "$connectchk" | grep "ORA-" | head -1)
203 echo "CRITICAL - $connectchk3" 203 echo "CRITICAL - $connectchk3"
204 exit $STATE_CRITICAL 204 exit "$STATE_CRITICAL"
205 fi 205 fi
206 ;; 206 ;;
207--cache) 207--cache)
208 if [ ${5} -gt ${6} ] ; then 208 if [ "${5}" -gt "${6}" ] ; then
209 echo "UNKNOWN - Warning level is less then Crit" 209 echo "UNKNOWN - Warning level is less then Crit"
210 exit $STATE_UNKNOWN 210 exit "$STATE_UNKNOWN"
211 fi 211 fi
212 result=`sqlplus -s ${3}/${4}@${2} << EOF 212 result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
213set pagesize 0 213set pagesize 0
214set numf '9999999.99' 214set numf '9999999.99'
215select (1-(pr.value/(dbg.value+cg.value)))*100 215select (1-(pr.value/(dbg.value+cg.value)))*100
@@ -219,48 +219,48 @@ and dbg.name='db block gets'
219and cg.name='consistent gets'; 219and cg.name='consistent gets';
220EOF` 220EOF`
221 221
222 if [ -n "`echo $result | grep ORA-`" ] ; then 222 if echo "$result" | grep -q 'ORA-' ; then
223 error=` echo "$result" | grep "ORA-" | head -1` 223 error=$(echo "$result" | grep "ORA-" | head -1)
224 echo "CRITICAL - $error" 224 echo "CRITICAL - $error"
225 exit $STATE_CRITICAL 225 exit "$STATE_CRITICAL"
226 fi 226 fi
227 227
228 buf_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` 228 buf_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}')
229 buf_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` 229 buf_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}')
230 result=`sqlplus -s ${3}/${4}@${2} << EOF 230 result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
231set pagesize 0 231set pagesize 0
232set numf '9999999.99' 232set numf '9999999.99'
233select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 233select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100
234from v\\$librarycache lc; 234from v\\$librarycache lc;
235EOF` 235EOF`
236 236
237 if [ -n "`echo $result | grep ORA-`" ] ; then 237 if echo "$result" | grep -q 'ORA-' ; then
238 error=` echo "$result" | grep "ORA-" | head -1` 238 error=$(echo "$result" | grep "ORA-" | head -1)
239 echo "CRITICAL - $error" 239 echo "CRITICAL - $error"
240 exit $STATE_CRITICAL 240 exit "$STATE_CRITICAL"
241 fi 241 fi
242 242
243 lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` 243 lib_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}')
244 lib_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` 244 lib_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}')
245 245
246 if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then 246 if [ "$buf_hr" -le "${5}" ] || [ "$lib_hr" -le "${5}" ] ; then
247 echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" 247 echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
248 exit $STATE_CRITICAL 248 exit "$STATE_CRITICAL"
249 fi 249 fi
250 if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then 250 if [ "$buf_hr" -le "${6}" ] || [ "$lib_hr" -le "${6}" ] ; then
251 echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" 251 echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
252 exit $STATE_WARNING 252 exit "$STATE_WARNING"
253 fi 253 fi
254 echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" 254 echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
255 255
256 exit $STATE_OK 256 exit "$STATE_OK"
257 ;; 257 ;;
258--tablespace) 258--tablespace)
259 if [ ${6} -lt ${7} ] ; then 259 if [ "${6}" -lt "${7}" ] ; then
260 echo "UNKNOWN - Warning level is more then Crit" 260 echo "UNKNOWN - Warning level is more then Crit"
261 exit $STATE_UNKNOWN 261 exit "$STATE_UNKNOWN"
262 fi 262 fi
263 result=`sqlplus -s ${3}/${4}@${2} << EOF 263 result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
264set pagesize 0 264set pagesize 0
265set numf '9999999.99' 265set numf '9999999.99'
266select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc 266select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
@@ -273,32 +273,32 @@ from dba_free_space group by tablespace_name) B
273ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; 273ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
274EOF` 274EOF`
275 275
276 if [ -n "`echo $result | grep ORA-`" ] ; then 276 if echo "$result" | grep -q 'ORA-' ; then
277 error=` echo "$result" | grep "ORA-" | head -1` 277 error=$(echo "$result" | grep "ORA-" | head -1)
278 echo "CRITICAL - $error" 278 echo "CRITICAL - $error"
279 exit $STATE_CRITICAL 279 exit "$STATE_CRITICAL"
280 fi 280 fi
281 281
282 ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'` 282 ts_free=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}')
283 ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'` 283 ts_total=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}')
284 ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'` 284 ts_pct=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}')
285 ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'` 285 ts_pctx=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}')
286 if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then 286 if [ "$ts_free" -eq 0 ] && [ "$ts_total" -eq 0 ] && [ "$ts_pct" -eq 0 ] ; then
287 echo "No data returned by Oracle - tablespace $5 not found?" 287 echo "No data returned by Oracle - tablespace $5 not found?"
288 exit $STATE_UNKNOWN 288 exit "$STATE_UNKNOWN"
289 fi 289 fi
290 if [ "$ts_pct" -ge ${6} ] ; then 290 if [ "$ts_pct" -ge "${6}" ] ; then
291 echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" 291 echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
292 exit $STATE_CRITICAL 292 exit "$STATE_CRITICAL"
293 fi 293 fi
294 if [ "$ts_pct" -ge ${7} ] ; then 294 if [ "$ts_pct" -ge "${7}" ] ; then
295 echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" 295 echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
296 exit $STATE_WARNING 296 exit "$STATE_WARNING"
297 fi 297 fi
298 echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" 298 echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
299 exit $STATE_OK 299 exit "$STATE_OK"
300 ;; 300 ;;
301*) 301*)
302 print_usage 302 print_usage
303 exit $STATE_UNKNOWN 303 exit "$STATE_UNKNOWN"
304esac 304esac
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh
index f742830..9a6cf5d 100755
--- a/plugins-scripts/check_sensors.sh
+++ b/plugins-scripts/check_sensors.sh
@@ -2,46 +2,46 @@
2 2
3PATH="@TRUSTED_PATH@" 3PATH="@TRUSTED_PATH@"
4export PATH 4export PATH
5PROGNAME=`basename $0` 5PROGNAME=$(basename "$0")
6PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 6PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
7REVISION="@NP_VERSION@" 7REVISION="@NP_VERSION@"
8 8
9. $PROGPATH/utils.sh 9. "$PROGPATH"/utils.sh
10 10
11print_usage() { 11print_usage() {
12 echo "Usage: $PROGNAME" [--ignore-fault] 12 echo "Usage: $PROGNAME" [--ignore-fault]
13} 13}
14 14
15print_help() { 15print_help() {
16 print_revision $PROGNAME $REVISION 16 print_revision "$PROGNAME" "$REVISION"
17 echo "" 17 echo ""
18 print_usage 18 print_usage
19 echo "" 19 echo ""
20 echo "This plugin checks hardware status using the lm_sensors package." 20 echo "This plugin checks hardware status using the lm_sensors package."
21 echo "" 21 echo ""
22 support 22 support
23 exit $STATE_OK 23 exit "$STATE_OK"
24} 24}
25 25
26case "$1" in 26case "$1" in
27 --help) 27 --help)
28 print_help 28 print_help
29 exit $STATE_OK 29 exit "$STATE_OK"
30 ;; 30 ;;
31 -h) 31 -h)
32 print_help 32 print_help
33 exit $STATE_OK 33 exit "$STATE_OK"
34 ;; 34 ;;
35 --version) 35 --version)
36 print_revision $PROGNAME $REVISION 36 print_revision "$PROGNAME" "$REVISION"
37 exit $STATE_OK 37 exit "$STATE_OK"
38 ;; 38 ;;
39 -V) 39 -V)
40 print_revision $PROGNAME $REVISION 40 print_revision "$PROGNAME" "$REVISION"
41 exit $STATE_OK 41 exit "$STATE_OK"
42 ;; 42 ;;
43 *) 43 *)
44 sensordata=`sensors 2>&1` 44 sensordata=$(sensors 2>&1)
45 status=$? 45 status=$?
46 if test ${status} -eq 127; then 46 if test ${status} -eq 127; then
47 text="SENSORS UNKNOWN - command not found (did you install lmsensors?)" 47 text="SENSORS UNKNOWN - command not found (did you install lmsensors?)"
@@ -49,10 +49,10 @@ case "$1" in
49 elif test ${status} -ne 0; then 49 elif test ${status} -ne 0; then
50 text="WARNING - sensors returned state $status" 50 text="WARNING - sensors returned state $status"
51 exit=$STATE_WARNING 51 exit=$STATE_WARNING
52 elif echo ${sensordata} | egrep ALARM > /dev/null; then 52 elif echo "${sensordata}" | egrep ALARM > /dev/null; then
53 text="SENSOR CRITICAL - Sensor alarm detected!" 53 text="SENSOR CRITICAL - Sensor alarm detected!"
54 exit=$STATE_CRITICAL 54 exit=$STATE_CRITICAL
55 elif echo ${sensordata} | egrep FAULT > /dev/null \ 55 elif echo "${sensordata}" | egrep FAULT > /dev/null \
56 && test "$1" != "-i" -a "$1" != "--ignore-fault"; then 56 && test "$1" != "-i" -a "$1" != "--ignore-fault"; then
57 text="SENSOR UNKNOWN - Sensor reported fault" 57 text="SENSOR UNKNOWN - Sensor reported fault"
58 exit=$STATE_UNKNOWN 58 exit=$STATE_UNKNOWN
@@ -63,8 +63,8 @@ case "$1" in
63 63
64 echo "$text" 64 echo "$text"
65 if test "$1" = "-v" -o "$1" = "--verbose"; then 65 if test "$1" = "-v" -o "$1" = "--verbose"; then
66 echo ${sensordata} 66 echo "${sensordata}"
67 fi 67 fi
68 exit $exit 68 exit "$exit"
69 ;; 69 ;;
70esac 70esac
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index c526d05..54befca 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1040,9 +1040,15 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
1040 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);
1041 get_path_stats(p_list, &tmpfsp); 1041 get_path_stats(p_list, &tmpfsp);
1042 if (verbose >= 3) 1042 if (verbose >= 3)
1043 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",
1044 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,
1045 p_list->dtotal_units, mult); 1045 tmpfsp.fsu_blocks,
1046 tmpfsp.fsu_blocksize,
1047 p_list->best_match->me_mountdir,
1048 p_list->dused_units,
1049 p_list->dfree_units,
1050 p_list->dtotal_units,
1051 mult);
1046 1052
1047 /* prevent counting the first FS of a group twice since its parameter_list entry 1053 /* prevent counting the first FS of a group twice since its parameter_list entry
1048 * 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 */
@@ -1063,14 +1069,12 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
1063 first = 0; 1069 first = 0;
1064 } 1070 }
1065 if (verbose >= 3) 1071 if (verbose >= 3)
1066 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",
1067 p->group, 1073 p->group,
1068 tmpfsp.fsu_bavail,
1069 tmpfsp.fsu_blocksize,
1070 p->best_match->me_mountdir,
1071 p->dused_units, 1074 p->dused_units,
1072 p->dfree_units, 1075 p->dfree_units,
1073 p->dtotal_units, 1076 p->dtotal_units,
1077 tmpfsp.fsu_blocksize,
1074 mult); 1078 mult);
1075 } 1079 }
1076 /* modify devname and mountdir for output */ 1080 /* modify devname and mountdir for output */
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_swap.c b/plugins/check_swap.c
index 7f71bf7..7da26cf 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -142,7 +142,7 @@ main (int argc, char **argv)
142 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 142 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
143 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb)); 143 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb));
144 if (verbose) 144 if (verbose)
145 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 145 xasprintf (&status, "%s [%lu (%d%%)]", status, dskfree_mb, 100 - percent);
146 } 146 }
147 } 147 }
148 /* 148 /*
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