File: //usr/lib64/nagios/plugins/check_a2_imunify_service
#!/bin/bash
# A2hosting Inc.
MWP=$(echo "$HOSTNAME" | grep -E 'mw[0-9]')
if [[ -n "$MWP" ]]; then
echo "check_imunify360 - Managed Wordpress servers do not use Imunify360."
exit 0
fi
imunify360_webshield_active=$(service imunify360-webshield status 2>/dev/null| awk '/Active: active \(running\)/ {print $2,$3}')
imunify360_active=$(service imunify360 status 2>/dev/null| awk '/Active: active \(running\)/ {print $2,$3}')
imunify360_licensed=$(imunify360-agent rstatus 2>/dev/null)
if [[ "$imunify360_licensed" == "OK" ]] && [[ "$imunify360_active" == "active (running)" ]] && [[ "$imunify360_webshield_active" == "active (running)" ]]; then
echo "check_imunify360 - Imunify360 and Imunify360-webshield are running and the license is valid."
exit 0
else
echo "check_imunify360 - Imunify360 or Imunify360-webshield are either not running, or Imunify360 is not licensed on this server."
exit 2
fi