[rrd-users] rrd dbi syntx

John Stile john at stilen.com
Tue Apr 1 00:22:58 CEST 2014


On Mon, 2014-03-31 at 21:19 +0000, Steve Shipway wrote:
> >rrdtool graph 
> >./test.png --imgformat=PNG --start=-1day --end=+0hours --width=1000 --height=600
> >"DEF:min=sql//mysql/host=127.0.0.1/dbname=thermal/username=thermal/password=thermal//temperature/date/cpu0:min:AVERAGE" 
> >"LINE1:min#FF0000:cpu0"
> >
> >Error:
> >ERROR: formatstring wrong - mysql
> 
> Second attempt at a solution, since the mysql drivers are confirmed to be 
> present!
> 
> See the documentation here 
> http://oss.oetiker.ch/rrdtool/doc/rrdgraph_libdbi.en.html
> 
> Your DEF specifies that the table to use is 'temperature', with the time 
> coming from field 'date' and the value from field 'cpu0'.
> 
> The 'date' field needs to be a UNIX timestamp, not a datetime field type. 
> Prefix it with a '*' if it is a datetime field -- this requires RRDTool 
> 1.4.something I believe.
> 
> You've not given a table definition for your 'temperature' table, but I 
> suspect 'date' is a datetime rather than a UNIX timestamp.  Try this instead:
> 
> DEF:min=sql//mysql/host=127.0.0.1/dbname=thermal/username=thermal/password=thermal//temperature/*date/cpu0:min:AVERAGE
> 
> ... and this should do the necessary datetime -> timestamp conversion.
> 
> Steve
> 
> 
> Steve Shipway
> s.shipway at auckland.ac.nz
> 
> 

I use 'timestamp' (noted in my first post), not datetime.

Am I supposed to use UNIX_TIMESTAMP() some how?

mysqldump -u'thermal' -p'thermal' --no-data thermal

CREATE TABLE `temperature` (
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cpuPhy` int(11) NOT NULL DEFAULT '0',
  `cpu0` int(11) NOT NULL DEFAULT '0',
  `cpu1` int(11) NOT NULL DEFAULT '0',
  `cpu2` int(11) NOT NULL DEFAULT '0',
  `cpu3` int(11) NOT NULL DEFAULT '0',
  `disk0` int(11) NOT NULL DEFAULT '0',
  `disk1` int(11) NOT NULL DEFAULT '0',
  `disk2` int(11) NOT NULL DEFAULT '0',
  `disk3` int(11) NOT NULL DEFAULT '0',
  `board0` int(11) NOT NULL DEFAULT '0',
  `board1` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;




More information about the rrd-users mailing list