Henk Helmantel wrote:
The Nagios plugin script from Ignacio can be downloaded from here. The links in this post are disabled, copy and paste the links to visit the link locations.
For our own organizational needs and due to the fact that I haven't found a way to reliably monitor Diafaan SMS Server status from Nagios, I've spent some hours in the last few days coding a Diafaan SMS Server plugin for the Nagios platform. The first version is ready (download it HERE), programmed in Python for portability and easy maintainability. I think it could be useful for other Diafaan SMS users, so I'm putting it in this support forum post.
It has been tested in the following environments:
• Windows 8.1 Pro (x64) with python 3.6.0
• Windows 8.1 Pro (x64) with python 2.7.13
• CentOS with python 2.6.6
INSTALLATION AND REQUIREMENTS
It makes use of the following:
• Diafaan SMS Server: The Web connector must be installed with the HTTP API enabled (located in the 'HTTP Server' tab). I also recommend enabling the anonymous HTTP API requests for simplicity.
• Nagios Server: Needs to have a Python interpreter version 2.6+ installed (recommended 2.7+ if possible, BUT take into account that Nagios might be using more python plugins so carelessly upgrading the Python version could break them; you can get installers from https://www.python.org).
• Nagios Server Python installation: Must have 'pip' command installed (try to get a list of packages with "pip list", if it works you have pip installed, if it doesn't even work you must download pip from https://bootstrap.pypa.io/get-pip.py and then execute it with 'python get-pip.py' to get pip working).
• Nagios Server Python 2.6 package installation: Must have 'lxml' package installed, you can verify it with 'pip list' from a command prompt. If it's not installed, simply type 'pip install lxml' to get it (you also may use 'pip download lxml' from another Python installation if the server has no internet connection and copy the file afterwards).
• Nagios Server Python 2.7+ installation: Must have 'requests' package installed, you can verify it with 'pip list' from a command prompt. If it's not installed, simply type 'pip install requests' to get it (you also may use 'pip download requests' from another Python installation if the server has no internet connection and copy the file afterwards).
RUNNING THE PLUGIN
Please verify manually the plugin running it manually from a command prompt, simply type 'check_diafaan.py' and see the result, it should be like this:
"UNKNOWN - Wrong number of arguments, need a URL to check"
Then try to put a wrong server URL argument like 'check_diafaan.py http://www.baddomain.org', should get:
"UNKNOWN - Server could not be contacted, maybe down or a typo"
Now try to put a good but invalid URL argument like 'check_diafaan.py http://www.python.org', should get:
"UNKNOWN - Server contacted but status page is not in XML format, maybe a typo"
After that, write down the HTTP API port set for Diafaan SMS Server (located in the 'HTTP Server' tab of the Web Connector) and try this:
'check_diafaan.py http://[yourserver_fqdn]:[port]/http/request-server-status' (if anonymous HTTP API requests are enabled) or
'check_diafaan.py http://[yourserver_fqdn]:[port]/http/request-server-status?username=%5Busername_for_HTTP_access%5D' (if anonymous HTTP API requests are disabled)
For example, in my own environment I can check it with the following command:
If everything is ok, it will return an OK code to Nagios, with the following details:
"OK - Server contacted: All services, gateways and connectors working [Q:0 S:32 R:49 E:0]" (where Q=queued messages, S=sent, R=received, E=errors)
If something is not working as it should, it will return a CRITICAL code to Nagios, with the following message:
"CRITICAL - Server contacted: One or more services, gateways or connectors down"
The code parses the Difaan SMS Server status XML document and checks for the following conditions:
• Server/Statistics/MessagesInSendQueue must be '0'
• For each defined Gateway in GatewayStatusList/Gateway, Active must be '1'
• For each defined Gateway in GatewayStatusList/Gateway, Status must be 'Ready to send and receive messages'
• For each defined Gateway in GatewayStatusList/Gateway, Statistics/NetworkSignalStrength must NOT be 'NoSignal'
• For each defined Connector in ConnectorStatusList/Connector, Active must be '1'
• For each defined Connector in ConnectorStatusList/Connector, Status must be 'Ready to send and receive messages'
• For each Web Connector in ConnectorStatusList/Connector, Statistics/WebserverActive must be '1'
If all of them are met, returns OK, if not returns CRITICAL.
INTEGRATION WITH NAGIOS
When you can run the plugin from the command line and get the desired results, then it's time to add it to Nagios. Please check the Nagios manual to do it (simply stated: first you must add the plugin, then create a new command that runs the plugin, a service based on that command and finally add the newly created service to your Diafaan SMS Server host).
I hope it can be useful for other users of the product. Please feel free to comment, ask for questions, or extend the plugin functionality (for my needs it's currently enough), but PLEASE post it here so anybody can benefit from it.
Kind regards from Spain,
Most Users Ever Online: 494
Currently Browsing this Page:
Guest Posters: 439
Newest Members:, Henk Helmantel
Administrators: Henk Helmantel: 740