Added monitoring script(#3882).
This commit is contained in:
parent
67c8d8a3ea
commit
f34781ca18
39
monitoring/check_statuschaprilorg_update
Executable file
39
monitoring/check_statuschaprilorg_update
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
json=$(curl -s https://status.chapril.org/api/v1/version)
|
||||
|
||||
#
|
||||
regexp='.*"data":\s*"([^"]+)".*'
|
||||
if [[ $json =~ $regexp ]]; then
|
||||
currentVersion=${BASH_REMATCH[1]}
|
||||
else
|
||||
currentVersion=
|
||||
fi
|
||||
|
||||
#
|
||||
regexp='.*"tag_name":\s*"v([^"]+)".*'
|
||||
if [[ $json =~ $regexp ]]; then
|
||||
lastVersion=${BASH_REMATCH[1]}
|
||||
else
|
||||
lastVersion=
|
||||
fi
|
||||
|
||||
#echo "$currentVersion"
|
||||
#echo "$lastVersion"
|
||||
|
||||
if [ -z "$currentVersion" ]; then
|
||||
echo "WARNING : current version not found."
|
||||
result=1
|
||||
elif [ -z "$lastVersion" ]; then
|
||||
echo "WARNING : last version not found."
|
||||
result=1
|
||||
elif [ $currentVersion = $lastVersion ]; then
|
||||
echo "OK"
|
||||
result=0
|
||||
else
|
||||
echo "WARNING : new version available, current is $currentVersion, last is $lastVersion."
|
||||
result=1
|
||||
fi
|
||||
|
||||
exit $result
|
Loading…
Reference in New Issue
Block a user