mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
host removal code
git-svn-id: http://www.observium.org/svn/observer/trunk@84 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+7
-6
@@ -8,13 +8,14 @@ include("includes/functions.php");
|
|||||||
if($argv[1]) {
|
if($argv[1]) {
|
||||||
$host = strtolower($argv[1]);
|
$host = strtolower($argv[1]);
|
||||||
$id = getidbyname($host);
|
$id = getidbyname($host);
|
||||||
mysql_query("DELETE FROM `devices` WHERE `id` = '$id'");
|
if($id) {
|
||||||
mysql_query("DELETE FROM `interfaces` WHERE `host` = '$id'");
|
delHost($id);
|
||||||
`rm -f rrd/$host-*.rrd`;
|
echo("Removed $host\n");
|
||||||
`./cleanup.php`;
|
} else {
|
||||||
echo("Removed $host");
|
echo("Host doesn't exist!\n");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
echo("Need host to remove!\n\n");
|
echo("Need host to remove!\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ $device_query = mysql_query($sql);
|
|||||||
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
|
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
|
||||||
|
|
||||||
while($device = mysql_fetch_array($device_query)) {
|
while($device = mysql_fetch_array($device_query)) {
|
||||||
$device['uptime'] = mysql_result(mysql_query("SELECT `attrib_value` FROM `devices_attribs` WHERE `device_id` = '" . $device['device_id'] ."' AND `attrib_type` = 'uptime'"), 0);
|
$device['uptime'] = @mysql_result(mysql_query("SELECT `attrib_value` FROM `devices_attribs` WHERE `device_id` = '" . $device['device_id'] ."' AND `attrib_type` = 'uptime'"), 0);
|
||||||
|
|
||||||
include("includes/hostbox.inc");
|
include("includes/hostbox.inc");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,21 +109,25 @@ function delHost($id) {
|
|||||||
|
|
||||||
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
|
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
|
||||||
mysql_query("DELETE FROM `devices` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `devices` WHERE `device_id` = '$id'");
|
||||||
$int_query = mysql_query("SELECT * FROM `interfaces` WHERE `host` = '$id'");
|
$int_query = mysql_query("SELECT * FROM `interfaces` WHERE `device_id` = '$id'");
|
||||||
while($int_data = mysql_fetch_array($int_query)) {
|
while($int_data = mysql_fetch_array($int_query)) {
|
||||||
$int_if = $int_data['if'];
|
$int_if = $int_data['ifDescr'];
|
||||||
$int_id = $int_data['id'];
|
$int_id = $int_data['interface_id'];
|
||||||
mysql_query("DELETE from `adjacencies` WHERE `interface_id` = '$int_id'");
|
mysql_query("DELETE from `adjacencies` WHERE `interface_id` = '$int_id'");
|
||||||
mysql_query("DELETE from `links` WHERE `src_if` = '$int_id'");
|
mysql_query("DELETE from `links` WHERE `src_if` = '$int_id'");
|
||||||
mysql_query("DELETE from `links` WHERE `dst_if` = '$int_id'");
|
mysql_query("DELETE from `links` WHERE `dst_if` = '$int_id'");
|
||||||
mysql_query("DELETE from `ipaddr` WHERE `interface_id` = '$int_id'");
|
mysql_query("DELETE from `ipaddr` WHERE `interface_id` = '$int_id'");
|
||||||
echo("Removed interface $int_id ($int_if)<br />");
|
echo("Removed interface $int_id ($int_if)<br />");
|
||||||
}
|
}
|
||||||
|
mysql_query("DELETE FROM `devices_attribs` WHERE `device_id` = '$id'");
|
||||||
|
mysql_query("DELETE FROM `temperature` WHERE `temp_host` = '$id'");
|
||||||
mysql_query("DELETE FROM `storage` WHERE `host_id` = '$id'");
|
mysql_query("DELETE FROM `storage` WHERE `host_id` = '$id'");
|
||||||
mysql_query("DELETE FROM `alerts` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `alerts` WHERE `device_id` = '$id'");
|
||||||
mysql_query("DELETE FROM `eventlog` WHERE `host` = '$id'");
|
mysql_query("DELETE FROM `eventlog` WHERE `host` = '$id'");
|
||||||
|
mysql_query("DELETE FROM `syslog` WHERE `host` = '$id'");
|
||||||
mysql_query("DELETE FROM `interfaces` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `interfaces` WHERE `device_id` = '$id'");
|
||||||
mysql_query("DELETE FROM `services` WHERE `service_host` = '$id'");
|
mysql_query("DELETE FROM `services` WHERE `service_host` = '$id'");
|
||||||
|
mysql_query("DELETE FROM `alerts` WHERE `device_id` = '$id'");
|
||||||
`rm -f rrd/$host-*.rrd`;
|
`rm -f rrd/$host-*.rrd`;
|
||||||
echo("Removed device $host<br />");
|
echo("Removed device $host<br />");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user