Pandora FMS is a monitoring software chosen by several companies all around the world to manage their IT infrastructures. Besides ensuring high performance and maximum flexibility, it has a large amount of features making Pandora FMS one of the most complete solutions in the market.
So we will use this software monitoring for monitoring our server and add feature for alert if anything bad is happen with our server via whatsapp.
We will install Pandora FMS first, in this tutorial we will install on Ubuntu 14.04, but before you must install MySQL first for database.
Before we install Pandora FMS package we need to install MySQL as database we will use for Pandora FMS store the data, its easy, just running this command as root :
$apt-get install mysql-server
Fill in MySQL password for we use later if asked in installation progress.
Install Pandora FMS
First we need add artice repo for install Pandora FMS package, you can edit repo file to add it.
deb http://www.artica.es/debian/squeeze/ in last line, save and update the source.
After update we can install Pandora FMS package.
$apt-get install pandorafms-console pandorafms-server pandorafms-agent-unix
Next step you can edit /etc/apache2/sites-available/000-default.conf and add
Alias /pandora_console /var/www/pandora_console/
Open http://ip/pandora_console/install.php in your broswer.
Do installation progress and fill your database information when asked.
Now you must fill database information what you fill when installation progress in /etc/pandora/pandora_server.conf.
Remove or rename /var/www/pandora_console/install.php and now you can login to http://ip/pandora_console with username is admin and password is pandora.
Pandora FMS can be start,stop and restart via init service.
$/etc/init.d/pandora_server start. Pandora FMS Server 5.1SP2 Build 150223 Copyright (c) 2004-2014 ArticaST This program is OpenSource, licensed under the terms of GPL License version 2. You can download latest versions and documentation at http://www.pandorafms.org [*] Backgrounding Pandora FMS Server process. Pandora Server is now running with PID 13164
Setup Whatsapp Alert In Pandora FMS
Before I already search and found some tutorial also in pandorafms blog it self, but nothing is working, so i use my dirty way to get it work.
First we need clone whatsAPI from github, thanks venomousox for push it to github.
$git clone https://github.com/venomous0x/WhatsAPI
next go to test directory in whatsapi folder, you can see whatsapp.php file there, that what we need later for send alert.
Before that we must register our number to use in whatsapp, you can use yowsup for register, we can clone or download from github.
wget https://github.com/tgalal/yowsup/archive/master.zip $unzip master.zip
#install yowup dependencies
$apt-get install python python-dateutil python-argparse
#go to src folder
#create config from default config
$cp config.example yowsup-cli.config
Fill cc,phone,id and password with yours. cc is your code area , phone is your number phone include your code area, id is your di, and paswword is pass you want set in your whatsapp account.
#give yowsup-cli file permission to execute.
$chmod +x yowsup-cli
#request whatsapp code registration
$./yowsup-cli --request-code sms --config yowsup-cli.config status: sent retry_after: 3605 length: 6 method: sms
#register with registration code
$./yowsup-cli --register <registration-code> --config yowsup-cli.config status: ok kind: free pw: <your password with base64 encode> price: 0,99 price_expiration: 1662803446 currency: USD cost : 0.99 expiration: 1691344106 login: <your phone number> type: new
#Fill yowsup-cli.config with what you get in register output.
$cat yowsup-cli.config cc=<code area> phone=<number phone> id= password=<your password>
Test send message before use whatsapi from venomous0x
$./yowsup-cli --send <destination number phone> "Test" --wati --config yowsu-cli.config Connecting to c.whatsapp.net Authed <your number phone> Sent message Got sent receipt
$./yowsup-cli --listen --autoack --keeplive --config yowsup-cli.config Connecting to c.whatsapp.net Authed <your number phone> email@example.com [05-03-2015 11.48]: I have received test from you
Interactive Mode: Send and Get messages
$./yowsup-cli --interactive 62111222333 --wait --autotack --keepalive --config yowsup-cli.config Connecting to c.whatsapp.net Authed <your number phone> Starting Interactive chat with 62111222333 Enter Message or command: (/available, /lastseen, /unavailable) Hi, whatsapp bro <your number phone> [05-03-2015 11:54: HI, whatsapp bro Enter Message or command: (/available, /lastseen, /unavailable) firstname.lastname@example.org [05-03-2015 11:55]:What are you doing? @s.whatsapp.net [02-02-2013 14:16]:What are you doing? Enter Message or command: (/available, /lastseen, /unavailable) Chat with you <your number phone> [05-03-2015 11:56]: Chat with you Enter Message or command: (/available, /lastseen, /unavailable) /unavailable.
If everything is well done, we continue to next step with WhatsAPI.
Fill in information what we got in yowsup to WhatsAPI.
Edit whatsapp.php file in whatsapi/test/ folder.
Fill $nickname in line 19, change with whatever nick you want to display or you can save number phone and give name in your contact as you alert bot server.
Fill value $sender variable with your phone number bot alert server, fill empty in $imei variable and fill $password variable with base64 password from yowsup, save and test send whatsapp message with it.
$php5 /path/whatsapi/test/whatsapp.php -s <destination number> "test message"
If well done too, so we can go to final step, config in pandora FMS panel.
Login to you Pandora FMS web pannel http://ip/pandora_console/ with default login admin:pandora.
Go to Manage alerts -> Command to create command for alert, click create button in right bottom.
Fill name form with whatever you want to give a name and fill the Command form with the command for sending message to whatsapp number via WhatsAPI like before.
php5 <path>/whatsapp.php -s <destination number> "_field3_"
then click create button. You will see your name command in list alert command, next we create action for alert.
Go to Manage alerts -> Actions, Click again create button on the right bottom, fill Name form with whatever you want, let the Group option still selected to all for let the action is can be use for all server, next choose name you create in the command alert in Command option and if box in Command preview show your command, you have to do it right, click Create button and you are done for creating alert action. You will see your action name in the list of Alert actions, next we create template message for alert.
Go to Manage alerts -> Templates. There are three type of alerts, the firs and the last type is that we will use, click Critical condition -> next to step 2 -> choose the name of action you create before in Default action -> next to last step -> enable for alert recovery and fill the Field 3 with whatever message you want to send to you if something bad happens, do the same instruction in Warning condition too.
Up to here we are done to create alert system integrated to whatsapp.
For test you can just create the agent,then create module and choose default action with action your create before to send alert to whatsapp number your already set.
Happy Monitoring !