Macros or env variables equivalence CheckMK-Nagios

Hello,

I am making a script to exchange nagios macros with CheckMK environment variables. That is, a kind of dictionary where calling $HOSTNAME$ gives me the value of $NOTIFY_HOSTNAME$.

I have found a list with some environment variables (in the documentation there are only a few) Environment Variable Prefixes · Issue #10 · PagerDuty/pagerduty-nagios-pl · GitHub but there is still some variable for which I can’t find its equivalent, specifically for these:

$HOSTATTEMPT$ $HOSTSTATETYPE$ $HOSTEXECUTIONTIME$ $SERVICEATTEMPT$ $SERVICEATTEMPT$ $SERVICEATTEMPT$ $SERVICEATTEMPT$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$ $SERVICELATENCY$ $SERVICELATENCY$ $SERVICELATENCY$ $SERVICELATENCY$ $LASTSERVICECHECK$ $LASTSERVICECHECK$ $LASTSERVICECHECK$ $LASTSERVICECHECK$ $LASTHOSTCHECK$ $LASTHOSTCHECK$ $LASTHOSTCHECK$ $LASTHOSTCHECK$ $TIMET$ $TIMET$

I need to get the complete list of environment variables. I have tried to use the foobar.sh script but it doesn’t work, it doesn’t write anything to the .out file (although in checkmk I see that the notification matches and it supposedly runs fine, and the permissions are also correct).

Can someone pass me the complete list?

In Setup | Services | Service monitoring rules | Parameters for HTML Email there is an option to enable complete variable list (for testing)
image
Next notification mail that is sent, you get a big list with all the variables inside.

A while ago I had it enabled on my 2.1.0p5 raw server and it gave these variables:

CONTACTALIAS
CONTACTEMAIL
CONTACTNAME
CONTACTPAGER
CONTACTS
DATE
EVENT_HTML
EVENT_TXT
HOSTACKAUTHOR
HOSTACKCOMMENT
HOSTADDRESS
HOSTALIAS
HOSTATTEMPT
HOSTCHECKCOMMAND
HOSTDOWNTIME
HOSTFORURL
HOSTGROUPNAMES
HOSTLABEL_cmk/device_type
HOSTLABEL_cmk/site
HOSTNAME
HOSTNOTIFICATIONNUMBER
HOSTOUTPUT
HOSTOUTPUT_HTML
HOSTPERFDATA
HOSTPROBLEMID
HOSTSHORTSTATE
HOSTSTATE
HOSTSTATEID
HOSTTAGS
HOSTURL
HOST_ADDRESS_4
HOST_ADDRESS_6
HOST_ADDRESS_FAMILY
HOST_EC_CONTACT
HOST_SL
LASTHOSTSHORTSTATE
LASTHOSTSTATE
LASTHOSTSTATECHANGE
LASTHOSTSTATECHANGE_REL
LASTHOSTSTATEID
LASTHOSTUP
LASTHOSTUP_REL
LASTSERVICEOK
LASTSERVICEOK_REL
LASTSERVICESHORTSTATE
LASTSERVICESTATE
LASTSERVICESTATECHANGE
LASTSERVICESTATECHANGE_REL
LASTSERVICESTATEID
LINKEDHOSTNAME
LINKEDSERVICEDESC
LOGDIR
LONGDATETIME
LONGHOSTOUTPUT
LONGSERVICEOUTPUT
LONGSERVICEOUTPUT_HTML
MICROTIME
MONITORING_HOST
NOTIFICATIONAUTHOR
NOTIFICATIONAUTHORALIAS
NOTIFICATIONAUTHORNAME
NOTIFICATIONCOMMENT
NOTIFICATIONTYPE
OMD_ROOT
OMD_SITE
PARAMETER_ELEMENTSS
PARAMETER_ELEMENTS_1
PARAMETER_ELEMENTS_2
PARAMETER_ELEMENTS_3
PARAMETER_ELEMENTS_4
PARAMETER_ELEMENTS_5
PARAMETER_ELEMENTS_6
PARAMETER_ELEMENTS_7
PARAMETER_FROM_ADDRESS
PARAMETER_GRAPHS_PER_NOTIFICATION
PARAMETER_NOTIFICATIONS_WITH_GRAPHS
PREVIOUSHOSTHARDSHORTSTATE
PREVIOUSHOSTHARDSTATE
PREVIOUSSERVICEHARDSHORTSTATE
PREVIOUSSERVICEHARDSTATE
SERVICEACKAUTHOR
SERVICEACKCOMMENT
SERVICEATTEMPT
SERVICECHECKCOMMAND
SERVICEDESC
SERVICEFORURL
SERVICEGROUPNAMES
SERVICELABEL_network/critical
SERVICENOTIFICATIONNUMBER
SERVICEOUTPUT
SERVICEOUTPUT_HTML
SERVICEPERFDATA
SERVICEPROBLEMID
SERVICESHORTSTATE
SERVICESTATE
SERVICESTATEID
SERVICEURL
SERVICE_EC_CONTACT
SERVICE_SL
SHORTDATETIME
SUBJECT
SVC_SL
WHAT

But not all the variables are available everywhere in Checkmk to use.

Thank you so much!!!

Do you know if this variables are available appending a “NOTIFY_” string at the beggining?
I’m interested in ENV variables starting with NOTIFY_ to use them in notifications scripts.

Thanks again

No, I don’t know which variables are available where. I just found out while using some, that they were not available everywhere. Would be nice if this was documented somewhere.

1 Like

Yeah, would be nice if this macros or envrioment variables where documented

@alz0 most important variables are listed in the documentation, section 11.5 I think.

Alternatively you can write a dummy script like in 11.4 and then you can write all variables to a file. Then you will see the variables after they are dumped into the file.

The online docs stops at 11.3.
So what source is the 11.4 and 11.5 you’re referring to?

Thanks @Yggy I see what you mean.

So let me clarify my reference:

In your link, you go to 5.6 Notifications, then you will find the sections I refer to. Hope this clarifies.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.