diff options
| -rw-r--r-- | inc/collectd.inc.php | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index f5769c0..7f88456 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php | |||
| @@ -31,31 +31,18 @@ function collectd_plugindata($host) { | |||
| 31 | if (!$files) | 31 | if (!$files) |
| 32 | return false; | 32 | return false; |
| 33 | 33 | ||
| 34 | $data; | 34 | $data = array(); |
| 35 | $i = 0; | ||
| 36 | foreach($files as $item) { | 35 | foreach($files as $item) { |
| 37 | unset($part); | 36 | preg_match('#([\w_]+)(?:\-(.+))?/([\w_]+)(?:\-(.+))?\.rrd#', $item, $matches); |
| 38 | 37 | ||
| 39 | # split item by plugin/type | 38 | $data[] = array( |
| 40 | $part = explode('/', $item); | 39 | 'p' => $matches[1], |
| 41 | $part[1] = preg_replace('/\.rrd/', '', $part[1]); | 40 | 'pi' => isset($matches[2]) ? $matches[2] : '', |
| 42 | 41 | 't' => $matches[3], | |
| 43 | # plugin | 42 | 'ti' => isset($matches[4]) ? $matches[4] : '', |
| 44 | $data[$i]['p'] = preg_replace('/-.+/', '', $part[0]); | 43 | ); |
| 45 | |||
| 46 | # plugin instance | ||
| 47 | if(preg_match('/-/', $part[0])) | ||
| 48 | $data[$i]['pi'] = preg_replace('/^[a-z_]+\-/', '', $part[0]); | ||
| 49 | |||
| 50 | # type | ||
| 51 | $data[$i]['t'] = preg_replace('/-.+/', '', $part[1]); | ||
| 52 | |||
| 53 | # type instance | ||
| 54 | if(preg_match('/-/', $part[1])) | ||
| 55 | $data[$i]['ti'] = preg_replace('/^[a-z_]+\-/', '', $part[1]); | ||
| 56 | |||
| 57 | $i++; | ||
| 58 | } | 44 | } |
| 45 | |||
| 59 | return($data); | 46 | return($data); |
| 60 | } | 47 | } |
| 61 | 48 | ||
