Page 1 of 1

make the status.dat file easier to read

Posted: Fri May 27, 2016 5:46 pm
by JeffreySilverman
I looked at the status.dat file, which is located by the status_file directive in nagios.cfg.

In it, I see that nagios logs events and time stamps them with UNIX epochs, which is a counter of seconds since Midnight, January 1st, 1971.

It is very easy to convert from timestamps to real ASCII time strings that can be easily parsed by human beings. For example

Code: Select all

[nagios@nagios-test etc]$ perl -le 'print scalar localtime 1463616608;'
Wed May 18 17:10:08 2016
[nagios@nagios-test etc]$ 
or

Code: Select all

[nagios@nagios-test ~]$ python -c "from datetime import datetime; print datetime.fromtimestamp(1463616608)"
2016-05-18 17:10:08
[nagios@nagios-test ~]$
Could the nagios software to be modified to do that?


Many thanks,

Jeff

Re: make the status.dat file easier to read

Posted: Sat May 28, 2016 6:36 pm
by tmcdonald
It certainly could, but I don't think this will ever be default behavior. There are a lot of advantages to having logs and files be easily parsed by machines, most notably the speed you get from not having to do a lot of English -> datestamp conversions. This file is also not generally intended to be for human consumption primarily, but there are plenty of tools you can run it through that will do the conversion for you.

Re: make the status.dat file easier to read

Posted: Mon May 30, 2016 2:19 am
by Box293
I hear what you're saying, but from a coding point of view epoch is such an easy number to programatically work with.

However there is no reason why you could not submit a feature request to GitHub so that the real date and time values were also written to the status.dat file in an additional field. Yes it would increase the size of the file, but it would certainly help reading it easier.

https://github.com/NagiosEnterprises/nagioscore