aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/type
diff options
context:
space:
mode:
authorPim van den Berg2009-11-04 21:05:37 +0100
committerPim van den Berg2009-11-04 21:05:37 +0100
commitaa454ff4b3d4d5be9d5cc9dff4b4246c6e655f3e (patch)
tree82b5e617ead0c3b50bbb0fb296f280be0b90a61e /type
parentmake dynamic title more detailed (diff)
downloadapt-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.php22
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) {