As well as putting your data in a database, you should have a look at RRDtool (
http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/) and MRTG (
http://people.ee.ethz.ch/~oetiker/webtools/mrtg/) for your graphing, as these tools were developed precisely for this sort of work. Written in C+Perl, too.