diff options
| author | Pim van den Berg | 2009-11-04 21:05:37 +0100 |
|---|---|---|
| committer | Pim van den Berg | 2009-11-04 21:05:37 +0100 |
| commit | aa454ff4b3d4d5be9d5cc9dff4b4246c6e655f3e (patch) | |
| tree | 82b5e617ead0c3b50bbb0fb296f280be0b90a61e | |
| parent | make dynamic title more detailed (diff) | |
| download | apt-panopticon_cgp-aa454ff4b3d4d5be9d5cc9dff4b4246c6e655f3e.zip apt-panopticon_cgp-aa454ff4b3d4d5be9d5cc9dff4b4246c6e655f3e.tar.gz apt-panopticon_cgp-aa454ff4b3d4d5be9d5cc9dff4b4246c6e655f3e.tar.bz2 apt-panopticon_cgp-aa454ff4b3d4d5be9d5cc9dff4b4246c6e655f3e.tar.xz | |
remove path_format from plugins
The relative path to an rrd file can be generated based on host, plugin,
plugin instance, type and type instance. In this case path_format is not
needed anymore.
This commit includes code based on the collectd_identifier function from
php-collection by Bruno Prémont.
Diffstat (limited to '')
| -rw-r--r-- | plugin/cpu.php | 1 | ||||
| -rw-r--r-- | plugin/df.php | 1 | ||||
| -rw-r--r-- | plugin/disk.php | 1 | ||||
| -rw-r--r-- | plugin/entropy.php | 1 | ||||
| -rw-r--r-- | plugin/interface.php | 1 | ||||
| -rw-r--r-- | plugin/irq.php | 1 | ||||
| -rw-r--r-- | plugin/load.php | 1 | ||||
| -rw-r--r-- | plugin/memory.php | 1 | ||||
| -rw-r--r-- | plugin/processes.php | 1 | ||||
| -rw-r--r-- | plugin/sensors.php | 1 | ||||
| -rw-r--r-- | plugin/swap.php | 1 | ||||
| -rw-r--r-- | plugin/users.php | 1 | ||||
| -rw-r--r-- | type/Default.class.php | 22 |
13 files changed, 17 insertions, 17 deletions
diff --git a/plugin/cpu.php b/plugin/cpu.php index 04ef3a4..d750a3a 100644 --- a/plugin/cpu.php +++ b/plugin/cpu.php | |||
| @@ -22,7 +22,6 @@ $tinstance = collectd_plugindetail($host, $plugin, 'ti'); | |||
| 22 | 22 | ||
| 23 | $obj = new Type_GenericStacked; | 23 | $obj = new Type_GenericStacked; |
| 24 | $obj->datadir = $CONFIG['datadir']; | 24 | $obj->datadir = $CONFIG['datadir']; |
| 25 | $obj->path_format = '{host}/{plugin}-{pinstance}/{type}-{tinstance}.rrd'; | ||
| 26 | $obj->args = array( | 25 | $obj->args = array( |
| 27 | 'host' => $host, | 26 | 'host' => $host, |
| 28 | 'plugin' => $plugin, | 27 | 'plugin' => $plugin, |
diff --git a/plugin/df.php b/plugin/df.php index 780ca0c..f4dd5d6 100644 --- a/plugin/df.php +++ b/plugin/df.php | |||
| @@ -12,7 +12,6 @@ require_once 'type/GenericStacked.class.php'; | |||
| 12 | 12 | ||
| 13 | $obj = new Type_GenericStacked; | 13 | $obj = new Type_GenericStacked; |
| 14 | $obj->datadir = $CONFIG['datadir']; | 14 | $obj->datadir = $CONFIG['datadir']; |
| 15 | $obj->path_format = '{host}/{plugin}/{type}-{tinstance}.rrd'; | ||
| 16 | $obj->args = array( | 15 | $obj->args = array( |
| 17 | 'host' => $host, | 16 | 'host' => $host, |
| 18 | 'plugin' => $plugin, | 17 | 'plugin' => $plugin, |
diff --git a/plugin/disk.php b/plugin/disk.php index e73cbac..0c18016 100644 --- a/plugin/disk.php +++ b/plugin/disk.php | |||
| @@ -14,7 +14,6 @@ require_once 'type/GenericIO.class.php'; | |||
| 14 | 14 | ||
| 15 | $obj = new Type_GenericIO; | 15 | $obj = new Type_GenericIO; |
| 16 | $obj->datadir = $CONFIG['datadir']; | 16 | $obj->datadir = $CONFIG['datadir']; |
| 17 | $obj->path_format = '{host}/{plugin}-{pinstance}/{type}.rrd'; | ||
| 18 | $obj->args = array( | 17 | $obj->args = array( |
| 19 | 'host' => $host, | 18 | 'host' => $host, |
| 20 | 'plugin' => $plugin, | 19 | 'plugin' => $plugin, |
diff --git a/plugin/entropy.php b/plugin/entropy.php index 58d810b..dcfbcc8 100644 --- a/plugin/entropy.php +++ b/plugin/entropy.php | |||
| @@ -10,7 +10,6 @@ require_once 'type/Default.class.php'; | |||
| 10 | 10 | ||
| 11 | $obj = new Type_Default; | 11 | $obj = new Type_Default; |
| 12 | $obj->datadir = $CONFIG['datadir']; | 12 | $obj->datadir = $CONFIG['datadir']; |
| 13 | $obj->path_format = '{host}/{plugin}/{type}.rrd'; | ||
| 14 | $obj->args = array( | 13 | $obj->args = array( |
| 15 | 'host' => $host, | 14 | 'host' => $host, |
| 16 | 'plugin' => $plugin, | 15 | 'plugin' => $plugin, |
diff --git a/plugin/interface.php b/plugin/interface.php index bda0550..a3fca3d 100644 --- a/plugin/interface.php +++ b/plugin/interface.php | |||
| @@ -13,7 +13,6 @@ require_once 'type/GenericIO.class.php'; | |||
| 13 | 13 | ||
| 14 | $obj = new Type_GenericIO; | 14 | $obj = new Type_GenericIO; |
| 15 | $obj->datadir = $CONFIG['datadir']; | 15 | $obj->datadir = $CONFIG['datadir']; |
| 16 | $obj->path_format = '{host}/{plugin}/{type}-{tinstance}.rrd'; | ||
| 17 | $obj->args = array( | 16 | $obj->args = array( |
| 18 | 'host' => $host, | 17 | 'host' => $host, |
| 19 | 'plugin' => $plugin, | 18 | 'plugin' => $plugin, |
diff --git a/plugin/irq.php b/plugin/irq.php index 6a05245..e442142 100644 --- a/plugin/irq.php +++ b/plugin/irq.php | |||
| @@ -16,7 +16,6 @@ sort($tinstance); | |||
| 16 | 16 | ||
| 17 | $obj = new Type_GenericStacked; | 17 | $obj = new Type_GenericStacked; |
| 18 | $obj->datadir = $CONFIG['datadir']; | 18 | $obj->datadir = $CONFIG['datadir']; |
| 19 | $obj->path_format = '{host}/{plugin}/{type}-{tinstance}.rrd'; | ||
| 20 | $obj->args = array( | 19 | $obj->args = array( |
| 21 | 'host' => $host, | 20 | 'host' => $host, |
| 22 | 'plugin' => $plugin, | 21 | 'plugin' => $plugin, |
diff --git a/plugin/load.php b/plugin/load.php index 17002ea..0246edc 100644 --- a/plugin/load.php +++ b/plugin/load.php | |||
| @@ -10,7 +10,6 @@ require_once 'type/Default.class.php'; | |||
| 10 | 10 | ||
| 11 | $obj = new Type_Default; | 11 | $obj = new Type_Default; |
| 12 | $obj->datadir = $CONFIG['datadir']; | 12 | $obj->datadir = $CONFIG['datadir']; |
| 13 | $obj->path_format = '{host}/{plugin}/{type}.rrd'; | ||
| 14 | $obj->args = array( | 13 | $obj->args = array( |
| 15 | 'host' => $host, | 14 | 'host' => $host, |
| 16 | 'plugin' => $plugin, | 15 | 'plugin' => $plugin, |
diff --git a/plugin/memory.php b/plugin/memory.php index 29f93fe..6cef5a7 100644 --- a/plugin/memory.php +++ b/plugin/memory.php | |||
| @@ -18,7 +18,6 @@ $tinstance = collectd_plugindetail($host, $plugin, 'ti'); | |||
| 18 | 18 | ||
| 19 | $obj = new Type_GenericStacked; | 19 | $obj = new Type_GenericStacked; |
| 20 | $obj->datadir = $CONFIG['datadir']; | 20 | $obj->datadir = $CONFIG['datadir']; |
| 21 | $obj->path_format = '{host}/{plugin}/{type}-{tinstance}.rrd'; | ||
| 22 | $obj->args = array( | 21 | $obj->args = array( |
| 23 | 'host' => $host, | 22 | 'host' => $host, |
| 24 | 'plugin' => $plugin, | 23 | 'plugin' => $plugin, |
diff --git a/plugin/processes.php b/plugin/processes.php index 32a925d..c741a02 100644 --- a/plugin/processes.php +++ b/plugin/processes.php | |||
| @@ -20,7 +20,6 @@ $tinstance = collectd_plugindetail($host, $plugin, 'ti'); | |||
| 20 | 20 | ||
| 21 | $obj = new Type_GenericStacked; | 21 | $obj = new Type_GenericStacked; |
| 22 | $obj->datadir = $CONFIG['datadir']; | 22 | $obj->datadir = $CONFIG['datadir']; |
| 23 | $obj->path_format = '{host}/{plugin}/{type}-{tinstance}.rrd'; | ||
| 24 | $obj->args = array( | 23 | $obj->args = array( |
| 25 | 'host' => $host, | 24 | 'host' => $host, |
| 26 | 'plugin' => $plugin, | 25 | 'plugin' => $plugin, |
diff --git a/plugin/sensors.php b/plugin/sensors.php index c7f038b..b1b15cf 100644 --- a/plugin/sensors.php +++ b/plugin/sensors.php | |||
| @@ -17,7 +17,6 @@ $tinstance = collectd_plugindetail($host, $plugin, 'ti', array('t' => $type)); | |||
| 17 | 17 | ||
| 18 | $obj = new Type_Default; | 18 | $obj = new Type_Default; |
| 19 | $obj->datadir = $CONFIG['datadir']; | 19 | $obj->datadir = $CONFIG['datadir']; |
| 20 | $obj->path_format = '{host}/{plugin}-{pinstance}/{type}-{tinstance}.rrd'; | ||
| 21 | $obj->args = array( | 20 | $obj->args = array( |
| 22 | 'host' => $host, | 21 | 'host' => $host, |
| 23 | 'plugin' => $plugin, | 22 | 'plugin' => $plugin, |
diff --git a/plugin/swap.php b/plugin/swap.php index d1ba823..7160ec3 100644 --- a/plugin/swap.php +++ b/plugin/swap.php | |||
| @@ -17,7 +17,6 @@ $tinstance = collectd_plugindetail($host, $plugin, 'ti'); | |||
| 17 | 17 | ||
| 18 | $obj = new Type_GenericStacked; | 18 | $obj = new Type_GenericStacked; |
| 19 | $obj->datadir = $CONFIG['datadir']; | 19 | $obj->datadir = $CONFIG['datadir']; |
| 20 | $obj->path_format = '{host}/{plugin}/{type}-{tinstance}.rrd'; | ||
| 21 | $obj->args = array( | 20 | $obj->args = array( |
| 22 | 'host' => $host, | 21 | 'host' => $host, |
| 23 | 'plugin' => $plugin, | 22 | 'plugin' => $plugin, |
diff --git a/plugin/users.php b/plugin/users.php index 41d4c25..00874a2 100644 --- a/plugin/users.php +++ b/plugin/users.php | |||
| @@ -10,7 +10,6 @@ require_once 'type/Default.class.php'; | |||
| 10 | 10 | ||
| 11 | $obj = new Type_Default; | 11 | $obj = new Type_Default; |
| 12 | $obj->datadir = $CONFIG['datadir']; | 12 | $obj->datadir = $CONFIG['datadir']; |
| 13 | $obj->path_format = '{host}/{plugin}/{type}.rrd'; | ||
| 14 | $obj->args = array( | 13 | $obj->args = array( |
| 15 | 'host' => $host, | 14 | 'host' => $host, |
| 16 | 'plugin' => $plugin, | 15 | 'plugin' => $plugin, |
diff --git a/type/Default.class.php b/type/Default.class.php index 8a5dd72..f40d12d 100644 --- a/type/Default.class.php +++ b/type/Default.class.php | |||
| @@ -46,14 +46,26 @@ class Type_Default { | |||
| 46 | return $c[r].$c[g].$c[b]; | 46 | return $c[r].$c[g].$c[b]; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | function identifier($host, $plugin, $pinst, $type, $tinst) { | ||
| 50 | $identifier = sprintf('%s/%s%s%s/%s%s%s', $host, | ||
| 51 | $plugin, strlen($pinst) ? '-' : '', $pinst, | ||
| 52 | $type, strlen($tinst) ? '-' : '', $tinst); | ||
| 53 | |||
| 54 | if (is_file($this->datadir.'/'.$identifier.'.rrd')) | ||
| 55 | return $identifier; | ||
| 56 | else | ||
| 57 | return FALSE; | ||
| 58 | } | ||
| 59 | |||
| 49 | function get_filename($tinstance=NULL) { | 60 | function get_filename($tinstance=NULL) { |
| 50 | if (!is_array($this->args['tinstance']) && $tinstance == NULL) | 61 | if (!is_array($this->args['tinstance']) && $tinstance == NULL) |
| 51 | $tinstance = $this->args['tinstance']; | 62 | $tinstance = $this->args['tinstance']; |
| 52 | 63 | ||
| 53 | $search = array('{host}', '{plugin}', '{pinstance}', '{type}', '{tinstance}'); | 64 | $identifier = $this->identifier($this->args['host'], |
| 54 | $replace = array($this->args['host'], $this->args['plugin'], $this->args['pinstance'], $this->args['type'], $tinstance); | 65 | $this->args['plugin'], $this->args['pinstance'], |
| 55 | $f = $this->datadir . '/' . str_replace($search, $replace, $this->path_format); | 66 | $this->args['type'], $tinstance); |
| 56 | return $f; | 67 | |
| 68 | return $this->datadir.'/'.$identifier.'.rrd'; | ||
| 57 | } | 69 | } |
| 58 | 70 | ||
| 59 | function rrd_graph($debug=false) { | 71 | function rrd_graph($debug=false) { |
