=begin sql use test; drop table bw_daily; create table bw_daily ( ip varchar(20) not null, interface varchar(25) not null, ndate date not null, ntime time not null, bin int(11), bout int(11), KEY(ip), KEY(interface), KEY(ndate), KEY(ntime) ); INSERT INTO bw_daily (ip, interface, ndate, ntime, bin, bout ) VALUES("10.151.1.254" , "fe0/1", "2004-03-20", "04:30:00", 0, 0); INSERT INTO bw_daily (ip, interface, ndate, ntime, bin, bout ) VALUES("10.151.1.254" , "s0/1" , "2004-03-20", "04:30:00", 33, 44); INSERT INTO bw_daily (ip, interface, ndate, ntime, bin, bout ) VALUES("138.198.1.254", "fe0/0", "2004-03-20", "04:30:00", 455, 455); =end sql =cut use strict; use warnings; use DBIx::Chart; my $db = "DBI:mysql:test"; my $dbh = DBIx::Chart->connect($db) or die "Can't connect to database: ",DBIx::Chart->errstr(); my $ip = $dbh->quote('xxx.xxx.xxx.xxx'); my $int = $dbh->quote('s0/0'); my $dt = $dbh->quote('2004-03-21'); my $sql = "SELECT ntime,bin,bout from bw_daily where ndate=" .$dt." and ip=" .$ip." and interface=" .$int." RETURNING LINEGRAPH(ntime,bin,bout) WHERE width=500 and height=250 and title='weekly bandwidth utilization graph' and colors in ('red','blue') and background = 'lgray' and x-axis='time' and y-axis='bandwidth' and signature='ESM\@ST' "; my $sth = $dbh->selectrow_arrayref($sql); open(FI, ">gp1.png"); binmode FI; print FI $$sth[0]; close FI; $dbh->disconnect; exit 0; __END__ Can't take log of 0 at C:/Perl/site/lib/DBD/Chart/Plot.pm line 1556. DBI handle has uncleared implementors data. dbih_clearcom (sth 0x246510c, com 0x2461ba8, imp DBD::mysql::st): FLAGS 0x180113: COMSET IMPSET Warn PrintError PrintWarn PARENT DBIx::Chart::db=HASH(0x24659a4) KIDS 0 (0 Active) IMP_DATA undef NUM_OF_FIELDS 3 NUM_OF_PARAMS 0