Merge branch 'master' of github.com:laf/librenms into issue-laf-110-new

Conflicts:
	includes/defaults.inc.php
This commit is contained in:
laf
2015-05-25 18:06:49 +01:00
189 changed files with 106921 additions and 56791 deletions

View File

@@ -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"); }