Advertisement
penzoiders

Check_MK Pi-Hole monitoring plugin

Dec 16th, 2019
1,340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.84 KB | None | 0 0
  1. #!/bin/sh
  2. pihole_status="$(/usr/local/bin/pihole status)"
  3. pihole_error="$(echo "$pihole_status" | grep 'DNS service is NOT running')"
  4. pihole_ok="$(echo "$pihole_status" | xargs | grep -E 'DNS service is running.*Pi-hole blocking is Enabled')"
  5.  
  6. pihole_version="$(/usr/local/bin/pihole -v)"
  7. pihole_installed_version="$(echo "$pihole_version" | awk {'print $4'})"
  8. pihole_last_version="$(echo "$pihole_version" | awk {'print $6'} | sed 's/)//')"
  9.  
  10.  
  11. if [ ! -z "$pihole_error" ]; then
  12.     echo "2 Pi-Hole - CRIT: Pi-Hole service is NOT running"
  13. elif [ ! -z "$pihole_ok" ]; then
  14.     if [ "$pihole_installed_version" != "$pihole_last_version" ]; then
  15.         echo "1 Pi-Hole - WARN: Pi-Hole updates are available"
  16.     else
  17.         echo "0 Pi-Hole - OK: Pi-Hole service is running"
  18.     fi
  19. else
  20.     echo "1 Pi-Hole - WARN: Pi-Hole is partially working, probably not blocking Ads"
  21. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement