Package: mrtg
Version: 2.9.17-4
Tags: patch

Every time the box is rebooted all the traffic counters are set with the
values of the last run of mrtg. This is erraneous and, if the box was
switched off for some time, it produces really wrong graphs! (all flat).

The traffic counters are in the first line of the mrtg-2 logfile. After a
period of poweroff you can see in the logs:

951759461 158622809 184439887
951759461 1079 626 1079 626
951759204 1079 626 1079 626
951759000 1079 626 1079 626
951758700 1079 626 1079 626
951758400 1079 626 1079 626
951758100 1079 626 1079 626
951757800 1079 626 1079 626

this repeats all the way til..

951743400 1079 626 1079 626

The proposed patch is to add this /etc/init.d/mrtg boot script that resets
all the counters to 0 (the first line only). This problem affects Debian
3.0-i386 that i use, but i think it is a problem since the year 2000 at
least (search the numbers on google groups) and persist in the unstable
release.

c-ya!

3               http://www.trek.eu.org/
k               PGPKey: 7016731A57D4A69B 1A8EE5E90EF2608E (since 1995)
#!/bin/sh
#
# MRTG Debian boot file by Trek <[EMAIL PROTECTED]>
#

case "$1" in
  start)
    if [ -e /etc/mrtg.cfg ]
    then
        logdir=`grep -i ^LogDir: /etc/mrtg.cfg | (read a b; echo $b)`

        if [ "$logdir" = "" ]
        then
            logdir=`grep -i ^WorkDir: /etc/mrtg.cfg | (read a b; echo $b)`
        fi

        echo "Reset MRTG logs counters in $logdir"
        for log in $logdir/*.log
        do
            mv $log ${log/%\.log/.old}
            sed '1,1s/^\([0-9]\+\) [0-9]\+ [0-9]\+$/\1 0 0/' \
                < ${log/%\.log/.old} > $log
        done
    fi
  ;;
  stop|restart|reload|force-reload)
  ;;
  *)
  echo "Usage: /etc/init.d/mrtg {start|stop|reload|force-reload|restart}"
  ;;
esac

exit 0

Reply via email to