From 44d1431f943e5bdcadb319ecd54853c5509e79eb Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 23 Mar 2009 17:32:25 +0000 Subject: [PATCH] lots of fixes for non-webroot installations git-svn-id: http://www.observium.org/svn/observer/trunk@362 61d68cd4-352d-0410-923a-c4978735b2b8 --- cron-hourly.sh | 2 +- generate-map.sh | 2 +- html/includes/print-interface-graphs.php | 16 +-- html/pages/bills.php | 2 +- html/pages/device.php | 32 ++--- html/pages/device/bgp.inc.php | 4 +- html/pages/device/graphs.inc.php | 2 +- html/pages/device/ifgraphs.inc.php | 8 +- html/pages/iftype.php | 2 +- includes/functions.php | 71 +++------ includes/polling/device-ios.inc.php | 18 ++- includes/polling/temperatures.inc.php | 2 +- includes/rewrites.php | 44 ++++++ map.php | 15 +- mysql-schema.sql | 176 +++++++++++++---------- 15 files changed, 214 insertions(+), 182 deletions(-) diff --git a/cron-hourly.sh b/cron-hourly.sh index 674a9fcfe..ee8174dbd 100755 --- a/cron-hourly.sh +++ b/cron-hourly.sh @@ -2,7 +2,7 @@ ./discovery.php --even & ./discovery.php --odd & ./update-interface.php -#./discover-cdp.php +./discover-cdp.php ./cleanup.php ./generate-map.sh ./check-errors.php diff --git a/generate-map.sh b/generate-map.sh index be7839f2b..0d7603d7f 100755 --- a/generate-map.sh +++ b/generate-map.sh @@ -1,4 +1,4 @@ #!/bin/bash -./map.php > map.dot && unflatten -l5 -f map.dot | dot -Tpng -o html/network-big.png && convert -resize 400x500 html/network-big.png html/network.png +./map.php > map.dot && unflatten -l5 -f map.dot | fdp -Tpng -o html/network-big.png && convert -resize 400x500 html/network-big.png html/network.png #./map.php > map.dot && unflatten -l5 -f map.dot | circo -Tpng -o html/network-screen-big.png && convert -resize 900x2000 html/network-screen-big.png html/network-screen.png diff --git a/html/includes/print-interface-graphs.php b/html/includes/print-interface-graphs.php index 07eb59c95..8990089bc 100644 --- a/html/includes/print-interface-graphs.php +++ b/html/includes/print-interface-graphs.php @@ -6,17 +6,17 @@ if(!$device) { $device['device_id'] = getifhost($interface['interface_id']); } - $daily_traffic = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=215&height=100"; - $daily_url = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150"; + $daily_traffic = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=215&height=100"; + $daily_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150"; - $weekly_traffic = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=215&height=100"; - $weekly_url = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150"; + $weekly_traffic = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=215&height=100"; + $weekly_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150"; - $monthly_traffic = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=215&height=100"; - $monthly_url = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150"; + $monthly_traffic = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=215&height=100"; + $monthly_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150"; - $yearly_traffic = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=215&height=100"; - $yearly_url = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150"; + $yearly_traffic = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=215&height=100"; + $yearly_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150"; echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> "); diff --git a/html/pages/bills.php b/html/pages/bills.php index ccba43827..2dc98fd4f 100644 --- a/html/pages/bills.php +++ b/html/pages/bills.php @@ -39,7 +39,7 @@ if($_GET['bill']) { echo(" - ".$bill['bill_name']." + ".$bill['bill_name']." $notes $type $allowed diff --git a/html/pages/device.php b/html/pages/device.php index 2a0975ff4..13e05ea8e 100644 --- a/html/pages/device.php +++ b/html/pages/device.php @@ -25,13 +25,13 @@ echo("
"); echo("
"); $dographs = 1; diff --git a/html/pages/iftype.php b/html/pages/iftype.php index 3db137b54..81d4d37a6 100644 --- a/html/pages/iftype.php +++ b/html/pages/iftype.php @@ -18,7 +18,7 @@ if($_GET['type']) { ".generatedevicelink($interface)." ".generateiflink($interface)." "); if(mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0)){ - echo(" MAC Accounting"); + echo(" MAC Accounting"); } diff --git a/includes/functions.php b/includes/functions.php index 95babe5f1..712747ef7 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -183,24 +183,9 @@ function percent_colour($perc) { $r = min(255, 5 * ($perc - 25)); $b = max(0, 255 - (5 * ($perc + 25))); - return sprintf('#%02x%02x%02x', $r, $b, $b); } -function percent_colour_old($perc) -{ - $red = round(5 * $perc); - $blue = round(255 - (5 * $perc)); - if($red > '255') { $red = "255"; } - if($blue < '0') { $blue = "0"; } - $red = dechex($red); - $blue = dechex($blue); - if(strlen($red) == 1) { $red = "0$red"; } - if(strlen($blue) == 1) { $blue = "0$blue"; } - $colour = "#$red" . "00" . "$blue"; - return $colour; -} - function print_error($text) { echo("
$text
"); @@ -218,8 +203,7 @@ function truncate($substring, $max = 50, $rep = '...') if(strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; } } - -function interface_rates ($interface) +function interface_rates ($interface) // Returns the last in/out value in RRD { global $config; $rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd"; @@ -233,8 +217,7 @@ function interface_rates ($interface) return $rate; } - -function interface_errors ($interface) +function interface_errors ($interface) // Returns the last in/out errors value in RRD { global $config; $rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd"; @@ -268,9 +251,9 @@ function generateiflink($interface, $text=0,$type=bits) if(!$text) { $text = fixIfName($interface['ifDescr']); } if(!$type) { $type = 'bits'; } $class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']); - $graph_url = "graph.php?if=" . $interface['interface_id'] . "&from=$day&to=$now&width=400&height=120&type=" . $type; + $graph_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&from=$day&to=$now&width=400&height=120&type=" . $type; $device_id = getifhost($interface['interface_id']); - $link = ""; if($interface['ifAlias']) { $link .= "
" . $interface['ifAlias']; } @@ -287,8 +270,8 @@ function generatedevicelink($device, $text=0, $start=0, $end=0) if(!$end) { $end = $now; } $class = devclass($device); if(!$text) { $text = $device['hostname']; } - $graph_url = "graph.php?host=" . $device['device_id'] . "&from=$start&to=$end&width=400&height=120&type=cpu"; - $link = "
".$device['hostname']." - CPU Load"; $link .= "'".$config['overlib_defaults'].", LEFT);\" onmouseout=\"return nd();\">$text"; return $link; @@ -300,7 +283,8 @@ function device_traffic_image($device, $width, $height, $from, $to) return ""; } -function devclass($device) { +function devclass($device) +{ if ($device['status'] == '0') { $class = "list-device-down"; } else { $class = "list-device"; } if ($device['ignore'] == '1') { $class = "list-device-ignored"; @@ -312,17 +296,18 @@ function devclass($device) { function getImage($host) { +global $config; $sql = "SELECT * FROM `devices` WHERE `device_id` = '$host'"; $data = mysql_fetch_array(mysql_query($sql)); $type = strtolower($data['os']); - if(file_exists("images/os/$type" . ".png")){ $image = ""; - } elseif(file_exists("images/os/$type" . ".gif")){ $image = ""; } - if($device['monowall']) {$image = "";} + if(file_exists($config['html_dir'] . "/images/os/$type" . ".png")){ $image = ""; + } elseif(file_exists($config['html_dir'] . "/images/os/$type" . ".gif")){ $image = ""; } + if($device['monowall']) {$image = "";} if($type == "linux") { $features = strtolower(trim($data[features])); list($distro) = split(" ", $features); - if(file_exists("images/os/$distro" . ".png")){ $image = ""; - } elseif(file_exists("images/os/$distro" . ".gif")){ $image = ""; } + if(file_exists($config['html_dir'] . "/images/os/$distro" . ".png")){ $image = ""; + } elseif(file_exists($config['html_dir'] . "/images/os/$distro" . ".gif")){ $image = ""; } } return $image; } @@ -416,37 +401,13 @@ function humanmedia($media) return $media; } - -function humanspeed($speed) { -# $speed = preg_replace("/^0$/", "-", $speed); -# $speed = preg_replace("/^9000$/", "9Kbps", $speed); -# $speed = preg_replace("/^48000$/", "48Kbps", $speed); -# $speed = preg_replace("/^56000$/", "56Kbps", $speed); -# $speed = preg_replace("/^64000$/", "64Kbps", $speed); -# $speed = preg_replace("/^128000$/", "128Kbps", $speed); -# $speed = preg_replace("/^256000$/", "256Kbps", $speed); -# $speed = preg_replace("/^448000$/", "448Kbps", $speed); -# $speed = preg_replace("/^512000$/", "512Kbps", $speed); -# $speed = preg_replace("/^768000$/", "768Kbps", $speed); -# $speed = preg_replace("/^1024000$/", "1Mbps", $speed); -# $speed = preg_replace("/^2048000$/", "2Mbps", $speed); -# $speed = preg_replace("/^4192000$/", "4Mbps", $speed); -# $speed = preg_replace("/^10000000$/", "10Mbps", $speed); -# $speed = preg_replace("/^34000000$/", "34Mbps", $speed); -# $speed = preg_replace("/^45000000$/", "45Mbps", $speed); -# $speed = preg_replace("/^54000000$/", "54Mbps", $speed); -# $speed = preg_replace("/^100000000$/", "100Mbps", $speed); -# $speed = preg_replace("/^155000000$/", "155Mbps", $speed); -# $speed = preg_replace("/^622000000$/", "622Mbps", $speed); -# $speed = preg_replace("/^1000000000$/", "1Gbps", $speed); -# $speed = preg_replace("/^10000000000$/", "10Gbps", $speed); -# $speed = preg_replace("/^4294967295$/", "", $speed); +function humanspeed($speed) +{ $speed = formatRates($speed); if($speed == "") { $speed = "-"; } return $speed; } - function netmask2cidr($netmask) { list ($network, $cidr) = explode("/", trim(`ipcalc $address/$mask | grep Network | cut -d" " -f 4`)); diff --git a/includes/polling/device-ios.inc.php b/includes/polling/device-ios.inc.php index bbcbca15b..59f1cbefb 100755 --- a/includes/polling/device-ios.inc.php +++ b/includes/polling/device-ios.inc.php @@ -21,7 +21,7 @@ $version = str_replace("-M|", "|", $version); $version = str_replace("-", "|", $version); list($hardware, $features, $version) = explode("|", $version); - $features = fixIOSFeatures($features); + #$features = rewrite_ios_features($features); #$hardware = fixIOSHardware($hardware); if(strstr($ciscomodel, "OID")){ unset($ciscomodel); } if(!strstr($ciscomodel, " ") && strlen($ciscomodel) >= '3') { @@ -29,15 +29,13 @@ } if($device['os'] == "IOS XE") { - list(,$features,$version) = explode(",", $sysDescr); - $version = str_replace(" Version ", "", $version); - - $features = str_replace(" IOS-XE Software (", "", $features); - $features = str_replace("-M", "", $features); - $features = str_replace(")", "", $features); - $features = str_replace("PPC_LINUX_IOSD-", "", $features); - $features = fixIOSFeatures($features); - + list(,$features,$version) = explode(",", $sysDescr); + $version = str_replace(" Version ", "", $version); + $features = str_replace(" IOS-XE Software (", "", $features); + $features = str_replace("-M", "", $features); + $features = str_replace(")", "", $features); + $features = str_replace("PPC_LINUX_IOSD-", "", $features); + #$features = rewrite_ios_features($features); } diff --git a/includes/polling/temperatures.inc.php b/includes/polling/temperatures.inc.php index 4ebd9a6ab..23a3dcb4d 100755 --- a/includes/polling/temperatures.inc.php +++ b/includes/polling/temperatures.inc.php @@ -9,7 +9,7 @@ while($temperature = mysql_fetch_array($temp_data)) { echo("Checking temp " . $temperature['temp_descr'] . "... "); - $temprrd = addslashes($rrd_dir . "/" . $device['hostname'] . "/temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd"); + $temprrd = addslashes($config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd"); $temprrd = str_replace(")", "_", $temprrd); $temprrd = str_replace("(", "_", $temprrd); diff --git a/includes/rewrites.php b/includes/rewrites.php index 700c9dfce..3bc4fa61c 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -1,5 +1,39 @@ "IP w/SSH LAN Only", + "LANBASEK9" => "Lan Base Crypto", + "LANBASE" => "Lan Base", + "ADVENTERPRISEK9" => "Advanced Enterprise Crypto", + "ADVSECURITYK9" => "Advanced Security Crypto", + "K91P" => "Provider Crypto", + "K4P" => "Provider Crypto", + "ADVIPSERVICESK9" => "Adv IP Services Crypto", + "ADVIPSERVICES" => "Adv IP Services", + "IK9P" => "IP Plus Crypto", + "K9O3SY7" => "IP ADSL FW IDS Plus IPSEC 3DES", + "SPSERVICESK9" => "SP Services Crypto", + "PK9SV" => "IP MPLS/IPV6 W/SSH + BGP", + "IS" => "IP Plus", + "IPSERVICESK9" => "IP Services Crypto", + "BROADBAND" => "Broadband", + "IPBASE" => "IP Base", + "IPSERVICE" => "IP Services", + "P" => "Service Provider", + "P11" => "Broadband Router", + "G4P5" => "NRP", + "JK9S" => "Enterprise Plus Crypto", + "IK9S" => "IP Plus Crypto", + "JK" => "Enterprise Plus", + "I6Q4L2" => "Layer 2", + "I6K2L2Q4" => "Layer 2 Crypto", + "C3H2S" => "Layer 2 SI/EI", + "_WAN" => " + WAN", + ); + + + $rewrite_shortif = array ( 'tengigabitethernet' => 'Te', 'gigabitethernet' => 'Gi', @@ -57,6 +91,8 @@ 'loop' => 'Loop', ); + + // Specific rewrite functions function makeshortif($if) @@ -68,6 +104,14 @@ function makeshortif($if) return $if; } +function rewrite_ios_features ($features) +{ + global $rewrite_ios_features; + $type = array_preg_replace($rewrite_ios_features, $features); + return ($features); +} + + function fixiftype ($type) { global $rewrite_iftype; diff --git a/map.php b/map.php index d23d71de4..f4c8a3df8 100755 --- a/map.php +++ b/map.php @@ -4,9 +4,9 @@ include("config.php"); include("includes/functions.php"); -echo("digraph G { sep=0.1; size=\"40,20\"; pack=10; bgcolor=transparent;splines=true; +echo("digraph G { sep=0.6; size=\"40,20\"; pack=10; bgcolor=transparent;splines=true; node [ fontname=\"helvetica\", fontsize=38, fontstyle=bold, shape=box, style=bold]; - edge [ labelfontsize=10, labelfontname=\"helvetica\", overlap=false, fontstyle= bold]; + edge [ labelfontsize=10, labelfontname=\"helvetica\", overlap=false, fontstyle=bold]; graph [bgcolor=transparent, remincross=true]; "); @@ -35,11 +35,14 @@ while($loc_data = mysql_fetch_array($loc_result)) { if(strpos($host, "cust." . $config['mydomain'])) { $hostinfo = "shape=egg style=filled fillcolor=pink"; } if(strpos($host, "bas")) { $hostinfo = "shape=rectangle style=filled fillcolor=skyblue"; } if(strpos($host, "crs")) { $hostinfo = "shape=box3d style=filled fillcolor=skyblue"; } - if(strpos($host, "ler")) { $hostinfo = "shape=tripleoctagon style=filled fillcolor=darkolivegreen3"; } + if(strpos($host, "lcr")) { $hostinfo = "shape=tripleoctagon style=filled fillcolor=darkolivegreen4"; } + if(strpos($host, "ler")) { $hostinfo = "shape=octagon style=filled fillcolor=darkolivegreen1"; } if(strpos($host, "pbr")) { $hostinfo = "shape=ellipse style=filled fillcolor=orange"; } - if(strpos($host, "tbr")) { $hostinfo = "shape=ellipse style=filled fillcolor=red"; } - if(strstr($host, "gw")) { $hostinfo = "shape=rect style=filled fillcolor=orange"; } - if(strpos($host, "bar")) { $hostinfo = "shape=egg style=filled fillcolor=darkolivegreen4"; } + if(strpos($host, "tbr")) { $hostinfo = "shape=ellipse style=filled fillcolor=orange"; } + if(strstr($host, "gwr")) { $hostinfo = "shape=ellipse style=filled fillcolor=orange"; } + if(strpos($host, "bgw")) { $hostinfo = "shape=ellipse style=filled fillcolor=orange"; } + if(strpos($host, "vax")) { $hostinfo = "shape=rect style=filled fillcolor=skyblue"; } + if(strpos($host, "vsx")) { $hostinfo = "shape=box3d style=filled fillcolor=skyblue"; } #} else { $hostinfo = "style=filled shape=circle fillcolor=lightgray"; } $host = $dev_data[hostname]; diff --git a/mysql-schema.sql b/mysql-schema.sql index 62609f8e5..69e83ba37 100644 --- a/mysql-schema.sql +++ b/mysql-schema.sql @@ -3,25 +3,12 @@ -- http://www.phpmyadmin.net -- -- Host: localhost --- Generation Time: Nov 20, 2008 at 03:39 PM +-- Generation Time: Mar 23, 2009 at 05:29 PM -- Server version: 5.0.51 --- PHP Version: 5.2.4-2ubuntu5.3 +-- PHP Version: 5.2.4-2ubuntu5.5 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` -- @@ -37,7 +24,7 @@ CREATE TABLE IF NOT EXISTS `adjacencies` ( `network_id` int(11) NOT NULL default '0', `interface_id` int(11) NOT NULL default '0', PRIMARY KEY (`adj_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -53,7 +40,22 @@ CREATE TABLE IF NOT EXISTS `alerts` ( `time_logged` timestamp NOT NULL default CURRENT_TIMESTAMP, `alerted` smallint(6) NOT NULL default '0', KEY `id` (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- 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=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -64,7 +66,7 @@ CREATE TABLE IF NOT EXISTS `alerts` ( CREATE TABLE IF NOT EXISTS `bgpPeers` ( `bgpPeer_id` int(11) NOT NULL auto_increment, `device_id` int(11) NOT NULL, - `astext` varchar(32) NOT NULL, + `astext` varchar(64) NOT NULL, `bgpPeerIdentifier` text NOT NULL, `bgpPeerRemoteAs` int(11) NOT NULL, `bgpPeerState` text NOT NULL, @@ -79,7 +81,7 @@ CREATE TABLE IF NOT EXISTS `bgpPeers` ( `bgpPeerInUpdateElapsedTime` int(11) NOT NULL, PRIMARY KEY (`bgpPeer_id`), KEY `device_id` (`device_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -95,7 +97,7 @@ CREATE TABLE IF NOT EXISTS `bills` ( `bill_day` int(11) NOT NULL default '1', `bill_gb` int(11) default NULL, UNIQUE KEY `bill_id` (`bill_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -111,7 +113,7 @@ CREATE TABLE IF NOT EXISTS `bill_data` ( `in_delta` bigint(11) NOT NULL, `out_delta` bigint(11) NOT NULL, KEY `bill_id` (`bill_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -122,7 +124,7 @@ CREATE TABLE IF NOT EXISTS `bill_data` ( CREATE TABLE IF NOT EXISTS `bill_perms` ( `user_id` int(11) NOT NULL, `bill_id` int(11) NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -133,7 +135,7 @@ CREATE TABLE IF NOT EXISTS `bill_perms` ( CREATE TABLE IF NOT EXISTS `bill_ports` ( `bill_id` int(11) NOT NULL, `port_id` int(11) NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -149,7 +151,7 @@ CREATE TABLE IF NOT EXISTS `customers` ( `level` tinyint(4) NOT NULL default '0', PRIMARY KEY (`customer_id`), UNIQUE KEY `username` (`username`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -159,26 +161,31 @@ CREATE TABLE IF NOT EXISTS `customers` ( CREATE TABLE IF NOT EXISTS `devices` ( `device_id` int(11) NOT NULL auto_increment, - `hostname` text NOT NULL, + `hostname` varchar(128) NOT NULL, + `sysName` varchar(128) default NULL, `community` varchar(32) NOT NULL, `snmpver` varchar(4) NOT NULL default 'v2c', + `port` smallint(5) NOT NULL default '161', `bgpLocalAs` varchar(16) default NULL, `sysDescr` text, - `sysContact` text NOT NULL, - `version` text NOT NULL, - `hardware` text NOT NULL, - `features` text NOT NULL, + `sysContact` text, + `version` text, + `hardware` text, + `features` text, `location` text, - `os` varchar(8) NOT NULL default '', + `os` varchar(8) default NULL, `status` tinyint(4) NOT NULL default '0', `ignore` tinyint(4) NOT NULL default '0', `disabled` tinyint(1) NOT NULL default '0', `lastchange` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `purpose` text NOT NULL, + `purpose` varchar(64) default NULL, `type` varchar(8) NOT NULL default 'other', PRIMARY KEY (`device_id`), - KEY `status` (`status`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; + KEY `status` (`status`), + KEY `hostname` (`hostname`), + KEY `sysName` (`sysName`), + KEY `os` (`os`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -190,11 +197,10 @@ CREATE TABLE IF NOT EXISTS `devices_attribs` ( `attrib_id` int(11) NOT NULL auto_increment, `device_id` int(11) NOT NULL, `attrib_type` varchar(32) NOT NULL, - `attrib_value` int(11) NOT NULL, + `attrib_value` text NOT NULL, `updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - PRIMARY KEY (`attrib_id`), - FULLTEXT KEY `attrib_type` (`attrib_type`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; + PRIMARY KEY (`attrib_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -207,7 +213,7 @@ CREATE TABLE IF NOT EXISTS `devices_perms` ( `device_id` int(11) NOT NULL, `access_level` int(4) NOT NULL default '0', KEY `user_id` (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -231,7 +237,7 @@ CREATE TABLE IF NOT EXISTS `entPhysical` ( `ifIndex` int(11) default NULL, PRIMARY KEY (`entPhysical_id`), KEY `device_id` (`device_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -247,7 +253,7 @@ CREATE TABLE IF NOT EXISTS `eventlog` ( `message` text NOT NULL, `type` int(11) NOT NULL, KEY `host` (`host`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -286,7 +292,7 @@ CREATE TABLE IF NOT EXISTS `interfaces` ( KEY `host` (`device_id`), KEY `snmpid` (`ifIndex`), KEY `if_2` (`ifDescr`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -298,7 +304,7 @@ CREATE TABLE IF NOT EXISTS `interfaces_perms` ( `user_id` int(11) NOT NULL, `interface_id` int(11) NOT NULL, `access_level` int(11) NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -316,7 +322,7 @@ CREATE TABLE IF NOT EXISTS `ip6addr` ( `interface_id` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `addr` (`addr`,`cidr`,`interface_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -329,7 +335,7 @@ CREATE TABLE IF NOT EXISTS `ip6adjacencies` ( `network_id` int(11) NOT NULL default '0', `interface_id` int(11) NOT NULL default '0', PRIMARY KEY (`adj_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -342,7 +348,7 @@ CREATE TABLE IF NOT EXISTS `ip6networks` ( `cidr` varchar(32) NOT NULL default '', PRIMARY KEY (`id`), UNIQUE KEY `cidr` (`cidr`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -358,7 +364,7 @@ CREATE TABLE IF NOT EXISTS `ipaddr` ( `interface_id` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `addr` (`addr`,`cidr`,`interface_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -372,8 +378,28 @@ CREATE TABLE IF NOT EXISTS `links` ( `dst_if` int(11) default NULL, `active` tinyint(4) NOT NULL default '1', `cdp` int(11) default NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; + PRIMARY KEY (`id`), + KEY `src_if` (`src_if`), + KEY `dst_if` (`dst_if`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `mac_accounting` +-- + +CREATE TABLE IF NOT EXISTS `mac_accounting` ( + `ma_id` int(11) NOT NULL auto_increment, + `interface_id` int(11) NOT NULL, + `peer_ip` varchar(32) NOT NULL, + `peer_desc` varchar(64) NOT NULL, + `peer_asn` int(11) NOT NULL, + `peer_mac` varchar(32) NOT NULL, + `in_oid` varchar(128) NOT NULL, + `out_oid` varchar(128) NOT NULL, + PRIMARY KEY (`ma_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -386,7 +412,7 @@ CREATE TABLE IF NOT EXISTS `networks` ( `cidr` varchar(32) NOT NULL default '', PRIMARY KEY (`id`), UNIQUE KEY `cidr` (`cidr`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -400,7 +426,7 @@ CREATE TABLE IF NOT EXISTS `port_in_measurements` ( `counter` bigint(11) NOT NULL, `delta` bigint(11) NOT NULL, KEY `port_id` (`port_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -414,7 +440,7 @@ CREATE TABLE IF NOT EXISTS `port_out_measurements` ( `counter` bigint(11) NOT NULL, `delta` bigint(11) NOT NULL, KEY `port_id` (`port_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -430,7 +456,7 @@ CREATE TABLE IF NOT EXISTS `pseudowires` ( `cpwVcID` int(11) NOT NULL, `cpwOid` int(11) NOT NULL, PRIMARY KEY (`pseudowire_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -453,7 +479,7 @@ CREATE TABLE IF NOT EXISTS `services` ( `service_disabled` tinyint(1) NOT NULL default '0', PRIMARY KEY (`service_id`), KEY `service_host` (`service_host`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -471,7 +497,7 @@ CREATE TABLE IF NOT EXISTS `storage` ( `hrStorageUsed` int(11) NOT NULL, `storage_perc` text NOT NULL, PRIMARY KEY (`storage_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -495,7 +521,7 @@ CREATE TABLE IF NOT EXISTS `syslog` ( KEY `datetime` (`datetime`), KEY `device_id` (`device_id`), KEY `processed` (`processed`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -513,7 +539,7 @@ CREATE TABLE IF NOT EXISTS `temperature` ( `temp_limit` tinyint(4) NOT NULL default '60', PRIMARY KEY (`temp_id`), KEY `temp_host` (`temp_host`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -526,11 +552,27 @@ CREATE TABLE IF NOT EXISTS `users` ( `username` char(30) NOT NULL, `password` char(32) NOT NULL, `realname` text NOT NULL, + `email` text NOT NULL, `descr` char(30) NOT NULL, `level` tinyint(4) NOT NULL default '0', PRIMARY KEY (`user_id`), UNIQUE KEY `username` (`username`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users_prefs` +-- + +CREATE TABLE IF NOT EXISTS `users_prefs` ( + `user_id` int(16) NOT NULL, + `pref` varchar(32) NOT NULL, + `value` varchar(128) NOT NULL, + PRIMARY KEY (`user_id`), + UNIQUE KEY `user_id.pref` (`user_id`,`pref`), + KEY `pref` (`pref`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -546,7 +588,7 @@ CREATE TABLE IF NOT EXISTS `vlans` ( `vlan_descr` text, PRIMARY KEY (`vlan_id`), KEY `device_id` (`device_id`,`vlan_vlan`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- @@ -563,21 +605,5 @@ CREATE TABLE IF NOT EXISTS `vrfs` ( `device_id` int(11) NOT NULL, PRIMARY KEY (`vrf_id`), KEY `device_id` (`device_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - --- --- Table structure for table `mac_accounting` --- - -CREATE TABLE IF NOT EXISTS `mac_accounting` ( - `ma_id` int(11) NOT NULL auto_increment, - `interface_id` int(11) NOT NULL, - `peer_ip` varchar(32) NOT NULL, - `peer_desc` varchar(64) NOT NULL, - `peer_asn` int(11) NOT NULL, - `peer_mac` varchar(32) NOT NULL, - `in_oid` varchar(128) NOT NULL, - `out_oid` varchar(128) NOT NULL, - PRIMARY KEY (`ma_id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=703 ; +) ENGINE=InnoDB DEFAULT CHARSET=latin1;