I have a PC on my network that I want to monitor with a simple periodic ping from a Raspberry Pi. I'm totally new to the RPi and Linux and this seemingly simple project is turning into a massive headache. However, I've made massive progress in installing Nagios PI on the RPi and configuring it to monitor my PC with a periodic ping via NConf. So within the Nagios GUI I can see when my PC is up and down (this took 2 days to get this far). I also setup e-mail on the RPi using sSMTP and I can send e-mails from the command line (this took another long day).

So all I now need to do is get Nagios/NConf to send me an e-mail when it sees my PC is down. Unfortunately, this is where my luck or talent (or both!) have run out. Can anyone help point me in the right direction to get these e-mail notifications working within Nagios/NConf please?

Any ideas greatly appreciated!

Cheers Simon

  • 1
    If not for a learning experience, monitoring a PC with Nagios seems like using a cannon to kill a flea. – Rui F Ribeiro Jan 30 '18 at 19:08
  • sure it starts out with "just one e-mail" but then 10,000 emails later nagios is all like why don't you talk to me any more? – thrig Jan 30 '18 at 19:14
  • Oh dear, I had no idea. What would you recommend to run on the RPi that will notify me once when my PC is down then>? – AnimalHungry Jan 30 '18 at 19:26

Nagios uses contact definitions that must be linked to the host or other such monitoring bit. The contact could be placed in in contacts.cfg or some other configuration file, depending on how you want to manage things:

define contact {
    contact_name foobar
    alias admin of something
    email fixmeyouremailhere@example.net
    host_notification_commands notify-host-by-email
    host_notification_options d,u,r
    host_notification_period 24x7
    service_notification_commands notify-service-by-email
    service_notification_options w,u,c,r
    service_notification_period 24x7

And then in your host definition reference the contact:

define host {
    host_name ...
    contacts foobar

And then restart nagios, fix any errors, etc.

| improve this answer | |
  • Thanks! I have contacts_nagio2.cfg in the etc/nagio3/conf.d directory which now looks like this: define contact { contact_name root alias Root email simon@mydomain.com host_notification_commands notify-host-by-email host_notification_options d,r host_notification_period 24x7 service_notification_commands notify-service-by-email service_notification_options w,u,c,r service_notification_period 24x7 } – AnimalHungry Jan 30 '18 at 23:00
  • I didn’t include the “u” option in host_notification_options as I only want to know when the PC goes down, and not when it’s back online. I don’t know whether I need to change the contact_name and alias so I left it as default. Then I don’t have a file called hosts, but I have one called localhost_nagios2.cfg. But in there I only have three “define service” sections. Which file is the host definition in? Thanks again! Simon – AnimalHungry Jan 30 '18 at 23:00
  • Nagios probably includes any *.cfg file in the /etc/nagio3/conf.d directory automatically, so you likely should create a new hosts.cfg in that directory to hold your host definitions. – thrig Jan 30 '18 at 23:13
  • Thanks again. I tried that and it still doesn't work. I'm afraid I've spent four days trying to get this to work and I've now run out of time I can spend on it right now. Thanks for trying! – AnimalHungry Jan 31 '18 at 2:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.