0

I'm going to add new target to my MRTG setup. And I already have raw data with measurements for past year. Is it possible to insert this data into my log file backdated? I know MRTG uses its own file format and it aggregates old data. Of course I can write a "time-machine" script which will reset current OS time to the start position of log and then retrieve that data in cycle, incrementing time by 5 mins. And obviously it looks like dirty hack.

1

I don't see why you wouldn't be able to, the format of the log files produced by MRTG is very simple.

The full break down is here : http://oss.oetiker.ch/mrtg/doc/mrtg-logfile.en.html

In general however:

the very first line is the total input, output and timestamp values of the last read:

[unix timestamp] [incoming bytes total] [outgoing bytes total]

After that, there is a line for every 5 minute interval (Or what ever the interval in your mrtg config file is) the default is 5 minutes

Each of the following lines are of the form

[unix timestamp] [average bytes in for period] [average bytes out for period] [max bytes in for period] [maxbytes out for period]

'Period' is defined as the time delta from the timestamp on this line subtracted from the timestamp on the previous line.

It wouldn't take much to write a small script to transfer the data in manually, create an appropriately named file in the MRTG work directory, then just let MRTG continue to update it.

You'd need to set the new interface to be monitored up in MRTG.CFG, get MRTG running in cron (Which you likely already have) then once you can see the first few updates in the new file, you'dd need to quickly run the update script to transfer the data before the next scheduled cron check.

As long as the files date and time information was accurate, and the timestamps in the log where accurate, then you should have little problem making this work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.