How to fetch and display Nagios service thresholds in Alert mails

I need to show the service threshold values (-w ARG1 and -c ARG2) for WARNING and CRITICAL state in the alert mail body.

Along with the SERVICESTATE and SERVICEOUTPUT mail recipients will get better understanding on what exactly is the threshold set for the service.

Tried following line in the mail body of commands.conf file. "Service threshold for WARNING at $ARG1$ and CRITICAL at $ARG$" It didnt work. Please help with any means to fetch the threshold values.

Note: All Hosts and Services are monitored via NRPE host agent with commands and thresholds mentioned in the local nrpe.conf file. Nagios version: 4.3 core


The values $ARG1$ and so on are passed to the check command. I don't believe there is a way for the notify command to access them. The arguments the notify command receives come from the service_notification_command or host_notification_command value.

One way to achieve your goal should be to define a custom variable in the host/service, e.g.

define service {
  service_description MyCheck
  ...
  _CWARN 5
  _CCRITICAL 10
}

Note the preceding underscore.

This variable is then accessible using the macros $_SERVICECWARN$ and $_SERVICECCRITICAL$ (or $_HOSTCWARN$ and $_HOSTCCRITICAL$ for a host object).

You can also refer to these macros in your check command rather than $ARG1$ etc. so that you don't need to update values in two places.