Page 1 of 1
Nagios Command File - Timestamp parsing
Posted: Thu Mar 05, 2015 3:42 am
by Sphinx
Hey all.
We have installed Nagios Core 3.5.0 and are in the need to process a vast amount from passive check results at once.
The results are comming from a database output and have different check result timestamps.
And here ist the problem, when we insert the passive check result into the nagios.cmd, the leading timestamp is dropped and replaced with the system timestamp when executing.
As an example:
Result Check Result from our test with only one result
Code: Select all
[1425537702] PROCESS_SERVICE_CHECK_RESULT;fkwinbck;Active Backups;0;No Backups Running
Nagios Log at the same second
Code: Select all
[1425541078] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;fkwinbck;Active Backups;0;No Backups Running
[1425541081] PASSIVE SERVICE CHECK: fkwinbck;Active Backups;0;No Backups Running
The CGI's and our database are showing the timestamp of the command execution rather than the check execution.
Is there any chance to configure the command file parser not to overwrite the timestamp?
Re: Nagios Command File - Timestamp parsing
Posted: Thu Mar 05, 2015 9:46 pm
by Box293
Can you show us the command you are using to submit the passive check to nagios.cmd
Re: Nagios Command File - Timestamp parsing
Posted: Fri Mar 06, 2015 2:33 am
by Sphinx
Sure, but it's just a redirected output from a file.
Command
Code: Select all
cat passive_check_results >> /usr/local/nagios/var/rw/nagios.cmd
Re: Nagios Command File - Timestamp parsing
Posted: Fri Mar 06, 2015 4:07 pm
by scottwilkerson
Not sure what you have in the file but this is the generally accepted way to send results
from
http://old.nagios.org/developerinfo/ext ... and_id=115
Code: Select all
#!/bin/sh
# This is a sample shell script showing how you can submit the PROCESS_HOST_CHECK_RESULT command
# to Nagios. Adjust variables to fit your environment as necessary.
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] PROCESS_HOST_CHECK_RESULT;host1;0;Host appears to be UP\n" $now > $commandfile
Re: Nagios Command File - Timestamp parsing
Posted: Mon Mar 09, 2015 10:07 am
by Sphinx
Hey.
The content of my output is stated on my first post.
The referenced shell script is doing the same thing as mine, basically.
But nagios totally ignores the timestamp in the brackets and replaces it with the current time.
What we need, is to insert check results from days, hours, minutes ago in the command file and want exactly this timestamp and not the timestamp when it is being processed by nagios.
To display it:
the output i want
Code: Select all
[1425537702] PROCESS_SERVICE_CHECK_RESULT;fkwinbck;Active Backups;0;No Backups Running
the output the script produces
Code: Select all
[1425912857] PROCESS_SERVICE_CHECK_RESULT;fkwinbck;Active Backups;0;No Backups Running
What's being inserted into nagios
Code: Select all
[1425912657] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;fkwinbck;Active Backups;0;No Backups Running
[1425912662] PASSIVE SERVICE CHECK: fkwinbck;Active Backups;0;No Backups Running
Re: Nagios Command File - Timestamp parsing
Posted: Mon Mar 09, 2015 3:33 pm
by scottwilkerson
Sphinx wrote:What we need, is to insert check results from days, hours, minutes ago in the command file and want exactly this timestamp and not the timestamp when it is being processed by nagios.
This does not work in Core, it cannot write/replace/update the log files into the past.
Re: Nagios Command File - Timestamp parsing
Posted: Tue Mar 10, 2015 2:18 am
by Sphinx
Okay, the timestamp in the log can be the current time, we don't care about that.
But is it possibly to parse our timestamp into nagios event queue instead of the current timestamp, so that we get an entry in the past.
Or are there any other possibilities, without database injection?
Re: Nagios Command File - Timestamp parsing
Posted: Tue Mar 10, 2015 1:10 pm
by jdalrymple
... The CGIs get their data from the log, so not really.
There is no database to inject.
If you have NDO then you can use database injection to update the timestamps there, but that won't get used in the Nagios Core interface. Where "in the world" do you need those original check timestamps to be reflected. If in the core web UI... there is no tidy way.
Re: Nagios Command File - Timestamp parsing
Posted: Wed Mar 11, 2015 2:14 am
by Sphinx
Yes, we have an NDO with a MySQL Database.
The use case we have is kind of special and i hoped that it would be possible.
Due to the fact that it is not possible, my question is answered, even if not succesfully resolved.
Re: Nagios Command File - Timestamp parsing
Posted: Wed Mar 11, 2015 10:40 am
by abrist
Fair enough. Nagios Core is tethered to time's arrow . . . .
Lockin' 'er up.