Context Templates

Introduction

Context templates are html files with some macros in them. These files can be used as context menus (right click menus) for the objects on the maps.

The context templates are located in share/userfiles/templates/ relative to the nagvis root directory. The templates are named like this: <name>.context.html. It is possible to add a css file to the template, the name has to be: <name>.context.css.

There are some so called macros available in context menus of all object types and some which are only available for some special objects. All standard macros are listed below.

General

The following macros are available in hover menus of all object types:

Macro Description
General
[obj_id]ID of object in JavaScript. Needed to locate the object specific parts e.g. to schedule a manual update of the state information.
[name]Name of the object (Hostname, Hostgroupname, Servicegroupname, Mapname,...)
[backend_id]Represents the backend_id of the used backend for this object (New in 1.5.2).
[custom_1]Represents the first custom macro which can be defined per backend. Might be useful to set backend individual URLs (New in 1.5).
[custom_2]Second custom macro. Same as above.
[custom_3]Third custom macro. Same as above.
[map_name]Name of the current map/automap (New in 1.5.2).
Language macros
[lang_refresh_status]Label for refreshing the status of the object in frontend.
[lang_schedule_downtime]Label for scheduling a downtime in Nagios.
[lang_reschedule_next_check]Label for re-scheduling the next check of the object in Nagios.
[lang_connect_by_ssh]Label for connecting a host by ssh.
Paths
[html_base]Absolute URL to HTML-Base (Default: /nagvis)
[html_cgi]Absolute URL to the Nagios CGIs. Using object specific value. Depends on the used backend. If no backend specific value set the default value will be used. (Default: /nagios/cgi-bin)
[html_templates] Path to context templates directory (Default: /nagvis/userfiles/templates)
[html_template_images] Path to context template images directory (Default: /nagvis/userfiles/images/templates)

Special macros

There are macros for context templates of a specified type. These macros should be surrounded by section macros. The section macros define that the included code will be removed if the hover template is not parsed for this type.

For example a section macro for host macros looks like this:

<!-- BEGIN host -->.+?<!-- END host -->

Below you can find a full list of the special macros.

Host objects

MacroDescription
[address]Address of the host configured in Nagios
[pnp_hostname]Hostname with replaced blanks for links to PNP (New in 1.5)

Service objects

MacroDescription
[service_description]Service description in Nagios
[pnp_service_description]Service description with replaced blanks for links to PNP (New in 1.5)

Host- and Servicegroup objects

The section macros <!-- BEGIN hostgroup --> and <!-- BEGIN servicegroup --> exist to make special template code for hostgroup and servicegroup contextmenus possible. Both don't bring any special object specific macros with them (New in 1.5.2).