Using custom variables at service check

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
junkertf
Posts: 119
Joined: Tue Aug 08, 2017 1:52 am

Using custom variables at service check

Post by junkertf »

Hello,

I had found the following documentations about the custom variables used by XI:

https://assets.nagios.com/downloads/nag ... tvars.html

https://assets.nagios.com/downloads/nag ... acros.html

But could not use a self defined variable.

The planed method is the following. I have many host objects, and wat separate them to A nd B and run a service check (nrpe) depending on these. So i created A and B host template and created an own variable "TYPE". After i managed the host to use for example "A" host template.
On the server object i had an nrpe service for what i want pass that TYPE variable, but cant figure it out how to pass for it. Tried it many form, but i becom eighter a "$" sing or nothing at the monitored service side script.

Can you help me out, where i make a mistake, what i misunderstood? I try to use the method for setting up other service also dependig on that grouping of hosts...

Thansk, best regards,

Ferenc
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Using custom variables at service check

Post by scottwilkerson »

Custom variable names must begin with an underscore (_) to prevent name collision with standard variables
If you have a host variable called _TYPE

You call it with $_HOSTTYPE$
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
junkertf
Posts: 119
Joined: Tue Aug 08, 2017 1:52 am

Re: Using custom variables at service check

Post by junkertf »

Hello,


Thanks for the fast answer :)
our check command looks like from GUI:

/usr/local/nagios/libexec/check_nrpe -H HOST -t 60 -c check_diskperf -a "$_HOSTTYPE$"

if i test run it i become error:

$ /usr/local/nagios/libexec/check_nrpe -H apt01 -t 60 -c check_diskperf -a "$_HOSTTYPE$"
PROBLEM
ERROR: Device incorrectly specified

its nrp config line looks like at the monitored side:

command[check_diskperf]=/usr/local/nagios/libexec/chkdsk_perf_nagios.sh $ARG1$

and if i run it from command line check:

# /usr/local/nagios/libexec/chkdsk_perf_nagios.sh "TYPE1"
OK - ....stats..............

i set the paramter "TYPE1" in the host-template custom variable TYPE="TYPE1"


howto go forward, or debug it?

Best regards,

Ferenc
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Using custom variables at service check

Post by scottwilkerson »

You cannot run it from the command line with these arguments, you have to actually put it in the nagios config.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
junkertf
Posts: 119
Joined: Tue Aug 08, 2017 1:52 am

Re: Using custom variables at service check

Post by junkertf »

Hello,

Dont understand exactly, but its working. Actually i configured it from the GUI so way and the counters are coming..
Any rtm for that? Maybe an implementation for testing eighter way for pre check the service can be good for debug (GUI or CLI)....

Eighter way, Thanks, the case can be closed..

Best regards,

Ferenc
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Using custom variables at service check

Post by scottwilkerson »

Unfortunately these special macros need to be read in at check time, and there isn't really any way to create a testing platform for it.

Locking thread.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked