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 /type | |
| 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 'type')
| -rw-r--r-- | type/Default.class.php | 22 |
1 files changed, 17 insertions, 5 deletions
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) { |
