function rammsteinUpdateRRD($station_id, $fuel_id, $price, $time = 0) { if ($time == 0) { $time = "now"; } $rrd = rammsteinGetRRDPath($station_id, $fuel_id); $cmd = "rrdtool update {$rrd} {$time}:{$price}"; echo system($cmd); }
\t\t\t'COMMENT: \\n' \\ EOT; //$colors = array('#F00','#0F0','#00F','#F0F','#0FF','#F00'); $colors = array('#A0BED9', '#88A61B', '#F29F05', '#6D0501', '#D92525', '#000'); $max_len = 0; foreach ($stations as &$station) { if (strlen($station['name']) > $max_len) { $max_len = strlen($station['name']); } } $i = 0; foreach ($stations as &$station) { $color = $colors[$i++ % sizeof($colors)]; $colorx = $color . '10'; $rrd = rammsteinGetRRDPath($station['id'], $fuel['id']); $id = $station['id']; $space = str_repeat(' ', $max_len - strlen($station['name'])); $cmd .= <<<EOF \t\t\t'DEF:p{$id}={$rrd}:price:LAST' \\ \t\t\t'CDEF:sp{$id}=p{$id},100,*' \\ \t\t\t'CDEF:ap{$id}=sp{$id},UN,PREV(sp{$id}),sp{$id},IF' \\ \t\t\t'LINE1:ap{$id}{$color}:{$station['name']}' \\ \t\t\t'COMMENT: {$space}' \\ \t\t\t'GPRINT:p{$id}:LAST:Current\\:%4.3lf%s' \\ \t\t\t'GPRINT:p{$id}:MIN:Minimum\\:%4.3lf%s' \\ \t\t\t'GPRINT:p{$id}:MAX:Maximum\\:%4.3lf%s\\l' \\ EOF; // 'AREA:sp$id$colorx' \ }