diff options
Diffstat (limited to '')
-rw-r--r-- | conf/config.php | 2 | ||||
-rw-r--r-- | inc/collectd.inc.php | 39 |
2 files changed, 24 insertions, 17 deletions
diff --git a/conf/config.php b/conf/config.php index b086455..223028d 100644 --- a/conf/config.php +++ b/conf/config.php | |||
@@ -7,7 +7,7 @@ $CONFIG['version'] = 5; | |||
7 | $CONFIG['datadir'] = '/var/lib/collectd/rrd'; | 7 | $CONFIG['datadir'] = '/var/lib/collectd/rrd'; |
8 | 8 | ||
9 | # location of the types.db file | 9 | # location of the types.db file |
10 | $CONFIG['typesdb'] = '/usr/share/collectd/types.db'; | 10 | $CONFIG['typesdb'][] = '/usr/share/collectd/types.db'; |
11 | 11 | ||
12 | # rrdtool executable | 12 | # rrdtool executable |
13 | $CONFIG['rrdtool'] = '/usr/bin/rrdtool'; | 13 | $CONFIG['rrdtool'] = '/usr/bin/rrdtool'; |
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index 695d79c..bbed611 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php | |||
@@ -168,25 +168,32 @@ function plugin_sort($data) { | |||
168 | return $data; | 168 | return $data; |
169 | } | 169 | } |
170 | 170 | ||
171 | function parse_typesdb_file($file = '/usr/share/collectd/types.db') { | 171 | function parse_typesdb_file($file = array('/usr/share/collectd/types.db')) { |
172 | if (!file_exists($file)) | 172 | if (!is_array($file)) |
173 | $file = 'inc/types.db'; | 173 | $file = array($file); |
174 | if (!file_exists($file[0])) | ||
175 | $file[0] = 'inc/types.db'; | ||
174 | 176 | ||
175 | $types = array(); | 177 | $types = array(); |
176 | foreach (file($file) as $type) { | 178 | foreach ($file as $single_file) |
177 | if(!preg_match('/^(?P<dataset>[\w_]+)\s+(?P<datasources>.*)/', $type, $matches)) | 179 | { |
180 | if (!file_exists($single_file)) | ||
178 | continue; | 181 | continue; |
179 | $dataset = $matches['dataset']; | 182 | foreach (file($single_file) as $type) { |
180 | $datasources = explode(', ', $matches['datasources']); | 183 | if(!preg_match('/^(?P<dataset>[\w_]+)\s+(?P<datasources>.*)/', $type, $matches)) |
181 | 184 | continue; | |
182 | foreach ($datasources as $ds) { | 185 | $dataset = $matches['dataset']; |
183 | if (!preg_match('/^(?P<dsname>\w+):(?P<dstype>[\w]+):(?P<min>[\-\dU\.]+):(?P<max>[\dU\.]+)/', $ds, $matches)) | 186 | $datasources = explode(', ', $matches['datasources']); |
184 | error_log(sprintf('CGP Error: DS "%s" from dataset "%s" did not match', $ds, $dataset)); | 187 | |
185 | $types[$dataset][$matches['dsname']] = array( | 188 | foreach ($datasources as $ds) { |
186 | 'dstype' => $matches['dstype'], | 189 | if (!preg_match('/^(?P<dsname>\w+):(?P<dstype>[\w]+):(?P<min>[\-\dU\.]+):(?P<max>[\dU\.]+)/', $ds, $matches)) |
187 | 'min' => $matches['min'], | 190 | error_log(sprintf('CGP Error: DS "%s" from dataset "%s" did not match', $ds, $dataset)); |
188 | 'max' => $matches['max'], | 191 | $types[$dataset][$matches['dsname']] = array( |
189 | ); | 192 | 'dstype' => $matches['dstype'], |
193 | 'min' => $matches['min'], | ||
194 | 'max' => $matches['max'], | ||
195 | ); | ||
196 | } | ||
190 | } | 197 | } |
191 | } | 198 | } |
192 | return $types; | 199 | return $types; |