From f33bca5e3e10ee1a088de8f2cce4fb0f555165fe Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 26 Nov 2008 14:01:09 +0000 Subject: [PATCH] better logon process git-svn-id: http://www.observium.org/svn/observer/trunk@318 61d68cd4-352d-0410-923a-c4978735b2b8 --- contrib/syslog-ng.conf | 10 +++----- html/includes/authenticate.inc | 3 ++- html/includes/print-menubar.php | 7 ++++++ html/pages/authlog.php | 43 +++++++++++++++++++++++++++++++++ includes/syslog.php | 10 +++++--- mibs/.index | 7 ++++++ mysql-schema.sql | 13 ++++++++++ test-discovery.php | 4 +-- 8 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 html/pages/authlog.php diff --git a/contrib/syslog-ng.conf b/contrib/syslog-ng.conf index 6637e2652..5a1562ef5 100644 --- a/contrib/syslog-ng.conf +++ b/contrib/syslog-ng.conf @@ -23,12 +23,10 @@ source s_net { udp(); }; -destination d_mysql { - pipe("/var/log/observer-mysql.pipe" - template("INSERT INTO syslog - (host, facility, priority, level, tag, datetime, program, msg) - VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC','$PROGRAM', '$MSG' );\n") template-escape(yes)); -}; +destination d_mysql { program("/usr/bin/mysql -u -p " template("INSERT + INTO syslog (host, facility, priority, level, tag, datetime, program, msg) + VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC', '$PROGRAM', '$MSG' );\n") template-escape(yes)); +}; log { source(s_net); diff --git a/html/includes/authenticate.inc b/html/includes/authenticate.inc index b7c48daec..0011d03de 100644 --- a/html/includes/authenticate.inc +++ b/html/includes/authenticate.inc @@ -30,8 +30,9 @@ if($_GET['logout']) { if($userlevel) { $_SESSION['userlevel'] = $userlevel; $_SESSION['authenticated'] = true; - $_SESSION['username'] = $_POST['username']; + $_SESSION['username'] = $username; mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('$username', '".$_SERVER["REMOTE_ADDR"]."', 'logged in')"); + header("Location: ".$_SERVER['REQUEST_URI']); } else { $auth_message = "Authentication Failed"; mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('$username', '".$_SERVER["REMOTE_ADDR"]."', 'authentication failure')"); diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 6eda3f098..4e73df02f 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -35,6 +35,13 @@ } ?>
  • Alerts
  • Inventory
  • += '10') { + echo(" + +
  • Authlog
  • "); +} +?> diff --git a/html/pages/authlog.php b/html/pages/authlog.php new file mode 100644 index 000000000..04a4e53db --- /dev/null +++ b/html/pages/authlog.php @@ -0,0 +1,43 @@ +"); + +while($entry = mysql_fetch_array($data)) { + + if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } + + echo(" + + " . $entry['datetime'] . " + + + ".$entry['user']." + + + ".$entry['address']." + + + ".$entry['result']." + + + "); + + +} + +echo(""); + +} else { + + + +} + +?> diff --git a/includes/syslog.php b/includes/syslog.php index 74d976ba1..eb888a688 100755 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -24,10 +24,13 @@ function process_syslog ($entry, $update) { if($device_id && !$delete) { $entry['device_id'] = $device_id; if(mysql_result(mysql_query("SELECT `os` FROM `devices` WHERE `device_id` = '$device_id'"),0) == "IOS") { - list(,$entry[msg]) = split(": %", $entry['msg']); - $entry['msg'] = "%" . $entry['msg']; - $entry['msg'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']); + if(strstr($entry[msg], "%")) { + list(,$entry[msg]) = split(": %", $entry['msg']); + $entry['msg'] = "%" . $entry['msg']; + $entry['msg'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']); + } else { $entry['msg'] = "||" . $entry['msg']; } list($entry['program'], $entry['msg']) = explode("||", $entry['msg']); + $entry['msg'] = preg_replace("/^[0-9]+:/", "", $entry['msg']); } else { $program = preg_quote($entry['program'],'/'); $entry['msg'] = preg_replace("/^$program:\ /", "", $entry['msg']); @@ -36,7 +39,6 @@ function process_syslog ($entry, $update) { list($entry['program'], $entry['msg']) = explode("||", $entry['msg']); } } - $x = "UPDATE `syslog` set `device_id` = '$device_id', `program` = '".$entry['program']."', `msg` = '" . mysql_real_escape_string($entry['msg']) . "', processed = '1' WHERE `seq` = '" . $entry['seq'] . "'"; $entry['processed'] = 1; if($update) { mysql_query($x); } diff --git a/mibs/.index b/mibs/.index index b73a7f46c..fafbba3c7 100644 --- a/mibs/.index +++ b/mibs/.index @@ -1,8 +1,11 @@ NETSCREEN-SET-LOG-MIB NS-SET-LOG.mib NETSCREEN-ADDR-MIB NS-ADDR.mib +CISCO-FRAME-RELAY-MIB CISCO-FRAME-RELAY-MIB.my CISCO-IETF-PW-ENET-MIB CISCO-IETF-PW-ENET-MIB.my NETSCREEN-SET-DHCP-MIB NS-SET-DHCP.mib CISCO-TCP-STD-CAPABILITY CISCO-TCP-STD-CAPABILITY.my +P-BRIDGE-MIB P-BRIDGE-MIB +CISCO-CLASS-BASED-QOS-MIB CISCO-CLASS-BASED-QOS-MIB.my ADSL-LINE-MIB ADSL-LINE-MIB.my NETSCREEN-IDS-MIB NS-IDS.mib NETSCREEN-SET-SNMP-MIB NS-SET-SNMP.mib @@ -28,9 +31,12 @@ CISCO-IETF-PW-TC-MIB CISCO-IETF-PW-TC-MIB.my NETSCREEN-RIPv2-MIB NS-RIP.mib NETSCREEN-CERTIFICATE-MIB NS-VPN-CERT.mib NETSCREEN-NSRP-MIB NS-NSRP.mib +RMON2-MIB RMON2-MIB.my +ISIS-MIB ISIS-MIB INTEGRATED-SERVICES-MIB INTEGRATED-SERVICES-MIB.my ENTITY-MIB ENTITY-MIB.my DIFFSERV-MIB DIFFSERV-MIB.my +Q-BRIDGE-MIB Q-BRIDGE-MIB NETSCREEN-CHASSIS-MIB NS-CHASSIS.mib CISCO-VTP-MIB CISCO-VTP-MIB.my NETSCREEN-BGP4-MIB NS-BGP4.mib @@ -44,6 +50,7 @@ NETSCREEN-ZONE-MIB NS-ZONE.mib MPLS-L3VPN-STD-MIB MPLS-L3VPN-STD-MIB.my CISCO-IETF-PW-MPLS-MIB CISCO-IETF-PW-MPLS-MIB.my CISCO-TCP-MIB CISCO-TCP-MIB.my +FRAME-RELAY-DTE-MIB FRAME-RELAY-DTE-MIB NETSCREEN-SET-GEN-MIB NS-SET-GEN.mib NETSCREEN-SET-DNS-MIB NS-SET-DNS.mib NETSCREEN-OSPF-MIB NS-OSPF.mib diff --git a/mysql-schema.sql b/mysql-schema.sql index e3b10dc4b..8a0afc601 100644 --- a/mysql-schema.sql +++ b/mysql-schema.sql @@ -9,6 +9,19 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; +-- +-- Table structure for table `authlog` +-- + +CREATE TABLE IF NOT EXISTS `authlog` ( + `id` int(11) NOT NULL auto_increment, + `datetime` timestamp NOT NULL default CURRENT_TIMESTAMP, + `user` text NOT NULL, + `address` text NOT NULL, + `result` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -- -- Database: `observer` -- diff --git a/test-discovery.php b/test-discovery.php index 501fa3d91..806add2d5 100755 --- a/test-discovery.php +++ b/test-discovery.php @@ -36,9 +36,9 @@ while ($device = mysql_fetch_array($device_query)) { echo($device['hostname'] ."\n"); -# include("includes/discovery/unix-memory.php"); + include("includes/discovery/cisco-physical.php"); - include("includes/discovery/ipv6-addresses.php"); +# include("includes/discovery/ipv6-addresses.php"); # include("includes/discovery/cisco-pw.php");