minor code cleanup, change queries to eventlog table to eventlog() function

git-svn-id: http://www.observium.org/svn/observer/trunk@609 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-01-07 16:50:52 +00:00
parent d06a4922fd
commit 6db77f3345
6 changed files with 44 additions and 46 deletions
+9 -1
View File
@@ -357,7 +357,7 @@ function renamehost($id, $new) {
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
shell_exec("mv ".$config['rrd_dir']."/$host ".$config['rrd_dir']."/$new");
mysql_query("UPDATE devices SET hostname = '$new' WHERE device_id = '$id'");
mysql_query("INSERT INTO eventlog (host, datetime, message) VALUES ('" . $id . "', NULL, NOW(), 'Hostname changed -> $new (console)')");
eventlog("Hostname changed -> $new (console)", $id);
}
function delHost($id)
@@ -734,5 +734,13 @@ function get_astext($asn)
$txt = explode('|',$result[0]['txt']);
return trim(str_replace('"', '', $txt[4]));
}
function eventlog($eventtext,$device_id = "", $interface_id = "")
{
$event_query = "INSERT INTO eventlog (host, interface, datetime, message) VALUES (" . ($device_id ? $device_id : "NULL");
$event_query .= ", " . ($interface_id ? $interface_id : "NULL") . ", NOW(), '" . mysql_escape_string($eventtext) . "')";
echo "$event_query\n";
mysql_query($event_query);
}
?>