Scripts for Nagios
###Find disk Space###
#!/bin/bash
used_space=`df -h / | grep -v Filesystem | awk '{print $5}' | sed 's/%//g'`
case $used_space in
[1-84]*)
echo "OK - $used_space% of disk space used."
exit 0
;;
[85]*)
echo "WARNING - $used_space% of disk space used."
exit 1
;;
[86-100]*)
echo "CRITICAL - $used_space% of disk space used."
exit 2
;;
*)
echo "UNKNOWN - $used_space% of disk space used."
exit 3
;;
esac
# for VM count in KVM
#!/bin/bash
VM_running=`virsh list --all | grep -i running | wc -l`
if [ $VM_running -lt 10 ] ; then
echo "OK - $VM_running are currently in running state."
exit 0
fi
if [[ "VM_running" -gt "10" ]] && [[ "VM_running" -lt "12" ]]; then
echo "WARNING - $VM_running are currently in running state."
exit 1
fi
if [[ "VM_running" -gt "12" ]] && [[ "VM_running" -lt "20" ]]; then
echo "CRITICAL - $VM_running are currently in running state."
exit 2
fi
if [ $VM_running -gt 21 ]
echo "UNKNOWN - $VM_running are out of system"
exit 3
fi
###Find error message in system###
#!/bin/bash
dmesg > dmesg.log
error_log=`egrep -c -i "EXT3-fs|error" dmesg.log`
if [ $error_log -gt 0 ] ; then
echo "CRITICAL - \n We have errors in file system \n `tail -3 dmesg.log`"
exit 2
else
echo "OK - file system is normal"
exit 0
fi
#!/bin/bash
used_space=`df -h / | grep -v Filesystem | awk '{print $5}' | sed 's/%//g'`
case $used_space in
[1-84]*)
echo "OK - $used_space% of disk space used."
exit 0
;;
[85]*)
echo "WARNING - $used_space% of disk space used."
exit 1
;;
[86-100]*)
echo "CRITICAL - $used_space% of disk space used."
exit 2
;;
*)
echo "UNKNOWN - $used_space% of disk space used."
exit 3
;;
esac
# for VM count in KVM
#!/bin/bash
VM_running=`virsh list --all | grep -i running | wc -l`
if [ $VM_running -lt 10 ] ; then
echo "OK - $VM_running are currently in running state."
exit 0
fi
if [[ "VM_running" -gt "10" ]] && [[ "VM_running" -lt "12" ]]; then
echo "WARNING - $VM_running are currently in running state."
exit 1
fi
if [[ "VM_running" -gt "12" ]] && [[ "VM_running" -lt "20" ]]; then
echo "CRITICAL - $VM_running are currently in running state."
exit 2
fi
if [ $VM_running -gt 21 ]
echo "UNKNOWN - $VM_running are out of system"
exit 3
fi
###Find error message in system###
#!/bin/bash
dmesg > dmesg.log
error_log=`egrep -c -i "EXT3-fs|error" dmesg.log`
if [ $error_log -gt 0 ] ; then
echo "CRITICAL - \n We have errors in file system \n `tail -3 dmesg.log`"
exit 2
else
echo "OK - file system is normal"
exit 0
fi
Comments
Post a Comment