aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/rrdtool.class.php
blob: f7907ec6db047dc7f9ba7ffc396897e32ddf0bcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

class RRDTool {
	var $rrdtool = '/usr/bin/rrdtool';

	function __construct($rrdtool) {
		if (file_exists($rrdtool)) {
			$this->rrdtool = $rrdtool;
		} else {
			printf('<p class="warn">Error: RRDTool (<em>%s</em>) is not executable. Please install RRDTool it and configure <em>$CONFIG[\'rrdtool\'].</em></p>', $rrdtool);
			die();
		}
	}

	function rrd_info($rrdfile) {
		if (file_exists($rrdfile)) {
			$raw_info = shell_exec($this->rrdtool.' info '.$rrdfile);
			$raw_array = explode("\n", $raw_info);
			foreach ($raw_array as $key => $info) {
				if ($info != "") {
					$item_info = explode(" = ", $info);
					$item_info[1] = preg_replace('/"/', '', $item_info[1]);
					$info_array[$item_info[0]] = $item_info[1];
				}
			}
			return($info_array);
		} else {
			return false;
		}
	}
}

?>