mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Move to fixed DS names in MIB-based polling; add script to convert RRDs
This commit is contained in:
17
contrib/convert-mib-graphs.sh
Executable file
17
contrib/convert-mib-graphs.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Script to convert RRDs from the experimental first release of MIB-based polling.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
for i; do
|
||||||
|
base=${i%%.rrd}
|
||||||
|
mv $i $i.old
|
||||||
|
echo "Processing $i"
|
||||||
|
rrdtool dump $i.old | sed -e 's|<name>.*</name>|<name>mibval</name>|' > $base.xml
|
||||||
|
rrdtool restore $base.xml $i
|
||||||
|
rm -f $base.xml
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
@ -16,14 +16,12 @@ $rrd_list = array();
|
|||||||
$prefix = rrd_name($device['hostname'], array($subtype, ''), '');
|
$prefix = rrd_name($device['hostname'], array($subtype, ''), '');
|
||||||
foreach (glob($prefix.'*.rrd') as $filename) {
|
foreach (glob($prefix.'*.rrd') as $filename) {
|
||||||
// find out what * expanded to
|
// find out what * expanded to
|
||||||
$globpart = str_replace($prefix, '', $filename);
|
$globpart = str_replace($prefix, '', $filename); // take off the prefix
|
||||||
// take off the prefix
|
$instance = substr($globpart, 0, -4); // take off ".rrd"
|
||||||
$instance = substr($globpart, 0, -4);
|
|
||||||
// take off ".rrd"
|
|
||||||
$ds = array();
|
$ds = array();
|
||||||
$mibparts = explode('-', $subtype);
|
$mibparts = explode('-', $subtype);
|
||||||
$mibvar = end($mibparts);
|
$mibvar = end($mibparts);
|
||||||
$ds['ds'] = name_shorten($mibvar);
|
$ds['ds'] = 'mibval';
|
||||||
$ds['descr'] = "$mibvar-$instance";
|
$ds['descr'] = "$mibvar-$instance";
|
||||||
$ds['filename'] = $filename;
|
$ds['filename'] = $filename;
|
||||||
$rrd_list[] = $ds;
|
$rrd_list[] = $ds;
|
||||||
|
@ -611,25 +611,6 @@ function d_print_r($var, $no_debug_text = null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Shorten the name so it works as an RRD data source name (limited to 19 chars by default).
|
|
||||||
* Substitute for $subst if necessary.
|
|
||||||
* @return the shortened name
|
|
||||||
*/
|
|
||||||
function name_shorten($name, $common = null, $subst = "mibval", $len = 19) {
|
|
||||||
if ($common !== null) {
|
|
||||||
// remove common from the beginning of the string, if present
|
|
||||||
if (strlen($name) > $len && strpos($name, $common) >= 0) {
|
|
||||||
$newname = str_replace($common, '', $name);
|
|
||||||
$name = $newname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strlen($name) > $len) {
|
|
||||||
$name = $subst;
|
|
||||||
}
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @return the name of the rrd file for $host's $extra component
|
* @return the name of the rrd file for $host's $extra component
|
||||||
* @param host Host name
|
* @param host Host name
|
||||||
|
@ -828,7 +828,6 @@ function snmp_mib_parse($oid, $mib, $module, $mibdir=null) {
|
|||||||
if ($f[1] && $f[1] == 'OBJECT-TYPE') {
|
if ($f[1] && $f[1] == 'OBJECT-TYPE') {
|
||||||
$result['object_type'] = $f[0];
|
$result['object_type'] = $f[0];
|
||||||
$result['shortname'] = str_replace($mib, '', $f[0]);
|
$result['shortname'] = str_replace($mib, '', $f[0]);
|
||||||
$result['dsname'] = name_shorten($f[0], $mib);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,8 +1080,8 @@ function save_mibs($device, $mibname, $oids, $mibdef, &$graphs) {
|
|||||||
$mibdef[$oid]['shortname'],
|
$mibdef[$oid]['shortname'],
|
||||||
$index,
|
$index,
|
||||||
),
|
),
|
||||||
array('DS:'.$mibdef[$oid]['dsname'].":$type"),
|
array("DS:mibval:$type"),
|
||||||
array($mibdef[$oid]['dsname'] => $val)
|
array("mibval" => $val)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user