How to view multiline service check data
How to view multiline service check data
I'm just getting started with Nagios XI and I can't figure out how to view the details of my service check output.
I've written a passive service check that sends data to nagios.cmd. I can see the check status on the Service Status Detail page, but nothing after the first line.
Is there something that needs to be enabled or customized in order to see multiline output?
Here's an example of one host result that is sent to nagios.cmd. (lines between the ---'s)
The only thing I see on the service status detail page is OK - no problems found.
---
[1354816132] PROCESS_SERVICE_CHECK_RESULT;xxx;BigIP;0;OK - no problems found
This report generated by check_bigip_vips on xxx
<OK>GREEN xxx:xxx(vip_xxx) ENABLED (The virtual server is available)</OK>
<OK>xxx:xxx (ENABLED) UP (Pool member is available)</OK>
<OK>xxx:xxx (ENABLED) UP (Pool member is available)</OK>
<OK>xxx:xxx (ENABLED) UP (Pool member is available)</OK>
<br><br>
---
I've written a passive service check that sends data to nagios.cmd. I can see the check status on the Service Status Detail page, but nothing after the first line.
Is there something that needs to be enabled or customized in order to see multiline output?
Here's an example of one host result that is sent to nagios.cmd. (lines between the ---'s)
The only thing I see on the service status detail page is OK - no problems found.
---
[1354816132] PROCESS_SERVICE_CHECK_RESULT;xxx;BigIP;0;OK - no problems found
This report generated by check_bigip_vips on xxx
<OK>GREEN xxx:xxx(vip_xxx) ENABLED (The virtual server is available)</OK>
<OK>xxx:xxx (ENABLED) UP (Pool member is available)</OK>
<OK>xxx:xxx (ENABLED) UP (Pool member is available)</OK>
<OK>xxx:xxx (ENABLED) UP (Pool member is available)</OK>
<br><br>
---
Re: How to view multiline service check data
If I remember correctly, the XI interface will only show the first line of data if there are multiple lines. You should be able to access the other lines by bringing up the service status details. I think you can get up to 3 lines of data in the main status tables if you return the output all as one line, and use <br /> tags inline.
Re: How to view multiline service check data
That was my question. One line on the main page is fine, but when I go to the 'Service Details Page', I don't see the rest of the ouput, just the first line.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: How to view multiline service check data
When you send this to the nagios.cmd you need to send it like this
(replaceing line endings with \n)
(replaceing line endings with \n)
Code: Select all
[1354816132] PROCESS_SERVICE_CHECK_RESULT;xxx;BigIP;0;OK - no problems found\nThis report generated by check_bigip_vips on xxx\n<OK>GREEN xxx:xxx(vip_xxx) ENABLED (The virtual server is available)</OK>\n<OK>xxx:xxx (ENABLED) UP (Pool member is available)</OK>\n<OK>xxx:xxx (ENABLED) UP (Pool member is available)</OK>\n<OK>xxx:xxx (ENABLED) UP (Pool member is available)</OK>\n<br><br>Re: How to view multiline service check data
The output comes from an array. After each element in the array I send a newline (\n). The output I posted is just what is fed into nagios.cmd, you just can't see the newlines. The <br>'s in the text are leftovers from another monitoring program that I send the output to. I was going to look at the output in nagios and modify the output to make it look pretty, but I can't seen *any* output after the first line. I didn't add any newlines to the output I posted.
This is the subroutine I use to push the results out to Nagios:
#----------------------------------------------------------------------------
# Send Results to nagios
#----------------------------------------------------------------------------
sub sendResultsToNagios(\@) {
open(Nagios, ">/usr/local/nagios/var/rw/nagios.cmd"); #nagios command file
foreach my $line (@{($_[0])}) {
print(Nagios "$line\n");
}
}
This is the subroutine I use to push the results out to Nagios:
#----------------------------------------------------------------------------
# Send Results to nagios
#----------------------------------------------------------------------------
sub sendResultsToNagios(\@) {
open(Nagios, ">/usr/local/nagios/var/rw/nagios.cmd"); #nagios command file
foreach my $line (@{($_[0])}) {
print(Nagios "$line\n");
}
}
Re: How to view multiline service check data
If I take *out* the newlines, everything is lumped together in one ugly mess in both the service status page, and the service status detail page. I really don't want the whole output on the service status page since that uses up too much screen space. I seem to remember reading somewhere that nagios core has one variable for the short output and another for the long output. It's as though the service status detail page is only using the short output.
Re: How to view multiline service check data
NOTE: When I added extra lines to the plugin stdout, they *did* display on the service status detail page for the active check. It's just the passive check output that I stuff into nagios.cmd that does not seem to handle multiple lines. The plugin active check measures the time it took to pull the raw data and sends that info to stdout. The raw data is processed into multiple passive check results which are stuffed into nagios.cmd under various hostnames. None of the passive check data written to nagios.cmd displays any data after the first line for any given host.
Plugin stdout:
OK: SOAP data collection time = 10 seconds| collection_time=10
Here is another line.
And here is a 3rd line
and on the service status detail line I see:
OK: SOAP data collection time = 10 seconds
Here is another line.
And here is a 3rd line
However, writing multiline output to nagios.cmd results in only the first line (the one containing the timestamp and PROCESS_SERVICE_CHECK_RESULT) being displayed in the service status page.
Plugin stdout:
OK: SOAP data collection time = 10 seconds| collection_time=10
Here is another line.
And here is a 3rd line
and on the service status detail line I see:
OK: SOAP data collection time = 10 seconds
Here is another line.
And here is a 3rd line
However, writing multiline output to nagios.cmd results in only the first line (the one containing the timestamp and PROCESS_SERVICE_CHECK_RESULT) being displayed in the service status page.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: How to view multiline service check data
I'm not exactly sure how this sub is getting data, but I believe you need to change to something like this to it adds the \n to the output instead of converting the newline char
Code: Select all
#----------------------------------------------------------------------------
# Send Results to nagios
#----------------------------------------------------------------------------
sub sendResultsToNagios(\@) {
open(Nagios, ">/usr/local/nagios/var/rw/nagios.cmd"); #nagios command file
foreach my $line (@{($_[0])}) {
print(Nagios "$line\\n");
}
}Re: How to view multiline service check data
Hmmm....here's the simplest example I can come up with:
1. Create a test host or use one that already exists.
2. Create a passive service called BigIP.
3. Create the following file (I named it t):
[1355930403] PROCESS_SERVICE_CHECK_RESULT;your.host.here;BigIP;0;OK - Bogus BigIP Data
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
4. Send it to nagios:
cat t > /usr/local/nagios/var/rw/nagios.cmd
On the 'Service Status Detail' page (I call it that because at the top of the page it says "Service Status Detail' and just below that it says 'BigIP')
I can see the check results (the first line at least), but I don't see the "This is line X" lines.
So either I'm doing something wrong when I create the file, there is something wrong with the way nagios.cmd is processing the data, or there is something wrong with the way the web interface is displaying the data. If I create an active service that outputs the same data, i can see all lines.
1. Create a test host or use one that already exists.
2. Create a passive service called BigIP.
3. Create the following file (I named it t):
[1355930403] PROCESS_SERVICE_CHECK_RESULT;your.host.here;BigIP;0;OK - Bogus BigIP Data
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
4. Send it to nagios:
cat t > /usr/local/nagios/var/rw/nagios.cmd
On the 'Service Status Detail' page (I call it that because at the top of the page it says "Service Status Detail' and just below that it says 'BigIP')
I can see the check results (the first line at least), but I don't see the "This is line X" lines.
So either I'm doing something wrong when I create the file, there is something wrong with the way nagios.cmd is processing the data, or there is something wrong with the way the web interface is displaying the data. If I create an active service that outputs the same data, i can see all lines.
Re: How to view multiline service check data
Never mind. i figured it out.