Custom Notification Data Sent from Nagios to PagerDuty

To customize the notification data Nagios sends to PagerDuty, you'll want to modify the commands specified in pagerduty_nagios.cfg. On Debian-based systems this file is usually found in /etc/nagios3/conf.d, and on RHEL-based systems you're most likely to find this file in /etc/nagios.
Looking at the command_line option, where pd-nagios is invoked (or pagerduty_nagios.pl, if you use the older Perl-based integration), you can add fields with the -f parameter, or modify existing fields as desired. For example, you may customize the pd_description with Nagios macros like $HOSTNAME$, $SERVICESTATE$, $LASTSERVICESTATE$, etc. as shown in the examples below. The information you include in pd_description will be relayed in the notifications sent to you via your personal notification rules.

Examples

Agent-based Integration

define command {
 command_name notify-service-by-pagerduty
 command_line /usr/share/pdagent-integrations/bin/pd-nagios -n service -k $CONTACTPAGER$ -t "$NOTIFICATIONTYPE$" -f SERVICEDESC="$SERVICEDESC$" -f SERVICESTATE="$SERVICESTATE$" -f HOSTNAME="$HOSTNAME$" -f HOSTDISPLAYNAME="$HOSTDISPLAYNAME$" -f SERVICEDISPLAYNAME="$SERVICEDISPLAYNAME$" -f SERVICEPROBLEMID="$SERVICEPROBLEMID$" -f SERVICEOUTPUT="$SERVICEOUTPUT$" -f pd_description="$SERVICEDESC$ : $SERVICEOUTPUT$"
}

define command {
 command_name notify-host-by-pagerduty
 command_line /usr/share/pdagent-integrations/bin/pd-nagios -n host -k $CONTACTPAGER$ -t "$NOTIFICATIONTYPE$" -f HOSTNAME="$HOSTNAME$" -f HOSTSTATE="$HOSTSTATE$" -f HOSTDISPLAYNAME="$HOSTDISPLAYNAME$" -f HOSTPROBLEMID="$HOSTPROBLEMID$" -f pd_description="$SERVICEDESC$ : $SERVICEOUTPUT$"
}

Perl-based Integration

define command {
  command_name     notify-service-by-pagerduty
  command_line     /usr/local/bin/pagerduty_nagios.pl enqueue -f pd_nagios_object=service -f pd_description="$SERVICEDESC$ : $SERVICEOUTPUT$"
}

define command {
  command_name     notify-host-by-pagerduty
  command_line     /usr/local/bin/pagerduty_nagios.pl enqueue -f pd_nagios_object=host -f pd_description="$SERVICEDESC$ : $SERVICEOUTPUT$"
}

The Standard Macros in Nagios list provides full list of Nagios macros you can send to PagerDuty.

Custom Notification Data Sent from Nagios to PagerDuty