diff options
Diffstat (limited to 'plugins-scripts/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh index 4330235..8a79704 100755 --- a/plugins-scripts/check_log.sh +++ b/plugins-scripts/check_log.sh | |||
@@ -59,11 +59,11 @@ | |||
59 | 59 | ||
60 | PATH="@TRUSTED_PATH@" | 60 | PATH="@TRUSTED_PATH@" |
61 | export PATH | 61 | export PATH |
62 | PROGNAME=`basename $0` | 62 | PROGNAME=$(basename "$0") |
63 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 63 | PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,') |
64 | REVISION="@NP_VERSION@" | 64 | REVISION="@NP_VERSION@" |
65 | 65 | ||
66 | . $PROGPATH/utils.sh | 66 | . "$PROGPATH"/utils.sh |
67 | 67 | ||
68 | print_usage() { | 68 | print_usage() { |
69 | echo "Usage: $PROGNAME -F logfile -O oldlog -q query" | 69 | echo "Usage: $PROGNAME -F logfile -O oldlog -q query" |
@@ -72,7 +72,7 @@ print_usage() { | |||
72 | } | 72 | } |
73 | 73 | ||
74 | print_help() { | 74 | print_help() { |
75 | print_revision $PROGNAME $REVISION | 75 | print_revision "$PROGNAME" $REVISION |
76 | echo "" | 76 | echo "" |
77 | print_usage | 77 | print_usage |
78 | echo "" | 78 | echo "" |
@@ -86,7 +86,7 @@ print_help() { | |||
86 | 86 | ||
87 | if [ $# -lt 1 ]; then | 87 | if [ $# -lt 1 ]; then |
88 | print_usage | 88 | print_usage |
89 | exit $STATE_UNKNOWN | 89 | exit "$STATE_UNKNOWN" |
90 | fi | 90 | fi |
91 | 91 | ||
92 | # Grab the command line arguments | 92 | # Grab the command line arguments |
@@ -99,19 +99,19 @@ while test -n "$1"; do | |||
99 | case "$1" in | 99 | case "$1" in |
100 | --help) | 100 | --help) |
101 | print_help | 101 | print_help |
102 | exit $STATE_OK | 102 | exit "$STATE_OK" |
103 | ;; | 103 | ;; |
104 | -h) | 104 | -h) |
105 | print_help | 105 | print_help |
106 | exit $STATE_OK | 106 | exit "$STATE_OK" |
107 | ;; | 107 | ;; |
108 | --version) | 108 | --version) |
109 | print_revision $PROGNAME $REVISION | 109 | print_revision "$PROGNAME" $REVISION |
110 | exit $STATE_OK | 110 | exit "$STATE_OK" |
111 | ;; | 111 | ;; |
112 | -V) | 112 | -V) |
113 | print_revision $PROGNAME $REVISION | 113 | print_revision "$PROGNAME" $REVISION |
114 | exit $STATE_OK | 114 | exit "$STATE_OK" |
115 | ;; | 115 | ;; |
116 | --filename) | 116 | --filename) |
117 | logfile=$2 | 117 | logfile=$2 |
@@ -148,7 +148,7 @@ while test -n "$1"; do | |||
148 | *) | 148 | *) |
149 | echo "Unknown argument: $1" | 149 | echo "Unknown argument: $1" |
150 | print_usage | 150 | print_usage |
151 | exit $STATE_UNKNOWN | 151 | exit "$STATE_UNKNOWN" |
152 | ;; | 152 | ;; |
153 | esac | 153 | esac |
154 | shift | 154 | shift |
@@ -156,22 +156,22 @@ done | |||
156 | 156 | ||
157 | # If the source log file doesn't exist, exit | 157 | # If the source log file doesn't exist, exit |
158 | 158 | ||
159 | if [ ! -e $logfile ]; then | 159 | if [ ! -e "$logfile" ]; then |
160 | echo "Log check error: Log file $logfile does not exist!" | 160 | echo "Log check error: Log file $logfile does not exist!" |
161 | exit $STATE_UNKNOWN | 161 | exit "$STATE_UNKNOWN" |
162 | elif [ ! -r $logfile ] ; then | 162 | elif [ ! -r "$logfile" ] ; then |
163 | echo "Log check error: Log file $logfile is not readable!" | 163 | echo "Log check error: Log file $logfile is not readable!" |
164 | exit $STATE_UNKNOWN | 164 | exit "$STATE_UNKNOWN" |
165 | fi | 165 | fi |
166 | 166 | ||
167 | # If the old log file doesn't exist, this must be the first time | 167 | # If the old log file doesn't exist, this must be the first time |
168 | # we're running this test, so copy the original log file over to | 168 | # we're running this test, so copy the original log file over to |
169 | # the old diff file and exit | 169 | # the old diff file and exit |
170 | 170 | ||
171 | if [ ! -e $oldlog ]; then | 171 | if [ ! -e "$oldlog" ]; then |
172 | cat $logfile > $oldlog | 172 | cat "$logfile" > "$oldlog" |
173 | echo "Log check data initialized..." | 173 | echo "Log check data initialized..." |
174 | exit $STATE_OK | 174 | exit "$STATE_OK" |
175 | fi | 175 | fi |
176 | 176 | ||
177 | # The old log file exists, so compare it to the original log now | 177 | # The old log file exists, so compare it to the original log now |
@@ -179,24 +179,24 @@ fi | |||
179 | # The temporary file that the script should use while | 179 | # The temporary file that the script should use while |
180 | # processing the log file. | 180 | # processing the log file. |
181 | if [ -x /bin/mktemp ]; then | 181 | if [ -x /bin/mktemp ]; then |
182 | tempdiff=`/bin/mktemp /tmp/check_log.XXXXXXXXXX` | 182 | tempdiff=$(/bin/mktemp /tmp/check_log.XXXXXXXXXX) |
183 | else | 183 | else |
184 | tempdiff=`/bin/date '+%H%M%S'` | 184 | tempdiff=$(/bin/date '+%H%M%S') |
185 | tempdiff="/tmp/check_log.${tempdiff}" | 185 | tempdiff="/tmp/check_log.${tempdiff}" |
186 | touch $tempdiff | 186 | touch "$tempdiff" |
187 | chmod 600 $tempdiff | 187 | chmod 600 "$tempdiff" |
188 | fi | 188 | fi |
189 | 189 | ||
190 | diff $logfile $oldlog | grep -v "^>" > $tempdiff | 190 | diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff" |
191 | 191 | ||
192 | # Count the number of matching log entries we have | 192 | # Count the number of matching log entries we have |
193 | count=`grep -c "$query" $tempdiff` | 193 | count=$(grep -c "$query" "$tempdiff") |
194 | 194 | ||
195 | # Get the last matching entry in the diff file | 195 | # Get the last matching entry in the diff file |
196 | lastentry=`grep "$query" $tempdiff | tail -1` | 196 | lastentry=$(grep "$query" "$tempdiff" | tail -1) |
197 | 197 | ||
198 | rm -f $tempdiff | 198 | rm -f "$tempdiff" |
199 | cat $logfile > $oldlog | 199 | cat "$logfile" > "$oldlog" |
200 | 200 | ||
201 | if [ "$count" = "0" ]; then # no matches, exit with no error | 201 | if [ "$count" = "0" ]; then # no matches, exit with no error |
202 | echo "Log check ok - 0 pattern matches found" | 202 | echo "Log check ok - 0 pattern matches found" |
@@ -206,4 +206,4 @@ else # Print total matche count and the last entry we found | |||
206 | exitstatus=$STATE_CRITICAL | 206 | exitstatus=$STATE_CRITICAL |
207 | fi | 207 | fi |
208 | 208 | ||
209 | exit $exitstatus | 209 | exit "$exitstatus" |