add custom problem detector plugin

This commit is contained in:
Andy Xie
2017-11-22 10:14:09 +08:00
parent ffc790976b
commit 10dbfef1a8
31 changed files with 1058 additions and 76 deletions
+32
View File
@@ -0,0 +1,32 @@
{
"plugin": "custom",
"pluginConfig": {
"invoke_interval": "30s",
"timeout": "5s",
"max_output_length": 80,
"concurrency": 3
},
"source": "ntp-custom-plugin-monitor",
"conditions": [
{
"type": "NTPProblem",
"reason": "NTPIsUp",
"message": "ntp service is up"
}
],
"rules": [
{
"type": "temporary",
"reason": "NTPIsDown",
"path": "./config/plugin/check_ntp.sh",
"timeout": "3s"
},
{
"type": "permanent",
"condition": "NTPProblem",
"reason": "NTPIsDown",
"path": "./config/plugin/check_ntp.sh",
"timeout": "3s"
}
]
}
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
# NOTE: THIS NTP SERVICE CHECK SCRIPT ASSUME THAT NTP SERVICE IS RUNNING UNDER SYSTEMD.
# THIS IS JUST AN EXAMPLE. YOU CAN WRITE YOUR OWN NODE PROBLEM PLUGIN ON DEMAND.
OK=0
NONOK=1
UNKNOWN=2
which systemctl >/dev/null
if [ $? -ne 0 ]; then
echo "Systemd is not supported"
exit $UNKNOWN
fi
systemctl status ntp.service | grep 'Active:' | grep -q running
if [ $? -ne 0 ]; then
echo "NTP service is not running"
exit $NONOK
fi
echo "NTP service is running"
exit $OK