Make clear that it is a Nagios plugin and cleaner code

This commit is contained in:
Laurent Poujoulat 2020-07-01 14:40:14 +02:00 committed by root
parent 62f23dc0bf
commit f60c0c1dc3
1 changed files with 15 additions and 2 deletions

View File

@ -22,11 +22,22 @@
# This checks for updates of nextcloud components.
# If any update is present, they are listed in human readable form on stdout, and 1 is returned,
# and if everything is OK, tell it on stdout "OK", and returns 0.
#
# This is a Nagios plugin and thus follows its return code standards
# ================================================
# Configuration data
NEXTCLOUD_ROOT="/var/www/valise.chapril.org"
# Constants for return codes
readonly NS_OK=0
readonly NS_WARNING=1
readonly NS_CRITICAL=1
readonly NS_UNKNOWN=1
# Returns script usage
function usage()
{
@ -36,7 +47,7 @@ function usage()
# Main entry point
# By default, we assume to fail
EXIT_RESULT=1
EXIT_RESULT=${NS_UNKNOWN}
# Usage check
if [ "$#" -ne 0 ]
@ -51,6 +62,7 @@ else
if [ $? != 0 ]
then
EXIT_RESULT=${NS_CRITICAL}
echo "Failed to check Nextcloud update"
else
@ -59,9 +71,10 @@ else
if [ $? == 0 ]
then
EXIT_RESULT=${NS_OK}
echo "OK"
EXIT_RESULT=0
else
EXIT_RESULT=${NS_WARNING}
echo ${UPDATE_LIST}
fi