diff --git a/.gitignore b/.gitignore index 949c9ec24..975011ebe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -Makefile +config.php +.index +logs patches +rrd diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..4ad69d63d --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +GIT=git +SYNC=rsync -rtvx --cvs-exclude --exclude '.*.swp' +TEST_DEST=librenms:/opt/librenms/ + +default: check + $(GIT) merge master + $(SYNC) html includes $(TEST_DEST) + +test t: merge check push-testing gc + +dev d: merge check push-dev gc + +check: + for i in `$(GIT) diff --name-only`; do php -l $$i; done + +gc: + $(GIT) gc + +merge: + $(GIT) merge master + +pull: + $(GIT) pull + +push-dev: + $(GIT) push + +push-testing: + $(GIT) push testing + diff --git a/html/css/styles.css b/html/css/styles.css index 11a70c9f4..4d9542937 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -495,7 +495,46 @@ a.list-device-disabled, a.list-device-disabled:visited { border-radius: 2pt 2pt 2pt 2pt; } -.front-syslog .front-eventlog { +.status-boxes { +} + +.boxes { + width: 350px; + height: 200px; + vertical-align: center; +} + +.left-2-col-fluid { + display: table-cell; + margin-right: 400px; +/* width: 100%; */ +/* vertical-align: top;*/ +} + +.right-2-col-fixed { + display: table-cell; + width: 350px; + height: 250px; + float: right; +/* vertical-align: top;*/ + + /* Rounded Corners */ + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + + /* Borders */ + border: 1px solid #aaaaaa; + padding: 5px; +} + +.front-syslog { + margin: 4px; + clear: both; + padding: 5px; +} + +.front-eventlog { margin: 4px; clear: both; padding: 5px; @@ -1521,3 +1560,16 @@ tr.search:nth-child(odd) { margin: 2px; } +.box { +} + +.welcome { + padding-right: 25px; +} + +.simple { + border: 0px; + width: 100%; + text-align: left; +} + diff --git a/html/includes/front/common.inc.php b/html/includes/front/common.inc.php new file mode 100644 index 000000000..155def0f7 --- /dev/null +++ b/html/includes/front/common.inc.php @@ -0,0 +1,16 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +?> + + diff --git a/html/includes/front/top_graphs.inc.php b/html/includes/front/top_graphs.inc.php new file mode 100644 index 000000000..b9876a386 --- /dev/null +++ b/html/includes/front/top_graphs.inc.php @@ -0,0 +1,38 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +require_once("includes/front/common.inc.php"); + +echo('
'); +echo('
'); + +echo('
'); +require_once("includes/front/top_ports.inc.php"); +echo('
'); + +/* +echo('
'); +echo('
Something
'); +echo('

Next 1

'); +echo('
'); + +echo('
'); +echo('
Something else
'); +echo('

Next 2

'); +echo('
'); +*/ + +echo('
'); +echo('
'); + +?> diff --git a/html/includes/front/top_ports.inc.php b/html/includes/front/top_ports.inc.php new file mode 100644 index 000000000..ff59d3a5e --- /dev/null +++ b/html/includes/front/top_ports.inc.php @@ -0,0 +1,224 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +$minutes = 15; +$seconds = $minutes * 60; +$top = $config['front_page_settings']['top']['ports']; +$query = " + SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total + FROM ports as p, devices as d + WHERE d.device_id = p.device_id + AND unix_timestamp() - p.poll_time < $seconds + ORDER BY total desc + LIMIT $top +"; + +echo("Top $top ports (last $minutes minutes)"); +echo(''); +foreach (dbFetchRows($query) as $result) { + echo(''); +} +echo('
'.$result['hostname'].''.$result['ifIndex'].''.$result['ifDescr'].''.$result['total'].'
'); + +/* +// FIXME: Change to port_rrd_exists($device, $port) +if (file_exists($config['rrd_dir'] . "/" . $device['hostname'] . "/port-". $port['ifIndex'] . ".rrd")) +{ + $iid = $id; + echo("
Interface Traffic
"); + $graph_type = "port_bits"; + + include("includes/print-interface-graphs.inc.php"); + + echo("
Interface Packets
"); + $graph_type = "port_upkts"; + + include("includes/print-interface-graphs.inc.php"); + + echo("
Interface Non Unicast
"); + $graph_type = "port_nupkts"; + + include("includes/print-interface-graphs.inc.php"); + + echo("
Interface Errors
"); + $graph_type = "port_errors"; + + include("includes/print-interface-graphs.inc.php"); + + if (is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . $port['ifIndex'] . "-dot3.rrd")) + { + echo("
Ethernet Errors
"); + $graph_type = "port_etherlike"; + + include("includes/print-interface-graphs.inc.php"); + } +} +*/ + +/* from html/includes/print-interface.inc.php: + +generate_port_link($port, $port['ifIndex'] . ". ".$port['label']) + +*/ + +/* from html/includes/functions.inc.php: + +function generate_port_link($port, $text = NULL, $type = NULL) +{ + global $config; + + $port = ifNameDescr($port); + if (!$text) { $text = fixIfName($port['label']); } + if ($type) { $port['graph_type'] = $type; } + if (!isset($port['graph_type'])) { $port['graph_type'] = 'port_bits'; } + + $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + + if (!isset($port['hostname'])) { $port = array_merge($port, device_by_id_cache($port['device_id'])); } + + $content = "
".$port['hostname']." - " . fixifName($port['label']) . "
"; + if ($port['ifAlias']) { $content .= $port['ifAlias']."
"; } + $content .= "
"; + $graph_array['type'] = $port['graph_type']; + $graph_array['legend'] = "yes"; + $graph_array['height'] = "100"; + $graph_array['width'] = "340"; + $graph_array['to'] = $config['time']['now']; + $graph_array['from'] = $config['time']['day']; + $graph_array['id'] = $port['port_id']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['week']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['month']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['year']; + $content .= generate_graph_tag($graph_array); + $content .= "
"; + + $url = generate_port_url($port); + + if (port_permitted($port['port_id'], $port['device_id'])) { + return overlib_link($url, $text, $content, $class); + } else { + return fixifName($text); + } +} +*/ + +/* includes/print-interface-graphs.inc.php: + +global $config; + +$graph_array['height'] = "100"; +$graph_array['width'] = "215"; +$graph_array['to'] = $config['time']['now']; +$graph_array['id'] = $port['port_id']; +$graph_array['type'] = $graph_type; + +include("includes/print-graphrow.inc.php"); + +*/ + +/* html/includes/print-graphrow.inc.php: +global $config; + +if($_SESSION['widescreen']) +{ + if (!$graph_array['height']) { $graph_array['height'] = "110"; } + if (!$graph_array['width']) { $graph_array['width'] = "215"; } + $periods = array('sixhour', 'day', 'week', 'month', 'year', 'twoyear'); +} else { + if (!$graph_array['height']) { $graph_array['height'] = "100"; } + if (!$graph_array['width']) { $graph_array['width'] = "215"; } + $periods = array('day', 'week', 'month', 'year'); +} + +$graph_array['to'] = $config['time']['now']; + +foreach ($periods as $period) +{ + $graph_array['from'] = $config['time'][$period]; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = "150"; + $graph_array_zoom['width'] = "400"; + + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width']); + $link = generate_url($link_array); + + echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); +} + +function overlib_link($url, $text, $contents, $class) +{ + global $config; + + $contents = str_replace("\"", "\'", $contents); + $output = '"; + $output .= $text.""; + + return $output; +} + +function print_graph_tag($args) +{ + echo(generate_graph_tag($args)); +} + +function generate_graph_tag($args) +{ + + foreach ($args as $key => $arg) + { + $urlargs[] = $key."=".$arg; + } + + return ''; +} + +function generate_port_url($port, $vars=array()) +{ + return generate_url(array('page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id']), $vars); +} + +function generate_link($text, $vars, $new_vars = array()) +{ + return ''.$text.''; +} + +function generate_url($vars, $new_vars = array()) +{ + + $vars = array_merge($vars, $new_vars); + + $url = $vars['page']."/"; + unset($vars['page']); + + foreach ($vars as $var => $value) + { + if ($value == "0" || $value != "" && strstr($var, "opt") === FALSE && is_numeric($var) === FALSE) + { + $url .= $var ."=".$value."/"; + } + } + + return($url); + +} + +*/ + +?> diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index d0cb2984c..32006a830 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -79,17 +79,22 @@ function generate_url($vars, $new_vars = array()) } +function escape_quotes($text) +{ + return str_replace('"', "\'", $text); +} + function generate_overlib_content($graph_array, $text) { global $config; - $overlib_content = '
'.$text."
"; + $overlib_content = '
'.$text.'
'; foreach (array('day','week','month','year') as $period) { $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + $overlib_content .= escape_quotes(generate_graph_tag($graph_array)); } - $overlib_content .= "
"; + $overlib_content .= '
'; return $overlib_content; @@ -159,8 +164,8 @@ function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end $graphhead = $entry['text']; $contents .= '
'; $contents .= ''.$graphhead.'
'; - $contents .= generate_minigraph_image($device, $start, $end, $graph); - $contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph); + $contents .= escape_quotes(generate_minigraph_image($device, $start, $end, $graph)); + $contents .= escape_quotes(generate_minigraph_image($device, $config['time']['week'], $end, $graph)); $contents .= '
'; } diff --git a/html/js/jquery-cycle-boxes.js b/html/js/jquery-cycle-boxes.js new file mode 100644 index 000000000..7af5e08b8 --- /dev/null +++ b/html/js/jquery-cycle-boxes.js @@ -0,0 +1,10 @@ +// cycle between divs in a set, from: http://jquery.malsup.com/cycle/basic.html (see also http://jsfiddle.net/n1ck/4PvU7/) +$(document).ready(function() { + $('.boxes').cycle({ + timeout: 5000, + speed: 1000, + random: 1, + pause: 1, + fx: 'scrollUp' // choose your transition type, ex: fade, scrollUp, shuffle, etc... + }); +}); diff --git a/html/pages/front/default.php b/html/pages/front/default.php index 7ee71c498..080d12fca 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -1,5 +1,7 @@ @@ -7,8 +9,13 @@ echo("
"); } -echo("
"); +echo('
'); +echo('
'); + +$count_boxes = 0; + +// Device down boxes if ($_SESSION['userlevel'] == '10') { $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); @@ -17,11 +24,10 @@ $sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.dev } while ($device = mysql_fetch_assoc($sql)) { - generate_front_box("device-down", "
".generate_device_link($device, shorthost($device['hostname']))."
- Device Down
- ".truncate($device['location'], 20)." -
"); - + generate_front_box("device-down", generate_device_link($device, shorthost($device['hostname']))."
+ Device Down
+ ".truncate($device['location'], 20).""); + ++$count_boxes; } if ($_SESSION['userlevel'] == '10') @@ -33,34 +39,37 @@ $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS // These things need to become more generic, and more manageable across different frontpages... rewrite inc :> +// Port down boxes if ($config['warn']['ifdown']) { while ($interface = mysql_fetch_assoc($sql)) { if (!$interface['deleted']) { - $interface = ifNameDescr($interface); - generate_front_box("port-down", "
".generate_device_link($interface, shorthost($interface['hostname']))."
- Port Down
+ $interface = ifNameDescr($interface); + generate_front_box("port-down", generate_device_link($interface, shorthost($interface['hostname']))."
+ Port Down
".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
- " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') . " -
"); + " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '')); + ++$count_boxes; } } } /* FIXME service permissions? seem nonexisting now.. */ +// Service down boxes $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); while ($service = mysql_fetch_assoc($sql)) { - generate_front_box("service-down", "
".generate_device_link($service, shorthost($service['hostname']))."
+ generate_front_box("service-down", generate_device_link($service, shorthost($service['hostname']))."
Service Down ".$service['service_type']."
- ".truncate($interface['ifAlias'], 20)." -
"); + ".truncate($interface['ifAlias'], 20).""); + ++$count_boxes; } +// BGP neighbour down boxes if (isset($config['enable_bgp']) && $config['enable_bgp']) { if ($_SESSION['userlevel'] == '10') @@ -71,14 +80,15 @@ if (isset($config['enable_bgp']) && $config['enable_bgp']) } while ($peer = mysql_fetch_assoc($sql)) { - generate_front_box("bgp-down", "
".generate_device_link($peer, shorthost($peer['hostname']))."
- BGP Down - ".$peer['bgpPeerIdentifier']."
- AS".truncate($peer['bgpPeerRemoteAs']." ".$peer['astext'], 14, "")." -
"); + generate_front_box("bgp-down", generate_device_link($peer, shorthost($peer['hostname']))."
+ BGP Down + ".$peer['bgpPeerIdentifier']."
+ AS".truncate($peer['bgpPeerRemoteAs']." ".$peer['astext'], 14, "").""); + ++$count_boxes; } } +// Device rebooted boxes if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) { if ($_SESSION['userlevel'] == '10') @@ -91,16 +101,21 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c while ($device = mysql_fetch_assoc($sql)) { - generate_front_box("device-rebooted", "
".generate_device_link($device, shorthost($device['hostname']))."
- Device Rebooted
- ".formatUptime($device['uptime'], 'short')." -
"); + generate_front_box("device-rebooted", generate_device_link($device, shorthost($device['hostname']))."
+ Device Rebooted
+ ".formatUptime($device['uptime'], 'short').""); + ++$count_boxes; } } +if ($count_boxes == 0) { + echo("
Nothing here yet

This is where status notifications about devices and services would normally go. You might have none + because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].", you might + want to start by adding one or more devices in the Devices menu.

"); +} +echo('
'); if ($config['enable_syslog']) { - // Open Syslog Div echo("

Recent Syslog Messages

"); @@ -115,12 +130,9 @@ if ($config['enable_syslog']) include("includes/print-syslog.inc.php"); } echo(""); - - echo("
"); // Close Syslog Div + echo("
"); } else { - - // Open eventlog Div echo("

Recent Eventlog Entries

"); @@ -142,7 +154,7 @@ if ($config['enable_syslog']) } echo(""); - echo("
"); // Close Syslog Div + echo("
"); } echo(""); diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 262f99cd6..68108e9f4 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -111,6 +111,7 @@ $config['favicon'] = ""; $config['header_color'] = "#1F334E"; $config['page_refresh'] = "300"; // Refresh the page every xx seconds, 0 to disable $config['front_page'] = "pages/front/default.php"; +$config['front_page_settings']['top']['ports'] = 10; $config['page_title_prefix'] = ""; $config['page_title_suffix'] = $config['project_name']; $config['timestamp_format'] = 'd-m-Y H:i:s';