ROOTPLOIT
Server: Apache
System: Linux node6122.myfcloud.com 6.14.3-x86_64-linode168 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 19:47:55 EDT 2025 x86_64
User: bashacomputer (1004)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
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