GTK

How much am I spending for internet ?

It was more than a year ago. I got only gprs connection and a laptop with bluetooth.

I subscribed gprs vodafone promotion: 500 MBytes per month for 20 euro.

One month later Vodafone debit me 25 euro for traffic. First they say it was becouse i used gprs for more than 500 MBytes of traffic. It was not true, obviousily, but how to demostrate it?
(well, next I discover it was a mistake debited traffic was for a paster connection, 5 month before)

It happen that at the time I was using a Debian Sarge on laptop. I just ... /var/log/messages ...

Jul  3 12:34:29 fincos pppd[27733]: Sent 39566 bytes, received 415222 bytes.

No, maybe it is better "grep -e 'pppd.*Sent' messages|less"

4133 + 20392 + 39566 ...

... well, but ... I am not a calculator, not me.

#!/usr/bin/perl -w

open(FILE,") {
    if ($line =~ /pppd.*Sent\ ([0-9]+).*received\ ([0-9]+)/) {
	$bytes += $1 +$2;
    }
}

print "$bytes\n";
print $bytes/1024 ."\n";
print $bytes/1000 . "\n";
...
114166219
111490.448242188
114166.219

.. umh 114 Mega, not bad for a GPRS connection in a month ... but not more than 500 MBytes .. I call Vodafone again. They find it was a paster traffic debit.

In the meantime, I got an ADSL modem with time based connection (while GPRS was traffic based). I also need internet: I was working on a web site from home. I need to monitor consumes.

I want something that permit me to monitor how much I am spending for connection, and I want statistics, maybe...

ppplogger version 0.2

I decided to use this C programs, which insert a db entry at connection startup and another (closing) entry at shutdown, logging connection seconds and connection traffic. This program, at the time, did not exist. Ok, I have got to write it.
Also I need some kind of interface to db, I write it in php, but it was hawful, I use GTK+.

Pppd

pppd deamon call ip-up at startup, and ip-down at shutdown (typically execute all contento of /etc/ppp/ip-up.d/ and /etc/ppp/ip-down.d/, rispectively). All params (pid, iface, ..) are in evironment.

Ok. I write. Compile. It works. Php interface is hawfull.

The GTK program ... I have a look on tutorial in gtk.org .. this library seems hawful to be true ... but maybe I am a bit snob. I tried libglade .. do not work: signal not connected .. ah now -export-dynamics !
...
...
figo!

I could use a library for db connection as libgda .. but I am tired to read: I will use libmysqlclient, like any common mortal.

Functions:

  • ADSL connection
    • pppd time from day-hour to day-hour
    • cost (given a price per minute)
  • GPRS connections
    • traffic from day-hour to day-hour
    • cost (given a price per 1024 bytes or per 1000 bytes)

It have to be a window, a connection selector (gprs, adsl ..a combo), 2 selector day-time, 2 textbox for price, I want a total report, and a column view for a list of connection occured in time intervall.
So:

Ok, I have some log saved (messages.?) I would to parse them and insert entries in db. I do it in perl.

Ok, Perl script reportcon.pl is in http://repository.smartango.com/parsing_log/

GTK+ program and pppd-logger deamon is in http://repository.smartango.com/debian/

There are debianized packages, I should make a real repository (with Packages.bz and Sources.bz)

Home pppd-logger

Ciao.

Syndicate content