Customized macros not working for contacts
Deborah Martin
Deborah.Martin at kognitio.com
Fri May 4 16:28:51 CEST 2012
Hi Paul,
I don’t think that will be feasible.
I have 10 template service definitions and these all contain static settings
Then for each customer, I define a service definition referencing that template and overriding only the parameters that are applicable to a specific customer such as the contact-group,
host_name etc etc
So for example, my template is defined below :-
define service{
name dbcon-service ; The 'name' of this service template, referenced in other service definitions
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major
; performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 0 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
notification_interval 240
notification_period 24x7
notification_options n ; Notifications are not sent out
servicegroups dns
check_period 24x7
is_volatile 0
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
And then I define a service using that template, adding anything else that is specific to that customer :-
define service{
use dbcon-service
active_checks_enabled 1 ; Active service checks are enabled
host_name <specific-host> ; Usually the first wx2 node
normal_check_interval 5
service_description DB Connection for Specific client; Uppercase
check_command check_wx2_conn!$HOSTALIAS$
contact_groups specific-contact-group
max_check_attempts 3 ; Changed from default of 1 to try and reduce Service check Timeout alerts
notification_interval 10
retry_check_interval 1;
check_period 24x7 ; 24x7 monitoring
notification_period 24x7 ; 24x7 monitoring
}
define contactgroup{
contactgroup_name specific-contact-group
alias Administrators
members specific-contact-admin
}
define contact{
contact_name specific-contact-admin
alias specific-contact-admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email specificcontact at kognitio.com
_EMAILCONTACTID deborah.martin at kognitio.com
}
So, as you can see I have a contact group defined in my service definition which is based on my contactgroup definition etc etc
This contact-group is the same group used across about 60 service definitions so I only had to define this *once* in my contacts.cfg file.
I wanted to then add a customized macro to the same contacts definition so that I can parse that to an event handler but this doesn't work.
So my eventhandler would parse $SERVICESTATEID$ $HOSTALIAS$ and $_EMAILCONTACTID
And in my eventhandler, I would have a line something like "echo <results> | mailx -s "Results from $NAGIOS_HOSTALIAS" $NAGIOS__CONTACTEMAILCONTACTID
So I've only defined the $_EMAILCONTACTID once (per customer contact) in my contacts.cfg file which can then be used, in this case by the 60 service definitions that use event handlers
So hopefully, you'll see why this is really useful to make it work in the contact definition rather the service definition ?
Regards,
Deborah
----Original Message-----
From: Paul Dubuc [mailto:work at paul.dubuc.org]
Sent: 04 May 2012 14:01
To: Nagios Developers List
Cc: Deborah Martin
Subject: Re: [Nagios-devel] Customized macros not working for contacts
Is is feasible to define the macro in a service template definition that your other service definitions use to get the value for the command-line parameter?
Deborah Martin wrote:
> Andreas,
>
> It doesn't work if I define a customized macro in the contact
> definition and try to use it at all!
>
> That means as a macro or as an environment variable.
>
> If I move the customized macro to my service definition then both work.
>
> The docs say this is supported so I believe this should be fixed. My
> configuration "is in the real world" and therefore would be very
> useful. As it's for use with an event handler I can't believe that it
> will have that much of a performance impact as the only time when the
> event handler needs to send out results is on a critical alert and
> that is based on certain criteria being met.
>
> Having the macro defined in the contact definition instead of the
> service definition is the difference between updating 1 contacts.cfg
> file which contain 30 different contacts versus updating 100's of
> service definitions where there is around 10 services for every contact.
>
> Regards, Deborah
>
>
> -----Original Message----- From: Andreas Ericsson [mailto:ae at op5.se] Sent:
> 04 May 2012 12:25 To: Deborah Martin Cc: Nagios Developers List Subject:
> Re: [Nagios-devel] Customized macros not working for contacts
>
> On 05/03/2012 04:58 PM, Deborah Martin wrote:
>> Thanks Andreas,
>>
>>>> Are environment macros are turned on and large_installation_tweaks
>>>> turned off? Otherwise, it's not supposed to work.
>> Yes for both settings
>>
>> I do see your point about a fix. It's a shame because setting this in
>> the contact definition would have made some event handlers easier to write.
>>
>> At the moment my event handler has to be customized per customer to
>> get the right email contacts but if I could define a customized macro
>> in the contact definition, I only need use that in my event handler
>> script and then I don't need to worry about a different event handler
>> per customer making it as generic as possible. Things like warning
>> and critical thresholds are parsed based on customer requirements
>> rather than hardcoded so I was hoping I could do that with contacts.
>>
>> Is there a different way of achieving this ?
>>
>
> Use the macro as a command-line parameter from Nagios' config. From
> what I read in your original mail, that seemed to work well, no?
>
This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, please delete this e-mail immediately. Any unauthorised distribution or copying is strictly prohibited.
Whilst Kognitio endeavours to prevent the transmission of viruses via e-mail, we cannot guarantee that any e-mail or attachment is free from computer viruses and you are strongly advised to undertake your own anti-virus precautions. Kognitio grants no warranties regarding performance, use or quality of any e-mail or attachment and undertakes no liability for loss or damage, howsoever caused.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel
More information about the Developers
mailing list