Moin, * Stefan Meister <stefan.meister@in-haspe.de> [02-11-01 20:41]: > Nun würde ich gerne ein wenig Kontrolle darüber haben, wie lange das > Internet genutzt worden ist. > Da alles über 20 Std im Monat natürlich extra Geld kostet, interessiert > mich das schon. > > Jetzt zum Problem. Ich würde gerne rausfinden, wieviel Zeit von dem 20 Std > Konto noch übrig ist. > Gibt es eine Möglichkeit dies anhand von Logfiles zu erfassen, auszuwerten > und dann als html Seite in /var/www abzulegen ? > Natürlich sollte es regelmäßig aktualisiert werden. 1. 'echo -n "$(date +"%d.%m.%Y %H:%M:%S") - " >> /var/log/online-time' in /etc/ppp/ip-up.d/XXotime 2. 'echo -n "$(date +"%d.%m.%Y %H:%M:%S")" >> /var/log/online-time' in /etc/ppp/ip-down.d/XXotime 3. cron job: 10 0 * * * user /bin/echo "<html><head><title></title></head><body>`/usr/local/bin/ocalc -m` is schon weg!</body></html>" > /foo/bar.html -- Janto Trappe Germany /* rapelcgrq znvy cersreerq! */ GnuPG-Key: http://www.sylence.de/gpgkey.asc Key ID: 0x8C53625F Fingerprint: 35D7 8CC0 3DAC 90CD B26F B628 C3AC 1AC5 8C53 625F
#!/bin/sh
#
PATH="/bin:/usr/bin:/usr/local/bin"
case $* in
-d) PARAM=`/bin/date +%d.%m.%Y`;;
-m) PARAM=`/bin/date +%m.%Y`;;
-y) PARAM=`/bin/date +%Y`;;
-?|-h|-help) echo "calc [-d|-m|-y|<pattern>]"
echo
exit;;
*) PARAM="$*";;
esac
grep "$PARAM" /var/log/online-time |
awk 'BEGIN { total=0 }
NF == 5 {
n=split($1,d,".")
date1=(d[1]+d[2]*30+d[3]*365)
n=split($2,t,":")
time1=(t[1]*3600+t[2]*60+t[3])
n=split($4,d,".")
date2=(d[1]+d[2]*30+d[3]*365)
n=split($5,t,":")
time2=(t[1]*3600+t[2]*60+t[3])
time=(date2-date1)*3600*24+time2-time1
total=total+time
}
END \
{
hours = total / 3600
print NR" connects, "hours" hours, (= "total" seconds)"
}'
Attachment:
pgplUXIUYfY5E.pgp
Description: PGP signature