// ************ RRD status class **************
class rrdstat {
- var $rrd_file = 'sample.rrd';
+ var $rrd_file = null;
var $config_raw = null;
var $config_graph = null;
// ***** init RRD stat module *****
$this->set_def($init_info);
- if (!is_writeable($this->rrd_file)) {
- if (!file_exists($this->rrd_file)) {
- if (touch($this->rrd_file)) { $this->create(); }
- else { trigger_error('RRD file can not be created', E_USER_WARNING); }
+ if (!is_null($this->rrd_file)) {
+ if (!is_writeable($this->rrd_file)) {
+ if (!file_exists($this->rrd_file)) {
+ if (touch($this->rrd_file)) { $this->create(); }
+ else { trigger_error('RRD file can not be created', E_USER_WARNING); }
+ }
+ else {
+ if (is_readable($this->rrd_file)) { $this->status = 'readonly'; }
+ else { trigger_error('RRD file is not readable', E_USER_WARNING); }
+ }
}
else {
- if (is_readable($this->rrd_file)) { $this->status = 'readonly'; }
- else { trigger_error('RRD file is not readable', E_USER_WARNING); }
+ $this->status = 'ok';
}
}
- else {
- $this->status = 'ok';
- }
}
function set_def($init_info = null) {
if (strpos($return, 'ERROR') !== false) {
trigger_error('rrd graph error: '.$return, E_USER_WARNING);
- $return = $graph_cmd."\n\n".$return;
+// $return = $graph_cmd."\n\n".$return;
}
return $return;
}
if (in_array($this->status, array('ok','readonly'))) {
foreach (array('day','week','month','year') as $tframe) {
$ret = $this->graph($tframe, null, $graph_extras);
- $out .= '<p>'.nl2br($ret).'</p>';
+// $out .= '<p>'.nl2br($ret).'</p>';
$out .= '<p><img src="'.$basename.'-'.$tframe.'.png"></p>';
}
}