How can i do this?

Please note that a similar post was also sent on mailing list, this is almost the same post as previous one, though differs a little, plus i am posting again hoping that this time i could get some real reference rather than google or reading 500 pages of documentation. Thanks…

I have a project developed using Java, in which a Servlet lists the all possible daemons/service of a system to which user is connected, the remote user selects the services he wants to monitor on that system, inputs his cell number and clicks save. This information (cell #, ip, and daemon monitor list) is stored in a file called .alerts of the following format:
number:ip:daemon1,daemon2,dameon3,daemon3
like:
1234567890:172.30.10.10:httpd,dhcpd,sshd,klogd

and the file contains a list of such entries, say 100 users has their entries in this file., What i want to do it to use nagios to check the status of the daemons/services mentioned in the file, and if any of these services changes status, goes down, etc, an sms should be sent to the number provided with the details of which daemon changes status on which server (ip) and etc…

Example:
//.alerts
1234567890:172.30.10.10:httpd,sshd,dhcpd
0987654321:172.30.10.10:klogd,sshd,mysqld
0987654321:172.30.10.11:mysqld

Case 1:
httpd changes status on 172.30.10.10:
SMS should be sent to 1234567890
SMS body:
httpd just changed its status to /down on the server at .

Case 2:
sshd changes status on 172.30.10.10
SMS should be sent to 1234567890 and 0987654321
SMS body:
sshd just changed its status to on the server at .

please note that entries in .alerts file can be modified, its possible that later using the web application 0987654321 subscribes for httpd on 172.30.10.10 as well, or 1234567890 unsubscribes for httpd on 172.30.10.10, so we will have to check that file at regular intervals. One more thing, remote host could be a windows based or nix based system (just if that matters, though in my opinion doesnt matter anymore as nagios achieved this long ago as per nagios documentation and the wikipedia page of nagios).

What i wanna know is can nagios do it? if yes? how? please post some short and useful manuals or links, i already know about notify_sms plugin and sms gateways (infact i have almost bought one from clickatell.com), my problem includes that how can i tell nagios to take that file as input on regular intervals say 10-15 minutes, parse it correctly, and do the desired things.

Thank you so much for reading the post, and willing to help me…

Hi!

sorry to disappoint you, but I’ve never seen anything like this in nagios (which doesn’t mean that it doesn’t exist, but almost :)).

That’s why I suggest you’d write your own script that would be called upon a service change. From the name of the service, you’d just have to extract the list of phone numbers you need and send it via a SMS gateway.
This way should be pretty easy to implement (it could be done in 30-40 lines of perl script, for example).

Good luck with this project :slight_smile:

i dont know perl :frowning:
i have found some extensions, but they are only for local and nix systems, not for remote or windows systems,

Hi,
Active Perl is a Windows port of Perl, and it works very well.

You can do anything in perl, locally or remotely, it just needs some programming/scripting.

Anyway this script could be run on the server running nagios (fetching the data file as first thing), or on the one holding the data file (putting the new config files on the nagios server and restarting nagios remotely).

You choose :frowning:
It’s a bit of work though.

Bye
Ivan