Conflicts:
	includes/services/check_dhcp.inc.php
This commit is contained in:
Rainer Schueler
2016-04-25 08:48:04 +02:00
70 changed files with 12698 additions and 162 deletions

View File

@@ -35,6 +35,7 @@ if ($type == 'placeholder') {
elseif (is_file('includes/common/'.$type.'.inc.php')) {
$results_limit = 10;
$typeahead_limit = $config['webui']['global_search_result_limit'];
$no_form = true;
$title = ucfirst($type);
$unique_id = str_replace(array("-","."),"_",uniqid($type,true));

View File

@@ -128,6 +128,19 @@ $app->group(
}
);
// End Inventory
// Routing section
$app->group(
'/routing',
function () use ($app) {
$app->group(
'/ipsec',
function () use ($app) {
$app->get('/data/:hostname', 'authToken', 'list_ipsec')->name('list_ipsec');
}
);
}
);
// End Routing
}
);
$app->get('/v0', 'authToken', 'show_endpoints');

View File

@@ -1288,3 +1288,33 @@ function get_devices_by_group() {
echo _json_encode($output);
}
function list_ipsec() {
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$status = 'error';
$code = 404;
$message = '';
$hostname = $router['hostname'];
// use hostname as device_id if it's all digits
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
if (!is_numeric($device_id)) {
$message = "No valid hostname or device ID provided";
}
else {
$ipsec = dbFetchRows("SELECT `D`.`hostname`, `I`.* FROM `ipsec_tunnels` AS `I`, `devices` AS `D` WHERE `I`.`device_id`=? AND `D`.`device_id` = `I`.`device_id`", array($device_id));
$total = count($ipsec);
$status = 'ok';
$code = 200;
}
$output = array(
'status' => $status,
'err-msg' => $message,
'count' => $total,
'ipsec' => $ipsec,
);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}

View File

@@ -204,6 +204,7 @@ function '.$unique_id.'() {
},
{
source: '.$unique_id.'_device.ttAdapter(),
limit: '.$typeahead_limit.',
async: false,
templates: {
header: "<h5><strong>&nbsp;Devices</strong></h5>",
@@ -240,6 +241,7 @@ function '.$unique_id.'() {
},
{
source: '.$unique_id.'_port.ttAdapter(),
limit: '.$typeahead_limit.',
async: false,
templates: {
header: "<h5><strong>&nbsp;Ports</strong></h5>",
@@ -275,6 +277,7 @@ function '.$unique_id.'() {
},
{
source: '.$unique_id.'_application.ttAdapter(),
limit: '.$typeahead_limit.',
async: false,
templates: {
header: "<h5><strong>&nbsp;Applications</strong></h5>",
@@ -312,6 +315,7 @@ function '.$unique_id.'() {
},
{
source: '.$unique_id.'_munin.ttAdapter(),
limit: '.$typeahead_limit.',
async: false,
templates: {
header: "<h5><strong>&nbsp;Munin</strong></h5>",
@@ -346,6 +350,7 @@ function '.$unique_id.'() {
},
{
source: '.$unique_id.'_bill.ttAdapter(),
limit: '.$typeahead_limit.',
async: false,
templates: {
header: "<h5><strong><i class=\'fa fa-money\'></i>&nbsp;Bill</strong></h5>",
@@ -432,3 +437,4 @@ else {
$common_output[] = '<a href="graphs/'.$param.'/type='.$widget_settings['graph_type'].'/from='.$config['time'][$widget_settings['graph_range']].'"><img class="minigraph-image" width="'.$widget_dimensions['x'].'" height="'.$widget_dimensions['y'].'" src="graph.php?'.$param.'&from='.$config['time'][$widget_settings['graph_range']].'&to='.$config['time']['now'].'&width='.$widget_dimensions['x'].'&height='.$widget_dimensions['y'].'&type='.$widget_settings['graph_type'].'&legend='.($widget_settings['graph_legend'] == 1 ? 'yes' : 'no').'&absolute=1"/></a>';
}

View File

@@ -20,7 +20,7 @@ $group_id = $_POST['group_id'];
if (is_numeric($group_id) && $group_id > 0) {
$group = dbFetchRow('SELECT * FROM `device_groups` WHERE `id` = ? LIMIT 1', array($group_id));
$group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@\[\]]+[&&\|\|]+)/', $group['pattern'], -1, (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY));
$group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@\[\]\^\$]+[&&\|\|]+)/', $group['pattern'], -1, (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY));
$count = (count($group_split) - 1);
if (preg_match('/\&\&$/', $group_split[$count]) == 1 || preg_match('/\|\|$/', $group_split[$count]) == 1) {
$group_split[$count] = $group_split[$count];

View File

@@ -27,7 +27,7 @@ $i = 0;
if ($handle = opendir($rrddir)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
if (eregi('app-shoutcast-'.$app['app_id'], $file)) {
if (stripos($file, 'app-shoutcast-'.$app['app_id']) != false) {
array_push($files, $file);
}
}
@@ -35,8 +35,8 @@ if ($handle = opendir($rrddir)) {
}
foreach ($files as $id => $file) {
$hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file);
$hostname = eregi_replace('.rrd', '', $hostname);
$hostname = str_ireplace('app-shoutcast-'.$app['app_id'].'-', '', $file);
$hostname = str_ireplace('.rrd', '', $hostname);
list($host, $port) = explode('_', $hostname, 2);
$rrd_filenames[] = $rrddir.'/'.$file;
$rrd_list[$i]['filename'] = $rrddir.'/'.$file;

View File

@@ -15,7 +15,7 @@ $x = 0;
if ($handle = opendir($rrddir)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
if (eregi('app-shoutcast-'.$app['app_id'], $file)) {
if (stripos($file, 'app-shoutcast-'.$app['app_id']) !== false) {
array_push($files, $file);
}
}
@@ -23,8 +23,8 @@ if ($handle = opendir($rrddir)) {
}
foreach ($files as $id => $file) {
$hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file);
$hostname = eregi_replace('.rrd', '', $hostname);
$hostname = str_ireplace('app-shoutcast-'.$app['app_id'].'-', '', $file);
$hostname = str_ireplace('.rrd', '', $hostname);
list($host, $port) = explode('_', $hostname, 2);
$rrd_filenames[] = $rrddir.'/'.$file;
$rrd_list[$i]['filename'] = $rrddir.'/'.$file;

View File

@@ -0,0 +1,20 @@
<?php
/*
* LibreNMS
*
* 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 'includes/graphs/common.inc.php';
$rrdfilename = $config['rrd_dir'].'/'.$device['hostname'].'/cisco-wwan-mnc.rrd';
if (file_exists($rrdfilename)) {
$rrd_options .= ' DEF:mnc='.$rrdfilename.':mnc:LAST ';
$rrd_options .= ' --lower-limit 0 ';
$rrd_options .= " --vertical-label='MNC'";
$rrd_options .= " LINE2:mnc#750F7DFF:'MNC Mobile Netwok Code'";
$rrd_options .= ' GPRINT:mnc:LAST:%0.2lf%s\\\l ';
}

View File

@@ -0,0 +1,24 @@
<?php
/*
* LibreNMS
*
* 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 'includes/graphs/common.inc.php';
$rrdfilename = $config['rrd_dir'].'/'.$device['hostname'].'/cisco-wwan-rssi.rrd';
if (file_exists($rrdfilename)) {
$rrd_options .= " COMMENT:'dBm Now Ave Max \\n'";
$rrd_options .= ' DEF:rssi='.$rrdfilename.':rssi:AVERAGE ';
$rrd_options .= ' --alt-autoscale';
$rrd_options .= ' --lower-limit=-110 ';
$rrd_options .= " --vertical-label='dBm'";
$rrd_options .= " LINE2:rssi#FF0000:'RSSI ' ";
$rrd_options .= ' GPRINT:rssi:LAST:%0.2lf%s ';
$rrd_options .= ' GPRINT:rssi:MIN:%0.2lf%s ';
$rrd_options .= ' GPRINT:rssi:MAX:%0.2lf%s\\\l ';
}

View File

@@ -11,17 +11,20 @@
* the source code distribution for details.
*/
if(is_admin() !== false) {
if (is_admin() !== false) {
// Build the types list.
if ($handle = opendir($config['nagios_plugins'])) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) {
list(,$check_name) = explode('_',$file,2);
$dir = $config['nagios_plugins'];
if (file_exists($dir) && is_dir($dir)) {
$files = scandir($dir);
$dir .= DIRECTORY_SEPARATOR;
d_print_r($files);
foreach ($files as $file) {
if (is_executable($dir.$file) && is_file($dir.$file) && strstr($file, 'check_')) {
list(,$check_name) = explode('_', $file, 2);
$stype .= "<option value='$check_name'>$check_name</option>";
}
}
closedir($handle);
}
?>
@@ -142,4 +145,4 @@ $('#service-submit').click('', function(e) {
</script>
<?php
}
}

View File

@@ -3,8 +3,9 @@ require $config['install_dir'].'/includes/object-cache.inc.php';
// FIXME - this could do with some performance improvements, i think. possible rearranging some tables and setting flags at poller time (nothing changes outside of then anyways)
$service_status = get_service_status();
$if_alerts = dbFetchCell("SELECT COUNT(port_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'");
$service_status = get_service_status();
$typeahead_limit = $config['webui']['global_search_result_limit'];
$if_alerts = dbFetchCell("SELECT COUNT(port_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'");
if ($_SESSION['userlevel'] >= 5) {
$links['count'] = dbFetchCell("SELECT COUNT(*) FROM `links`");
@@ -717,6 +718,7 @@ $('#gsearch').typeahead({
},
{
source: devices.ttAdapter(),
limit: '<?php echo($typeahead_limit); ?>',
async: true,
display: 'name',
valueKey: 'name',
@@ -727,6 +729,7 @@ $('#gsearch').typeahead({
},
{
source: ports.ttAdapter(),
limit: '<?php echo($typeahead_limit); ?>',
async: true,
display: 'name',
valueKey: 'name',
@@ -737,6 +740,7 @@ $('#gsearch').typeahead({
},
{
source: bgp.ttAdapter(),
limit: '<?php echo($typeahead_limit); ?>',
async: true,
display: 'name',
valueKey: 'name',
@@ -749,3 +753,4 @@ $('#gsearch').bind('typeahead:open', function(ev, suggestion) {
$('#gsearch').addClass('search-box');
});
</script>

View File

@@ -10,7 +10,7 @@ $files = array();
if ($handle = opendir($rrddir)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
if (eregi('app-shoutcast-'.$app['app_id'], $file)) {
if (stripos($file, 'app-shoutcast-'.$app['app_id']) !== false) {
array_push($files, $file);
}
}
@@ -45,8 +45,8 @@ if (isset($total) && $total === true) {
}
foreach ($files as $id => $file) {
$hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file);
$hostname = eregi_replace('.rrd', '', $hostname);
$hostname = str_ireplace('app-shoutcast-'.$app['app_id'].'-', '', $file);
$hostname = str_ireplace('.rrd', '', $hostname);
list($host, $port) = explode('_', $hostname, 2);
$graphs = array(
'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')',

View File

@@ -1,9 +1,11 @@
<?php
$sensors = dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND device_id = ? ORDER BY `poller_type`, `sensor_oid`, `sensor_index`', array($sensor_class, $device['device_id']));
if ($sensor_class == 'state') {
$sensors = dbFetchRows('SELECT * FROM `sensors` LEFT JOIN `sensors_to_state_indexes` ON sensors_to_state_indexes.sensor_id = sensors.sensor_id LEFT JOIN state_indexes ON state_indexes.state_index_id = sensors_to_state_indexes.state_index_id WHERE `sensor_class` = ? AND device_id = ? ORDER BY `poller_type`, `sensor_oid`, `sensor_index`', array($sensor_class, $device['device_id']));
$sensors = dbFetchRows('SELECT * FROM `sensors` LEFT JOIN `sensors_to_state_indexes` ON sensors_to_state_indexes.sensor_id = sensors.sensor_id LEFT JOIN state_indexes ON state_indexes.state_index_id = sensors_to_state_indexes.state_index_id WHERE `sensor_class` = ? AND device_id = ? ORDER BY `poller_type`, `sensor_index`+0, `sensor_oid`', array($sensor_class, $device['device_id']));
}
else {
$sensors = dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND device_id = ? ORDER BY `poller_type`, `sensor_oid`, `sensor_index`', array($sensor_class, $device['device_id']));
}
if (count($sensors)) {

View File

@@ -157,7 +157,7 @@ echo ' </div>
//From default.php - This code is not part of above license.
if ($config['enable_syslog']) {
$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20";
$query = mysql_query($sql);
echo('<div class="container-fluid">
<div class="row">
<div class="col-md-12">
@@ -196,8 +196,6 @@ echo('<div class="container-fluid">
P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15";
}
$data = mysql_query($query);
echo('<div class="container-fluid">
<div class="row">
<div class="col-md-12">