Skip to content

Instantly share code, notes, and snippets.

@kaellego
Last active January 2, 2024 18:02
Show Gist options
  • Save kaellego/64db06659a364f2ec75c9b2a34a71523 to your computer and use it in GitHub Desktop.
Save kaellego/64db06659a364f2ec75c9b2a34a71523 to your computer and use it in GitHub Desktop.
monitoring alexanderzobnin zabbix app memory consume */5 * * * * root /root/monitoring.sh > /dev/null 2>/dev/null
#!/bin/bash
#service monitoring
# Verifica o serviço HTTPs
/bin/netstat -tulpn | awk '{print $4}' | awk -F: '{print $2}' | grep ^443$ > /dev/null 2>/dev/null
a=$(echo $?)
if test $a -ne 0
then
echo "http service down" | mail -s "HTTP Service DOWN and restarted now" root@localhost
/etc/init.d/grafana-server start > /dev/null 2>/dev/null
else
sleep 0
fi
# Verifica o uso de memória do plugin do Zabbix
PLUGIN_PATH="/var/lib/grafana/plugins/alexanderzobnin-zabbix-app/gpx_zabbix-plugin_linux_amd64"
PID=$(pidof -x $PLUGIN_PATH)
if [ ! -z "$PID" ]; then
MEM_USAGE=$(pmap $PID | tail -n 1 | awk '/[0-9]K/{print $2}')
MEM_USAGE=${MEM_USAGE%%K}
MEM_USAGE_MB=$((MEM_USAGE / 1024))
if [ $MEM_USAGE_MB -gt 3500 ]; then
echo "gpx_zabbix-plugin consume over 3.5G" | mail -s "gpx_zabbix-plugin consume over 3.5G and kill pid" root@localhost
kill $PID
else
sleep 0
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment