diff --git a/database-update.sql b/database-update.sql
index 10a03ab6c..69ceded35 100644
--- a/database-update.sql
+++ b/database-update.sql
@@ -102,3 +102,5 @@ ALTER TABLE `links` CHANGE `vendor` `protocol` VARCHAR( 11 ) CHARACTER SET latin
ALTER TABLE `processors` CHANGE `processor_type` `processor_type` varchar(16) NOT NULL;
ALTER TABLE `bgpPeers_cbgp` CHANGE `afi` `afi` VARCHAR( 16 ) NOT NULL , CHANGE `safi` `safi` VARCHAR( 16 ) NOT NULL;
ALTER TABLE `eventlog` ADD `reference` VARCHAR( 64 ) NOT NULL AFTER `type`;
+ALTER TABLE `syslog` CHANGE `datetime` `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
+ALTER TABLE `syslog` DROP `host`, DROP `processed`;
diff --git a/html/includes/print-syslog.inc b/html/includes/print-syslog.inc
index 9c25aad1e..67bf695e1 100644
--- a/html/includes/print-syslog.inc
+++ b/html/includes/print-syslog.inc
@@ -5,10 +5,6 @@
$syslog_iter++;
if(!is_integer($syslog_iter/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
-
- if(!$entry['processed']) { $entry = process_syslog($entry, 1); }
- if(!$entry['deleted']) {
-
echo("
| ");
@@ -27,6 +23,4 @@ if(!is_integer($syslog_iter/2)) { $bg_colour = $list_colour_a; } else { $bg_colo
|
");
- }
-
?>
diff --git a/html/pages/default-jt.php b/html/pages/default-jt.php
index 3aed39019..d3e442ee6 100644
--- a/html/pages/default-jt.php
+++ b/html/pages/default-jt.php
@@ -91,7 +91,7 @@ if($config['frontpage_display'] == 'syslog') {
Recent Syslog Messages
");
- $sql = "SELECT *, DATE_FORMAT(datetime, '%D %b %T') AS date from syslog ORDER BY datetime DESC LIMIT 20";
+ $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
$query = mysql_query($sql);
echo("");
while($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
diff --git a/html/pages/device/syslog.inc.php b/html/pages/device/syslog.inc.php
index 8716a0ce2..eb8d6518c 100644
--- a/html/pages/device/syslog.inc.php
+++ b/html/pages/device/syslog.inc.php
@@ -37,8 +37,8 @@ if($_POST['program']) {
$where .= " AND program = '".$_POST['program']."'";
}
-$sql = "SELECT *, DATE_FORMAT(datetime, '%D %b %T') AS date from syslog WHERE device_id = '" . $_GET['id'] . "' $where";
-$sql .= " ORDER BY datetime DESC LIMIT 1000";
+$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog WHERE device_id = '" . $_GET['id'] . "' $where";
+$sql .= " ORDER BY timestamp DESC LIMIT 1000";
$query = mysql_query($sql);
echo("");
while($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
diff --git a/html/pages/front/default.php b/html/pages/front/default.php
index 14a508e60..08fc56c4c 100644
--- a/html/pages/front/default.php
+++ b/html/pages/front/default.php
@@ -99,7 +99,7 @@ if($config['enable_syslog']) {
Recent Syslog Messages
");
- $sql = "SELECT *, DATE_FORMAT(datetime, '%D %b %T') AS date from syslog ORDER BY datetime DESC LIMIT 20";
+ $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
$query = mysql_query($sql);
echo("");
while($entry = mysql_fetch_array($query)) {
diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php
index 2706db9e9..77e5edf17 100644
--- a/html/pages/front/demo.php
+++ b/html/pages/front/demo.php
@@ -72,8 +72,8 @@ echo("
Recent Syslog Messages
");
-$sql = "SELECT *, DATE_FORMAT(datetime, '%D %b %T') AS date from syslog AS S, devices AS D
- WHERE S.device_id = D.device_id ORDER BY datetime DESC LIMIT 20";
+$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog AS S, devices AS D
+ WHERE S.device_id = D.device_id ORDER BY timestamp DESC LIMIT 20";
$query = mysql_query($sql);
echo("");
while($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php
index 52f14801d..fa0a02743 100644
--- a/html/pages/front/example2.php
+++ b/html/pages/front/example2.php
@@ -93,7 +93,7 @@ echo("
");
-$sql = "SELECT *, DATE_FORMAT(datetime, '%D %b %T') AS date from syslog ORDER BY datetime DESC LIMIT 20";
+$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
$query = mysql_query($sql);
echo("");
while($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php
index 4a2046ac5..23befc982 100644
--- a/html/pages/front/jt.php
+++ b/html/pages/front/jt.php
@@ -93,7 +93,7 @@ echo("
");
-$sql = "SELECT *, DATE_FORMAT(datetime, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
+$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
$query = mysql_query($sql);
echo("");
while($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); }
diff --git a/html/pages/syslog.php b/html/pages/syslog.php
index c68aece9c..6b433dec1 100644
--- a/html/pages/syslog.php
+++ b/html/pages/syslog.php
@@ -60,11 +60,11 @@ if($_POST['device']) {
}
if($_SESSION['userlevel'] >= '5') {
- $sql = "SELECT *, DATE_FORMAT(datetime, '%D %b %T') AS date from syslog AS S, devices AS D
- WHERE S.device_id = D.device_id $where ORDER BY datetime DESC LIMIT 1000";
+ $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog AS S, devices AS D
+ WHERE S.device_id = D.device_id $where ORDER BY timestamp DESC LIMIT 1000";
} else {
- $sql = "SELECT *, DATE_FORMAT(datetime, '%D %b %T') AS date from syslog AS S, devices AS D, devices_perms AS P
- WHERE S.device_id = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " AND S.device_id = D.device_id $where ORDER BY datetime DESC LIMIT 1000";
+ $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog AS S, devices AS D, devices_perms AS P
+ WHERE S.device_id = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " AND S.device_id = D.device_id $where ORDER BY timestamp DESC LIMIT 1000";
}
$query = mysql_query($sql);
diff --git a/includes/syslog.php b/includes/syslog.php
index a2a31d47f..943f79c81 100755
--- a/includes/syslog.php
+++ b/includes/syslog.php
@@ -65,15 +65,11 @@ function process_syslog ($entry, $update) {
}
}
$x = "UPDATE `syslog` set `device_id` = '".$entry['device_id']."', `program` = '".$entry['program']."', `msg` = '" . mysql_real_escape_string($entry['msg']) . "', processed = '1' WHERE `seq` = '" . $entry['seq'] . "'";
- $entry['processed'] = 1;
+ $x = "INSERT INTO `syslog` (`device_id`,`program`,`facility`,`priority`, `level`, `tag`, `msg`, `timestamp`) ";
+ $x .= "VALUES ('".$entry['device_id']."','".$entry['program']."','".$entry['facility']."','".$entry['priority']."', '".$entry['level']."', '".$entry['tag']."', '".$entry['msg']."','".$entry['timestamp']."')";
if($update) { mysql_query($x); }
+ if(mysql_affected_rows() > "0") { shell_exec("echo written $x >> /tmp/syslog"); } else { echo(mysql_error()); }
unset ($fix);
- } else {
- $x = "DELETE FROM `syslog` where `seq` = '" . $entry['seq'] . "'";
- if($update) { mysql_query($x);}
-
- $entry['deleted'] = '1';
-
}
return $entry;
diff --git a/process-syslog.php b/process-syslog.php
deleted file mode 100755
index 632984499..000000000
--- a/process-syslog.php
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/php
-
diff --git a/syslog.php b/syslog.php
new file mode 100755
index 000000000..2536f9873
--- /dev/null
+++ b/syslog.php
@@ -0,0 +1,29 @@
+#!/usr/bin/php
+> /tmp/syslog`;
+ list($entry['host'],$entry['facility'],$entry['priority'], $entry['level'], $entry['tag'], $entry['timestamp'], $entry['msg']) = explode("||", trim($line));
+ shell_exec('echo "'.$i.'. '.$entry['host'].' -> '.$entry['msg'].'" >> /tmp/syslog');
+
+ process_syslog($entry, 1);
+
+ unset($entry); unset($line);
+ $i++;
+}
+
+?>