#!/bin/bash localnodeip=`ifconfig M2 |grep "inet "|sed -re 's/inet ([1].*) netmask.*/\1/g'` hainfo=`psql -d sbcedb -c "SELECT status FROM ha_info WHERE ha_ip = '$(echo $localnodeip)';"|sed -re '3! d'|sed 's/^.//'` if [ $1 = "sipstatus" ]; then if [[ $hainfo == "Primary" || -z $localnodeip ]]; then #echo "Is Primary" sipstatus=`psql -d sbcedb -c "select * from sip_server_status_info WHERE NOT hb_status = 'UP';"|tail -n +3|head -n -2` #echo $sipstatus if [[ -z "$sipstatus" ]]; then echo -e "\n" echo "SIP Endpoint Status" echo "UP" echo -e "\n" else echo -e "" echo "2" echo "`psql -d sbcedb -c "select ip_address,transport_type, port,hb_status from sip_server_status_info WHERE NOT hb_status = 'UP';"|tail -n +3|head -n -2`" echo -e "" fi else echo -e "\n" echo "Is not Primary SBC" echo "UP" echo -e "\n" fi elif [ $1 = "alarmstatus" ]; then alarms=`psql -d sbcedb -c "select * from alarms;"|tail -n +3|head -n -2` if [[ -z "$alarms" ]]; then echo -e "\n" echo "SBC Alarms" echo "OK" echo -e "\n" else echo -e "" echo "2" echo -e "\n" psql -d sbcedb -c "select trap_severity_level,alarm_notes,alarm_timestampsecs from alarms;"|tail -n +3|head -n -2|sed -re 's/.(.*).*\|.(.*).\|.*([0-9]{10}).*/echo "Serverity: \1 Alarmtext: \2 Date: `date -d @\3`"/e' echo -e "\n" fi elif [ $1 = "hastatus" ]; then if [[ $hainfo == "Primary" || $hainfo == "Secondary" ]]; then echo -e "\n" echo "HA Status" echo "$hainfo" echo "$hainfo" echo -e "\n" elif [ -z "$nodeip" ]; then echo -e "\n" echo "HA Status" echo "NO HA" echo -e "\n" else exit 0 fi else echo "No or wrong command suffix used. Possible options: sipstatus, alarmstatus, hastatus" fi