echo "RHEL Service Status - Ad-hoc Commands"
echo "====================================="
echo "🔍 Checking auditd service status..."
ansible all -i inventory.ini -m systemd -a "name=auditd" --become
echo ""
echo "----------------------------------------"
echo "🔍 Checking auditd processes..."
ansible all -i inventory.ini -m shell -a "pgrep -f auditd | wc -l"
echo ""
echo "----------------------------------------"
echo "📍 Checking mlocate updatedb timer..."
ansible all -i inventory.ini -m systemd -a "name=mlocate-updatedb.timer"
echo ""
echo "----------------------------------------"
echo "📚 Checking locate database..."
ansible all -i inventory.ini -m stat -a "path=/var/lib/mlocate/mlocate.db"
echo ""
echo "----------------------------------------"
echo "🔍 Checking multiple critical services..."
ansible all -i inventory.ini -m shell -a "for service in auditd sshd chronyd firewalld; do echo -n \"$service: \"; systemctl is-active $service 2>/dev/null || echo 'not-found'; done"
echo ""
echo "----------------------------------------"
echo "🔍 Searching for audit and locate related services..."
ansible all -i inventory.ini -m shell -a "systemctl list-units --type=service,timer | grep -E '(audit|locate|updatedb)'"
echo ""
echo "✅ Ad-hoc commands completed!"