Library

Docs
Beta

Projects

Nagios Core 4 Home PageNagios Core 4 Host InformationNagios Core 4 Host Status DetailsNagios Core 4 IntroductionNagios Core 4 Service InformationNagios Core 4 Service Overview For All Host GroupsNagios Core 4 Service Overview For All Service GroupsNagios Core 4 Service Status DetailsNagios Core 4 Status MapsNagios Core 4 Tactical OverviewNagios Core Active ChecksNagios Core Adaptive MonitoringNagios Core Alerting With MySQL and Nagios NWC13Nagios Core Authentication And Authorization In The CGIsNagios Core CGI Configuration File OptionsNagios Core Cached ChecksNagios Core Configuration OverviewNagios Core Configuring SSL/TLSNagios Core Custom CGI Headers and FootersNagios Core Detection and Handling of State FlappingNagios Core Distributed MonitoringNagios Core Enhanced CGI Security and AuthenticationNagios Core Event HandlersNagios Core External CommandsNagios Core Fast Startup OptionsNagios Core Graphing Performance Info With MRTGNagios Core Host ChecksNagios Core Host and Service DependenciesNagios Core How To Monitor A Linux/Unix MachineNagios Core How To Monitor A Netware ServerNagios Core How To Monitor A Network PrinterNagios Core How To Monitor A Publicly Available Service (HTTP, FTP, SSH, etc.)Nagios Core How To Monitor A Router/SwitchNagios Core How To Monitor A Windows MachineNagios Core How to Maintain Over 20 Monitoring Appliances NWC14Nagios Core Integration OverviewNagios Core Leveraging SNMP Extensions with Nagios NWC13Nagios Core Main Configuration File OptionsNagios Core Monitoring Remote Locations with Nagios NWC13Nagios Core Monitoring Service and Host ClustersNagios Core Nagios, AWS, and Hosted VoIP NWC13Nagios Core Nagios Plugin APINagios Core Nagios URL In NotificationsNagios Core Nagios on AWS NWC14Nagios Core Notification EscalationsNagios Core NotificationsNagios Core Object Configuration OverviewNagios Core Object DefinitionsNagios Core Object InheritanceNagios Core On Call RotationsNagios Core Passive ChecksNagios Core Passive Host State TranslationNagios Core Performance DataNagios Core Performance Graphs Using InfluxDB + Nagflux + Grafana + HistouNagios Core Performance Graphs Using PNP4NagiosNagios Core Plugin Development GuidelinesNagios Core Predictive Dependency ChecksNagios Core SNMP Explained NWC15Nagios Core SNMP Monitoring Architecture With Nagios NWC13Nagios Core SNMP Trap IntegrationNagios Core Scheduled DowntimeNagios Core Security ConsiderationsNagios Core Service And Daemon ChecksNagios Core Service and Host Freshness ChecksNagios Core Standard Macros in NagiosNagios Core Starting and Stopping NagiosNagios Core State StalkingNagios Core State TypesNagios Core Status Map Customization (Legacy)Nagios Core Status Map CustomizationNagios Core TCP Wrapper IntegrationNagios Core Time Period InheritanceNagios Core Time PeriodsNagios Core Understanding Macros and How They WorkNagios Core Upgrading From Previous VersionsNagios Core Upgrading Nagios Core From SourceNagios Core Using Grafana With PNP4NagiosNagios Core Using The Nagiostats UtilityNagios Core Verifying Your ConfigurationNagios Core Volatile ServicesNagios Core Writing a Custom Worker

Nagios Core - Nagios URL In Notifications

Overview

This KB article shows you how to provide a URL for the Nagios host or service object in your notifications. This allows your end users to go directly to the object they are being notified about.

This functionality was introduced in Nagios Core 4.3.3.

Editing Files

In many steps of this article you will be required to edit files. This documentation will use the vi text editor. When using the vi editor:

  • To make changes press i on the keyboard first to enter insert mode
  • Press Esc to exit insert mode
  • When you have finished, save the changes in vi by typing :wq and press Enter

Nagios Configuration

There is a configuration directive called website_url that needs to be defined in nagios.cfg before you can use the URL in your notifications.

Execute the following command to open the nagios.cfg file in vi:

vi /usr/local/nagios/etc/nagios.cfg

Add the following line to the file:

website_url=http://xxx.xxx.xxx.xxx/nagios

Change xxx.xxx.xxx.xxx to the IP Address or DNS record of your Nagios Core server, for example:

website_url=http://core-015/nagios

Save your changes and close the nagios.cfg file.

The next step is to update your host and service notification commands to use the relevant macros. In this example these are defined in the commands.cfg file. Execute the following command to open the file in vi:

vi /usr/local/nagios/etc/objects/commands.cfg

For the host notification command you use the $HOSTINFOURL$ as per the following example:

define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "* Nagios *\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\n
                        State: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n
                        Host Info URL: $HOSTINFOURL$\n" | /bin/mail -s " $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ " $CONTACTEMAIL$
        }

For the service notification command you use the $SERVICEINFOURL$ as per the following example:

define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "* Nagios *\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\n
                        Host: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n
                        Service Info URL: $SERVICEINFOURL$\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s " $NOTIFICATIONTYPE$
                        Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ " $CONTACTEMAIL$
        }

Save your changes and close the commands.cfg file.

Restart the nagios service for these changes to take effect. If you are unsure of the command required for restarting the nagios service please refer to the following KB article:

Nagios Core - Installing Nagios Core From Source

Example Notifications

When a notification is now sent there will be a link available for that object in Nagios Core, here are two examples:

Host

* Nagios *

Notification Type: CUSTOM
Host: localhost
State: UP
Address: 127.0.0.1
Info: PING OK - Packet loss = 0%, RTA = 0.04 ms

Date/Time: Mon Oct 23 12:58:34 AEDT 2017
Host Info URL: http://core-015/nagios/cgi-bin/extinfo.cgi?type=1&host=localhost

Service

* Nagios *

Notification Type: CUSTOM

Service: PING
Host: localhost
Address: 127.0.0.1
State: OK

Date/Time: Mon Oct 23 12:58:53 AEDT 2017
Service Info URL: http://core-015/nagios/cgi-bin/extinfo.cgi?type=2&host=localhost&service=PING
Additional Info:

PING OK - Packet loss = 0%, RTA = 0.05 ms

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/

Nagios Enterprises, LLC

© All rights reserved. 2026