From 924495bb2d732548083de9e54bf93eebe7f0d910 Mon Sep 17 00:00:00 2001
From: Pim van den Berg
Date: Tue, 12 Jan 2010 19:58:47 +0100
Subject: make rrdtool executable configurable
---
conf/config.php | 3 +++
inc/html.inc.php | 2 +-
inc/rrdtool.class.php | 13 ++++++++++++-
layout/style.css | 5 +++++
plugin/cpu.php | 2 +-
plugin/df.php | 2 +-
plugin/disk.php | 2 +-
plugin/entropy.php | 2 +-
plugin/interface.php | 2 +-
plugin/irq.php | 2 +-
plugin/load.php | 2 +-
plugin/memory.php | 2 +-
plugin/processes.php | 2 +-
plugin/sensors.php | 2 +-
plugin/swap.php | 4 ++--
plugin/users.php | 2 +-
type/Default.class.php | 9 ++++++---
17 files changed, 40 insertions(+), 18 deletions(-)
diff --git a/conf/config.php b/conf/config.php
index 149348a..d904751 100644
--- a/conf/config.php
+++ b/conf/config.php
@@ -6,6 +6,9 @@ $CONFIG['version'] = 4;
# collectd's datadir
$CONFIG['datadir'] = '/var/lib/collectd/rrd';
+# rrdtool executable
+$CONFIG['rrdtool'] = '/usr/bin/rrdtool';
+
# category of hosts to show on main page
#$CONFIG['cat']['category1'] = array('host1', 'host2');
diff --git a/inc/html.inc.php b/inc/html.inc.php
index e38ca8e..6ab84d9 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -62,7 +62,7 @@ function plugin_header($host, $plugin, $status) {
function host_summary($hosts) {
global $CONFIG;
- $rrd = new RRDTool;
+ $rrd = new RRDTool($CONFIG['rrdtool']);
echo "
\n";
diff --git a/inc/rrdtool.class.php b/inc/rrdtool.class.php
index 7dcbc2a..f7907ec 100644
--- a/inc/rrdtool.class.php
+++ b/inc/rrdtool.class.php
@@ -1,9 +1,20 @@
rrdtool = $rrdtool;
+ } else {
+ printf('Error: RRDTool (%s) is not executable. Please install RRDTool it and configure $CONFIG[\'rrdtool\'].
', $rrdtool);
+ die();
+ }
+ }
+
function rrd_info($rrdfile) {
if (file_exists($rrdfile)) {
- $raw_info = shell_exec('/usr/bin/rrdtool info '.$rrdfile);
+ $raw_info = shell_exec($this->rrdtool.' info '.$rrdfile);
$raw_array = explode("\n", $raw_info);
foreach ($raw_array as $key => $info) {
if ($info != "") {
diff --git a/layout/style.css b/layout/style.css
index 2e2003e..83664a4 100644
--- a/layout/style.css
+++ b/layout/style.css
@@ -81,3 +81,8 @@ hr {
.small {
font-size: 0.7em;
}
+
+.warn {
+ font-weight: bold;
+ color: #D50100;
+}
diff --git a/plugin/cpu.php b/plugin/cpu.php
index d4097b0..081427f 100644
--- a/plugin/cpu.php
+++ b/plugin/cpu.php
@@ -17,7 +17,7 @@ require_once 'inc/collectd.inc.php';
# cpu-X/cpu-user.rrd
# cpu-X/cpu-wait.rrd
-$obj = new Type_GenericStacked($CONFIG['datadir']);
+$obj = new Type_GenericStacked($CONFIG);
$obj->data_sources = array('value');
$obj->order = array('idle', 'nice', 'user', 'wait', 'system', 'softirq', 'interrupt', 'steal');
$obj->ds_names = array(
diff --git a/plugin/df.php b/plugin/df.php
index 79c5cb5..b3bba84 100644
--- a/plugin/df.php
+++ b/plugin/df.php
@@ -11,7 +11,7 @@ require_once 'inc/collectd.inc.php';
# df/
# df/df-XXXX.rrd
-$obj = new Type_GenericStacked($CONFIG['datadir']);
+$obj = new Type_GenericStacked($CONFIG);
$obj->data_sources = array('free', 'used');
$obj->ds_names = array(
'free' => 'Free',
diff --git a/plugin/disk.php b/plugin/disk.php
index f1100d6..0f7a11a 100644
--- a/plugin/disk.php
+++ b/plugin/disk.php
@@ -13,7 +13,7 @@ require_once 'inc/collectd.inc.php';
# disk-XXXX/disk_ops.rrd
# disk-XXXX/disk_time.rrd
-$obj = new Type_GenericIO($CONFIG['datadir']);
+$obj = new Type_GenericIO($CONFIG);
$obj->data_sources = array('read', 'write');
$obj->ds_names = array(
'read' => 'Read ',
diff --git a/plugin/entropy.php b/plugin/entropy.php
index 8705894..3583550 100644
--- a/plugin/entropy.php
+++ b/plugin/entropy.php
@@ -9,7 +9,7 @@ require_once 'inc/collectd.inc.php';
## LAYOUT
# entropy/entropy.rrd
-$obj = new Type_Default($CONFIG['datadir']);
+$obj = new Type_Default($CONFIG);
$obj->data_sources = array('entropy');
$obj->ds_names = array(
'entropy' => 'Entropy bits',
diff --git a/plugin/interface.php b/plugin/interface.php
index 89e4280..833de38 100644
--- a/plugin/interface.php
+++ b/plugin/interface.php
@@ -12,7 +12,7 @@ require_once 'inc/collectd.inc.php';
# interface/if_octets-XXXX.rrd
# interface/if_packets-XXXX.rrd
-$obj = new Type_GenericIO($CONFIG['datadir']);
+$obj = new Type_GenericIO($CONFIG);
$obj->data_sources = array('rx', 'tx');
$obj->ds_names = array(
'rx' => 'Receive ',
diff --git a/plugin/irq.php b/plugin/irq.php
index ba0e7cb..10c6393 100644
--- a/plugin/irq.php
+++ b/plugin/irq.php
@@ -10,7 +10,7 @@ require_once 'inc/collectd.inc.php';
# irq/
# irq/irq-XX.rrd
-$obj = new Type_GenericStacked($CONFIG['datadir']);
+$obj = new Type_GenericStacked($CONFIG);
$obj->width = $width;
$obj->heigth = $heigth;
diff --git a/plugin/load.php b/plugin/load.php
index 44baf45..b33739e 100644
--- a/plugin/load.php
+++ b/plugin/load.php
@@ -9,7 +9,7 @@ require_once 'inc/collectd.inc.php';
## LAYOUT
# load/load.rrd
-$obj = new Type_Default($CONFIG['datadir']);
+$obj = new Type_Default($CONFIG);
$obj->data_sources = array('shortterm', 'midterm', 'longterm');
$obj->ds_names = array(
'shortterm' => ' 1 min',
diff --git a/plugin/memory.php b/plugin/memory.php
index ade242c..48a3048 100644
--- a/plugin/memory.php
+++ b/plugin/memory.php
@@ -13,7 +13,7 @@ require_once 'inc/collectd.inc.php';
# memory/memory-free.rrd
# memory/memory-used.rrd
-$obj = new Type_GenericStacked($CONFIG['datadir']);
+$obj = new Type_GenericStacked($CONFIG);
$obj->order = array('free', 'buffered', 'cached', 'used');
$obj->ds_names = array(
'free' => 'Free ',
diff --git a/plugin/processes.php b/plugin/processes.php
index 1487568..a560b13 100644
--- a/plugin/processes.php
+++ b/plugin/processes.php
@@ -15,7 +15,7 @@ require_once 'inc/collectd.inc.php';
# processes/ps_state-running.rrd
# processes/ps_state-sleeping.rrd
-$obj = new Type_GenericStacked($CONFIG['datadir']);
+$obj = new Type_GenericStacked($CONFIG);
$obj->ds_names = array(
'paging' => 'Paging ',
'blocked' => 'Blocked ',
diff --git a/plugin/sensors.php b/plugin/sensors.php
index fda5432..29110f1 100644
--- a/plugin/sensors.php
+++ b/plugin/sensors.php
@@ -12,7 +12,7 @@ require_once 'inc/collectd.inc.php';
# disk-XXXX/temerature-XXXX.rrd
# disk-XXXX/voltage-XXXX.rrd
-$obj = new Type_Default($CONFIG['datadir']);
+$obj = new Type_Default($CONFIG);
$obj->ds_names = array(
'value' => 'Value ',
);
diff --git a/plugin/swap.php b/plugin/swap.php
index 27bf7f9..e1fa3f6 100644
--- a/plugin/swap.php
+++ b/plugin/swap.php
@@ -14,7 +14,7 @@ require_once 'inc/collectd.inc.php';
switch($_GET['t']) {
case 'swap':
require_once 'type/GenericStacked.class.php';
- $obj = new Type_GenericStacked($CONFIG['datadir']);
+ $obj = new Type_GenericStacked($CONFIG);
$obj->order = array('free', 'cached', 'used');
$obj->ds_names = array(
'free' => 'Free ',
@@ -31,7 +31,7 @@ switch($_GET['t']) {
break;
case 'swap_io':
require_once 'type/GenericIO.class.php';
- $obj = new Type_GenericIO($CONFIG['datadir']);
+ $obj = new Type_GenericIO($CONFIG);
$obj->order = array('out', 'in');
$obj->ds_names = array(
'out' => 'Out',
diff --git a/plugin/users.php b/plugin/users.php
index d94a8c1..5df16bc 100644
--- a/plugin/users.php
+++ b/plugin/users.php
@@ -9,7 +9,7 @@ require_once 'inc/collectd.inc.php';
## LAYOUT
# users/users.rrd
-$obj = new Type_Default($CONFIG['datadir']);
+$obj = new Type_Default($CONFIG);
$obj->data_sources = array('users');
$obj->ds_names = array(
'users' => 'Users',
diff --git a/type/Default.class.php b/type/Default.class.php
index 0c992e2..ad880b3 100644
--- a/type/Default.class.php
+++ b/type/Default.class.php
@@ -4,6 +4,7 @@
class Type_Default {
var $datadir;
+ var $rrdtool;
var $args;
var $seconds;
var $data_sources = array('value');
@@ -21,8 +22,9 @@ class Type_Default {
var $tinstances;
var $identifiers;
- function __construct($datadir) {
- $this->datadir = $datadir;
+ function __construct($config) {
+ $this->datadir = $config['datadir'];
+ $this->rrdtool = $config['rrdtool'];
$this->parse_get();
$this->rrd_files();
$this->identifiers = $this->file2identifier($this->files);
@@ -124,7 +126,8 @@ class Type_Default {
}
function rrd_options() {
- $rrdgraph[] = '/usr/bin/rrdtool graph - -a PNG';
+ $rrdgraph[] = $this->rrdtool;
+ $rrdgraph[] = 'graph - -a PNG';
$rrdgraph[] = sprintf('-w %d', is_numeric($this->width) ? $this->width : 400);
$rrdgraph[] = sprintf('-h %d', is_numeric($this->heigth) ? $this->heigth : 175);
$rrdgraph[] = '-l 0';
--
cgit v1.1