Skip to content

Instantly share code, notes, and snippets.

@shyamjos
Created May 11, 2019 13:57
Show Gist options
  • Save shyamjos/1c590deee629cf1be2ea467ba9697c0a to your computer and use it in GitHub Desktop.
Save shyamjos/1c590deee629cf1be2ea467ba9697c0a to your computer and use it in GitHub Desktop.
Icinga2 plugin to check if server rebooted
#!/bin/bash
# shyam jos
# Icinga plugin to check if server was rebooted less than 30 minutes ago
read -d. uptime < /proc/uptime
days=$(( uptime/60/60/24 ))
if (( uptime > 1800 ))
then
echo -n "OK! UP $days days | uptime_days=$days"
exit 0
else
echo "Critical: Reboot Detected! - Server Rebooted Less than 30 minutes ago! | uptime_days=$days"
exit 2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment