LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Tool to monitor hosts and services & notify through mail and XMPP? (https://www.linuxquestions.org/questions/linux-software-2/tool-to-monitor-hosts-and-services-and-notify-through-mail-and-xmpp-4175549033/)

Peterken 07-27-2015 04:34 AM

Tool to monitor hosts and services & notify through mail and XMPP?
 
Hi all,

Currently I'm using a windows based program to do this but I wonder if there is something similar for linux and move away from a complete win-based system, just for this.
If possible, doing this on a RPI would be awesome.

What I would like to do is to be able to monitor:
- hosts
- services
and notify by mail or XMPP when going offline or online.

Thanks a lot in advance for your suggestions!
Peter

zhjim 07-27-2015 05:02 AM

There are a bunch of monitoring tools. Most notable is nagios. Though I dig Zabbix. A more complete and easier to setup tool imho.
For only a few machines maybe munin might suite. Also i don't know if it has an alert function. But creates nice graphs and does not need a server on its own but can just run the client.
Nother thing to do if it really is only a few systems use some hand rolled bash script.

Quote:

#!/bin/bash
ping hostname -c 1 -t 5
if [ $? -eq 0 ]; then
echo "System up"
else
echo "system down $hostname" | mail your@address.com
fi

Habitual 07-27-2015 08:22 AM

zabbix supports the jabber protocol.

Peterken 07-28-2015 03:49 AM

Thank you for these suggestions, I will have a look at them.

@zhjim: is it possible with scripting to check if services on remote hosts are running and I guess that notifications through XMPP also might be possible but it will become quite complex for me.
Therefore: if there are tools for this, I will certainly not reinvent the wheel.

Peterken 07-29-2015 03:10 AM

zhjim, can you - or someone else - elaborate a little on sending a mail based on this example?
I would like to use it for a friend to check the availability of his VPN host which runs on a private connection.

What are the minimum requirements to be able to make this work and just send a mail on a system without GUI? I guess:
1) finalizing your example - assume that the $hostname has to be defined
2) SMTP configuration
3) creating a cron job

Since this doesn't work for a service, what would be the way through a script?

TIA!

zhjim 07-30-2015 02:19 AM

Quote:

Originally Posted by Peterken (Post 5397663)
What are the minimum requirements to be able to make this work and just send a mail on a system without GUI? I guess:
1) finalizing your example - assume that the $hostname has to be defined
2) SMTP configuration
3) creating a cron job

hostname needs to be defined and mail needs some more arguments. Namely -s "the subject of the mail". Just run the example and see what mail asks for. Also check the options for ping. -t should be the time out and -c be the count. Just double check. And while your at it use some absolute path to the binaries so you don't run into trouble when using cron.
working smtp configuration check
cronjob check


Quote:

Originally Posted by Peterken (Post 5397663)
Since this doesn't work for a service, what would be the way through a script?

By some degree it can be done. I sometimes use telnet to see if services are alive. If it returns cryptic characters the service is a live. Also with the SSL upcome on most services telnet is lacking. Nother approach would be to use expect and parse the output of telnet.
But for checking on services i would use some of the tools metioned above. Way easier. Though the hand roll approach should be more rewarding.


All times are GMT -5. The time now is 05:09 AM.