1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Performance Data</title>
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 8pt; }
.PageTitle { font-family: verdana,arial,serif; font-size: 12pt; font-weight: bold; }
-->
</STYLE>
</head>
<body bgcolor="#FFFFFF" text="black" class="Default">
<p>
<div align="center">
<h2 class="PageTitle">Performance Data</h2>
</div>
</p>
<hr>
<p>
<strong><u>Introduction</u></strong>
</p>
<p>
Nagios is designed to allow <a href="plugins.html">plugins</a> to return optional performance data in addition to normal status data, as well as allow you to pass that performance data to external applications for processing. A description of the different types of performance data, as well as information on how to go about processing that data is described below...
</p>
<p>
<strong><u>Types of Performance Data</u></strong>
</p>
<p>
There are two basic categories of performance data that can be obtained from Nagios:
</p>
<p>
<ol>
<li><b>Check performance data</b>
<li><b>Plugin performance data</b>
</ol>
</p>
<p>
<i>Check performance data</i> is internal data that relates to the actual execution of a host or service check. This might include things like service check latency (i.e. how "late" was the service check from its scheduled execution time) and the number of seconds a host or service check took to execute. This type of performance data is available for all checks that are performed. The $HOSTEXECUTIONTIME$ and $SERVICEEXECUTIONTIME$ <a href="macros.html">macros</a> can be used to determine the number of seconds a host or service check was running and the $HOSTLATENCY$ and $SERVICELATENCY$ macros can be used to determine how "late" a regularly-scheduled host or service check was.
</p>
<p>
<i>Plugin performance data</i> is external data specific to the plugin used to perform the host or service check. Plugin-specific data can include things like percent packet loss, free disk space, processor load, number of current users, etc. - basically any type of metric that the plugin is measuring when it executes. Plugin-specific performance data is optional and may not be supported by all plugins. As of this writing, no plugins return performance data, although they mostly likely will in the near future. Plugin-specific performance data (if available) can be obtained by using the $HOSTPERFDATA$ and $SERVICEPERFDATA$ <a href="macros.html">macros</a>. See below for more information on how plugins can return performance data to Nagios for inclusion in the $HOSTPERFDATA$ and $SERVICEPERFDATA$ macros.
</p>
<p>
<strong><u>Performance Data Support For Plugins</u></strong>
</p>
<p>
Normally plugins return a single line of text that indicates the status of some type of measurable data. For example, the check_ping plugin might return a line of text like the following:
</p>
<p>
<dir>
PING ok - Packet loss = 0%, RTA = 0.80 ms
</dir>
</p>
<p>
With this type of output, the entire line of text is available in the $HOSTOUTPUT$ or $SERVICEOUTPUT$ <a href="macros.html">macros</a> (depending on whether this plugin was used as a host check or service check).
</p>
<p>
In order to facilitate the passing of plugin-specific performance data to Nagios, the plugin specification has been expanded. If a plugin wishes to pass performance data back to Nagios, it does so by sending the normal text string that it usually would, followed by a pipe character (|), and then a string containing one or more performance data metrics. Let's take the check_ping plugin as an example and assume that it has been enhanced to return percent packet loss and average round trip time as performance data metrics. A sample plugin output might look like this:
</p>
<p>
<dir>
PING ok - Packet loss = 0%, RTA = 0.80 ms | percent_packet_loss=0, rta=0.80
</dir>
</p>
<p>
When Nagios seems this format of plugin output it will split the output into two parts: everything before the pipe character is considered to be the "normal" plugin output and everything after the pipe character is considered to be the plugin-specific performance data. The "normal" output gets stored in the $HOSTOUTPUT$ or $SERVICEOUTPUT$ macro, while the optional performance data gets stored in the $HOSTPERFDATA$ or $SERVICEPERFDATA$ macro. In the example above, the $HOSTOUTPUT$ or $SERVICEOUTPUT$ macro would contain "<i>PING ok - Packet loss = 0%, RTA = 0.80 ms</i>" (without quotes) and the $HOSTPERFDATA$ or $SERVICEPERFDATA$ macro would contain "<i>percent_packet_loss=0, rta=0.80</i>" (without quotes).
</p>
<p>
<strong><u>Format of Performance Data Output</u></strong>
</p>
<p>
The Nagios daemon doesn't directly process performance data, so it doesn't really care what the performance data looks like. There aren't really any inherent limitations on the format or content of the performance data. However, if you are using an external addon to process the performance data (i.e. PerfParse), the addon may be expecting that the plugin returns performance data in a specific format. Check the documentation that comes with the addon for more information. Also, make sure to check the plugin developer guidelines at SourceForge (<a href="http://nagiosplug.sourceforge.net/">http://nagiosplug.sourceforge.net/</a>) for information on writing plugins.
</p>
<p>
<strong><u>Enabling Performance Data Processing</u></strong>
</p>
<p>
If you want to process the performance data that is available from Nagios and the plugins, you'll need to do the following:
</p>
<p>
<ol>
<li>Enable the <a href="configmain.html#process_performance_data">process_performance_data</a> option.<br><br>
<li>Configure Nagios so that performance data is written to files and/or processed by executing commands.
</ol>
</p>
<p>
<strong><u>Writing Performance Data To Files</u></strong>
</p>
<p>
You can have Nagios write all host and service performance data to files using the <a href="configmain.html#host_perfdata_file">host_perfdata_file</a> and <a href="configmain.html#service_perfdata_file">service_perfdata_file</a> options. You can control how the data is written to those files using the <a href="configmain.html#host_perfdata_file_template">host_perfdata_file_template</a> and <a href="configmain.html#service_perfdata_file_template">service_perfdata_file_template</a> options. Additionally, you can have Nagios periodically execute commands to process the performance data files using the <a href="configmain.html#host_perfdata_file_processing_command">host_perfdata_file_processing_command</a> and <a href="configmain.html#service_perfdata_file_processing_command">service_perfdata_file_processing_command</a> options.
</p>
<p>
<strong><u>Processing Performance Data Using Commands</u></strong>
</p>
<p>
You can have Nagios process host and service performance data by executing commands by using the <a href="configmain.html#host_perfdata_command">host_perfdata_command</a> or <a href="configmain.html#service_perfdata_command">service_perfdata_command</a> options. An example command definition that simply writes service performance data to a file is shown below:
</p>
<p>
<font color='red'>
<pre>
define command{
command_name process-service-perfdata
command_line /bin/echo -e "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$" >> /usr/local/nagios/var/service-perfdata.dat
}
</pre>
</font>
</p>
<hr>
</body>
</html>
|