Skip to content

Shellscript - Nagios Plugins - UCARP



 
UCARP-Master
 
#!/bin/sh

virtuelle_ip=192.168.0.1
interface=eth1:1

/sbin/ifconfig $interface | grep $virtuelle_ip &> /dev/null

        if [ $? = 1 ]; then
                echo "CRITICAL – Virtual IP $ip on master"
                exit 1
        else
                /sbin/ifconfig $interface | grep $virtuelle_ip | cut -f 2 -d ":" | while read output;
        do
                ip=$(echo $output | awk ‘{print $1}’ )
                echo "OK – Virtual IP on master"
                exit 0
        done
fi
 
UCARP-Slave
 
#!/bin/sh

virtuelle_ip=192.168.0.1
interface=eth1:1

/sbin/ifconfig $interface | grep $virtuelle_ip &> /dev/null

        if [ $? = 1 ]; then
                echo "OK – No Virtual IP on slave"
                exit 0
        else
                /sbin/ifconfig $interface | grep $virtuelle_ip | cut -f 2 -d ":" | while read output;
        do
                ip=$(echo $output | awk ‘{print $1}’ )
                echo "CRITICAL – Virtual IP $ip on slave"
                exit 1
        done
fi


Shellscript - Nagios Plugins - Swap & Memory


 
Plugin zum Überwachen des Arbeitsspeichers
 
#!/bin/sh

free -m | grep Mem | while read output;
do
  mem=$(echo $output | awk ‘{print $2}’ )
  used=$(echo $output | awk ‘{ print $3 }’ )
  free=$(echo $output | awk ‘{ print $4 }’ )
  use=`expr $used \* 100 / $mem`

  if [ $use -ge 90 ]; then
    echo "CRITICAL Total Mem: \"$mem\" Used: \"$used ($use%)\" Free: \"$free\" "
    exit 2
  elif [ $usep -ge 50 ]; then
    echo "WARNING Total Mem: \"$mem\" Used: \"$used ($use%)\" Free: \"$free\" "
    exit 1
  else
    echo "OK Mem: $mem" "Used: $used" "Free: $free"
    exit 0
  fi

done
 
Plugin zum Überwachen des Swap
 
#!/bin/sh
free -m | grep Swap | while read output;
do
  swap=$(echo $output | awk ‘{print $2}’ )
  used=$(echo $output | awk ‘{ print $3 }’ )
  free=$(echo $output | awk ‘{ print $4 }’ )
  use=`expr $used \* 100 / $swap`

  if [ $use -ge 90 ]; then
    echo "CRITICAL Swap: \"$swap\" Used: \"$used ($use%)\" Free: \"$free\" "
    exit 2
  elif [ $use -ge 50 ]; then
    echo "WARNING Swap: \"$swap\" Used: \"$used ($use%)\" Free: \"$free\" "
    exit 1
  else
    echo "OK Swap: $swap" "Used: $used" "Free: $free"
    exit 0
  fi

done
 

Download: memory.sh swap.sh
Imprint | Contact | Privacy Statement