mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix: Fixed IPv6 host renaming (#7275)
* Fixed IPv6 host renaming * Added get_rrd_dir() and modified other files to use it where appropriate. * rrd_name() now uses the new function get_rrd_dir(), to make it simpler to modify the escaping in the future. * Wrong function name in rrdstep.php
This commit is contained in:
@@ -8,7 +8,7 @@ $bigdescrlen = 15;
|
||||
$smalldescrlen = 15;
|
||||
$dostack = 0;
|
||||
$printtotal = 0;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfsstats-'.$app['app_id'].'.rrd';
|
||||
$rrd_filename = get_rrd_dir($device['hostname']).'/app-nfsstats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'total' => array(
|
||||
'descr' => 'Total',
|
||||
|
||||
@@ -10,7 +10,7 @@ $dostack = 0;
|
||||
$printtotal = 0;
|
||||
$addarea = 1;
|
||||
$transparency = 33;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$rrd_filename = get_rrd_dir($device['hostname']).'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'fh_lookup' => array('descr' => 'lookup','colour' => '136421',),
|
||||
'fh_anon' => array('descr' => 'anon','colour' => 'B2C945',),
|
||||
|
||||
@@ -10,7 +10,7 @@ $dostack = 0;
|
||||
$printtotal = 0;
|
||||
$addarea = 1;
|
||||
$transparency = 33;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$rrd_filename = get_rrd_dir($device['hostname']).'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'io_read' => array('descr' => 'read','colour' => '2B9220',),
|
||||
'io_write' => array('descr' => 'write','colour' => 'B0262D',),
|
||||
|
||||
@@ -10,7 +10,7 @@ $dostack = 0;
|
||||
$printtotal = 0;
|
||||
$addarea = 1;
|
||||
$transparency = 33;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$rrd_filename = get_rrd_dir($device['hostname']).'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'net_all' => array('descr' => 'total','colour' => '000000',),
|
||||
'net_udp' => array('descr' => 'udp','colour' => 'AA3F39',),
|
||||
|
||||
@@ -10,7 +10,7 @@ $dostack = 0;
|
||||
$printtotal = 0;
|
||||
$addarea = 1;
|
||||
$transparency = 33;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$rrd_filename = get_rrd_dir($device['hostname']).'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'ra_size' => array('descr' => 'size','colour' => '091B40',),
|
||||
'ra_range01' => array('descr' => '0-10','colour' => '8293B3',),
|
||||
|
||||
@@ -10,7 +10,7 @@ $dostack = 0;
|
||||
$printtotal = 0;
|
||||
$addarea = 1;
|
||||
$transparency = 33;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$rrd_filename = get_rrd_dir($device['hostname']).'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'rc_hits' => array('descr' => 'hits','colour' => '2B9220',),
|
||||
'rc_misses' => array('descr' => 'misses','colour' => 'B36326',),
|
||||
|
||||
@@ -10,7 +10,7 @@ $dostack = 0;
|
||||
$printtotal = 0;
|
||||
$addarea = 1;
|
||||
$transparency = 33;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$rrd_filename = get_rrd_dir($device['hostname']).'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'rpc_calls' => array('descr' => 'calls','colour' => '000000',),
|
||||
'rpc_badcalls' => array('descr' => 'bad calls','colour' => '600604',),
|
||||
|
||||
@@ -10,7 +10,7 @@ $dostack = 0;
|
||||
$printtotal = 0;
|
||||
$addarea = 1;
|
||||
$transparency = 33;
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$rrd_filename = get_rrd_dir($device['hostname']).'/app-nfs-stats-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'proc3_null' => array('descr' => 'Null','colour' => '630606',),
|
||||
'proc3_getattr' => array('descr' => 'Get attributes','colour' => '50C150',),
|
||||
|
||||
@@ -15,7 +15,7 @@ $sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars[
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
$rrd_options .= ' -l 0 -E ';
|
||||
$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd');
|
||||
$rrd_filename = get_rrd_dir($device['hostname'])."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd');
|
||||
|
||||
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
|
||||
@@ -213,7 +213,7 @@ if ($updated && $update_message) {
|
||||
</script>
|
||||
<?php
|
||||
print_optionbar_start();
|
||||
list($sizeondisk, $numrrds) = foldersize($config['rrd_dir']."/".$device['hostname']);
|
||||
list($sizeondisk, $numrrds) = foldersize(get_rrd_dir($device['hostname']));
|
||||
echo("Size on Disk: <b>" . formatStorage($sizeondisk) . "</b> in <b>" . $numrrds . " RRD files</b>.");
|
||||
print_optionbar_end();
|
||||
?>
|
||||
|
||||
@@ -318,7 +318,7 @@ function renamehost($id, $new, $source = 'console')
|
||||
global $config;
|
||||
|
||||
$host = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id));
|
||||
if (!is_dir($config['rrd_dir']."/$new") && rename($config['rrd_dir']."/$host", $config['rrd_dir']."/$new") === true) {
|
||||
if (!is_dir(get_rrd_dir($new)) && rename(get_rrd_dir($host), get_rrd_dir($new)) === true) {
|
||||
dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id));
|
||||
log_event("Hostname changed -> $new ($source)", $id, 'system', 3);
|
||||
} else {
|
||||
@@ -374,7 +374,7 @@ function delete_device($id)
|
||||
}
|
||||
}
|
||||
|
||||
$ex = shell_exec("bash -c '( [ ! -d ".trim($config['rrd_dir'])."/".$host." ] || rm -vrf ".trim($config['rrd_dir'])."/".$host." 2>&1 ) && echo -n OK'");
|
||||
$ex = shell_exec("bash -c '( [ ! -d ".trim(get_rrd_dir($host))." ] || rm -vrf ".trim(get_rrd_dir($host))." 2>&1 ) && echo -n OK'");
|
||||
$tmp = explode("\n", $ex);
|
||||
if ($tmp[sizeof($tmp)-1] != "OK") {
|
||||
$ret .= "Could not remove files:\n$ex\n";
|
||||
|
||||
@@ -300,10 +300,24 @@ function rrd_name($host, $extra, $extension = ".rrd")
|
||||
{
|
||||
global $config;
|
||||
$filename = safename(is_array($extra) ? implode("-", $extra) : $extra);
|
||||
$host = str_replace(':', '_', trim($host, '[]'));
|
||||
return implode("/", array($config['rrd_dir'], $host, $filename.$extension));
|
||||
return implode("/", array(get_rrd_dir($host), $filename.$extension));
|
||||
} // rrd_name
|
||||
|
||||
|
||||
/**
|
||||
* Generates a path based on the hostname (or IP)
|
||||
*
|
||||
* @param string $host Host name
|
||||
* @return string the name of the rrd directory for $host
|
||||
*/
|
||||
function get_rrd_dir($host)
|
||||
{
|
||||
global $config;
|
||||
$host = str_replace(':', '_', trim($host, '[]'));
|
||||
return implode("/", array($config['rrd_dir'], $host));
|
||||
} // rrd_dir
|
||||
|
||||
|
||||
/**
|
||||
* Generates a filename for a proxmox cluster rrd
|
||||
*
|
||||
|
||||
@@ -51,14 +51,13 @@ if (empty($hostname)) {
|
||||
|
||||
$step = $config['rrd']['step'];
|
||||
$heartbeat = $config['rrd']['heartbeat'];
|
||||
$rrd_path = $config['rrd_dir'];
|
||||
$rrdtool = $config['rrdtool'];
|
||||
$tmp_path = $config['temp_dir'];
|
||||
|
||||
if ($hostname === 'all') {
|
||||
$hostname = '*';
|
||||
}
|
||||
$files = glob($rrd_path . '/' . $hostname . '/*.rrd');
|
||||
$files = glob(get_rrd_dir($hostname) . '/*.rrd');
|
||||
|
||||
$run = readline("Are you sure you want to run this command [N/y]: ");
|
||||
if (!($run == 'y' || $run == 'Y')) {
|
||||
|
||||
Reference in New Issue
Block a user