Introduce own librenms user and remove rrds when removing a device

This commit is contained in:
f0o
2015-05-19 14:25:17 +00:00
parent 66297e1a19
commit 1f8db156eb
7 changed files with 53 additions and 8 deletions

View File

@@ -240,6 +240,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 +263,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;