File: //usr/lib64/nagios/plugins/vz7_check_a2_template_count.sh
#!/bin/bash
# SYSENG-26861 ensure the correct number of templates. Update this script when adding new templates. unmanaged has 1 less template than managed. If over min, warn/remind to update this script with new values
# Get the current hostname
hostname=$(hostname)
# Skip if its a VZBK server
if [[ $(hostname) =~ -vzbk* ]]; then
exit
fi
# Check if 'vu' is in the hostname after 2nd hyphen for unmanaged
if [[ $hostname =~ -[^-]*-.*vu ]]; then
min=16
else
min=18
fi
count=$(/sbin/vzpkg list -Oc | wc -l)
if [ "$count" -lt "$min" ]; then
echo "vz7-template_count - VZ7 Template count is less than $min!"
exit 2
elif [ "$count" -gt "$min" ]; then
echo "vz7-template_count - VZ7 Template count exceeds $min! Update vz7-template_count.vz7 with new values."
exit 1
else
echo "vz7-template_count - VZ7 Template count is OK!"
exit 0
fi