Page 1 of 1

Printer contacts now working

Posted: Thu Jul 23, 2015 5:24 am
by nathanplatt
Hi Everyone,

I'm trying to setup different contacts so that a printer contacts its owner rather than IT when Ink is needed to be replaced. I've created the contact and set the contact on the device but IT still gets contacted. Any ideas?

Code: Select all

define contact{
        contact_name                    itsupport
        alias                           IT Support
        service_notification_period     workhours
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           [email protected]
        }

define contact{
        contact_name                    marketing
        alias                           Marketing Department
        service_notification_period     workhours
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           [email protected]
        }

define contact{
        contact_name                    software
        alias                           Software Department
        service_notification_period     workhours
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           [email protected]
        }

define contact{
        contact_name                    nathan
        alias                           Nathan Test Group
        service_notification_period     workhours
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           [email protected]
        }

Code: Select all

define host{
        use             generic-printer                 ; Inherit default values from a template
        host_name       Marketing                       ; The name we're giving to this printer
        alias           Marketing                       ; A longer name associated with the printer
        address         192.168.1.23                    ; IP address of the printer
        hostgroups      network-printers                ; Host groups this printer is associated with
        parents         Printers
        contacts        marketing
        }

define host{
        use             generic-printer                 ; Inherit default values from a template
        host_name       Marketing Plotter               ; The name we're giving to this printer
        alias           Marketing Plotter               ; A longer name associated with the printer
        address         192.168.1.132                   ; IP address of the printer
        hostgroups      network-printers                ; Host groups this printer is associated with
        parents         Printers
        contacts        marketing
        }


Re: Printer contacts now working

Posted: Thu Jul 23, 2015 9:26 am
by lmiltchev
Have you restarted nagios after making the changes? Can you show us the actual email notification and the "generic-printer" template?

Re: Printer contacts now working

Posted: Thu Jul 23, 2015 9:50 am
by nathanplatt
This is the email we get in IT

Code: Select all

-----Original Message-----
From: Nagios VM [mailto:nagios@nagios] 
Sent: 23 July 2015 15:28
To: [email protected]
Subject: ** PROBLEM Service Alert: Marketing Plotter/Toner Supply is CRITICAL **

***** Nagios *****

Notification Type: PROBLEM

Service: Toner Supply
Host: Marketing Plotter
Address: 192.168.1.132
State: CRITICAL

Date/Time: Thu Jul 23 15:28:26 BST 2015

Additional Info:

HP 72 ( C9374A ) is at 35% - OK! HP 72 ( C9370A ) is at 50% - OK! HP 72 ( C9402A ) is at 50% - OK! HP 72 ( C9373A ) is at 0% - CRITICAL! HP 72 ( C9372A ) is at 28% - OK! HP 72 ( C9371A ) is at 31% - OK!

Code: Select all

define host{
        name                    generic-printer ; The name of this host template
        use                     generic-host    ; Inherit default values from the generic-host template
        check_period            24x7            ; By default, printers are monitored round the clock
        check_interval          5               ; Actively check the printer every 5 minutes
        retry_interval          1               ; Schedule host check retries at 1 minute intervals
        max_check_attempts      10              ; Check each printer 10 times (max)
        check_command           check-host-alive        ; Default command to check if printers are "alive"
        notification_period     workhours               ; Printers are only used during the workday
        notification_interval   30              ; Resend notifications every 30 minutes
        notification_options    d,r             ; Only send notifications for specific host states
        contact_groups          admins          ; Notifications get sent to the admins by default
        register                0               ; DONT REGISTER THIS - ITS JUST A TEMPLATE
        }
Just looking here, if I remove contact_groups will it take the contact from the printer.cfg file?

Re: Printer contacts now working

Posted: Thu Jul 23, 2015 10:06 am
by tgriep
Your host configuration looks good but I think you need to edit the service check's contacts to marketing and then they will get notified of the supplies.

Re: Printer contacts now working

Posted: Thu Jul 23, 2015 10:09 am
by nathanplatt
The problem is i want to send different notifications to different departments, would i need to edit the generic template for each printer, or can i specify it at the printer level?

Re: Printer contacts now working

Posted: Thu Jul 23, 2015 10:18 am
by tgriep
Could you describe what type of notifications you want sent to what contacts?
If you want the host down to be sent to IT, change the host check contact to the IT department and if the supplies are out to the marketing group, you would add them to the service check.
Is that what you are looking for?

Re: Printer contacts now working

Posted: Thu Jul 23, 2015 10:38 am
by nathanplatt
yes that's about right, so in my printer.cfg file it should read;

Code: Select all

define service{
        use                     generic-service
        host_name               IT,Software,Marketing,Marketing Plotter
        service_description     PING
        check_command           check_ping!3000.0,80%!5000.0,100%
        normal_check_interval   10
        retry_check_interval    1
        }

add a line;

contacts marketing

Would that be right?

Re: Printer contacts now working

Posted: Thu Jul 23, 2015 11:05 am
by tgriep
Yes, that should do it.

Re: Printer contacts now working

Posted: Thu Jul 23, 2015 11:08 am
by nathanplatt
Worked a charm, thank you for all the help, This can now be locked!