[mrtg] Reuse .old logfiles after rateup error
Morty Abzug
morty+mrtg at frakir.org
Wed Feb 24 06:54:28 CET 2010
On Tue, Feb 23, 2010 at 06:28:26AM -0800, alfo wrote:
> Right now, when rateup fails it stops updating the .log file and only the
> .old logfile remains in the system. When the error is solved I am not able
> to reuse that logfile anymore (the .old one), because the timestamps are not
> udpated (basically, mrtg doesn't update them if the last one is older than X
> hours), so I'm losing the historical information in case of error.
>
> I was wondering if there is any script to update a .old logfile after an
> error occurs.
Which error are you getting?
I use the following bash functions to help find and fix MRTG logfile
problems:
function mrtg-logfile-check(){
for file in "$@"; do
echo file: $file
echo ' Sort diff (you can ignore problems with line1 and 2):'
sort -rn $file | diff - $file
echo ' Lines with wrong size:'
awk 'NR>1 && NF!=5{printf "line %-5d: ", NR; print}' $file
echo
echo
done
}
function mrtg-fix-time-problem (){
perl -nae 'BEGIN{$now=time}
if ($F[0]>$now && ($.==1 or $F[0]==$then)) {
s{^\d+}{$now}; $then=$F[0]
} elsif ($F[0]>$now) {
next
};
print' "$@"
}
- Morty
More information about the mrtg
mailing list