mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
more db*
git-svn-id: http://www.observium.org/svn/observer/trunk@2312 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
46
attic/purgeports.inc.php
Normal file
46
attic/purgeports.inc.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
# FIXME there's a delete port function in the functions... merge?!
|
||||||
|
function delete_port($interface_id)
|
||||||
|
{
|
||||||
|
$ipaddrs = mysql_query("SELECT * FROM `ipaddr` WHERE `interface_id` = '$interface_id'");
|
||||||
|
while ($ipaddr = mysql_fetch_assoc($ipaddrs))
|
||||||
|
{
|
||||||
|
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr']);
|
||||||
|
mysql_query("DELETE FROM addr WHERE id = '".$addr['id']."'");
|
||||||
|
echo("</div>");
|
||||||
|
}
|
||||||
|
|
||||||
|
$ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'");
|
||||||
|
while ($ip6addr = mysql_fetch_assoc($ip6addrs))
|
||||||
|
{
|
||||||
|
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']);
|
||||||
|
mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'");
|
||||||
|
echo("</div>");
|
||||||
|
}
|
||||||
|
|
||||||
|
$ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'");
|
||||||
|
while ($ip6addr = mysql_fetch_assoc($ip6addrs))
|
||||||
|
{
|
||||||
|
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']);
|
||||||
|
mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'");
|
||||||
|
echo("</div>");
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_query("DELETE FROM `pseudowires` WHERE `interface_id` = '$interface_id'");
|
||||||
|
mysql_query("DELETE FROM `mac_accounting` WHERE `interface_id` = '$interface_id'");
|
||||||
|
mysql_query("DELETE FROM `links` WHERE `local_interface_id` = '$interface_id'");
|
||||||
|
mysql_query("DELETE FROM `links` WHERE `remote_interface_id` = '$interface_id'");
|
||||||
|
mysql_query("DELETE FROM `ports_perms` WHERE `interface_id` = '$interface_id'");
|
||||||
|
mysql_query("DELETE FROM `ports` WHERE `interface_id` = '$interface_id'");
|
||||||
|
}
|
||||||
|
|
||||||
|
$ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'");
|
||||||
|
while ($port = mysql_fetch_assoc($ports))
|
||||||
|
{
|
||||||
|
echo("<div style='font-weight: bold;'>Deleting port " . $port['interface_id'] . " - " . $port['ifDescr']);
|
||||||
|
delete_port($port['interface_id']);
|
||||||
|
echo("</div>");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@@ -7,17 +7,17 @@ foreach (getlocations() as $location)
|
|||||||
|
|
||||||
if ($_SESSION['userlevel'] == '10')
|
if ($_SESSION['userlevel'] == '10')
|
||||||
{
|
{
|
||||||
$num = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "'"),0);
|
$num = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "'");
|
||||||
$net = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'network'"),0);
|
$net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'network'");
|
||||||
$srv = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'server'"),0);
|
$srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'server'");
|
||||||
$fwl = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'firewall'"),0);
|
$fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'firewall'");
|
||||||
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND status = '0'"),0);
|
$hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND status = '0'");
|
||||||
} else {
|
} else {
|
||||||
$num = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "'"),0);
|
$num = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "'");
|
||||||
$net = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND D.type = 'network'"),0);
|
$net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND D.type = 'network'");
|
||||||
$srv = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND type = 'server'"),0);
|
$srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND type = 'server'");
|
||||||
$fwl = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND type = 'firewall'"),0);
|
$fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND type = 'firewall'");
|
||||||
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE location = '" . $location . "' AND status = '0'"),0);
|
$hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE location = '" . $location . "' AND status = '0'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hostalerts) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
|
if ($hostalerts) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
|
||||||
@@ -40,4 +40,4 @@ foreach (getlocations() as $location)
|
|||||||
|
|
||||||
echo("</table>");
|
echo("</table>");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -2,6 +2,25 @@
|
|||||||
|
|
||||||
## Common Functions
|
## Common Functions
|
||||||
|
|
||||||
|
function delete_port($int_id)
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$interface = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE P.interface_id = ? AND D.device_id = P.device_id", array($int_id));
|
||||||
|
|
||||||
|
$interface_tables = array('adjacencies', 'ipaddr', 'ip6adjacencies', 'ip6addr', 'mac_accounting', 'bill_ports', 'pseudowires', 'ports');
|
||||||
|
|
||||||
|
foreach($interface_tables as $table) {
|
||||||
|
dbDelete($table, "`interface_id` = ?", array($int_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
dbDelete('links', "`local_interface_id` = ?", array($int_id));
|
||||||
|
dbDelete('links', "`remote_interface_id` = ?", array($int_id));
|
||||||
|
dbDelete('bill_ports', "`port_id` = ?", array($int_id));
|
||||||
|
|
||||||
|
unlink(trim($config['rrd_dir'])."/".trim($interface['hostname'])."/".$interface['ifIndex'].".rrd");
|
||||||
|
}
|
||||||
|
|
||||||
function sgn($int)
|
function sgn($int)
|
||||||
{
|
{
|
||||||
if ($int < 0)
|
if ($int < 0)
|
||||||
|
@@ -145,25 +145,6 @@ function renamehost($id, $new, $source = 'console')
|
|||||||
log_event("Hostname changed -> $new ($source)", $id, 'system');
|
log_event("Hostname changed -> $new ($source)", $id, 'system');
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_port($int_id)
|
|
||||||
{
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$interface = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE P.interface_id = ? AND D.device_id = P.device_id", array($int_id));
|
|
||||||
|
|
||||||
$interface_tables = array('adjacencies', 'ipaddr', 'ip6adjacencies', 'ip6addr', 'mac_accounting', 'bill_ports', 'pseudowires', 'ports');
|
|
||||||
|
|
||||||
foreach($interface_tables as $table) {
|
|
||||||
dbDelete($table, "`interface_id` = ?", array($int_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
dbDelete('links', "`local_interface_id` = ?", array($int_id));
|
|
||||||
dbDelete('links', "`remote_interface_id` = ?", array($int_id));
|
|
||||||
dbDelete('bill_ports', "`port_id` = ?", array($int_id));
|
|
||||||
|
|
||||||
unlink(trim($config['rrd_dir'])."/".trim($interface['hostname'])."/".$interface['ifIndex'].".rrd");
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete_device($id)
|
function delete_device($id)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
Reference in New Issue
Block a user