mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge branch 'master' of github.com:laf/librenms into issue-laf-110-new
Conflicts: includes/defaults.inc.php
This commit is contained in:
@@ -229,9 +229,13 @@ function renamehost($id, $new, $source = 'console')
|
||||
|
||||
// FIXME does not check if destination exists!
|
||||
$host = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id));
|
||||
rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new");
|
||||
dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id));
|
||||
log_event("Hostname changed -> $new ($source)", $id, 'system');
|
||||
if (rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new") === TRUE) {
|
||||
dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id));
|
||||
log_event("Hostname changed -> $new ($source)", $id, 'system');
|
||||
} else {
|
||||
echo "Renaming of $host failed\n";
|
||||
log_event("Renaming of $host failed", $id, 'system');
|
||||
}
|
||||
}
|
||||
|
||||
function delete_device($id)
|
||||
@@ -240,6 +244,9 @@ function delete_device($id)
|
||||
$ret = '';
|
||||
|
||||
$host = dbFetchCell("SELECT hostname FROM devices WHERE device_id = ?", array($id));
|
||||
if( empty($host) ) {
|
||||
return "No such host.";
|
||||
}
|
||||
|
||||
foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data)
|
||||
{
|
||||
@@ -260,7 +267,11 @@ function delete_device($id)
|
||||
}
|
||||
}
|
||||
|
||||
shell_exec("rm -rf ".trim($config['rrd_dir'])."/$host");
|
||||
$ex = shell_exec("bash -c '( [ ! -d ".trim($config['rrd_dir'])."/".$host." ] || rm -vrf ".trim($config['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";
|
||||
}
|
||||
|
||||
$ret .= "Removed device $host\n";
|
||||
return $ret;
|
||||
@@ -274,9 +285,6 @@ function addHost($host, $snmpver, $port = '161', $transport = 'udp', $quiet = '0
|
||||
// Test Database Exists
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `devices` WHERE `hostname` = ?", array($host)) == '0')
|
||||
{
|
||||
// Test if IP or Hostname
|
||||
if (!(inet_pton($host)))
|
||||
{
|
||||
// Test reachability
|
||||
if ($force_add == 1 || isPingable($host))
|
||||
{
|
||||
@@ -361,10 +369,6 @@ function addHost($host, $snmpver, $port = '161', $transport = 'udp', $quiet = '0
|
||||
// failed Reachability
|
||||
if($quiet == '0') { print_error("Could not ping $host"); }
|
||||
}
|
||||
} else {
|
||||
// Failed DNS lookup
|
||||
if($quiet == '0') { print_error("$host looks like an IP address, please use FQDN"); }
|
||||
}
|
||||
} else {
|
||||
// found in database
|
||||
if($quiet == '0') { print_error("Already got host $host"); }
|
||||
|
Reference in New Issue
Block a user