Printer contacts now working

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Printer contacts now working

Post 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
        }

User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Printer contacts now working

Post by lmiltchev »

Have you restarted nagios after making the changes? Can you show us the actual email notification and the "generic-printer" template?
Be sure to check out our Knowledgebase for helpful articles and solutions!
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Printer contacts now working

Post 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?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Printer contacts now working

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Printer contacts now working

Post 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?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Printer contacts now working

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Printer contacts now working

Post 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?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Printer contacts now working

Post by tgriep »

Yes, that should do it.
Be sure to check out our Knowledgebase for helpful articles and solutions!
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Printer contacts now working

Post by nathanplatt »

Worked a charm, thank you for all the help, This can now be locked!
Locked