whats app plugin for Nagios


If you want to send alerts to your phone on watsapp this is one way . 

apt-get install python python-dateutil python-argparse python-dev python-setuptools



python install setup.py

cd yowsup

./yowsup-cli registration --requestcode sms --phone 91yournumber  --cc 91  --mcc 404 --mnc 20

./yowsup-cli registration --register 671587 --phone 91yournumber --cc 91


cat yowsup-cli.config

cc=91
phone=yournumber
id=yourimeanumber
password=yourpassword


./yowsup-cli demos -c yowsup-cli.config  -s tonumber " saleeeeee"


Nagios Plugin config : 


cat /etc/nagios3/commands.cfg
 
define command{
        command_name    notify-service-by-watsapp
        command_line    /usr/lib/nagios/plugins/whatsapp.sh --numbers $_CONTACTDEVOPSPHONE$  --msg "***** Nagios : $NOTIFICATIONTYPE$ ***** \n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$ "
}


cat  /etc/nagios3/contacts.cfg


define contact{
        contact_name                    admin
        alias                           root
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email,notify-service-by-watsapp
        host_notification_commands      notify-host-by-email
        _devopsphone                    9819031945
        email                           youremailid
        }




cat /usr/lib/nagios/plugins/whatsapp.sh

#!/bin/bash


while [  "$1" != "" ]
do
case "$1" in
--numbers) numbers=$2; shift;;
--msg) msg=$2; shift;;
*) echo "$0: invalid option $1" >&2
echo "Usage: $0   --numbers 9819031911 --msg \" test mgs\"" >&2
exit 1
esac
shift
done


ph_nums=($(echo $numbers | sed 's/,/ /g' ))

prntmsg=$(printf "$msg")


for i in ${ph_nums[@]}
do
sudo /opt/yowsup/yowsup/yowsup-cli demos -c /opt/yowsup/yowsup/yowsup-cli.config  -s 91${i} "$prntmsg"
echo "$i $msg"

done

No comments:

Other Articles

Enter your email address: