Skip to content

Commit d7e2787

Browse files
committed
Merge branch 'feature/nagios-output'
* feature/nagios-output: #3 Wording: db updates -> db migrations #3 Improve short output and performance data
2 parents 2cad86d + eb9ae3c commit d7e2787

File tree

3 files changed

+104
-51
lines changed

3 files changed

+104
-51
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Version 0.3 (unreleased)
22
-----------
33

4+
- [Fea] Added performance data: Sec Updates
5+
- [Fea] Added performance data: Updates
6+
- [Fea] Added performance data: Core errors
7+
- [Fea] Added performance data: Core warnings
8+
- [Fea] Added performance data: DB migrations
9+
- [Fea] Improved short output
10+
411

512
Version 0.2
613
-----------

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# check_drupal
2-
Nagios drupal plugin to monitor the state of a drupal site for security updates, system updates, core errors, core warnings and missing db updates.
2+
Nagios drupal plugin to monitor the state of a drupal site for security updates, system updates, core errors, core warnings and missing database migrations.
33

44
[![Build Status](https://travis-ci.org/cytopia/check_drupal.svg?branch=master)](https://travis-ci.org/cytopia/check_drupal)
55
[![Latest Stable Version](https://poser.pugx.org/cytopia/check_drupal/v/stable)](https://packagist.org/packages/cytopia/check_drupal) [![Total Downloads](https://poser.pugx.org/cytopia/check_drupal/downloads)](https://packagist.org/packages/cytopia/check_drupal) [![Latest Unstable Version](https://poser.pugx.org/cytopia/check_drupal/v/unstable)](https://packagist.org/packages/cytopia/check_drupal) [![License](https://poser.pugx.org/cytopia/check_drupal/license)](http://opensource.org/licenses/MIT)
@@ -32,7 +32,7 @@ I would recommend the second option as you do not check each drupal site every 5
3232
##### Features
3333
* Check for Drupal security updates
3434
* Check for Drupal system updates
35-
* Check for Drupal required database updates
35+
* Check for Drupal required database migrations
3636
* Check for Drupal core errors
3737
* Check for Drupal core warnings
3838
* Every check can specify its own nagios severity (Error or Warning)
@@ -59,7 +59,7 @@ OR check_drupal --version
5959

6060
Nagios plugin that will check drupal sites for errors.
6161
Errors include the following: available security updates,
62-
missed database updates and drupal status errors.
62+
missed database migrations and drupal status errors.
6363
For each check you can specify the nagios severity (error or warning).
6464

6565
-d <drupal root> The full path to the drupal document root (usually
@@ -90,7 +90,7 @@ For each check you can specify the nagios severity (error or warning).
9090
Warning: -w w
9191
Error: -w e
9292

93-
-m <w|e> [optional] Check for drupal missed database updates
93+
-m <w|e> [optional] Check for drupal missed database migrations
9494
and return nagios error or warning. (They can occur
9595
when you update core or modules and forget the db).
9696
Warning: -m w
@@ -135,7 +135,7 @@ Also to note: The first line until the `|` represents the actual nagios output.
135135
**Check for security updates**
136136
```bash
137137
./check_drupal -d /shared/httpd/sites-drupal/COOL-PROJECT/drupal/ -n COOL-PROJECT -s e
138-
[ERROR] COOL-PROJECT has errors: Security update(s) | 'OK'=0;;;0;1 'Errors'=1;1;1;0;1 'Warnings'=0;1;;0;1 'Unknown'=0;;;0;1
138+
[CRITICAL] COOL-PROJECT has errors: 2 Security updates | 'Security Updates'=2;;;; 'Updates'=0;;;; 'Core Errors'=0;;;; 'Core Warnings'=0;;;; 'Database Migrations'=0;;;; 'OK'=0;;;0;1 'Errors'=1;1;1;0;1 'Warnings'=0;1;;0;1 'Unknown'=0;;;0;1
139139
==== SECURITY UPDATES ====
140140
[CRITICAL] drupal 7.40 -> 7.41
141141
[CRITICAL] jquery_update 7.x-2.6 -> 7.x-2.7
@@ -144,27 +144,29 @@ Also to note: The first line until the `|` represents the actual nagios output.
144144
**Check for security and normal updates**
145145
```bash
146146
./check_drupal -d /shared/httpd/sites-drupal/COOL-PROJECT/drupal/ -n COOL-PROJECT -s e -u w
147-
[ERROR] COOL-PROJECT has errors: Security update(s), Update(s) | 'OK'=0;;;0;2 'Errors'=1;1;1;0;2 'Warnings'=1;1;;0;2 'Unknown'=0;;;0;2
147+
[CRITICAL] COOL-PROJECT has errors: 3 Security updates, 3 Updates | 'Security Updates'=3;;;; 'Updates'=3;;;; 'Core Errors'=0;;;; 'Core Warnings'=0;;;; 'Database Migrations'=0;;;; 'OK'=0;;;0;2 'Errors'=1;1;1;0;2 'Warnings'=1;1;;0;2 'Unknown'=0;;;0;2
148148
==== SECURITY UPDATES ====
149149
[CRITICAL] drupal 7.40 -> 7.41
150+
[CRITICAL] block_class 7.x-2.1 -> 7.x-2.3
150151
[CRITICAL] jquery_update 7.x-2.6 -> 7.x-2.7
151152
==== SYSTEM UPDATES ====
152153
[WARNING] field_collection 7.x-1.0-beta9 -> 7.x-1.0-beta10
153154
[WARNING] views 7.x-3.11 -> 7.x-3.13
154-
[WARNING] bootstrap 7.x-3.0 -> 7.x-3.1
155+
[WARNING] bootstrap 7.x-3.0 -> 7.x-3.4
155156
```
156157
157158
**Check for all possible stuff**
158159
```bash
159160
./check_drupal -d /shared/httpd/sites-drupal/COOL-PROJECT/drupal/ -n COOL-PROJECT -s e -u w -e e -w w -m e
160-
[ERROR] COOL-PROJECT has errors: Security update(s), Update(s), Core error(s), Core warning(s) | 'OK'=1;;;0;5 'Errors'=2;1;1;0;5 'Warnings'=2;1;;0;5 'Unknown'=0;;;0;5
161+
[CRITICAL] COOL-PROJECT has errors: 3 Security updates, 3 Updates, 5 Core errors, 1 Core warning | 'Security Updates'=3;;;; 'Updates'=3;;;; 'Core Errors'=5;;;; 'Core Warnings'=1;;;; 'Database Migrations'=0;;;; 'OK'=1;;;0;5 'Errors'=2;1;1;0;5 'Warnings'=2;1;;0;5 'Unknown'=0;;;0;5
161162
==== SECURITY UPDATES ====
162163
[CRITICAL] drupal 7.40 -> 7.41
164+
[CRITICAL] block_class 7.x-2.1 -> 7.x-2.3
163165
[CRITICAL] jquery_update 7.x-2.6 -> 7.x-2.7
164166
==== SYSTEM UPDATES ====
165167
[WARNING] field_collection 7.x-1.0-beta9 -> 7.x-1.0-beta10
166168
[WARNING] views 7.x-3.11 -> 7.x-3.13
167-
[WARNING] bootstrap 7.x-3.0 -> 7.x-3.1
169+
[WARNING] bootstrap 7.x-3.0 -> 7.x-3.4
168170
==== CORE ERRORS ====
169171
[CRITICAL] CKeditor
170172
[CRITICAL] Cron-Wartungsaufgaben
@@ -174,14 +176,14 @@ Also to note: The first line until the `|` represents the actual nagios output.
174176
==== CORE WARNINGS ====
175177
[WARNING] Token
176178
==== DB UPDATES ====
177-
[OK] No database updates required
179+
[OK] No database migrations required
178180
```
179181
**Check for db updates**
180182
```bash
181183
./check_drupal -d /shared/httpd/sites-drupal/COOL-PROJECT/drupal/ -n COOL-PROJECT -m e
182-
[OK] COOL-PROJECT is healthy | 'OK'=1;;;0;1 'Errors'=0;1;1;0;1 'Warnings'=0;1;;0;1 'Unknown'=0;;;0;1
184+
[OK] COOL-PROJECT is healty | 'Security Updates'=0;;;; 'Updates'=0;;;; 'Core Errors'=0;;;; 'Core Warnings'=0;;;; 'Database Migrations'=0;;;; 'OK'=1;;;0;1 'Errors'=0;1;1;0;1 'Warnings'=0;1;;0;1 'Unknown'=0;;;0;1
183185
==== DB UPDATES ====
184-
[OK] No database updates required
186+
[OK] No database migrations required
185187
```
186188
187189
## 3. Nagios Configuration
@@ -202,7 +204,7 @@ $ARG1$: /var/www/cool-drupal-project/drupal/
202204
$ARG2$: Cool Drupal Project
203205
$ARG3$: -s e -u w -e e -w w -m e
204206
```
205-
The above service defintion will check against security updates (with nagios error), against normal updates (with nagios warning), against core errors (with nagios error), against core warnings (with nagios warning) and finally against missed database updates (with nagios error).
207+
The above service defintion will check against security updates (with nagios error), against normal updates (with nagios warning), against core errors (with nagios error), against core warnings (with nagios warning) and finally against missed database migrations (with nagios error).
206208
207209
### 3.2 check_drupal_log
208210

bin/check_drupal

Lines changed: 82 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
INFO_NAME="check_drupal"
1414
INFO_AUTHOR="Patrick Plocke <patrick@plocke.de>"
1515
INFO_GPGKEY="0x28BF179F"
16-
INFO_DATE="2015-12-09"
16+
INFO_DATE="2015-12-19"
1717
INFO_LICENSE="MIT"
18-
INFO_VERSION="0.2"
18+
INFO_VERSION="0.3"
1919

2020
# Get the path
2121
export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
@@ -455,7 +455,7 @@ print_help() {
455455
# Show help and details
456456
printf "Nagios plugin that will check drupal sites for errors.\n"
457457
printf "Errors include the following: available security updates,\n"
458-
printf "missed database updates and drupal status errors.\n"
458+
printf "missed database migrations and drupal status errors.\n"
459459
printf "For each check you can specify the nagios severity (error or warning).\n\n"
460460

461461
printf " -d <drupal root> The full path to the drupal document root (usually\n"
@@ -486,7 +486,7 @@ print_help() {
486486
printf " Warning: -w w\n"
487487
printf " Error: -w e\n\n"
488488

489-
printf " -m <w|e> [optional] Check for drupal missed database updates\n"
489+
printf " -m <w|e> [optional] Check for drupal missed database migrations\n"
490490
printf " and return nagios error or warning. (They can occur\n"
491491
printf " when you update core or modules and forget the db).\n"
492492
printf " Warning: -m w\n"
@@ -559,11 +559,11 @@ MSG_CORE_WARNING=""
559559
MSG_DB_UPDATE=""
560560

561561
# Info for normal Status message if there is an error/warning
562-
HAS_SECURITY_UPDATE_ERROR=""
563-
HAS_SYSTEM_UPDATE_ERROR=""
564-
HAS_CORE_ERR_ERROR=""
565-
HAS_CORE_WARN_ERROR=""
566-
HAS_DB_UPDATE_ERROR=""
562+
CNT_SECURITY_UPDATE_ERROR="0"
563+
CNT_SYSTEM_UPDATE_ERROR="0"
564+
CNT_CORE_ERR_ERROR="0"
565+
CNT_CORE_WARN_ERROR="0"
566+
CNT_DB_UPDATE_ERROR="0"
567567

568568
# Count warnings and errors for performance data
569569
CNT_ALL=0
@@ -706,6 +706,9 @@ if [ -n "$CHECK_S" ]; then
706706

707707
# Merge exit codes
708708
if [ "$TMP_EXIT" != "0" ]; then
709+
# Count lines as number of issues
710+
CNT_SECURITY_UPDATE_ERROR="$(echo "${MSG_SECURITY_UPDATE}" | wc -l | xargs)"
711+
709712
if [ "$SEVERITY" = "$EXIT_ERR" ]; then
710713
CNT_ERROR=$((CNT_ERROR+1))
711714
MSG_SECURITY_UPDATE="$(prepend_line "${MSG_SECURITY_UPDATE}" "[CRITICAL] ")"
@@ -717,7 +720,6 @@ if [ -n "$CHECK_S" ]; then
717720
MSG_SECURITY_UPDATE="==== SECURITY UPDATES ====\n${MSG_SECURITY_UPDATE}"
718721
NAGIOS_EXIT="$(merge_exit_codes "$NAGIOS_EXIT" "1")"
719722
fi
720-
HAS_SECURITY_UPDATE_ERROR="true"
721723
else
722724
CNT_OK=$((CNT_OK+1))
723725
MSG_SECURITY_UPDATE="==== SECURITY UPDATES ====\n[OK] No Security updates required"
@@ -739,6 +741,9 @@ if [ -n "$CHECK_U" ]; then
739741

740742
# Merge exit codes
741743
if [ "$TMP_EXIT" != "0" ]; then
744+
# Count lines as number of issues
745+
CNT_SYSTEM_UPDATE_ERROR="$(echo "${MSG_SYSTEM_UPDATE}" | wc -l | xargs)"
746+
742747
if [ "$SEVERITY" = "$EXIT_ERR" ]; then
743748
CNT_ERROR=$((CNT_ERROR+1))
744749
MSG_SYSTEM_UPDATE="$(prepend_line "${MSG_SYSTEM_UPDATE}" "[CRITICAL] ")"
@@ -750,7 +755,6 @@ if [ -n "$CHECK_U" ]; then
750755
MSG_SYSTEM_UPDATE="==== SYSTEM UPDATES ====\n${MSG_SYSTEM_UPDATE}"
751756
NAGIOS_EXIT="$(merge_exit_codes "$NAGIOS_EXIT" "1")"
752757
fi
753-
HAS_SYSTEM_UPDATE_ERROR="true"
754758
else
755759
CNT_OK=$((CNT_OK+1))
756760
MSG_SYSTEM_UPDATE="==== SYSTEM UPDATES ====\n[OK]\nNo Updates required"
@@ -772,6 +776,9 @@ if [ -n "$CHECK_E" ]; then
772776

773777
# Merge exit codes
774778
if [ "$TMP_EXIT" != "0" ]; then
779+
# Count lines as number of issues
780+
CNT_CORE_ERR_ERROR="$(echo "${MSG_CORE_ERROR}" | wc -l | xargs)"
781+
775782
if [ "$SEVERITY" = "$EXIT_ERR" ]; then
776783
CNT_ERROR=$((CNT_ERROR+1))
777784
MSG_CORE_ERROR="$(prepend_line "${MSG_CORE_ERROR}" "[CRITICAL] ")"
@@ -783,7 +790,6 @@ if [ -n "$CHECK_E" ]; then
783790
MSG_CORE_ERROR="==== CORE ERRORS ====\n${MSG_CORE_ERROR}"
784791
NAGIOS_EXIT="$(merge_exit_codes "$NAGIOS_EXIT" "1")"
785792
fi
786-
HAS_CORE_ERR_ERROR="true"
787793
else
788794
CNT_OK=$((CNT_OK+1))
789795
MSG_CORE_ERROR="==== CORE ERRORS ====\n[OK] No core errors"
@@ -805,6 +811,9 @@ if [ -n "$CHECK_W" ]; then
805811

806812
# Merge exit codes
807813
if [ "$TMP_EXIT" != "0" ]; then
814+
# Count lines as number of issues
815+
CNT_CORE_WARN_ERROR="$(echo "${MSG_CORE_WARNING}" | wc -l | xargs)"
816+
808817
if [ "$SEVERITY" = "$EXIT_ERR" ]; then
809818
CNT_ERROR=$((CNT_ERROR+1))
810819
MSG_CORE_WARNING="$(prepend_line "${MSG_CORE_WARNING}" "[CRITICAL] ")"
@@ -816,7 +825,6 @@ if [ -n "$CHECK_W" ]; then
816825
MSG_CORE_WARNING="==== CORE WARNINGS ====\n${MSG_CORE_WARNING}"
817826
NAGIOS_EXIT="$(merge_exit_codes "$NAGIOS_EXIT" "1")"
818827
fi
819-
HAS_CORE_WARN_ERROR="true"
820828
else
821829
CNT_OK=$((CNT_OK+1))
822830
MSG_CORE_WARNING="==== CORE WARNINGS ====\n[OK] No core warnings"
@@ -838,6 +846,9 @@ if [ -n "$CHECK_M" ]; then
838846

839847
# Merge exit codes
840848
if [ "$TMP_EXIT" != "0" ]; then
849+
# Count lines as number of issues
850+
CNT_DB_UPDATE_ERROR="$(echo "${MSG_DB_UPDATE}" | wc -l | xargs)"
851+
841852
if [ "$SEVERITY" = "$EXIT_ERR" ]; then
842853
CNT_ERROR=$((CNT_ERROR+1))
843854
MSG_DB_UPDATE="$(prepend_line "${MSG_DB_UPDATE}" "[CRITICAL] ")"
@@ -849,10 +860,9 @@ if [ -n "$CHECK_M" ]; then
849860
MSG_DB_UPDATE="==== DB UPDATES ====\n${MSG_DB_UPDATE}"
850861
NAGIOS_EXIT="$(merge_exit_codes "$NAGIOS_EXIT" "1")"
851862
fi
852-
HAS_DB_UPDATE_ERROR="true"
853863
else
854864
CNT_OK=$((CNT_OK+1))
855-
MSG_DB_UPDATE="==== DB UPDATES ====\n[OK] No database updates required"
865+
MSG_DB_UPDATE="==== DB UPDATES ====\n[OK] No database migrations required"
856866
NAGIOS_EXIT="$(merge_exit_codes "$NAGIOS_EXIT" "0")"
857867
fi
858868
CNT_ALL=$((CNT_ALL+1))
@@ -866,53 +876,87 @@ fi
866876

867877
#### Build status text
868878
INFO=""
869-
if [ "$HAS_SECURITY_UPDATE_ERROR" != "" ]; then
870-
INFO="$(merge_text "${INFO}" "Security update(s)" ", ")"
879+
if [ "$CNT_SECURITY_UPDATE_ERROR" != "0" ]; then
880+
if [ "$CNT_SECURITY_UPDATE_ERROR" = "1" ]; then
881+
INFO="$(merge_text "${INFO}" "1 Security update" ", ")"
882+
else
883+
INFO="$(merge_text "${INFO}" "${CNT_SECURITY_UPDATE_ERROR} Security updates" ", ")"
884+
fi
871885
fi
872-
if [ "$HAS_SYSTEM_UPDATE_ERROR" != "" ]; then
873-
INFO="$(merge_text "${INFO}" "Update(s)" ", ")"
886+
if [ "$CNT_SYSTEM_UPDATE_ERROR" != "0" ]; then
887+
if [ "$CNT_SYSTEM_UPDATE_ERROR" = "1" ]; then
888+
INFO="$(merge_text "${INFO}" "1 Update" ", ")"
889+
else
890+
INFO="$(merge_text "${INFO}" "${CNT_SYSTEM_UPDATE_ERROR} Updates" ", ")"
891+
fi
874892
fi
875-
if [ "$HAS_CORE_ERR_ERROR" != "" ]; then
876-
INFO="$(merge_text "${INFO}" "Core error(s)" ", ")"
893+
if [ "$CNT_CORE_ERR_ERROR" != "0" ]; then
894+
if [ "$CNT_CORE_ERR_ERROR" = "1" ]; then
895+
INFO="$(merge_text "${INFO}" "1 Core error" ", ")"
896+
else
897+
INFO="$(merge_text "${INFO}" "${CNT_CORE_ERR_ERROR} Core errors" ", ")"
898+
fi
877899
fi
878-
if [ "$HAS_CORE_WARN_ERROR" != "" ]; then
879-
INFO="$(merge_text "${INFO}" "Core warning(s)" ", ")"
900+
if [ "$CNT_CORE_WARN_ERROR" != "0" ]; then
901+
if [ "$CNT_CORE_WARN_ERROR" = "1" ]; then
902+
INFO="$(merge_text "${INFO}" "1 Core warning" ", ")"
903+
else
904+
INFO="$(merge_text "${INFO}" "${CNT_CORE_WARN_ERROR} Core warnings" ", ")"
905+
fi
880906
fi
881-
if [ "$HAS_DB_UPDATE_ERROR" != "" ]; then
882-
INFO="$(merge_text "${INFO}" "DB update(s)" ", ")"
907+
if [ "$CNT_DB_UPDATE_ERROR" != "0" ]; then
908+
if [ "$CNT_DB_UPDATE_ERROR" = "1" ]; then
909+
INFO="$(merge_text "${INFO}" "1 DB migration" ", ")"
910+
else
911+
INFO="$(merge_text "${INFO}" "${CNT_DB_UPDATE_ERROR} DB migrations" ", ")"
912+
fi
883913
fi
884914

885-
886-
#### Performance Data
887-
# @see http://docs.icinga.org/latest/en/perfdata.html
888-
# 'label'=value[UOM];[warn];[crit];[min];[max]
889-
915+
#### Short output (std status)
890916
OUTPUT=""
891917
if [ "$NAGIOS_EXIT" = "$EXIT_OK" ]; then
892-
OUTPUT="$(printf "%s | %s\n" "[OK] ${DRUPAL_NAME} is healthy" "'OK'=${CNT_OK};;;0;${CNT_ALL} 'Errors'=${CNT_ERROR};1;1;0;${CNT_ALL} 'Warnings'=${CNT_WARNING};1;;0;${CNT_ALL} 'Unknown'=0;;;0;${CNT_ALL}")"
918+
OUTPUT="$(printf "[OK] %s is healty" "${DRUPAL_NAME}")"
893919
elif [ "$NAGIOS_EXIT" = "$EXIT_WARN" ]; then
894-
OUTPUT="$(printf "%s: %s | %s\n" "[WARN] ${DRUPAL_NAME} has warnings" "${INFO}" "'OK'=${CNT_OK};;;0;${CNT_ALL} 'Errors'=${CNT_ERROR};1;1;0;${CNT_ALL} 'Warnings'=${CNT_WARNING};1;;0;${CNT_ALL} 'Unknown'=0;;;0;${CNT_ALL}")"
920+
OUTPUT="$(printf "[WARNING] %s has warnings: %s" "${DRUPAL_NAME}" "${INFO}")"
895921
elif [ "$NAGIOS_EXIT" = "$EXIT_ERR" ]; then
896-
OUTPUT="$(printf "%s: %s | %s\n" "[ERROR] ${DRUPAL_NAME} has errors" "${INFO}" "'OK'=${CNT_OK};;;0;${CNT_ALL} 'Errors'=${CNT_ERROR};1;1;0;${CNT_ALL} 'Warnings'=${CNT_WARNING};1;;0;${CNT_ALL} 'Unknown'=0;;;0;${CNT_ALL}")"
922+
OUTPUT="$(printf "[CRITICAL] %s has errors: %s" "${DRUPAL_NAME}" "${INFO}")"
897923
else
898-
OUTPUT="$(printf "%s: %s | %s\n" "[UNKNOWN] ${DRUPAL_NAME} is at unknown state - check extended info." "${INFO}" "OK'=0;;;0;${CNT_ALL} 'Errors'=${CNT_ERROR};1;1;0;${CNT_ALL} 'Warnings'=${CNT_WARNING};1;;0;${CNT_ALL} 'Unknown'=1;;;0;${CNT_ALL}")"
924+
OUTPUT="$(printf "[UNKNOWN] %s is at unknown state - check extended info" "${DRUPAL_NAME}")"
899925
fi
900926

927+
928+
#### Performance Data
929+
# @see http://docs.icinga.org/latest/en/perfdata.html
930+
# 'label'=value[UOM];[warn];[crit];[min];[max]
931+
PERF=""
932+
PERF="$(printf "%s'Security Updates'=%d;;;; " "${PERF}" "${CNT_SECURITY_UPDATE_ERROR}")"
933+
PERF="$(printf "%s'Updates'=%d;;;; " "${PERF}" "${CNT_SYSTEM_UPDATE_ERROR}")"
934+
PERF="$(printf "%s'Core Errors'=%d;;;; " "${PERF}" "${CNT_CORE_ERR_ERROR}")"
935+
PERF="$(printf "%s'Core Warnings'=%d;;;; " "${PERF}" "${CNT_CORE_WARN_ERROR}")"
936+
PERF="$(printf "%s'Database Migrations'=%d;;;; " "${PERF}" "${CNT_DB_UPDATE_ERROR}")"
937+
938+
PERF="$(printf "%s'OK'=%d;;;0;%d " "${PERF}" "${CNT_OK}" "${CNT_ALL}")"
939+
PERF="$(printf "%s'Errors'=%d;1;1;0;%d " "${PERF}" "${CNT_ERROR}" "${CNT_ALL}")"
940+
PERF="$(printf "%s'Warnings'=%d;1;;0;%d " "${PERF}" "${CNT_WARNING}" "${CNT_ALL}")"
941+
PERF="$(printf "%s'Unknown'=0;;;0;%d " "${PERF}" "${CNT_ALL}")"
942+
943+
901944
#### Extended status data
902945
if [ "$MSG_SECURITY_UPDATE" != "" ]; then E_OUTPUT="$(merge_text "${E_OUTPUT}" "${MSG_SECURITY_UPDATE}" "\n")"; fi
903946
if [ "$MSG_SYSTEM_UPDATE" != "" ]; then E_OUTPUT="$(merge_text "${E_OUTPUT}" "${MSG_SYSTEM_UPDATE}" "\n")"; fi
904947
if [ "$MSG_CORE_ERROR" != "" ]; then E_OUTPUT="$(merge_text "${E_OUTPUT}" "${MSG_CORE_ERROR}" "\n")"; fi
905948
if [ "$MSG_CORE_WARNING" != "" ]; then E_OUTPUT="$(merge_text "${E_OUTPUT}" "${MSG_CORE_WARNING}" "\n")"; fi
906949
if [ "$MSG_DB_UPDATE" != "" ]; then E_OUTPUT="$(merge_text "${E_OUTPUT}" "${MSG_DB_UPDATE}" "\n")"; fi
907950

951+
908952
#### Log to file?
909953
if [ -n "$LOGGING" ]; then
910-
echo "${OUTPUT}" > "$LOGGING"
911-
echo "${E_OUTPUT}" >> "$LOGGING"
912-
echo "${NAGIOS_EXIT}" >> "$LOGGING"
954+
echo "${OUTPUT} | ${PERF}" > "$LOGGING"
955+
echo "${E_OUTPUT}" >> "$LOGGING"
956+
echo "${NAGIOS_EXIT}" >> "$LOGGING"
913957
exit 0
914958
else
915-
echo "${OUTPUT}"
959+
echo "${OUTPUT} | ${PERF}"
916960
echo "${E_OUTPUT}"
917961
exit "$NAGIOS_EXIT"
918962
fi

0 commit comments

Comments
 (0)