mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
initial version
This commit is contained in:
@@ -54,7 +54,7 @@ Note if not using HTTPd (Apache): RHEL requires `httpd` to be installed regardle
|
||||
### Adding the librenms-user ###
|
||||
|
||||
useradd librenms -d /opt/librenms -M -r
|
||||
usermod -a -G librenms www-data
|
||||
usermod -a -G librenms apache
|
||||
|
||||
### Using HTTPd (Apache2) ###
|
||||
|
||||
|
||||
+9
-3
@@ -11,6 +11,7 @@
|
||||
- [How do I debug pages not loading correctly?](#faq7)
|
||||
- [How do I debug the discovery process?](#faq11)
|
||||
- [How do I debug the poller process?](#faq12)
|
||||
- [Why do I get a lot apache or rrdtool zombies in my process list?](#faq14)
|
||||
|
||||
### Developing
|
||||
- [How do I add support for a new OS?](#faq8)
|
||||
@@ -82,11 +83,16 @@ You will then have a two options in the footer of the website - Show SQL Debug a
|
||||
|
||||
#### <a name="faq11"> How do I debug the discovery process?</a>
|
||||
|
||||
Please see the (Discovery Support)[http://docs.librenms.org/Support/Discovery Support] document for further details.
|
||||
Please see the [Discovery Support](http://docs.librenms.org/Support/Discovery Support) document for further details.
|
||||
|
||||
#### <a name="faq12"> How do I debug the poller process?</a>
|
||||
|
||||
Please see the (Poller Support)[http://docs.librenms.org/Support/Poller Support] document for further details.
|
||||
Please see the [Poller Support](http://docs.librenms.org/Support/Poller Support) document for further details.
|
||||
|
||||
#### <a name="faq14"> Why do I get a lot apache or rrdtool zombies in my process list?</a>
|
||||
|
||||
If this is related to your web service for LibreNMS then this has been tracked down to an issue within php which the developers aren't fixing. We have implemented a work around which means you
|
||||
shouldn't be seeing this. If you are, please report this in [issue 443](https://github.com/librenms/librenms/issues/443).
|
||||
|
||||
#### <a name="faq8"> How do I add support for a new OS?</a>
|
||||
|
||||
@@ -153,4 +159,4 @@ If you want to pull any new updates provided by f0o's branch then whilst you are
|
||||
|
||||
```bash
|
||||
git pull f0o issue-1337
|
||||
```
|
||||
```
|
||||
|
||||
+5
-1
@@ -14,6 +14,10 @@
|
||||
color: #357ebd;
|
||||
}
|
||||
|
||||
.fa-col-danger {
|
||||
color: #e30613;
|
||||
}
|
||||
|
||||
.twitter-typeahead .tt-hint {
|
||||
border-color: #000 !important;
|
||||
}
|
||||
@@ -93,4 +97,4 @@
|
||||
@keyframes pace-spinner {
|
||||
0% { transform: rotate(0deg); transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); transform: rotate(360deg); }
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -14,6 +14,10 @@
|
||||
color: #357ebd;
|
||||
}
|
||||
|
||||
.fa-col-danger {
|
||||
color: #e30613;
|
||||
}
|
||||
|
||||
.pace {
|
||||
-webkit-pointer-events: none;
|
||||
pointer-events: none;
|
||||
@@ -89,4 +93,4 @@
|
||||
@keyframes pace-spinner {
|
||||
0% { transform: rotate(0deg); transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); transform: rotate(360deg); }
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -14,6 +14,10 @@
|
||||
color: #357ebd;
|
||||
}
|
||||
|
||||
.fa-col-danger {
|
||||
color: #e30613;
|
||||
}
|
||||
|
||||
.twitter-typeahead .tt-hint {
|
||||
border-color: #000 !important;
|
||||
}
|
||||
@@ -93,4 +97,4 @@
|
||||
@keyframes pace-spinner {
|
||||
0% { transform: rotate(0deg); transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); transform: rotate(360deg); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip_forward.rrd";
|
||||
|
||||
$stats = array('ipCidrRouteNumber' => array());
|
||||
|
||||
$i=0;
|
||||
foreach ($stats as $stat => $array)
|
||||
{
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = str_replace("ip", "", $stat);
|
||||
$rrd_list[$i]['ds'] = $stat;
|
||||
}
|
||||
|
||||
$colours='mixed';
|
||||
|
||||
$scale_min = "0";
|
||||
$nototal = 1;
|
||||
$simple_rrd = TRUE;
|
||||
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
|
||||
@@ -185,7 +185,8 @@ if ($_SESSION['userlevel'] >= '10')
|
||||
echo('
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li><a href="addsrv/"><i class="fa fa-cog fa-col-success fa-fw fa-lg"></i> Add Service</a></li>
|
||||
<li><a href="delsrv/"><i class="fa fa-cog fa-col-info fa-fw fa-lg"></i> Delete Service</a></li>');
|
||||
<li><a href="editsrv/"><i class="fa fa-cog fa-col-primary fa-fw fa-lg"></i> Edit Service</a></li>
|
||||
<li><a href="delsrv/"><i class="fa fa-cog fa-col-danger fa-fw fa-lg"></i> Delete Service</a></li>');
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
echo("
|
||||
<h3><span class='label label-success threeqtr-width'>Add Service</span></h3>
|
||||
<form id='addsrv' name='addsrv' method='post' action='' class='form-horizontal' role='form'>
|
||||
<div class='well well-lg'>
|
||||
<div class='form-group'>
|
||||
<input type='hidden' name='addsrv' value='yes'>
|
||||
<label for='device' class='col-sm-2 control-label'>Device</label>
|
||||
<div class='col-sm-5'>
|
||||
<select name='device' class='form-control input-sm'>
|
||||
$devicesform
|
||||
</select>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='type' class='col-sm-2 control-label'>Type</label>
|
||||
<div class='col-sm-5'>
|
||||
<select name='type' id='type' class='form-control input-sm'>
|
||||
$servicesform
|
||||
</select>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='descr' class='col-sm-2 control-label'>Description</label>
|
||||
<div class='col-sm-5'>
|
||||
<textarea name='descr' id='descr' class='form-control input-sm' rows='5'></textarea>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='ip' class='col-sm-2 control-label'>IP Address</label>
|
||||
<div class='col-sm-5'>
|
||||
<input name='ip' id='ip' class='form-control input-sm' placeholder='IP Address'>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='params' class='col-sm-2 control-label'>Parameters</label>
|
||||
<div class='col-sm-5'>
|
||||
<input name='params' id='params' class='form-control input-sm'>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<button type='submit' name='Submit' class='btn btn-success input-sm'>Add Service</button>
|
||||
</div>
|
||||
</form>");
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
if (isset($_POST['service']) && is_numeric($_POST['service'])) {
|
||||
|
||||
$service = dbFetchRow("SELECT * FROM `services` WHERE `service_id`=?", array($_POST['service']));
|
||||
|
||||
echo("
|
||||
<h3><span class='label label-primary threeqtr-width'>Edit Service</span></h3>
|
||||
<form id='confirm-editsrv' name='confirm-editsrv' method='post' action='' class='form-horizontal' role='form'>
|
||||
<input type='hidden' name='device' value='" . $service['device_id'] . "'>
|
||||
<input type='hidden' name='service' value='" . $service['service_id'] . "'>
|
||||
<div class='well well-lg'>
|
||||
<div class='form-group'>
|
||||
<label for='descr' class='col-sm-2 control-label'>Description</label>
|
||||
<div class='col-sm-5'>
|
||||
<textarea name='descr' id='descr' class='form-control input-sm' rows='5'>" . $service['service_desc'] . "</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='ip' class='col-sm-2 control-label'>IP Address</label>
|
||||
<div class='col-sm-5'>
|
||||
<input name='ip' id='ip' value='" . $service['service_ip'] . "' class='form-control input-sm' placeholder='IP Address'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='params' class='col-sm-2 control-label'>Parameters</label>
|
||||
<div class='col-sm-5'>
|
||||
<input name='params' id='params' value='" . $service['service_param'] . "' class='form-control input-sm'>
|
||||
</div>
|
||||
</div>
|
||||
<button type='submit' id='confirm-editsrv' name='confirm-editsrv' value='yes' class='btn btn-primary input-sm'>Edit Service</button>
|
||||
</div>
|
||||
</form>");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$updated = '1';
|
||||
|
||||
$service_id = add_service(mres($_POST['device']), mres($_POST['type']), mres($_POST['descr']), mres($_POST['ip']), mres($_POST['params']));
|
||||
|
||||
if ($service_id) {
|
||||
$message .= $message_break . "Service added (".$service_id.")!";
|
||||
$message_break .= "<br />";
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$updated = '1';
|
||||
|
||||
$updated = edit_service(mres($_POST['service']), mres($_POST['descr']), mres($_POST['ip']), mres($_POST['params']));
|
||||
@@ -44,58 +44,14 @@ else
|
||||
|
||||
$pagetitle[] = "Add service";
|
||||
|
||||
echo("
|
||||
<h4>Add Service</h4>
|
||||
<form id='addsrv' name='addsrv' method='post' action='' class='form-horizontal' role='form'>
|
||||
<div class='well well-lg'>
|
||||
<div class='form-group'>
|
||||
<input type='hidden' name='addsrv' value='yes'>
|
||||
<label for='device' class='col-sm-2 control-label'>Device</label>
|
||||
<div class='col-sm-5'>
|
||||
<select name='device' class='form-control input-sm'>
|
||||
$devicesform
|
||||
</select>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='type' class='col-sm-2 control-label'>Type</label>
|
||||
<div class='col-sm-5'>
|
||||
<select name='type' id='type' class='form-control input-sm'>
|
||||
$servicesform
|
||||
</select>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='descr' class='col-sm-2 control-label'>Description</label>
|
||||
<div class='col-sm-5'>
|
||||
<textarea name='descr' id='descr' class='form-control input-sm' rows='5'></textarea>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='ip' class='col-sm-2 control-label'>IP Address</label>
|
||||
<div class='col-sm-5'>
|
||||
<input name='ip' id='ip' class='form-control input-sm' placeholder='IP Address'>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='params' class='col-sm-2 control-label'>Parameters</label>
|
||||
<div class='col-sm-5'>
|
||||
<input name='params' id='params' class='form-control input-sm'>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<button type='submit' name='Submit' class='btn btn-default input-sm'>Add Service</button>
|
||||
</div>
|
||||
</form>");
|
||||
echo "<div class='row'>
|
||||
<div class='col-sm-6'>";
|
||||
|
||||
require_once "includes/print-service-add.inc.php";
|
||||
|
||||
echo "</div>
|
||||
</div>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ if ($_SESSION['userlevel'] < '5')
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<button type='submit' name='Submit' class='btn btn-default input-sm'>Delete</button>
|
||||
<button type='submit' name='Submit' class='btn btn-danger input-sm'>Delete</button>
|
||||
</div>
|
||||
</form>");
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ if ($_SESSION['userlevel'] < '7')
|
||||
$panes['alert-rules'] = 'Alert Rules';
|
||||
$panes['modules'] = 'Modules';
|
||||
|
||||
if ($config['enable_services'])
|
||||
if ($config['show_services'])
|
||||
{
|
||||
$panes['services'] = 'Services';
|
||||
}
|
||||
|
||||
@@ -1,101 +1,85 @@
|
||||
<?php
|
||||
|
||||
echo('<div style="padding: 10px;">');
|
||||
if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
|
||||
if ($_POST['addsrv']) {
|
||||
if ($_SESSION['userlevel'] >= '10') {
|
||||
include("includes/service-add.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['delsrv']) {
|
||||
if ($_SESSION['userlevel'] >= '10') {
|
||||
include("includes/service-delete.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
if ($handle = opendir($config['install_dir'] . "/includes/services/"))
|
||||
{
|
||||
while (false !== ($file = readdir($handle)))
|
||||
{
|
||||
if ($file != "." && $file != ".." && !strstr($file, "."))
|
||||
{
|
||||
$servicesform .= "<option value='$file'>$file</option>";
|
||||
if ($_POST['addsrv']) {
|
||||
if ($_SESSION['userlevel'] >= '10') {
|
||||
include("includes/service-add.inc.php");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
if ($_POST['delsrv']) {
|
||||
if ($_SESSION['userlevel'] >= '10') {
|
||||
include("includes/service-delete.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `devices` ORDER BY `hostname`") as $dev);
|
||||
{
|
||||
$devicesform .= "<option value='" . $dev['device_id'] . "'>" . $dev['hostname'] . "</option>";
|
||||
}
|
||||
if ($_POST['confirm-editsrv']) {
|
||||
echo "yeah";
|
||||
if ($_SESSION['userlevel'] >= '10') {
|
||||
include("includes/service-edit.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated) { print_message("Device Settings Saved"); }
|
||||
if ($handle = opendir($config['install_dir'] . "/includes/services/")) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != ".." && !strstr($file, ".")) {
|
||||
$servicesform .= "<option value='$file'>$file</option>";
|
||||
}
|
||||
}
|
||||
|
||||
if (dbFetchCell("SELECT COUNT(*) from `services` WHERE `device_id` = ?", array($device['device_id'])) > '0')
|
||||
{
|
||||
$i = "1";
|
||||
foreach (dbFetchRows("select * from services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $service)
|
||||
{
|
||||
$existform .= "<option value='" . $service['service_id'] . "'>" . $service['service_type'] . "</option>";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
if($existform)
|
||||
{
|
||||
echo('<div style="float: left;">');
|
||||
echo("
|
||||
$dev = device_by_id_cache($device['device_id']);
|
||||
$devicesform = "<option value='" . $dev['device_id'] . "'>" . $dev['hostname'] . "</option>";
|
||||
|
||||
<h1>Remove Service</h1>
|
||||
if ($updated) {
|
||||
print_message("Device Settings Saved");
|
||||
}
|
||||
|
||||
<form id='delsrv' name='delsrv' method='post' action=''>
|
||||
<input type=hidden name='delsrv' value='yes'>
|
||||
<table width='200' border='0'>
|
||||
<option type=hidden name=device value='".$device['device_id']."'>
|
||||
<tr>
|
||||
<td>
|
||||
Type
|
||||
</td>
|
||||
<td>
|
||||
<select name='service'>
|
||||
$existform
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type='submit' name='Submit' value='Delete' />
|
||||
</label>
|
||||
</form>");
|
||||
if (dbFetchCell("SELECT COUNT(*) from `services` WHERE `device_id` = ?", array($device['device_id'])) > '0') {
|
||||
$i = "1";
|
||||
foreach (dbFetchRows("select * from services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $service) {
|
||||
$existform .= "<option value='" . $service['service_id'] . "'>" . $service['service_type'] . "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
echo('</div>');
|
||||
}
|
||||
echo '<div class="row">';
|
||||
|
||||
echo('<div style="width: 45%; float: right;">');
|
||||
if ($existform) {
|
||||
echo '<div class="col-sm-6">';
|
||||
if ($_POST['editsrv'] == "yes") {
|
||||
include_once "includes/print-service-edit.inc.php";
|
||||
} else {
|
||||
echo "
|
||||
<h3><span class='label label-info threeqtr-width'>Edit / Delete Service</span></h3>
|
||||
<form method='post' action='' class='form-horizontal'>
|
||||
<div class='well well-lg'>
|
||||
<div class='form-group'>
|
||||
<label for='service' class='col-sm-2 control-label'>Type: </label>
|
||||
<div class='col-sm-4'>
|
||||
<select name='service' class='form-control input-sm'>
|
||||
$existform
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<div class='col-sm-offset-2 col-sm-4'>
|
||||
<button type='submit' class='btn btn-primary btn-sm' name='editsrv' id='editsrv' value='yes'>Edit</button> <button type='submit' class='btn btn-danger btn-sm' name='delsrv' id='delsrv' value='yes'>Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>";
|
||||
}
|
||||
|
||||
echo("
|
||||
<h1>Add Service</h1>
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
<form id='addsrv' name='addsrv' method='post' action=''>
|
||||
<input type=hidden name='addsrv' value='yes'>
|
||||
<table width='200' border='0'>
|
||||
<option type=hidden name=device value='".$device['device_id']."'>
|
||||
<tr>
|
||||
<td>
|
||||
Type
|
||||
</td>
|
||||
<td>
|
||||
<select name='type'>
|
||||
$servicesform
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type='submit' name='Submit' value='Add' />
|
||||
<label><br />
|
||||
</label>
|
||||
</form>
|
||||
</div>");
|
||||
echo '<div class="col-sm-6">';
|
||||
|
||||
?>
|
||||
require_once "includes/print-service-add.inc.php";
|
||||
|
||||
} else {
|
||||
include("includes/error-no-perm.inc.php");
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if (is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-ip_forward.rrd"))
|
||||
{
|
||||
$graph_title = "IP Forward statistics";
|
||||
$graph_type = "device_ip_forward";
|
||||
|
||||
include("includes/print-device-graph.php");
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
if (is_admin() === FALSE && is_read() === FALSE) {
|
||||
|
||||
include "includes/error-no-perm.inc.php";
|
||||
|
||||
} else {
|
||||
|
||||
$pagetitle[] = "Edit service";
|
||||
|
||||
if ($_POST['confirm-editsrv'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] > "5")
|
||||
{
|
||||
include("includes/service-edit.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname") as $device)
|
||||
{
|
||||
$servicesform .= "<option value='" . $device['service_id'] . "'>" . $device['hostname'] . " - " . $device['service_type'] . "</option>";
|
||||
}
|
||||
|
||||
if ($updated) { print_message("Service updated!"); }
|
||||
|
||||
if ($_POST['editsrv'] == 'yes') {
|
||||
|
||||
require_once "includes/print-service-edit.inc.php";
|
||||
|
||||
} else {
|
||||
|
||||
echo("
|
||||
<h4>Delete Service</h4>
|
||||
<form id='editsrv' name='editsrv' method='post' action='' class='form-horizontal' role='form'>
|
||||
<input type=hidden name='delsrv' value='yes'>
|
||||
<div class='well well-lg'>
|
||||
<div class='form-group'>
|
||||
<label for='service' class='col-sm-2 control-label'>Device - Service</label>
|
||||
<div class='col-sm-5'>
|
||||
<select name='service' id='service' class='form-control input-sm'>
|
||||
$servicesform
|
||||
</select>
|
||||
</div>
|
||||
<div class='col-sm-5'>
|
||||
</div>
|
||||
</div>
|
||||
<button type='submit' name='editsrv' id='editsrv' value='yes' class='btn btn-primary input-sm'>Edit</button>
|
||||
</div>
|
||||
</form>");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -299,8 +299,12 @@ function GetContacts($results) {
|
||||
}
|
||||
}
|
||||
if( is_numeric($result["device_id"]) ) {
|
||||
$tmpa = dbFetchRow("SELECT sysContact FROM devices WHERE device_id = ?",array($result["device_id"]));
|
||||
$contacts[$tmpa["sysContact"]] = "NOC";
|
||||
if( dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_bool' AND device_id = ?",array($result["device_id"])) === "1" ) {
|
||||
$tmpa = dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_string' AND device_id = ?",array($result["device_id"]));
|
||||
} else {
|
||||
$tmpa = dbFetchCell("SELECT sysContact FROM devices WHERE device_id = ?",array($result["device_id"]));
|
||||
}
|
||||
$contacts[$tmpa] = "NOC";
|
||||
$tmpa = dbFetchRows("SELECT user_id FROM devices_perms WHERE access_level >= 0 AND device_id = ?", array($result["device_id"]));
|
||||
foreach( $tmpa as $tmp ) {
|
||||
$uids[$tmp['user_id']] = $tmp['user_id'];
|
||||
|
||||
+28
-5
@@ -561,12 +561,35 @@ function is_valid_hostname($hostname)
|
||||
return ctype_alnum(str_replace('_','',str_replace('-','',str_replace('.','',$hostname))));
|
||||
}
|
||||
|
||||
function add_service($device, $service, $descr)
|
||||
{
|
||||
$insert = array('device_id' => $device['device_id'], 'service_ip' => $device['hostname'], 'service_type' => $service,
|
||||
'service_changed' => array('UNIX_TIMESTAMP(NOW())'), 'service_desc' => $descr, 'service_param' => "", 'service_ignore' => "0");
|
||||
function add_service($device, $service, $descr, $service_ip, $service_param = "", $service_ignore = 0) {
|
||||
|
||||
if (!is_array($device)) {
|
||||
$device = device_by_id_cache($device);
|
||||
}
|
||||
|
||||
if (empty($service_ip)) {
|
||||
$service_ip = $device['hostname'];
|
||||
}
|
||||
|
||||
$insert = array('device_id' => $device['device_id'], 'service_ip' => $service_ip, 'service_type' => $service,
|
||||
'service_changed' => array('UNIX_TIMESTAMP(NOW())'), 'service_desc' => $descr, 'service_param' => $service_param, 'service_ignore' => $service_ignore);
|
||||
|
||||
return dbInsert($insert, 'services');
|
||||
}
|
||||
|
||||
function edit_service($service, $descr, $service_ip, $service_param = "", $service_ignore = 0) {
|
||||
|
||||
if (!is_numeric($service)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$update = array('service_ip' => $service_ip,
|
||||
'service_changed' => array('UNIX_TIMESTAMP(NOW())'),
|
||||
'service_desc' => $descr,
|
||||
'service_param' => $service_param,
|
||||
'service_ignore' => $service_ignore);
|
||||
return dbUpdate($update, 'services', '`service_id`=?', array($service));
|
||||
|
||||
echo dbInsert($insert, 'services');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1560,6 +1560,10 @@ $config['graph_types']['device']['netstat_snmp_pkt']['section'] = 'netstats';
|
||||
$config['graph_types']['device']['netstat_snmp_pkt']['order'] = '0';
|
||||
$config['graph_types']['device']['netstat_snmp_pkt']['descr'] = 'SNMP Packet Type Statistics';
|
||||
|
||||
$config['graph_types']['device']['netstat_ip_forward']['section'] = 'netstats';
|
||||
$config['graph_types']['device']['netstat_ip_forward']['order'] = '0';
|
||||
$config['graph_types']['device']['netstat_ip_forward']['descr'] = 'IP Forwarding Statistics';
|
||||
|
||||
$config['graph_types']['device']['netstat_tcp']['section'] = 'netstats';
|
||||
$config['graph_types']['device']['netstat_tcp']['order'] = '0';
|
||||
$config['graph_types']['device']['netstat_tcp']['descr'] = 'TCP Statistics';
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "routeros")
|
||||
{
|
||||
$oids = snmp_walk($device, "mtxrHlActiveFan", "-OsqnU", "MIKROTIK-MIB");
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
if ($oids) echo("MIKROTIK-MIB ");
|
||||
$divisor = 1;
|
||||
$type = "mikrotik";
|
||||
|
||||
foreach (explode("\n", $oids) as $data)
|
||||
{
|
||||
$data = trim($data);
|
||||
if ($data)
|
||||
{
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$index = $split_oid[count($split_oid)-1];
|
||||
$descr = "Fan " . $index;
|
||||
$oid = ".1.3.6.1.4.1.14988.1.1.3.9." . $index;
|
||||
$fanspeed = snmp_get($device, $oid, "-Oqv") / $divisor;
|
||||
if ($fanspeed > 0)
|
||||
{
|
||||
discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $fanspeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "routeros")
|
||||
{
|
||||
$oids = snmp_walk($device, "mtxrHlTemperature", "-OsqnU", "MIKROTIK-MIB");
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
if ($oids) echo("MIKROTIK-MIB ");
|
||||
$divisor = 10.0;
|
||||
$type = "mikrotik";
|
||||
|
||||
foreach (explode("\n", $oids) as $data)
|
||||
{
|
||||
$data = trim($data);
|
||||
if ($data)
|
||||
{
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$index = $split_oid[count($split_oid)-1];
|
||||
$descr = "Temperature " . $index;
|
||||
$oid = ".1.3.6.1.4.1.14988.1.1.3.10." . $index;
|
||||
$temperature = snmp_get($device, $oid, "-Oqv") / $divisor;
|
||||
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $temperature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "routeros")
|
||||
{
|
||||
$oids = snmp_walk($device, "mtxrHlVoltage", "-OsqnU", "MIKROTIK-MIB");
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
if ($oids) echo("MIKROTIK-MIB ");
|
||||
$divisor = 10.0;
|
||||
$type = "mikrotik";
|
||||
|
||||
foreach (explode("\n", $oids) as $data)
|
||||
{
|
||||
$data = trim($data);
|
||||
if ($data)
|
||||
{
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$index = $split_oid[count($split_oid)-1];
|
||||
$descr = "Voltage " . $index;
|
||||
$oid = ".1.3.6.1.4.1.14988.1.1.3.8." . $index;
|
||||
$voltage = snmp_get($device, $oid, "-Oqv") / $divisor;
|
||||
|
||||
discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $voltage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -229,9 +229,13 @@ function renamehost($id, $new, $source = 'console')
|
||||
|
||||
// FIXME does not check if destination exists!
|
||||
$host = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id));
|
||||
rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new");
|
||||
dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id));
|
||||
log_event("Hostname changed -> $new ($source)", $id, 'system');
|
||||
if (rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new") === TRUE) {
|
||||
dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id));
|
||||
log_event("Hostname changed -> $new ($source)", $id, 'system');
|
||||
} else {
|
||||
echo "Renaming of $host failed\n";
|
||||
log_event("Renaming of $host failed", $id, 'system');
|
||||
}
|
||||
}
|
||||
|
||||
function delete_device($id)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" IP-FORWARD");
|
||||
|
||||
// Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
|
||||
$oids = array ('ipCidrRouteNumber');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip_forward.rrd";
|
||||
|
||||
$rrd_create = $config['rrd_rra'];
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:GAUGE:600:U:1000000"; // Limit to 1MPPS?
|
||||
$snmpstring .= " IP-FORWARD-MIB::".$oid.".0";
|
||||
}
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring, "-OQUs", "IP-FORWARD-MIB");
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "U";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data[0]['ipCidrRouteNumber']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_ip_forward'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos, $snmpstring);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
include("netstats-udp.inc.php");
|
||||
include("netstats-icmp.inc.php");
|
||||
include("netstats-snmp.inc.php");
|
||||
include("netstats-ip_forward.inc.php");
|
||||
|
||||
echo("\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user