Commit version 24.12.13800

This commit is contained in:
2025-01-06 17:35:06 -05:00
parent b7f6a79c2c
commit 55d9218816
6133 changed files with 4239740 additions and 1374287 deletions

View File

@ -4,209 +4,267 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
?>
<div class="row">
<div class="col-md-6">
<?php
<div class="row">
<div class="col-md-6">
<?php
print_versions();
print_versions();
$ua = detect_browser();
//r($ua);
register_html_resource('js', 'moment.min.js');
$tz = get_timezone(TRUE); // Refresh timezone, for get system TZ
//r($tz);
?>
<div class="box box-solid">
<div class="box-header">
<h3 class="box-title">Browser & Timezone Information</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed-more">
<tbody>
<tr><td><b>User-Agent</b></td><td><?php echo $ua['user_agent']; ?></td></tr>
<tr><td><b>Browser</b></td><td><?php echo $ua['browser_full'] . ' (' . $ua['platform'] . ')'; ?></td></tr>
<tr><td><b>Screen&nbsp;Resolution</b></td><td><?php echo $ua['screen_resolution']; ?></td></tr>
<tr><td><b>Timezone</b></td><td><?php echo $tz['system'] . ' (System), ' . $tz['php'] . ' (PHP), ' . $tz['mysql'] . ' (DB), '; ?><script>document.write(moment().format('Z') + ' (User)');</script></td></tr>
</tbody>
</table>
</div>
</div>
$ua = detect_browser();
//r($ua);
register_html_resource('js', 'moment.min.js');
$tz = get_timezone(TRUE); // Refresh timezone, for get system TZ
//r($tz);
?>
<div class="box box-solid">
<div class="box-header">
<h3 class="box-title">Browser & Timezone Information</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed-more">
<tbody>
<tr>
<td><b>User-Agent</b></td>
<td><?php echo $ua['user_agent']; ?></td>
</tr>
<tr>
<td><b>Browser</b></td>
<td><?php echo $ua['browser_full'] . ' (' . $ua['platform'] . ')'; ?></td>
</tr>
<tr>
<td><b>Screen&nbsp;Resolution</b></td>
<td><?php echo $ua['screen_resolution']; ?></td>
</tr>
<tr>
<td><b>Timezone</b></td>
<td><?php echo $tz['system'] . ' (System), ' . $tz['php'] . ' (PHP), ' . $tz['mysql'] . ' (DB), '; ?>
<script>document.write(moment().format('Z') + ' (User)');</script>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div style="margin-bottom: 10px; margin-top: 10px;">
<table style="width: 100%; background: transparent;">
<tr>
<td style="width: 12%; text-align: center;"><a class="btn btn" target="_blank" href="<?php echo OBSERVIUM_URL; ?>"><i style="font-size: small;" class="icon-globe"></i>&nbsp; Web</a></td>
<td style="width: 12%; text-align: center;"><a class="btn btn" target="_blank" href="<?php echo OBSERVIUM_DOCS_URL; ?>"><i style="font-size: small;" class="icon-info"></i>&nbsp; Docs</a></td>
<td style="width: 18%; text-align: center;"><a class="btn btn" target="_blank" href="https://jira.observium.org/"><i style="font-size: small;" class="icon-bug"></i>&nbsp; Bugtracker</a></td>
<td style="width: 19%; text-align: center;"><a class="btn btn" target="_blank" href="https://discord.gg/GjpNXKWm8W"><i class="icon-gamepad"></i> Discord</a></td>
<!-- <td style="width: 19%; text-align: center;"><a class="btn btn" target="_blank" href="<?php echo OBSERVIUM_URL; ?>/docs/mailinglists"><i class="icon-envelope"></i>&nbsp; Mailing&nbsp;List</a></td> -->
<td style="width: 17%; text-align: center;"><a class="btn btn" target="_blank" href="https://twitter.com/observium"><i style="font-size: small;" class="icon-twitter-sign"></i>&nbsp; Twitter</a></td>
<td style="width: 16%; text-align: center;"><a class="btn btn" target="_blank" href="https://www.facebook.com/pages/Observium/128354461353"><i style="font-size: small;" class="icon-facebook-sign"></i>&nbsp; Facebook</a></td>
</tr>
</table>
</div>
<div style="margin-bottom: 10px; margin-top: 10px;">
<table style="width: 100%; background: transparent;">
<tr>
<td style="width: 12%; text-align: center;"><a class="btn btn" target="_blank" href="<?php echo OBSERVIUM_URL; ?>"><i
style="font-size: small;" class="icon-globe"></i>&nbsp; Web</a></td>
<td style="width: 12%; text-align: center;"><a class="btn btn" target="_blank" href="<?php echo OBSERVIUM_DOCS_URL; ?>"><i
style="font-size: small;" class="icon-info"></i>&nbsp; Docs</a></td>
<td style="width: 18%; text-align: center;"><a class="btn btn" target="_blank" href="<?php echo OBSERVIUM_BUG_URL; ?>"><i
style="font-size: small;" class="icon-bug"></i>&nbsp; Bugtracker</a></td>
<td style="width: 19%; text-align: center;"><a class="btn btn" target="_blank" href="https://discord.gg/GjpNXKWm8W"><i
class="icon-gamepad"></i> Discord</a></td>
<td style="width: 17%; text-align: center;"><a class="btn btn" target="_blank" href="https://twitter.com/observium"><i
style="font-size: small;" class="icon-twitter-sign"></i>&nbsp; Twitter</a></td>
<td style="width: 16%; text-align: center;"><a class="btn btn" target="_blank"
href="https://www.facebook.com/pages/Observium/128354461353">
<i style="font-size: small;" class="icon-facebook-sign"></i>&nbsp;
Facebook</a></td>
</tr>
</table>
</div>
<div class="box box-solid">
<div class="box-header with-border"><h3 class="box-title">Development Team</h3></div>
<div class="box-body no-padding">
<dl class="dl-horizontal" style="margin: 0px; padding:5px;">
<dt style="text-align: left;"><i class="icon-user"></i> Adam Armstrong</dt><dd>Project Leader</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Tom Laermans</dt><dd>Committer & Developer</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Mike Stupalov</dt><dd>Committer & Developer</dd>
</dl>
</div>
</div>
<div class="box box-solid">
<div class="box-header with-border"><h3 class="box-title">Development Team</h3></div>
<div class="box-body no-padding">
<dl class="dl-horizontal" style="margin: 0px; padding:5px;">
<dt style="text-align: left;"><i class="icon-user"></i> Adam Armstrong</dt>
<dd>Project Leader</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Tom Laermans</dt>
<dd>Committer & Developer</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Mike Stupalov</dt>
<dd>Committer & Developer</dd>
</dl>
</div>
</div>
<div class="box box-solid">
<div class="box-header with-border"><h3 class="box-title">Acknowledgements</h3></div>
<div class="box-body no-padding">
<dl class="dl-horizontal" style="margin: 0px; padding:5px;">
<dt style="text-align: left;"><i class="icon-user"></i> Jonathan De Graeve</dt><dd>SNMP code improvements</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Xiaochi Jin</dt><dd>Logo design</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Akichi Ren</dt><dd>Post-steampunk observational hamster</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Bruno Pramont</dt><dd>Collectd code</dd>
<dt style="text-align: left;"><i class="icon-user"></i> David Farrell</dt><dd>Help with parsing net-SNMP output in PHP</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Dennis de Houx</dt><dd>Code contributions</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Geert Hauwaerts</dt><dd>Code contributions</dd>
</dl>
<div class="box box-solid">
<div class="box-header with-border"><h3 class="box-title">Acknowledgements</h3></div>
<div class="box-body no-padding">
<dl class="dl-horizontal" style="margin: 0px; padding:5px;">
<dt style="text-align: left;"><i class="icon-user"></i> Maarten Moerman</dt>
<dd>Makes the magic happen</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Jonathan De Graeve</dt>
<dd>SNMP code improvements</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Xiaochi Jin</dt>
<dd>Logo design</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Akichi Ren</dt>
<dd>Post-steampunk observational hamster</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Bruno Pramont</dt>
<dd>Collectd code</dd>
<dt style="text-align: left;"><i class="icon-user"></i> David Farrell</dt>
<dd>Help with parsing net-SNMP output in PHP</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Dennis de Houx</dt>
<dd>Code contributions</dd>
<dt style="text-align: left;"><i class="icon-user"></i> Geert Hauwaerts</dt>
<dd>Code contributions</dd>
</dl>
</div>
</div>
<?php
if (!$_SESSION['user_limited']) {
$cache_item = get_cache_item('stats');
if (!ishit_cache_item($cache_item)) {
$stats = [];
$stats['devices'] = dbFetchCell('SELECT COUNT(*) FROM `devices`');
$stats['ports'] = dbFetchCell('SELECT COUNT(*) FROM `ports`');
$stats['syslog'] = dbFetchCell('SELECT COUNT(*) FROM `syslog`');
$stats['events'] = dbFetchCell('SELECT COUNT(*) FROM `eventlog`');
$stats['applications'] = dbFetchCell('SELECT COUNT(*) FROM `applications`');
$stats['storage'] = dbFetchCell('SELECT COUNT(*) FROM `storage`');
$stats['diskio'] = dbFetchCell('SELECT COUNT(*) FROM `ucd_diskio`');
$stats['processors'] = dbFetchCell('SELECT COUNT(*) FROM `processors`');
$stats['memory'] = dbFetchCell('SELECT COUNT(*) FROM `mempools`');
$stats['sensors'] = dbFetchCell('SELECT COUNT(*) FROM `sensors`');
$stats['sensors'] += dbFetchCell('SELECT COUNT(*) FROM `status`');
$stats['printersupplies'] = dbFetchCell('SELECT COUNT(*) FROM `printersupplies`');
$stats['hrdevice'] = dbFetchCell('SELECT COUNT(*) FROM `hrDevice`');
$stats['entphysical'] = dbFetchCell('SELECT COUNT(*) FROM `entPhysical`');
$stats['ipv4_addresses'] = dbFetchCell('SELECT COUNT(*) FROM `ipv4_addresses`');
$stats['ipv4_networks'] = dbFetchCell('SELECT COUNT(*) FROM `ipv4_networks`');
$stats['ipv6_addresses'] = dbFetchCell('SELECT COUNT(*) FROM `ipv6_addresses`');
$stats['ipv6_networks'] = dbFetchCell('SELECT COUNT(*) FROM `ipv6_networks`');
$stats['pseudowires'] = dbFetchCell('SELECT COUNT(*) FROM `pseudowires`');
$stats['vrfs'] = dbFetchCell('SELECT COUNT(*) FROM `vrfs`');
$stats['vlans'] = dbFetchCell('SELECT COUNT(*) FROM `vlans`');
$stats['netscaler_vservers'] = dbFetchCell('SELECT COUNT(*) FROM `netscaler_vservers`');
$stats['netscaler_services'] = dbFetchCell('SELECT COUNT(*) FROM `netscaler_services`');
$stats['vms'] = dbFetchCell('SELECT COUNT(*) FROM `vminfo`');
$stats['slas'] = dbFetchCell('SELECT COUNT(*) FROM `slas`');
$stats['db'] = get_db_size();
$stats['rrd'] = get_dir_size($config['rrd_dir']);
set_cache_item($cache_item, $stats, ['ttl' => 900]); // 15 min
} else {
$stats = get_cache_data($cache_item);
}
// Clean cache item
unset($cache_item);
?>
<div class="box box-solid">
<div class="box-header"><h3 class="box-title">Statistics</h3></div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed">
<tbody>
<tr>
<td style="width: 45%;"><i class="<?php echo $config['icon']['storage']; ?>"></i> <strong>DB size</strong></td>
<td><span class="pull-right"><?php echo format_bytes($stats['db']); ?></span></td>
<td style="width: 45%;"><i class="<?php echo $config['icon']['database']; ?>"></i> <strong>RRD size</strong></td>
<td><span class="pull-right"><?php echo format_bytes($stats['rrd']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['devices']; ?>"></i> <strong>Devices</strong></td>
<td><span class="pull-right"><?php echo $stats['devices']; ?></span></td>
<td><i class="<?php echo $config['icon']['port']; ?>"></i> <strong>Ports</strong></td>
<td><span class="pull-right"><?php echo $stats['ports']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['ipv4']; ?>"></i> <strong>IPv4 Addresses</strong></td>
<td><span class="pull-right"><?php echo $stats['ipv4_addresses']; ?></span></td>
<td><i class="<?php echo $config['icon']['ipv4']; ?>"></i> <strong>IPv4 Networks</strong></td>
<td><span class="pull-right"><?php echo $stats['ipv4_networks']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['ipv6']; ?>"></i> <strong>IPv6 Addresses</strong></td>
<td><span class="pull-right"><?php echo $stats['ipv6_addresses']; ?></span></td>
<td><i class="<?php echo $config['icon']['ipv6']; ?>"></i> <strong>IPv6 Networks</strong></td>
<td><span class="pull-right"><?php echo $stats['ipv6_networks']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['service']; ?>"></i> <strong>Services</strong></td>
<td><span class="pull-right"><?php echo $stats['services']; ?></span></td>
<td><i class="<?php echo $config['icon']['apps']; ?>"></i> <strong>Applications</strong></td>
<td><span class="pull-right"><?php echo $stats['applications']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['processor']; ?>"></i> <strong>Processors</strong></td>
<td><span class="pull-right"><?php echo $stats['processors']; ?></span></td>
<td><i class="<?php echo $config['icon']['mempool']; ?>"></i> <strong>Memory pools</strong></td>
<td><span class="pull-right"><?php echo $stats['memory']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['storage']; ?>"></i> <strong>Storage Entries</strong></td>
<td><span class="pull-right"><?php echo $stats['storage']; ?></span></td>
<td><i class="<?php echo $config['icon']['diskio']; ?>"></i> <strong>Disk I/O Entries</strong></td>
<td><span class="pull-right"><?php echo $stats['diskio']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['inventory']; ?>"></i> <strong>HR-MIB Entries</strong></td>
<td><span class="pull-right"><?php echo $stats['hrdevice']; ?></span></td>
<td><i class="<?php echo $config['icon']['inventory']; ?>"></i> <strong>Entity-MIB Entries</strong></td>
<td><span class="pull-right"><?php echo $stats['entphysical']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['syslog']; ?>"></i> <strong>Syslog Entries</strong></td>
<td><span class="pull-right"><?php echo $stats['syslog']; ?></span></td>
<td><i class="<?php echo $config['icon']['eventlog']; ?>"></i> <strong>Eventlog Entries</strong></td>
<td><span class="pull-right"><?php echo $stats['events']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['sensor']; ?>"></i> <strong>Sensors</strong></td>
<td><span class='pull-right'><?php echo $stats['sensors']; ?></span></td>
<td><i class="<?php echo $config['icon']['printersupply']; ?>"></i> <strong>Printer Supplies</strong></td>
<td><span class='pull-right'><?php echo $stats['printersupplies']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['vserver']; ?>"></i> <strong>Netscaler VServers</strong></td>
<td><span class="pull-right"><?php echo $stats['netscaler_vservers']; ?></span></td>
<td><i class="<?php echo $config['icon']['service']; ?>"></i> <strong>Netscaler Services</strong></td>
<td><span class="pull-right"><?php echo $stats['netscaler_services']; ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['virtual-machine']; ?>"></i> <strong>Virtual Machines</strong></td>
<td><span class="pull-right"><?php echo $stats['vms']; ?></span></td>
<td><i class="<?php echo $config['icon']['sla']; ?>"></i> <strong>IP SLAs</strong></td>
<td><span class="pull-right"><?php echo $stats['slas']; ?></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
} // End statistics for not limited users
?>
</div>
</div>
<div class="col-md-6">
<?php
if (!$_SESSION['user_limited']) {
$cache_item = get_cache_item('stats');
if (!ishit_cache_item($cache_item)) {
$stats = [];
$stats['devices'] = dbFetchCell('SELECT COUNT(*) FROM `devices`');
$stats['ports'] = dbFetchCell('SELECT COUNT(*) FROM `ports`');
$stats['syslog'] = dbFetchCell('SELECT COUNT(*) FROM `syslog`');
$stats['events'] = dbFetchCell('SELECT COUNT(*) FROM `eventlog`');
$stats['applications'] = dbFetchCell('SELECT COUNT(*) FROM `applications`');
$stats['storage'] = dbFetchCell('SELECT COUNT(*) FROM `storage`');
$stats['diskio'] = dbFetchCell('SELECT COUNT(*) FROM `ucd_diskio`');
$stats['processors'] = dbFetchCell('SELECT COUNT(*) FROM `processors`');
$stats['memory'] = dbFetchCell('SELECT COUNT(*) FROM `mempools`');
$stats['sensors'] = dbFetchCell('SELECT COUNT(*) FROM `sensors`');
$stats['sensors'] += dbFetchCell('SELECT COUNT(*) FROM `status`');
$stats['printersupplies'] = dbFetchCell('SELECT COUNT(*) FROM `printersupplies`');
$stats['hrdevice'] = dbFetchCell('SELECT COUNT(*) FROM `hrDevice`');
$stats['entphysical'] = dbFetchCell('SELECT COUNT(*) FROM `entPhysical`');
$stats['ipv4_addresses'] = dbFetchCell('SELECT COUNT(*) FROM `ipv4_addresses`');
$stats['ipv4_networks'] = dbFetchCell('SELECT COUNT(*) FROM `ipv4_networks`');
$stats['ipv6_addresses'] = dbFetchCell('SELECT COUNT(*) FROM `ipv6_addresses`');
$stats['ipv6_networks'] = dbFetchCell('SELECT COUNT(*) FROM `ipv6_networks`');
$stats['pseudowires'] = dbFetchCell('SELECT COUNT(*) FROM `pseudowires`');
$stats['vrfs'] = dbFetchCell('SELECT COUNT(*) FROM `vrfs`');
$stats['vlans'] = dbFetchCell('SELECT COUNT(*) FROM `vlans`');
$stats['netscaler_vservers'] = dbFetchCell('SELECT COUNT(*) FROM `netscaler_vservers`');
$stats['netscaler_services'] = dbFetchCell('SELECT COUNT(*) FROM `netscaler_services`');
$stats['vms'] = dbFetchCell('SELECT COUNT(*) FROM `vminfo`');
$stats['slas'] = dbFetchCell('SELECT COUNT(*) FROM `slas`');
$stats['db'] = get_db_size();
$stats['rrd'] = get_dir_size($config['rrd_dir']);
set_cache_item($cache_item, $stats, [ 'ttl' => 900 ]); // 15 min
} else {
$stats = get_cache_data($cache_item);
}
// Clean cache item
unset($cache_item);
?>
<div class="box box-solid">
<div class="box-header"><h3 class="box-title">Statistics</h3></div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed">
<tbody>
<tr>
<td style="width: 45%;"><i class="<?php echo $config['icon']['storage']; ?>"></i> <strong>DB size</strong></td><td><span class="pull-right"><?php echo(formatStorage($stats['db'])); ?></span></td>
<td style="width: 45%;"><i class="<?php echo $config['icon']['database']; ?>"></i> <strong>RRD size</strong></td><td><span class="pull-right"><?php echo(formatStorage($stats['rrd'])); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['devices']; ?>"></i> <strong>Devices</strong></td><td><span class="pull-right"><?php echo($stats['devices']); ?></span></td>
<td><i class="<?php echo $config['icon']['port']; ?>"></i> <strong>Ports</strong></td><td><span class="pull-right"><?php echo($stats['ports']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['ipv4']; ?>"></i> <strong>IPv4 Addresses</strong></td><td><span class="pull-right"><?php echo($stats['ipv4_addresses']); ?></span></td>
<td><i class="<?php echo $config['icon']['ipv4']; ?>"></i> <strong>IPv4 Networks</strong></td><td><span class="pull-right"><?php echo($stats['ipv4_networks']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['ipv6']; ?>"></i> <strong>IPv6 Addresses</strong></td><td><span class="pull-right"><?php echo($stats['ipv6_addresses']); ?></span></td>
<td><i class="<?php echo $config['icon']['ipv6']; ?>"></i> <strong>IPv6 Networks</strong></td><td><span class="pull-right"><?php echo($stats['ipv6_networks']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['service']; ?>"></i> <strong>Services</strong></td><td><span class="pull-right"><?php echo($stats['services']); ?></span></td>
<td><i class="<?php echo $config['icon']['apps']; ?>"></i> <strong>Applications</strong></td><td><span class="pull-right"><?php echo($stats['applications']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['processor']; ?>"></i> <strong>Processors</strong></td><td><span class="pull-right"><?php echo($stats['processors']); ?></span></td>
<td><i class="<?php echo $config['icon']['mempool']; ?>"></i> <strong>Memory pools</strong></td><td><span class="pull-right"><?php echo($stats['memory']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['storage']; ?>"></i> <strong>Storage Entries</strong></td><td><span class="pull-right"><?php echo($stats['storage']); ?></span></td>
<td><i class="<?php echo $config['icon']['diskio']; ?>"></i> <strong>Disk I/O Entries</strong></td><td><span class="pull-right"><?php echo($stats['diskio']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['inventory']; ?>"></i> <strong>HR-MIB Entries</strong></td><td><span class="pull-right"><?php echo($stats['hrdevice']); ?></span></td>
<td><i class="<?php echo $config['icon']['inventory']; ?>"></i> <strong>Entity-MIB Entries</strong></td><td><span class="pull-right"><?php echo($stats['entphysical']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['syslog']; ?>"></i> <strong>Syslog Entries</strong></td><td><span class="pull-right"><?php echo($stats['syslog']); ?></span></td>
<td><i class="<?php echo $config['icon']['eventlog']; ?>"></i> <strong>Eventlog Entries</strong></td><td><span class="pull-right"><?php echo($stats['events']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['sensor']; ?>"></i> <strong>Sensors</strong></td><td><span class='pull-right'><?php echo($stats['sensors']); ?></span></td>
<td><i class="<?php echo $config['icon']['printersupply']; ?>"></i> <strong>Printer Supplies</strong></td><td><span class='pull-right'><?php echo($stats['printersupplies']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['vserver']; ?>"></i> <strong>Netscaler VServers</strong></td><td><span class="pull-right"><?php echo($stats['netscaler_vservers']); ?></span></td>
<td><i class="<?php echo $config['icon']['service']; ?>"></i> <strong>Netscaler Services</strong></td><td><span class="pull-right"><?php echo($stats['netscaler_services']); ?></span></td>
</tr>
<tr>
<td><i class="<?php echo $config['icon']['virtual-machine']; ?>"></i> <strong>Virtual Machines</strong></td><td><span class="pull-right"><?php echo($stats['vms']); ?></span></td>
<td><i class="<?php echo $config['icon']['sla']; ?>"></i> <strong>IP SLAs</strong></td><td><span class="pull-right"><?php echo($stats['slas']); ?></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
} // End statistics for not limited users
?>
</div>
<div class="col-md-6">
<div class="box box-solid">
<div class="box-header with-border"><h3 class="box-title">License</h3></div>
<div class="box-body no-padding">
<div style="padding:5px;"><pre class="small" style="margin:0px;">
<div class="box box-solid">
<div class="box-header with-border"><h3 class="box-title">License</h3></div>
<div class="box-body no-padding">
<div style="padding:5px;"><pre class="small" style="margin:0px;">
<?php include($config['install_dir'] . '/LICENSE.' . strtoupper(OBSERVIUM_EDITION)); ?>
</pre></div>
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php

View File

@ -6,15 +6,14 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
// Global write permissions required.
if ($_SESSION['userlevel'] < 10)
{
print_error_permission();
return;
if ($_SESSION['userlevel'] < 9) {
print_error_permission();
return;
}
register_html_resource('css', 'query-builder.default.css');
@ -25,34 +24,37 @@ register_html_resource('js', 'bootbox.min.js');
//register_html_resource('js', 'bootstrap-select.min.js');
register_html_resource('js', 'interact.min.js');
include($config['html_dir']."/includes/alerting-navbar.inc.php");
include($config['html_dir'] . "/includes/alerting-navbar.inc.php");
// print_vars($vars);
// print_vars($vars);
if (!isset($vars['entity_type'])) {
if (empty($vars['entity_type']) || !isset($config['entities'][$vars['entity_type']])) {
print generate_box_open(array('title' => 'Select Alert Checker Entity Type', 'padding' => true, 'header-border' => true));
if (!empty($vars['entity_type'])) {
print_warning("Unknown Entity Type, please select a valid entity type from the list.");
}
//echo '<h4>Select Entity Type</h4>';
register_html_title('Add Alert Checker: Select Entity Type');
echo generate_box_open([ 'title' => 'Select Alert Checker Entity Type', 'padding' => TRUE, 'header-border' => TRUE ]);
ksort($config['entities']);
//echo '<h4>Select Entity Type</h4>';
foreach ($config['entities'] as $entity_type => $entity_type_array) {
ksort($config['entities']);
if (!$entity_type_array['hide']) {
//echo '<option value="' . generate_url(array('page' => 'group_add', 'entity_type' => $entity_type)) . '" ' . ($entity_type == $vars['entity_type'] ? ' selected' : '') . '>' . $entity_type . '</option>';
foreach ($config['entities'] as $entity_type => $entity_type_array) {
echo '<btn class="btn" style="margin: 5px;"><a href="'.generate_url(array('page' => 'add_alert_check', 'entity_type' => $entity_type)) . '" ' . ($entity_type == $vars['entity_type'] ? ' selected' : '').'">
<i class="'.$config['entities'][$entity_type]['icon'].'"></i> '.nicecase($entity_type).'</a></btn>';
if (!$entity_type_array['hide']) {
//echo '<option value="' . generate_url(array('page' => 'group_add', 'entity_type' => $entity_type)) . '" ' . ($entity_type == $vars['entity_type'] ? ' selected' : '') . '>' . $entity_type . '</option>';
echo '<btn class="btn" style="margin: 5px;"><a href="' . generate_url([ 'page' => 'add_alert_check', 'entity_type' => $entity_type ]) . '">' .
get_icon($config['entities'][$entity_type]['icon']) . ' ' . nicecase($entity_type) . '</a></btn>';
}
}
}
}
echo generate_box_close();
echo generate_box_close();
echo '<script type="text/javascript">
echo '<script type="text/javascript">
$(document).ready(function () {
$("#selection").change(function () {
location = $("#selection option:selected").val();
@ -60,91 +62,83 @@ if (!isset($vars['entity_type'])) {
});
</script>';
/*
// Allow duplication of existing checks
echo generate_box_open(array('title' => 'Duplicate Existing Checker', 'padding' => true, 'header-border' => true));
/*
// Allow duplication of existing checks
echo generate_box_open(array('title' => 'Duplicate Existing Checker', 'padding' => true, 'header-border' => true));
$alert_checks = cache_alert_rules($vars);
$alert_checks = array_sort($alert_checks, 'alert_name');
$alert_checks = cache_alert_rules($vars);
$alert_checks = array_sort($alert_checks, 'alert_name');
echo '<table class="table table-striped table-hover">
<thead>
<tr>
<th class="state-marker"></th>
<th style="width: 1px;"></th>
<th style="width: 400px">Name</th>
<th style="width: 140px"></th>
<th></th>
</tr>
</thead>
<tbody>', PHP_EOL;
echo '<table class="table table-striped table-hover">
<thead>
<tr>
<th class="state-marker"></th>
<th style="width: 1px;"></th>
<th style="width: 400px">Name</th>
<th style="width: 140px"></th>
<th></th>
</tr>
</thead>
<tbody>', PHP_EOL;
foreach ($alert_checks as $check) {
foreach ($alert_checks as $check) {
// Process the alert checker to add classes and colours and count status.
humanize_alert_check($check);
// Process the alert checker to add classes and colours and count status.
humanize_alert_check($check);
echo('<tr class="' . $check['html_row_class'] . '">');
echo('<tr class="' . $check['html_row_class'] . '">');
echo('
<td class="state-marker"></td>
<td style="width: 1px;"></td>');
echo('
<td class="state-marker"></td>
<td style="width: 1px;"></td>');
// Print the conditions applied by this alert
// Print the conditions applied by this alert
echo '<td><strong>';
echo '<a href="', generate_url(array('page' => 'alert_check', 'alert_test_id' => $check['alert_test_id'])), '">' . escape_html($check['alert_name']) . '</a></strong><br />';
echo '<small>', escape_html($check['alert_message']), '</small>';
echo '</td>';
echo '<td><strong>';
echo '<a href="', generate_url(array('page' => 'alert_check', 'alert_test_id' => $check['alert_test_id'])), '">' . escape_html($check['alert_name']) . '</a></strong><br />';
echo '<small>', escape_html($check['alert_message']), '</small>';
echo '</td>';
echo '<td><i class="' . $config['entities'][$check['entity_type']]['icon'] . '"></i></td>';
echo '<td><i class="' . $config['entities'][$check['entity_type']]['icon'] . '"></i></td>';
echo('</td>');
echo('</td>');
echo('</tr>');
echo('</tr>');
}
// End loop of associations
}
// End loop of associations
echo '</table>';
echo generate_box_close();
// End duplication of existing checks
*/
echo '</table>';
echo generate_box_close();
// End duplication of existing checks
*/
} else {
if(isset($vars['duplicate_id']) && $alert_dupe = get_alert_test_by_id($vars['duplicate_id'])){
humanize_alert_check($alert_dupe);
$conditions = safe_json_decode($alert_dupe['conditions']);
$condition_text_block = array();
foreach ($conditions as $condition)
{
$condition_text_block[] = $condition['metric'] .' '. $condition['condition'] .' ' .
str_replace(',', ',&#x200B;', $condition['value']); // Add hidden space char (&#x200B;) for wrap long lists
}
$vars['alert_conditions'] = implode(PHP_EOL, $condition_text_block);
$vars = array_merge($vars, $alert_dupe);
}
//r($vars);
register_html_title('Add Alert Checker');
?>
// Duplicate alert checker when requested by $vars['duplicate_id']
alert_test_duplicate($vars);
<form name="form1" method="post" action="<?php echo(generate_url(array('page' => 'add_alert_check'))); ?>"
?>
<form name="form1" method="post" action="<?php echo(generate_url(['page' => 'add_alert_check'])); ?>"
class="form-horizontal">
<div class="row">
<div class="col-md-5">
<?php
<?php
$box_args = array('title' => 'New Checker Details',
'header-border' => TRUE,
'padding' => TRUE,
);
$box_args = ['title' => 'New Checker Details',
'header-border' => TRUE,
'padding' => TRUE,
];
echo generate_box_open($box_args);
echo generate_box_open($box_args);
?>
?>
<fieldset>
<!--
@ -152,24 +146,23 @@ if (!isset($vars['entity_type'])) {
<label class="control-label" for="entity_type">Entity Type</label>
<div class="controls">
<?php
$item = array('id' => 'entity_type',
'live-search' => FALSE,
'width' => '220px',
'value' => $vars['entity_type']);
foreach ($config['entities'] as $entity_type => $entity_type_array)
{
if (!$entity_type_array['hide'])
{ // ignore this type if it's a meta-entity
if (!isset($entity_type_array['icon']))
{
$entity_type_array['icon'] = $config['entity_default']['icon'];
}
$item['values'][$entity_type] = array('name' => nicecase($entity_type),
'icon' => $entity_type_array['icon']);
}
}
echo(generate_form_element($item, 'select'));
?>
$item = [
'id' => 'entity_type',
'live-search' => FALSE,
'width' => '220px',
'value' => $vars['entity_type']
];
foreach ($config['entities'] as $entity_type => $entity_type_array) {
if (!$entity_type_array['hide']) { // ignore this type if it's a meta-entity
if (!isset($entity_type_array['icon'])) {
$entity_type_array['icon'] = $config['entity_default']['icon'];
}
$item['values'][$entity_type] = [ 'name' => nicecase($entity_type),
'icon' => $entity_type_array['icon'] ];
}
}
echo(generate_form_element($item, 'select'));
?>
</div>
</div>
-->
@ -178,7 +171,7 @@ if (!isset($vars['entity_type'])) {
<label class="control-label" for="group_name">Entity Type</label>
<div class="controls">
<?php echo '<i class="'.$config['entities'][$vars['entity_type']]['icon'].'"></i> <span class="entity">'.nicecase($vars['entity_type']).'</span>'; ?>
<?php echo get_icon($config['entities'][$vars['entity_type']]['icon']) . ' <span class="entity">' . nicecase($vars['entity_type']) . '</span>'; ?>
</div>
</div>
@ -186,70 +179,70 @@ if (!isset($vars['entity_type'])) {
<div class="control-group">
<label class="control-label" for="alert_name">Alert Name</label>
<div class="controls">
<?php
$item = array('id' => 'alert_name',
'name' => 'Alert name',
'placeholder' => TRUE,
'width' => '220px',
'value' => $vars['alert_name']);
echo(generate_form_element($item, 'text'));
?>
<?php
$item = ['id' => 'alert_name',
'name' => 'Alert name',
'placeholder' => TRUE,
'width' => '220px',
'value' => $vars['alert_name']];
echo(generate_form_element($item, 'text'));
?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="alert_message">Message</label>
<div class="controls">
<?php
$item = array('id' => 'alert_message',
'name' => 'Alert message',
'placeholder' => TRUE,
//'width' => '220px',
'class' => 'col-md-11',
'rows' => 3,
'value' => $vars['alert_message']);
echo(generate_form_element($item, 'textarea'));
?>
<?php
$item = ['id' => 'alert_message',
'name' => 'Alert message',
'placeholder' => TRUE,
//'width' => '220px',
'class' => 'col-md-11',
'rows' => 3,
'value' => $vars['alert_message']];
echo(generate_form_element($item, 'textarea'));
?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="alert_delay">Alert Delay</label>
<div class="controls">
<?php
$item = array('id' => 'alert_delay',
'name' => '&#8470; of checks to delay alert',
'placeholder' => TRUE,
'width' => '220px',
'value' => $vars['alert_delay']);
echo(generate_form_element($item, 'text'));
?>
<?php
$item = ['id' => 'alert_delay',
'name' => '&#8470; of checks to delay alert',
'placeholder' => TRUE,
'width' => '220px',
'value' => $vars['alert_delay']];
echo(generate_form_element($item, 'text'));
?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="alert_send_recovery">Send recovery</label>
<div class="controls">
<?php
$item = array('id' => 'alert_send_recovery',
'size' => 'big',
'view' => 'toggle',
'palette' => 'blue',
'value' => (isset($vars['alert_send_recovery']) ? $vars['alert_send_recovery'] : 1)); // Set to on by default
echo(generate_form_element($item, 'toggle'));
?>
<?php
$item = ['id' => 'alert_send_recovery',
'size' => 'big',
'view' => 'toggle',
'palette' => 'blue',
'value' => $vars['alert_send_recovery'] ?? 1 ]; // Set to on by default
echo(generate_form_element($item, 'toggle'));
?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="alert_severity">Severity</label>
<div class="controls">
<?php
$item = array('id' => 'alert_severity',
//'name' => 'Severity',
'live-search' => FALSE,
'width' => '220px',
'value' => $vars['alert_severity'],
'values' => $config['alert']['severity'],
);
echo(generate_form_element($item, 'select'));
?>
<?php
$item = ['id' => 'alert_severity',
//'name' => 'Severity',
'live-search' => FALSE,
'width' => '220px',
'value' => $vars['alert_severity'],
'values' => $config['alerts']['severity'],
];
echo(generate_form_element($item, 'select'));
?>
</div>
</div>
</fieldset>
@ -262,135 +255,92 @@ if (!isset($vars['entity_type'])) {
<div class="col-md-7">
<?php
<?php
$box_args = array('title' => 'Test Conditions',
'header-border' => TRUE,
'padding' => TRUE,
);
$box_args = ['title' => 'Test Conditions',
'header-border' => TRUE,
'padding' => TRUE,
];
$box_args['header-controls'] = array('controls' => array('tooltip' => array('icon' => $config['icon']['info'],
'anchor' => TRUE,
'class' => 'tooltip-from-element',
//'url' => '#',
'data' => 'data-tooltip-id="tooltip-help-conditions"')));
$box_args['header-controls'] = ['controls' => ['tooltip' => ['icon' => $config['icon']['info'],
'anchor' => TRUE,
'class' => 'tooltip-from-element',
//'url' => '#',
'data' => 'data-tooltip-id="tooltip-help-conditions"']]];
echo generate_box_open($box_args);
echo generate_box_open($box_args);
?>
?>
<div style="margin-bottom: 10px;">
<?php
$item = array('id' => 'alert_and',
//'name' => 'Severity',
'live-search' => FALSE,
'width' => '220px',
'value' => (isset($vars['alert_and']) ? $vars['alert_and'] : 1), // Set to and by default
'values' => array('0' => array('name' => 'Require any condition',
'icon' => $config['icon']['or-gate']),
'1' => array('name' => 'Require all conditions',
'icon' => $config['icon']['and-gate']),
)
);
echo(generate_form_element($item, 'select'));
<?php
$item = [ 'id' => 'alert_and',
//'name' => 'Severity',
'live-search' => FALSE,
'width' => '220px',
'value' => $vars['alert_and'] ?? 1, // Set to and by default
'values' => [ '0' => [ 'name' => 'Require any condition',
'icon' => $config['icon']['or-gate'] ],
'1' => [ 'name' => 'Require all conditions',
'icon' => $config['icon']['and-gate'] ],
]
];
echo(generate_form_element($item, 'select'));
echo(PHP_EOL . ' </div>' . PHP_EOL);
echo(PHP_EOL . ' </div>' . PHP_EOL);
/// FIXME. Better styling on page...
$metrics_list = [];
foreach ($config['entities'][$vars['entity_type']]['metrics'] as $metric => $entry) {
$metric_list = [
'metric' => $metric,
'description' => $entry['label'],
];
$metric_list['values'] = '';
if (is_array($entry['values'])) {
if (is_array_list($entry['values'])) {
$values = $entry['values'];
} else {
$values = [];
foreach ($entry['values'] as $value => $descr) {
$values[] = "$value ($descr)";
}
}
$metric_list['values'] = '<span class="label">'.implode('</span> <span class="label">', $values).'</span>';
} elseif ($entry['type'] === 'integer') {
$metric_list['values'] = escape_html('<numeric>');
if (str_contains($metric, 'value')) {
$metric_list['values'] .= '<br />';
// some table fields
foreach ([ 'limit_high', 'limit_high_warn', 'limit_low', 'limit_low_warn' ] as $field) {
if (isset($config['entities'][$vars['entity_type']]['table_fields'][$field])) {
$metric_list['values'] .= '<span class="label">@' . $config['entities'][$vars['entity_type']]['table_fields'][$field].'</span> ';
}
}
}
} else {
$metric_list['values'] = escape_html('<'.$entry['type'].'>');
}
$metrics_list[] = $metric_list;
//$metrics_list[] = '<span class="label">'.$metric.'</span>&nbsp;-&nbsp;'.$entry['label'];
}
//$form_params['metrics'] = implode(',<br/>', $metrics_list);
$metrics_opts = [
'columns' => [
[ 'Metrics', 'style="width: 5%;"' ],
'Description',
'Values'
],
'metric' => [ 'class' => 'label' ],
'description' => [ 'class' => 'text-nowrap' ],
'values' => [ 'escape' => FALSE ]
];
$metrics_box = generate_alert_metrics_table($vars['entity_type'], $metrics_list);
$item = array('id' => 'alert_conditions',
'name' => 'Metric Conditions',
'placeholder' => TRUE,
//'width' => '220px',
'class' => 'col-md-10',
'style' => 'margin-right: 10px',
'rows' => count($metrics_list) > 3 ? count($metrics_list) : 3,
'value' => $vars['alert_conditions']);
echo generate_form_element($item, 'textarea');
$item = [ 'id' => 'alert_conditions',
'name' => 'Metric Conditions',
'placeholder' => TRUE,
//'width' => '220px',
'class' => 'col-md-10',
'style' => 'margin-right: 10px',
'rows' => max(count($metrics_list), 3),
'value' => $vars['alert_conditions']
];
echo generate_form_element($item, 'textarea');
echo('<div class="col-md-12"><b>List of known metrics:</b><br />' . build_table($metrics_list, $metrics_opts) . '</div>');
echo $metrics_box;
unset($metrics_box, $metrics_list);
echo generate_box_close();
echo generate_box_close();
$box_args = array('title' => 'Association Ruleset',
'header-border' => TRUE,
'padding' => TRUE,
);
$box_args = ['title' => 'Association Ruleset',
'header-border' => TRUE,
'padding' => TRUE,
];
$box_args['header-controls'] = array('controls' => array('tooltip' => array('icon' => $config['icon']['info'],
'anchor' => TRUE,
'class' => 'tooltip-from-element',
//'url' => '#',
'data' => 'data-tooltip-id="tooltip-help-associations"')));
echo generate_box_open($box_args);
$box_args['header-controls'] = ['controls' => ['tooltip' => ['icon' => $config['icon']['info'],
'anchor' => TRUE,
'class' => 'tooltip-from-element',
//'url' => '#',
'data' => 'data-tooltip-id="tooltip-help-associations"']]];
echo generate_box_open($box_args);
$form_id = 'rules-' . generate_random_string(8);
$form_id = 'rules-' . random_string(8);
echo '<div id="' . $form_id . '"></div>';
echo '<div id="' . $form_id . '"></div>';
generate_querybuilder_form($vars['entity_type'], 'attribs', $form_id, $alert_dupe['alert_assoc']);
generate_querybuilder_form($vars['entity_type'], 'attribs', $form_id, $alert_dupe['alert_assoc']);
// generate_querybuilder_form($vars['entity_type'], 'metrics');
// generate_querybuilder_form($vars['entity_type'], 'metrics');
$footer_content = '
$footer_content = '
<div class="btn-group pull-right">
<btn class="btn btn-danger" id="btn-reset" data-target="' . $form_id . '"><i class="icon-trash"></i> Clear Rules</btn>
<btn class="btn btn-success" id="btn-save" data-target="' . $form_id . '"><i class="icon-plus-sign"></i> Add Checker</btn>
</div>'.$script;
</div>' . $script;
echo generate_box_close(array('footer_content' => $footer_content));
echo generate_box_close(['footer_content' => $footer_content]);
// echo generate_box_close();
// echo generate_box_close();
?>
?>
</div> <!-- col -->
</div> <!-- row -->
@ -399,22 +349,22 @@ if (!isset($vars['entity_type'])) {
<div class="form-actions">
<?php
$item = array('id' => 'submit',
'name' => 'Add Check',
'class' => 'btn-success',
'icon' => $config['icon']['checked'],
'value' => 'add_alert_check');
echo(generate_form_element($item, 'submit'));
?>
$item = ['id' => 'submit',
'name' => 'Add Check',
'class' => 'btn-success',
'icon' => $config['icon']['checked'],
'value' => 'add_alert_check'];
echo(generate_form_element($item, 'submit'));
?>
</div>
-->
</form>
<?php
<?php
$script
$script
= "<script>
$('#btn-save').on('click', function() {
var result = $('#" . $form_id . "').queryBuilder('getRules');
@ -425,7 +375,7 @@ if (!isset($vars['entity_type'])) {
var formData = JSON.stringify({
action: 'alert_check_add',
alert_assoc: JSON.stringify(result),
entity_type: '" . $vars['entity_type'] . "',
entity_type: '" . escape_html($vars['entity_type']) . "',
alert_name: document.getElementById('alert_name').value,
alert_message: document.getElementById('alert_message').value,
alert_delay: document.getElementById('alert_delay').value,
@ -466,9 +416,9 @@ if (!isset($vars['entity_type'])) {
</script>
";
echo $script;
echo $script;
?>
?>
<div id="tooltip-help-conditions" style="display: none;">
@ -484,7 +434,7 @@ ifOperStatus equals down</pre>
</div>
<?php
<?php
}

View File

@ -1,132 +1,129 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
// Global write permissions required.
if ($_SESSION['userlevel'] < 10)
{
print_error_permission();
return;
if ($_SESSION['userlevel'] < 9) {
print_error_permission();
return;
}
include($config['html_dir']."/includes/alerting-navbar.inc.php");
include($config['html_dir'] . "/includes/alerting-navbar.inc.php");
if (isset($vars['submit']) && $vars['submit'] == "add_alertlog_rule")
{
if (isset($vars['submit']) && $vars['submit'] === "add_alertlog_rule") {
$message = '<h4>Adding alert checker</h4> ';
$ok = TRUE;
foreach (array('name', 'descr', 'regex') as $var)
{
$value = trim($vars[$var]);
if (!isset($vars[$var]) || strlen($value) == '0') { $ok = FALSE; }
else if ($var == 'regex' && preg_match($value, NULL) === FALSE) { $ok = FALSE; } // Check if valid regex
$vars[$var] = $value;
foreach (['name', 'descr', 'regex'] as $var) {
$value = trim($vars[$var]);
if (!isset($vars[$var]) || safe_empty($value)) {
$ok = FALSE;
} elseif ($var === 'regex' && preg_match($value, NULL) === FALSE) {
$ok = FALSE;
} // Check if valid regex
$vars[$var] = $value;
}
if ($ok)
{
$rule = array();
$rule['la_name'] = $vars['name'];
$rule['la_descr'] = $vars['descr'];
$rule['la_rule'] = $vars['regex'];
$rule['la_severity'] = '8';
$rule['la_disable'] = '0';
if ($ok) {
$rule = [];
$rule['la_name'] = $vars['name'];
$rule['la_descr'] = $vars['descr'];
$rule['la_rule'] = $vars['regex'];
$rule['la_severity'] = '8';
$rule['la_disable'] = '0';
$rule_id = dbInsert('syslog_rules', $rule);
$rule_id = dbInsert('syslog_rules', $rule);
if (is_numeric($rule_id))
{
print_success('<p>Syslog rule inserted as <a href="'.generate_url(array('page' => 'syslog_rules', 'la_id' => $rule_id)).'">'.$rule_id.'</a></p>');
if (is_numeric($rule_id)) {
print_success('<p>Syslog rule inserted as <a href="' . generate_url(['page' => 'syslog_rules', 'la_id' => $rule_id]) . '">' . $rule_id . '</a></p>');
unset($vars['name'], $vars['descr'], $vars['regex']);
unset($vars['name'], $vars['descr'], $vars['regex']);
set_obs_attrib('syslog_rules_changed', time()); // Trigger reload syslog script
set_obs_attrib('syslog_rules_changed', time()); // Trigger reload syslog script
} else {
print_error('Failed to create new rule.');
}
} else {
print_error('Failed to create new rule.');
}
} else {
print_error('<b>Failed to create new rule</b>: Rule name, message and valid regular expression are mandatory.');
print_error('<b>Failed to create new rule</b>: Rule name, message and valid regular expression are mandatory.');
}
}
}
?>
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="col-md-8">
<?php
<?php
$form = array('type' => 'horizontal',
'id' => 'logalert_rule',
'title' => 'New Syslog Rule Details',
//'url' => generate_url(array('page' => 'add_alertlog_rule')),
);
$form = ['type' => 'horizontal',
'id' => 'logalert_rule',
'title' => 'New Syslog Rule Details',
//'url' => generate_url(array('page' => 'add_alertlog_rule')),
];
$form['row'][1]['name'] = array(
'type' => 'text',
'name' => 'Rule Name',
'placeholder' => TRUE,
//'class' => 'input-xlarge',
'width' => '250px',
//'readonly' => $readonly,
'value' => $vars['name']);
$form['row'][2]['descr'] = array(
'type' => 'textarea',
'name' => 'Message',
'placeholder' => TRUE,
'class' => 'col-md-11 col-xs-11',
//'width' => '250px',
'rows' => 4,
//'readonly' => $readonly,
'value' => $vars['descr']);
$form['row'][3]['regex'] = array(
'type' => 'textarea',
'name' => 'Regular Expression',
'placeholder' => TRUE,
'class' => 'col-md-11 col-xs-11',
//'width' => '250px',
'rows' => 4,
//'readonly' => $readonly,
'value' => $vars['regex']);
$form['row'][7]['submit'] = array(
'type' => 'submit',
'name' => 'Add Rule',
'icon' => 'icon-plus icon-white',
//'right' => TRUE,
'class' => 'btn-success',
//'readonly' => $readonly,
'value' => 'add_alertlog_rule');
$form['row'][1]['name'] = [
'type' => 'text',
'name' => 'Rule Name',
'placeholder' => TRUE,
//'class' => 'input-xlarge',
'width' => '250px',
//'readonly' => $readonly,
'value' => $vars['name']];
$form['row'][2]['descr'] = [
'type' => 'textarea',
'name' => 'Message',
'placeholder' => TRUE,
'class' => 'col-md-11 col-xs-11',
//'width' => '250px',
'rows' => 4,
//'readonly' => $readonly,
'value' => $vars['descr']];
$form['row'][3]['regex'] = [
'type' => 'textarea',
'name' => 'Regular Expression',
'placeholder' => TRUE,
'class' => 'col-md-11 col-xs-11',
//'width' => '250px',
'rows' => 4,
//'readonly' => $readonly,
'value' => $vars['regex']];
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Add Rule',
'icon' => 'icon-plus icon-white',
//'right' => TRUE,
'class' => 'btn-success',
//'readonly' => $readonly,
'value' => 'add_alertlog_rule'];
print_form($form);
unset($form);
print_form($form);
unset($form);
?>
?>
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
<?php
<?php
$box_args = array('title' => 'Syslog Regular Expressions',
'header-border' => TRUE,
'padding' => TRUE,
);
$box_args = ['title' => 'Syslog Regular Expressions',
'header-border' => TRUE,
'padding' => TRUE,
];
echo generate_box_open($box_args);
echo generate_box_open($box_args);
echo <<<SYSLOG_RULES
echo <<<SYSLOG_RULES
<p><strong>Syslog Rules</strong> are built using standard PCRE regular expressions.</p>
<p>There are many online resources to help you learn and test regular expressions.
Good resources include <a href="https://regex101.com/">regex101.com</a>,
@ -139,12 +136,12 @@ include($config['html_dir']."/includes/alerting-navbar.inc.php");
<code>/pam.+\(sshd:auth\).+failure.+user\=(root|adama)/</code>
SYSLOG_RULES;
echo generate_box_close();
echo generate_box_close();
?>
?>
</div>
</div>
</div>
</div>
<?php

View File

@ -6,39 +6,42 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($_SESSION['userlevel'] < 9) {
print_error_permission("You don't have the necessary privileges to add hosts.");
return;
print_error_permission("You don't have the necessary privileges to add hosts.");
return;
}
//echo("<h2>Add Device</h2>");
if (get_var_true($vars['submit'], 'save') && $vars['hostname']) {
if (request_token_valid($vars) && $result = add_device_vars($vars)) {
$device_url = generate_device_url([ 'device_id' => $result ]);
$device_link = '<a href="' . $device_url . '" class="entity-popup" data-eid="' . $result . '" data-etype="device">' . escape_html($vars['hostname']) . '</a>';
print_success("Device added (id = $result): $device_link");
}
if (request_token_valid($vars) && $result = add_device_vars($vars)) {
$device_url = generate_device_url(['device_id' => $result]);
$device_link = '<a href="' . $device_url . '" class="entity-popup" data-eid="' . $result . '" data-etype="device">' . escape_html($vars['hostname']) . '</a>';
if (!isset($vars['poller_id']) || $vars['poller_id'] == $config['poller_id']) {
// Do not show message for remote pollers (it's added to queue)
print_success("Device added (id = $result): $device_link");
}
}
} else {
// Defaults
switch ($vars['snmp_version']) {
case 'v1':
case 'v2c':
case 'v3':
$snmp_version = $vars['snmp_version'];
break;
default:
$snmp_version = $config['snmp']['version'];
}
if (in_array($vars['snmp_transport'], $config['snmp']['transports'])) {
$snmp_transport = $vars['snmp_transport'];
} else {
$snmp_transport = $config['snmp']['transports'][0];
}
// Defaults
switch ($vars['snmp_version']) {
case 'v1':
case 'v2c':
case 'v3':
$snmp_version = $vars['snmp_version'];
break;
default:
$snmp_version = $config['snmp']['version'];
}
if (in_array($vars['snmp_transport'], $config['snmp']['transports'])) {
$snmp_transport = $vars['snmp_transport'];
} else {
$snmp_transport = $config['snmp']['transports'][0];
}
}
register_html_title("Add Device");
@ -46,45 +49,56 @@ register_html_title("Add Device");
// Add form
$transports = [];
foreach ($config['snmp']['transports'] as $transport) {
$transports[$transport] = strtoupper($transport);
$transports[$transport] = strtoupper($transport);
}
$snmp_version = get_versions('snmp');
if (version_compare($snmp_version, '5.8', '<')) {
$authclass = 'bg-warning';
$authtext = 'Poller required net-snmp >= 5.8';
$authclass = 'bg-warning';
$authtext = 'Poller required net-snmp >= 5.8';
$cryptoclass = 'bg-warning';
$cryptotext = 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes';
} else {
$authclass = 'bg-success';
$authtext = '';
$authclass = 'bg-success';
$authtext = '';
$cryptoclass = 'bg-warning';
$cryptotext = 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes';
// Detect if local net-snmp support AES+
$snmp_cmd = is_executable($GLOBALS['config']['snmpget']) ? $GLOBALS['config']['snmpget'] : '/usr/bin/env snmpget';
if (str_contains(external_exec($snmp_cmd . " -h 2>&1"), 'AES-192')) {
$cryptoclass = 'bg-success';
$cryptotext = '';
}
}
$authalgo = [
'MD5' => [ 'name' => 'MD5' ],
'SHA' => [ 'name' => 'SHA' ],
'SHA-224' => [ 'name' => 'SHA-224', 'class' => $authclass, 'subtext' => $authtext ],
'SHA-256' => [ 'name' => 'SHA-256', 'class' => $authclass, 'subtext' => $authtext ],
'SHA-384' => [ 'name' => 'SHA-384', 'class' => $authclass, 'subtext' => $authtext ],
'SHA-512' => [ 'name' => 'SHA-512', 'class' => $authclass, 'subtext' => $authtext ],
'MD5' => ['name' => 'MD5'],
'SHA' => ['name' => 'SHA'],
'SHA-224' => ['name' => 'SHA-224', 'class' => $authclass, 'subtext' => $authtext],
'SHA-256' => ['name' => 'SHA-256', 'class' => $authclass, 'subtext' => $authtext],
'SHA-384' => ['name' => 'SHA-384', 'class' => $authclass, 'subtext' => $authtext],
'SHA-512' => ['name' => 'SHA-512', 'class' => $authclass, 'subtext' => $authtext],
];
$cryptoalgo = [
'DES' => [ 'name' => 'DES' ],
'AES' => [ 'name' => 'AES' ],
'AES-192' => [ 'name' => 'AES-192', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'AES-192-C' => [ 'name' => 'AES-192 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'AES-256' => [ 'name' => 'AES-256', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'AES-256-C' => [ 'name' => 'AES-256 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'DES' => ['name' => 'DES'],
'AES' => ['name' => 'AES (AES-128)'],
'AES-192' => ['name' => 'AES-192', 'class' => $cryptoclass, 'subtext' => $cryptotext],
'AES-192-C' => ['name' => 'AES-192 Cisco', 'class' => $cryptoclass, 'subtext' => $cryptotext],
'AES-256' => ['name' => 'AES-256', 'class' => $cryptoclass, 'subtext' => $cryptotext],
'AES-256-C' => ['name' => 'AES-256 Cisco', 'class' => $cryptoclass, 'subtext' => $cryptotext],
];
$form = [
'type' => 'horizontal',
'id' => 'edit',
'type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
//'title' => 'Add Device',
//'icon' => 'oicon-gear',
];
// top row div
$form['fieldset']['edit'] = [
$form['fieldset']['edit'] = [
'div' => 'top',
'title' => 'Basic Configuration',
'class' => 'col-md-6'
@ -99,7 +113,7 @@ $form['fieldset']['snmpv3'] = [
'title' => 'SNMP v3 Authentication',
'class' => 'col-md-6 col-md-pull-0'
];
$form['fieldset']['extra'] = [
$form['fieldset']['extra'] = [
'div' => 'top',
'title' => 'Extra Configuration',
'class' => 'col-sm-12 col-md-6 pull-right'
@ -118,43 +132,43 @@ $form['fieldset']['submit'] = [
// left fieldset
$form['row'][0]['hostname'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Hostname',
'width' => '250px',
'value' => $vars['hostname']
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Hostname',
'width' => '250px',
'value' => $vars['hostname']
];
if (OBS_DISTRIBUTED) {
$poller_list = [];
$poller_list[0] = [ 'name' => 'Default Poller' ];
if ($config['poller_id'] != 0) {
$poller_list[0]['group'] = 'External';
}
foreach(dbFetchRows("SELECT * FROM `pollers`") as $poller) {
$poller_list[$poller['poller_id']] = [
'name' => $poller['poller_name'],
'subtext' => $poller['host_id']
//'subtext' => $poller['host_uname']
];
if ($config['poller_id'] != $poller['poller_id']) {
$poller_list[$poller['poller_id']]['group'] = 'External';
$poller_list = [];
$poller_list[0] = ['name' => 'Default Poller'];
if ($config['poller_id'] != 0) {
$poller_list[0]['group'] = 'External';
}
}
$form['row'][1]['poller_id'] = [
'community' => FALSE, // not available on community edition
'type' => 'select',
//'fieldset' => 'extra',
'fieldset' => 'edit',
'name' => 'Poller',
'width' => '250px',
'disabled' => !(count($poller_list) > 1),
'values' => $poller_list,
'value' => isset($vars['poller_id']) ? $vars['poller_id'] : $config['poller_id']
];
foreach (dbFetchRows("SELECT * FROM `pollers`") as $poller) {
$poller_list[$poller['poller_id']] = [
'name' => $poller['poller_name'],
'subtext' => $poller['host_id']
//'subtext' => $poller['host_uname']
];
if ($config['poller_id'] != $poller['poller_id']) {
$poller_list[$poller['poller_id']]['group'] = 'External';
}
}
$form['row'][1]['poller_id'] = [
'community' => FALSE, // not available on community edition
'type' => 'select',
//'fieldset' => 'extra',
'fieldset' => 'edit',
'name' => 'Poller',
'width' => '250px',
'disabled' => !(count($poller_list) > 1),
'values' => $poller_list,
'value' => $vars['poller_id'] ?? $config['poller_id']
];
}
$form['row'][2]['ping_skip'] = [
$form['row'][2]['ping_skip'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
@ -163,23 +177,23 @@ $form['row'][2]['ping_skip'] = [
'placeholder' => 'Skip ICMP echo checks',
'value' => ''
];
$form['row'][3]['snmp_version'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'values' => [ 'v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3' ],
'value' => $vars['snmp_version'] ?: $config['snmp']['version']
$form['row'][3]['snmp_version'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'values' => ['v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3'],
'value' => $vars['snmp_version'] ?: $config['snmp']['version']
];
$form['row'][4]['snmp_transport'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'values' => $transports,
'value' => $vars['snmp_transport'] ?: $config['snmp']['transports'][0]
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'values' => $transports,
'value' => $vars['snmp_transport'] ?: $config['snmp']['transports'][0]
];
$form['row'][5]['snmp_port'] = [
$form['row'][5]['snmp_port'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Port',
@ -187,7 +201,7 @@ $form['row'][5]['snmp_port'] = [
'width' => '250px',
'value' => $vars['snmp_port']
];
$form['row'][6]['snmp_timeout'] = [
$form['row'][6]['snmp_timeout'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Timeout',
@ -195,7 +209,7 @@ $form['row'][6]['snmp_timeout'] = [
'width' => '250px',
'value' => $vars['snmp_timeout']
];
$form['row'][7]['snmp_retries'] = [
$form['row'][7]['snmp_retries'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Retries',
@ -203,7 +217,7 @@ $form['row'][7]['snmp_retries'] = [
'width' => '250px',
'value' => $vars['snmp_retries']
];
$form['row'][8]['snmp_maxrep'] = [
$form['row'][8]['snmp_maxrep'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Max Repetitions',
@ -211,7 +225,7 @@ $form['row'][8]['snmp_maxrep'] = [
'placeholder' => '0-500. Default 10. 0 for disable snmpbulk.',
'value' => $vars['snmp_maxrep']
];
$form['row'][9]['ignorerrd'] = [
$form['row'][9]['ignorerrd'] = [
'type' => 'checkbox',
'fieldset' => 'edit',
'name' => 'Ignore existing RRDs',
@ -222,65 +236,65 @@ $form['row'][9]['ignorerrd'] = [
// Snmp v1/2c fieldset
$form['row'][16]['snmp_community'] = [
'type' => 'text',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'value' => $vars['snmp_community'] // FIXME. For passwords we should use filter instead escape!
'type' => 'text',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'value' => $vars['snmp_community'] // FIXME. For passwords we should use filter instead escape!
];
// Snmp v3 fieldset
$form['row'][17]['snmp_authlevel'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'values' => [
$form['row'][17]['snmp_authlevel'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'values' => [
'noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'
],
'value' => $vars['snmp_authlevel']
'value' => $vars['snmp_authlevel']
];
$form['row'][18]['snmp_authname'] = [
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'value' => $vars['snmp_authname']
$form['row'][18]['snmp_authname'] = [
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'value' => $vars['snmp_authname']
];
$form['row'][19]['snmp_authpass'] = [
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'value' => $vars['snmp_authpass'] // FIXME. For passwords we should use filter instead escape!
$form['row'][19]['snmp_authpass'] = [
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'value' => $vars['snmp_authpass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][20]['snmp_authalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'values' => $authalgo,
'value' => $vars['snmp_authalgo']
$form['row'][20]['snmp_authalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'values' => $authalgo,
'value' => $vars['snmp_authalgo']
];
$form['row'][21]['snmp_cryptopass'] = [
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'value' => $vars['snmp_cryptopass'] // FIXME. For passwords we should use filter instead escape!
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'value' => $vars['snmp_cryptopass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][22]['snmp_cryptoalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'values' => $cryptoalgo,
'value' => $vars['snmp_cryptoalgo']
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'values' => $cryptoalgo,
'value' => $vars['snmp_cryptoalgo']
];
$form['row'][24]['snmpable'] = [
$form['row'][24]['snmpable'] = [
'type' => 'text',
'fieldset' => 'extra',
'name' => 'SNMPable OIDs',
@ -300,13 +314,13 @@ $form['row'][25]['snmp_context'] = [
];
$form['row'][30]['submit'] = [
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Add device',
'icon' => 'icon-ok icon-white',
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Add device',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'save'
'class' => 'btn-primary',
'value' => 'save'
];
print_form_box($form);
@ -314,43 +328,43 @@ unset($form);
?>
<script type="text/javascript">
<!--
$("#snmp_version").change(function() {
var select = this.value;
if (select === 'v3') {
$('#snmpv3').show();
$("#snmpv2").hide();
} else {
$('#snmpv2').show();
$('#snmpv3').hide();
}
}).change();
<script type="text/javascript">
<!--
$("#snmp_version").change(function () {
var select = this.value;
if (select === 'v3') {
$('#snmpv3').show();
$("#snmpv2").hide();
} else {
$('#snmpv2').show();
$('#snmpv3').hide();
}
}).change();
$("#snmp_authlevel").change(function() {
var select = this.value;
if (select === 'authPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').show();
$('[id^="snmp_cryptoalgo"]').show();
} else if (select === 'authNoPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
} else {
$('[id^="snmp_authname"]').hide();
$('[id^="snmp_authpass"]').hide();
$('[id^="snmp_authalgo"]').hide();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
}
}).change();
// -->
</script>
$("#snmp_authlevel").change(function () {
var select = this.value;
if (select === 'authPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').show();
$('[id^="snmp_cryptoalgo"]').show();
} else if (select === 'authNoPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
} else {
$('[id^="snmp_authname"]').hide();
$('[id^="snmp_authpass"]').hide();
$('[id^="snmp_authalgo"]').hide();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
}
}).change();
// -->
</script>
<?php

File diff suppressed because it is too large Load Diff

View File

@ -6,70 +6,62 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($_SESSION['userlevel'] < 5)
{
print_error_permission();
return;
if ($_SESSION['userlevel'] < 5) {
print_error_permission();
return;
}
// Export or save templates
$templates_export = FALSE;
if ($vars['saveas'] == 'yes') { $templates_export = $vars['filename']; }
else if ($vars['export'] == 'yes') { $templates_export = 'print'; }
unset($vars['export'], $vars['saveas'], $vars['filename']);
include($config['html_dir']."/includes/alerting-navbar.inc.php");
include($config['html_dir'] . "/includes/alerting-navbar.inc.php");
// Page to display list of configured alert checks
$alert_check = cache_alert_rules($vars);
#$alert_assoc = cache_alert_assoc($vars);
$where = ' WHERE 1' . generate_query_permitted(array('alert'));
$where = ' WHERE 1' . generate_query_permitted(['alert']);
// Build header menu
foreach (dbFetchRows("SELECT * FROM `alert_assoc` WHERE 1") as $entry)
{
$alert_assoc[$entry['alert_test_id']][$entry['alert_assoc_id']]['entity_type'] = $entry['entity_type'];
$alert_assoc[$entry['alert_test_id']][$entry['alert_assoc_id']]['entity_attribs'] = safe_json_decode($entry['entity_attribs']);
$alert_assoc[$entry['alert_test_id']][$entry['alert_assoc_id']]['device_attribs'] = safe_json_decode($entry['device_attribs']);
foreach (dbFetchRows("SELECT * FROM `alert_assoc` WHERE 1") as $entry) {
$alert_assoc[$entry['alert_test_id']][$entry['alert_assoc_id']]['entity_type'] = $entry['entity_type'];
$alert_assoc[$entry['alert_test_id']][$entry['alert_assoc_id']]['entity_attribs'] = safe_json_decode($entry['entity_attribs']);
$alert_assoc[$entry['alert_test_id']][$entry['alert_assoc_id']]['device_attribs'] = safe_json_decode($entry['device_attribs']);
}
$navbar['class'] = "navbar-narrow";
$navbar['brand'] = "Alert Checks";
$types = dbFetchRows("SELECT DISTINCT `entity_type` FROM `alert_table`" . $where);
$types = dbFetchRows("SELECT DISTINCT `entity_type` FROM `alert_table`" . $where);
$types_count = count($types);
$navbar['options']['all']['url'] = generate_url($vars, array('page' => 'alert_checks', 'entity_type' => NULL));
$navbar['options']['all']['url'] = generate_url($vars, ['page' => 'alert_checks', 'entity_type' => NULL]);
$navbar['options']['all']['text'] = escape_html(nicecase('all'));
if (!isset($vars['entity_type'])) {
$navbar['options']['all']['class'] = "active";
$navbar['options']['all']['url'] = generate_url($vars, array('page' => 'alert_checks', 'entity_type' => NULL));
$navbar['options']['all']['class'] = "active";
$navbar['options']['all']['url'] = generate_url($vars, ['page' => 'alert_checks', 'entity_type' => NULL]);
}
foreach ($types as $thing)
{
if ($vars['entity_type'] == $thing['entity_type'])
{
$navbar['options'][$thing['entity_type']]['class'] = "active";
$navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, array('page' => 'alert_checks', 'entity_type' => NULL));
} else {
if ($types_count > 6) { $navbar['options'][$thing['entity_type']]['class'] = "icon"; }
$navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, array('page' => 'alert_checks', 'entity_type' => $thing['entity_type']));
}
$navbar['options'][$thing['entity_type']]['icon'] = $config['entities'][$thing['entity_type']]['icon'];
$navbar['options'][$thing['entity_type']]['text'] = escape_html(nicecase($thing['entity_type']));
foreach ($types as $thing) {
if ($vars['entity_type'] == $thing['entity_type']) {
$navbar['options'][$thing['entity_type']]['class'] = "active";
$navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, ['page' => 'alert_checks', 'entity_type' => NULL]);
} else {
if ($types_count > 6) {
$navbar['options'][$thing['entity_type']]['class'] = "icon";
}
$navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, ['page' => 'alert_checks', 'entity_type' => $thing['entity_type']]);
}
$navbar['options'][$thing['entity_type']]['icon'] = $config['entities'][$thing['entity_type']]['icon'];
$navbar['options'][$thing['entity_type']]['text'] = escape_html(nicecase($thing['entity_type']));
}
$navbar['options']['export']['text'] = 'Export';
$navbar['options']['export']['icon'] = $config['icon']['export'];
$navbar['options']['export']['url'] = generate_url($vars, array('page' => 'alert_checks', 'export' => 'yes'));
$navbar['options']['export']['right'] = TRUE;
$navbar['options']['export']['text'] = 'Export';
$navbar['options']['export']['icon'] = $config['icon']['export'];
$navbar['options']['export']['url'] = generate_url($vars, ['page' => 'alert_checks', 'export' => 'yes']);
$navbar['options']['export']['right'] = TRUE;
$navbar['options']['export']['userlevel'] = 7;
// Print out the navbar defined above
@ -77,82 +69,62 @@ print_navbar($navbar);
// Generate contacts cache array for use in table
$contacts = [];
$sql = "SELECT * FROM `alert_contacts_assoc` LEFT JOIN `alert_contacts` ON `alert_contacts`.`contact_id` = `alert_contacts_assoc`.`contact_id`";
$contacts_db = dbFetchRows($sql, $params);
foreach($contacts_db as $db_contact) { $contacts[$db_contact['alert_checker_id']][] = $db_contact; }
if ($templates_export)
{
//r($alert_check);
//r($alert_assoc);
// Export alert checkers as templates
$for_export = array();
foreach ($alert_check as $id => $entry)
{
foreach ($alert_assoc[$id] as $assoc)
{
// Multiple association sets (device+entity)
$entry['associations'][] = $assoc;
}
$for_export[] = $entry;
}
$templates_xml = generate_templates('alert', $for_export);
if ($templates_export == 'print')
{
$templates_filename = 'observium_templates_alert_';
if ($vars['entity_type'])
{
$templates_filename .= $vars['entity_type'];
} else{
$templates_filename .= 'all';
}
$form = array('type' => 'rows',
'space' => '10px',
'url' => generate_url($vars));
// Filename
$form['row'][0]['filename'] = array(
'type' => 'text',
'name' => 'Filename',
'value' => $templates_filename . '.xml',
'grid_xs' => 8,
'width' => '100%',
'placeholder' => TRUE);
// Save as human formatted XML
$form['row'][0]['formatted'] = array(
'type' => 'select',
'grid_xs' => 4,
'value' => (class_exists('DOMDocument') ? 'yes' : 'no'),
'values' => array('yes' => 'Formatted',
'no' => 'Unformatted'));
// search button
$form['row'][0]['saveas'] = array(
'type' => 'submit',
'name' => 'Save as..',
'icon' => 'icon-save',
'right' => TRUE,
'value' => 'yes'
);
print_form($form);
print_xml($templates_xml);
//r(xml_to_array($templates_xml));
} else {
$templates_filename = $templates_export;
download_as_file($templates_xml, $templates_filename, $vars);
}
unset($for_export, $templates_xml, $templates_export, $templates_filename, $form);
$sql = "SELECT * FROM `alert_contacts_assoc` LEFT JOIN `alert_contacts` USING(`contact_id`) WHERE `aca_type` = ?";
$params = [ 'alert' ];
foreach (dbFetchRows($sql, $params) as $db_contact) {
$contacts[$db_contact['alert_checker_id']][] = $db_contact;
}
foreach (dbFetchRows("SELECT * FROM `alert_table`" . $where) as $entry)
{
$alert_table[$entry['alert_test_id']][$entry['alert_table_id']] = $entry;
if (get_var_true($vars['export'])) {
// Export requested
if (!get_var_true($vars['saveas'])) {
$export_filename = 'observium_alerts_';
$export_filename .= $vars['entity_type'] ?: 'all';
$export_filename .= '.json';
$form = ['type' => 'rows',
'space' => '10px',
'url' => generate_url($vars)];
// Filename
$form['row'][0]['filename'] = [
'type' => 'text',
'name' => 'Filename',
'value' => $export_filename,
'grid_xs' => 8,
'width' => '100%',
'placeholder' => TRUE
];
// Save as human formatted XML
$form['row'][0]['formatted'] = [
'type' => 'select',
'grid_xs' => 4,
'value' => 'yes',
'values' => [ 'yes' => 'Formatted',
'no' => 'Unformatted' ]
];
// search button
$form['row'][0]['saveas'] = [
'type' => 'submit',
'name' => 'Save as..',
'icon' => 'icon-save',
'right' => TRUE,
'value' => 'yes'
];
print_form($form);
}
json_export('alerts', $vars);
unset($export_filename, $form);
}
echo generate_box_open();
foreach (dbFetchRows("SELECT * FROM `alert_table`" . $where) as $entry) {
$alert_table[$entry['alert_test_id']][$entry['alert_table_id']] = $entry;
}
echo '<table class="table table-striped table-hover">
echo generate_box_open();
echo '<table class="table table-striped table-hover">
<thead>
<tr>
<th class="state-marker"></th>
@ -170,120 +142,138 @@ foreach (dbFetchRows("SELECT * FROM `alert_table`" . $where) as $entry)
$alert_check = array_sort($alert_check, 'alert_name');
foreach ($alert_check as $check)
{
foreach ($alert_check as $check) {
// Process the alert checker to add classes and colours and count status.
humanize_alert_check($check);
// Process the alert checker to add classes and colours and count status.
humanize_alert_check($check);
echo('<tr class="'.$check['html_row_class'].'">');
echo('<tr class="' . $check['html_row_class'] . '">');
echo('
echo('
<td class="state-marker"></td>
<td style="width: 1px;"></td>');
// Print the conditions applied by this alert
// Print the conditions applied by this alert
echo '<td><strong>';
echo '<a href="', generate_url(array('page' => 'alert_check', 'alert_test_id' => $check['alert_test_id'])), '">' . escape_html($check['alert_name']). '</a></strong><br />';
echo '<small>',escape_html($check['alert_message']),'</small>';
echo '</td>';
echo '<td><strong>';
echo '<a href="', generate_url(['page' => 'alert_check', 'alert_test_id' => $check['alert_test_id']]), '">' . escape_html($check['alert_name']) . '</a></strong><br />';
echo '<small>', escape_html($check['alert_message']), '</small>';
echo '</td>';
echo '<td><i class="' . $config['entities'][$check['entity_type']]['icon'] . '"></i></td>';
echo '<td><i class="' . $config['entities'][$check['entity_type']]['icon'] . '"></i></td>';
// Loop the tests used by this alert
echo '<td>';
$text_block = array();
//r($check);
foreach ($check['conditions'] as $condition)
{
$text_block[] = escape_html($condition['metric'].' '.$condition['condition'].' '.$condition['value']);
}
echo('<span class="label">'.($check['and'] ? 'ALL' : 'ANY').'</span><br />');
echo('<code>'.implode('<br />', $text_block).'</code>');
echo('</td>');
echo('<td>');
if (!is_null($check['alert_assoc'])) {
$check['assoc'] = safe_json_decode($check['alert_assoc']);
echo render_qb_rules($check['entity_type'], $check['assoc']);
} else {
echo generate_box_open();
echo('<table class="table table-condensed-more table-striped" style="margin-bottom: 0px;">');
// Loop the associations which link this alert to this device
foreach ($alert_assoc[$check['alert_test_id']] as $assoc_id => $assoc)
{
echo('<tr>');
echo('<td style="width: 50%">');
if (is_array($assoc['device_attribs']))
{
$text_block = array();
foreach ($assoc['device_attribs'] as $attribute)
{
$text_block[] = escape_html($attribute['attrib'] . ' ' . $attribute['condition'] . ' ' . $attribute['value']);
}
echo('<code>' . implode('<br />', $text_block) . '</code>');
}
else
{
echo '<code>*</code>';
}
echo('</td>');
echo('<td>');
if (is_array($assoc['entity_attribs']))
{
$text_block = array();
foreach ($assoc['entity_attribs'] as $attribute)
{
$text_block[] = escape_html($attribute['attrib'] . ' ' . $attribute['condition'] . ' ' . $attribute['value']);
}
echo('<code>' . implode('<br />', $text_block) . '</code>');
}
else
{
echo '<code>*</code>';
}
echo('</td>');
echo('</tr>');
}
// End loop of associations
echo '</table>';
echo generate_box_close();
}
echo '</td>';
// Print the count of entities this alert applies to and a popup containing a list and Print breakdown of entities by status.
// We assume each row here is going to be two lines, so we just <br /> them.
echo '<td style="text-align: right;">';
#echo overlib_link('#', count($entities), $entities_content, NULL));
echo '<span class="label label-primary">', $check['num_entities'], '</span>&nbsp;';
//echo '<br />';
echo $check['status_numbers'];
echo '<br />';
if ($notifiers_count = safe_count($contacts[$check['alert_test_id']])) {
$content = "";
foreach($contacts[$check['alert_test_id']] as $contact) {
$content .= '<span class="label">'.$contact['contact_method'].'</span> '.escape_html($contact['contact_descr']).'<br />';
// Loop the tests used by this alert
echo '<td>';
$text_block = [];
//r($check);
foreach ($check['conditions'] as $condition) {
$text_block[] = escape_html($condition['metric'] . ' ' . $condition['condition'] . ' ' . $condition['value']);
}
echo generate_tooltip_link('', '<span class="label label-success">'.$notifiers_count.' Notifiers</span>', $content);
} else {
echo '<span class="label label-primary">Default Notifier</span>';
}
echo ($check['and'] ? '<i class="sprite-logic-and"></i> <span class="label label-primary">AND (ALL)</span>' : '<i class="sprite-logic-and"></i> <span class="label label-success">OR (ANY)</span>') . '<br />';
echo '<table class="' . OBS_CLASS_TABLE_STRIPED_MORE . '">';
echo '</td>';
$allowed_metrics = array_keys($config['entities'][$check['entity_type']]['metrics']);
// FIXME. Currently hardcoded in check_entity(), need rewrite to timeranges.
$allowed_metrics[] = 'time';
$allowed_metrics[] = 'weekday';
foreach ($check['conditions'] as $condition) {
// Detect incorrect metric used
if (!in_array($condition['metric'], $allowed_metrics, TRUE)) {
print_error("Unknown condition metric '" . escape_html($condition['metric']) . "' for Entity type '" . escape_html($check['entity_type']) . "'");
foreach (array_keys($config['entities']) as $suggest_entity) {
if (isset($config['entities'][$suggest_entity]['metrics'][$condition['metric']])) {
print_warning("Suggested Entity type: '$suggest_entity'. Change Entity in Edit Alert below.");
$suggest_entity_types[$suggest_entity] = ['name' => $config['entities'][$suggest_entity]['name'],
'icon' => $config['entities'][$suggest_entity]['icon']];
}
}
}
echo '<tr><td>' . escape_html($condition['metric']) . '</td><td>' . escape_html($condition['condition']) .
'</td><td>' . escape_html(str_replace(",", ", ", $condition['value'])) . '</td></tr>';
$condition_text_block[] = $condition['metric'] . ' ' . $condition['condition'] . ' ' . $condition['value'];
//str_replace(',', ',&#x200B;', $condition['value']); // Add hidden space char (&#x200B;) for wrap long lists
}
echo '</table>';
echo('</td>');
echo('<td>');
if (!is_null($check['alert_assoc'])) {
$check['assoc'] = safe_json_decode($check['alert_assoc']);
echo render_qb_rules($check['entity_type'], $check['assoc']);
} else {
echo generate_box_open();
echo('<table class="table table-condensed-more table-striped" style="margin-bottom: 0px;">');
// Loop the associations which link this alert to this device
foreach ($alert_assoc[$check['alert_test_id']] as $assoc_id => $assoc) {
echo('<tr>');
echo('<td style="width: 50%">');
if (is_array($assoc['device_attribs'])) {
$text_block = [];
foreach ($assoc['device_attribs'] as $attribute) {
$text_block[] = escape_html($attribute['attrib'] . ' ' . $attribute['condition'] . ' ' . $attribute['value']);
}
echo('<code>' . implode('<br />', $text_block) . '</code>');
} else {
echo '<code>*</code>';
}
echo('</td>');
echo('<td>');
if (is_array($assoc['entity_attribs'])) {
$text_block = [];
foreach ($assoc['entity_attribs'] as $attribute) {
$text_block[] = escape_html($attribute['attrib'] . ' ' . $attribute['condition'] . ' ' . $attribute['value']);
}
echo('<code>' . implode('<br />', $text_block) . '</code>');
} else {
echo '<code>*</code>';
}
echo('</td>');
echo('</tr>');
}
// End loop of associations
echo '</table>';
echo generate_box_close();
}
echo '</td>';
// Print the count of entities this alert applies to and a popup containing a list and Print breakdown of entities by status.
// We assume each row here is going to be two lines, so we just <br /> them.
echo '<td style="text-align: right;">';
#echo overlib_link('#', count($entities), $entities_content, NULL));
echo '<span class="label label-primary">', $check['num_entities'], '</span>&nbsp;';
//echo '<br />';
echo $check['status_numbers'];
echo '<br />';
if ($notifiers_count = safe_count($contacts[$check['alert_test_id']])) {
$content = "";
foreach ($contacts[$check['alert_test_id']] as $contact) {
$content .= '<span class="label">' . $contact['contact_method'] . '</span> ' . escape_html($contact['contact_descr']) . '<br />';
}
echo generate_tooltip_link('', '<span class="label label-success">' . $notifiers_count . ' Notifiers</span>', $content);
} else {
echo '<span class="label label-primary">Default Notifier</span>';
}
echo '</td>';
}

View File

@ -4,112 +4,111 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
// Alert test display and editing page.
include($config['html_dir']."/includes/alerting-navbar.inc.php");
include($config['html_dir'] . "/includes/alerting-navbar.inc.php");
?>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
<?php
<?php
// Note, this form have more complex grid and class elements for responsive datetime field
$form = array('type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => generate_url($vars));
// Note, this form have more complex grid and class elements for responsive datetime field
$form = ['type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => generate_url($vars)];
$where = ' WHERE 1 ' . $cache['where']['devices_permitted'];
$where = generate_where_clause($cache['where']['devices_permitted']);
// Show devices only with alert logs
$form_devices = dbFetchColumn('SELECT DISTINCT `device_id` FROM `alert_log`' . $where);
$form_items['devices'] = generate_form_values('device', $form_devices);
// Show devices only with alert logs
$form_devices = dbFetchColumn('SELECT DISTINCT `device_id` FROM `alert_log`' . $where);
$form_items['devices'] = generate_form_values('device', $form_devices);
// Device field
$form['row'][0]['device_id'] = array(
'type' => 'multiselect',
'name' => 'Devices',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-2 col-sm-2',
'value' => $vars['device_id'],
'groups' => array('', 'UP', 'DOWN', 'DISABLED'), // This is optgroup order for values (if required)
'values' => $form_items['devices']);
// Device field
$form['row'][0]['device_id'] = [
'type' => 'multiselect',
'name' => 'Devices',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-2 col-sm-2',
'value' => $vars['device_id'],
'groups' => ['', 'UP', 'DOWN', 'DISABLED'], // This is optgroup order for values (if required)
'values' => $form_items['devices']];
// Add device_id limit for other fields
if (isset($vars['device_id']))
{
$where .= generate_query_values_and($vars['device_id'], 'device_id');
}
// Add device_id limit for other fields
if (isset($vars['device_id']) && device_permitted($vars['device_id'])) {
$where = generate_where_clause(generate_query_values($vars['device_id'], 'device_id'));
}
// Checkers Field
$form_filter = dbFetchColumn('SELECT DISTINCT `alert_test_id` FROM `alert_log`' . $where);
$form_items['checkers'] = generate_form_values('alert_log', $form_filter, 'alert_test_id');
$form['row'][0]['alert_test_id'] = array(
'type' => 'multiselect',
'name' => 'Checkers',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-1 col-sm-3',
'subtext' => TRUE,
'value' => $vars['alert_test_id'],
'values' => $form_items['checkers']);
// Checkers Field
$form_filter = dbFetchColumn('SELECT DISTINCT `alert_test_id` FROM `alert_log`' . $where);
$form_items['checkers'] = generate_form_values('alert_log', $form_filter, 'alert_test_id');
$form['row'][0]['alert_test_id'] = [
'type' => 'multiselect',
'name' => 'Checkers',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-1 col-sm-3',
'subtext' => TRUE,
'value' => $vars['alert_test_id'],
'values' => $form_items['checkers']];
// Status Type Field
$form_filter = dbFetchColumn('SELECT DISTINCT `log_type` FROM `alert_log`' . $where);
$form_items['statuses'] = generate_form_values('alert_log', $form_filter, 'log_type');
$form['row'][0]['log_type'] = array(
'type' => 'multiselect',
'name' => 'Status Type',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-1 col-sm-3',
'size' => '15',
'value' => $vars['log_type'],
'values' => $form_items['statuses']);
// Status Type Field
$form_filter = dbFetchColumn('SELECT DISTINCT `log_type` FROM `alert_log`' . $where);
$form_items['statuses'] = generate_form_values('alert_log', $form_filter, 'log_type');
$form['row'][0]['log_type'] = [
'type' => 'multiselect',
'name' => 'Status Type',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-1 col-sm-3',
'size' => '15',
'value' => $vars['log_type'],
'values' => $form_items['statuses']];
// Datetime Field
$form['row'][0]['timestamp'] = array(
'type' => 'datetime',
//'grid' => 5,
//'width' => '70%',
'div_class' => 'col-lg-5 col-md-7 col-sm-9 col-md-push-0 col-sm-push-2',
'presets' => TRUE,
'min' => dbFetchCell('SELECT `timestamp` FROM `alert_log`' . $where . ' ORDER BY `timestamp` LIMIT 0,1;'),
'max' => dbFetchCell('SELECT `timestamp` FROM `alert_log`' . $where . ' ORDER BY `timestamp` DESC LIMIT 0,1;'),
'from' => $vars['timestamp_from'],
'to' => $vars['timestamp_to']);
// Datetime Field
$form['row'][0]['timestamp'] = [
'type' => 'datetime',
//'grid' => 5,
//'width' => '70%',
'div_class' => 'col-lg-5 col-md-7 col-sm-9 col-md-push-0 col-sm-push-2',
'presets' => TRUE,
'min' => dbFetchCell('SELECT `timestamp` FROM `alert_log`' . $where . ' ORDER BY `timestamp` LIMIT 0,1;'),
'max' => dbFetchCell('SELECT `timestamp` FROM `alert_log`' . $where . ' ORDER BY `timestamp` DESC LIMIT 0,1;'),
'from' => $vars['timestamp_from'],
'to' => $vars['timestamp_to']];
// search button
$form['row'][0]['search'] = array(
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'div_class' => 'col-lg-1 col-md-1 col-sm-3',
//'grid' => 1,
'right' => TRUE);
// search button
$form['row'][0]['search'] = [
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'div_class' => 'col-lg-1 col-md-1 col-sm-3',
//'grid' => 1,
'right' => TRUE];
print_form($form);
unset($form, $form_items, $form_devices, $form_filter);
print_form($form);
unset($form, $form_items, $form_devices, $form_filter);
// Pagination
$vars['pagination'] = TRUE;
// Pagination
$vars['pagination'] = TRUE;
// Print Alert Log
print_alert_log($vars);
// Print Alert Log
print_alert_log($vars);
register_html_title('Alert Log');
register_html_title('Alert Log');
?>
</div> <!-- col-md-12 -->
?>
</div> <!-- col-md-12 -->
</div> <!-- row -->
</div> <!-- row -->
<?php
// EOF

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,11 +14,11 @@
// Global write permissions required.
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
print_error_permission();
return;
}
include($config['html_dir']."/includes/alerting-navbar.inc.php");
include($config['html_dir'] . "/includes/alerting-navbar.inc.php");
// Regenerate alerts
@ -28,18 +28,18 @@ echo generate_box_open();
$checkers = cache_alert_rules();
$assocs = cache_alert_assoc();
foreach($assocs as $assoc) {
$checkers[$assoc['alert_test_id']]['assocs'][] = $assoc;
foreach ($assocs as $assoc) {
$checkers[$assoc['alert_test_id']]['assocs'][] = $assoc;
}
foreach ($checkers as $alert) {
echo '<h3>Updating Alert <b>' . escape_html($alert['alert_name']) . '</b></h3>';
echo '<br />';
echo '<h3>Updating Alert <b>' . escape_html($alert['alert_name']) . '</b></h3>';
echo '<br />';
//r($alert);
//r($alert);
update_alert_table($alert);
update_alert_table($alert);
}

View File

@ -6,92 +6,50 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
include($config['html_dir']."/includes/alerting-navbar.inc.php");
include($config['html_dir'] . "/includes/alerting-navbar.inc.php");
if (!isset($vars['status'])) { $vars['status'] = 'failed'; }
if (!$vars['entity_type']) { $vars['entity_type'] = "all"; }
if (!isset($vars['status'])) {
$vars['status'] = 'failed';
}
if (!$vars['entity_type']) {
$vars['entity_type'] = "all";
}
$navbar['class'] = "navbar-narrow";
$navbar['brand'] = "Alert Types";
$types = dbFetchRows("SELECT DISTINCT `entity_type` FROM `alert_table` WHERE 1" . generate_query_permitted([ 'alert' ]));
$types = dbFetchRows("SELECT DISTINCT `entity_type` FROM `alert_table` " . generate_where_clause(generate_query_permitted_ng([ 'alert' ])));
$types_count = safe_count($types);
$navbar['options']['all']['url'] = generate_url($vars, array('page' => 'alerts', 'entity_type' => 'all'));
$navbar['options']['all']['url'] = generate_url($vars, ['page' => 'alerts', 'entity_type' => 'all']);
$navbar['options']['all']['text'] = escape_html(nicecase('all'));
if ($vars['entity_type'] === 'all') {
$navbar['options']['all']['class'] = "active";
$navbar['options']['all']['url'] = generate_url($vars, array('page' => 'alerts', 'entity_type' => NULL));
$navbar['options']['all']['class'] = "active";
$navbar['options']['all']['url'] = generate_url($vars, ['page' => 'alerts', 'entity_type' => NULL]);
}
foreach ($types as $thing) {
if ($vars['entity_type'] == $thing['entity_type']) {
$navbar['options'][$thing['entity_type']]['class'] = "active";
$navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, array('page' => 'alerts', 'entity_type' => NULL));
} else {
if ($types_count > 6) { $navbar['options'][$thing['entity_type']]['class'] = "icon"; }
$navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, array('page' => 'alerts', 'entity_type' => $thing['entity_type']));
}
$navbar['options'][$thing['entity_type']]['icon'] = $config['entities'][$thing['entity_type']]['icon'];
$navbar['options'][$thing['entity_type']]['text'] = escape_html(nicecase($thing['entity_type']));
}
$navbar['options_right']['filters']['url'] = '#';
$navbar['options_right']['filters']['text'] = 'Filter';
$navbar['options_right']['filters']['icon'] = $config['icon']['filter'];
//$navbar['options_right']['filters']['link_opts'] = 'data-hover="dropdown" data-toggle="dropdown"';
$filters = [
'all' => [
'url' => generate_url($vars, array('page' => 'alerts', 'status' => 'all')),
'url_o' => generate_url($vars, array('page' => 'alerts', 'status' => 'all')),
'icon' => $config['icon']['info'],
'text' => 'All'
],
'failed_delayed' => [
'url' => generate_url($vars, array('page' => 'alerts', 'status' => 'failed_delayed')),
'url_o' => generate_url($vars, array('page' => 'alerts', 'status' => 'all')),
'icon' => $config['icon']['important'],
'text' => 'Failed & Delayed'
],
'failed' => [
'url' => generate_url($vars, array('page' => 'alerts', 'status' => 'failed')),
'url_o' => generate_url($vars, array('page' => 'alerts', 'status' => 'all')),
'icon' => $config['icon']['stop'],
'text' => 'Failed'
],
'suppressed' => [
'url' => generate_url($vars, array('page' => 'alerts', 'status' => 'suppressed')),
'url_o' => generate_url($vars, array('page' => 'alerts', 'status' => 'all')),
'icon' => $config['icon']['shutdown'],
'text' => 'Suppressed'
]
];
foreach ($filters as $option => $option_array) {
$navbar['options_right']['filters']['suboptions'][$option]['text'] = $option_array['text'];
$navbar['options_right']['filters']['suboptions'][$option]['icon'] = $option_array['icon'];
if ($vars['status'] == $option) {
$navbar['options_right']['filters']['suboptions'][$option]['class'] = "active";
if ($vars['status'] !== "all") {
$navbar['options_right']['filters']['class'] = "active";
if ($vars['entity_type'] == $thing['entity_type']) {
$navbar['options'][$thing['entity_type']]['class'] = "active";
$navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, ['page' => 'alerts', 'entity_type' => NULL]);
} else {
if ($types_count > 6) {
$navbar['options'][$thing['entity_type']]['class'] = "icon";
}
$navbar['options'][$thing['entity_type']]['url'] = generate_url($vars, ['page' => 'alerts', 'entity_type' => $thing['entity_type']]);
}
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url_o'];
$navbar['options_right']['filters']['text'] .= " (".$option_array['text'].")";
$navbar['options_right']['filters']['icon'] = $option_array['icon'];
} else {
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url'];
}
$navbar['options'][$thing['entity_type']]['icon'] = $config['entities'][$thing['entity_type']]['icon'];
$navbar['options'][$thing['entity_type']]['text'] = $config['entities'][$thing['entity_type']]['names'];
}
// Add filters to navbar
navbar_alerts_filter($navbar, $vars);
// Print out the navbar defined above
print_navbar($navbar);
@ -100,9 +58,14 @@ $alert_rules = cache_alert_rules($vars);
// Print out a table of alerts matching $vars
if ($vars['status'] !== 'failed') {
$vars['pagination'] = TRUE;
$vars['pagination'] = TRUE;
}
print_alert_table($vars);
register_html_title('Alerts');
if (is_string($vars['entity_type']) && isset($config['entities'][$vars['entity_type']]['names'])) {
register_html_title($config['entities'][$vars['entity_type']]['names']);
}
// EOF

View File

@ -1,71 +1,65 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) Adam Armstrong
*
*/
$navbar['class'] = 'navbar-narrow';
$navbar['brand'] = 'Apps';
$app_types = array();
foreach ($app_list as $app)
{
if ($vars['app'] == $app['app_type'])
{
$navbar['options'][$app['app_type']]['class'] = 'active';
}
$navbar['options'][$app['app_type']]['url'] = generate_url(array('page' => 'apps', 'app' => $app['app_type']));
$navbar['options'][$app['app_type']]['text'] = nicecase($app['app_type']);
// Detect and add application icon
$icon = $app['app_type'];
$image = $config['html_dir'].'/images/apps/'.$icon.'.png';
if (is_file($image))
{
// Icon found
//$icon = $app['app_type'];
} else {
list($icon) = explode('-', str_replace('_', '-', $app['app_type']));
$image = $config['html_dir'].'/images/apps/'.$icon.'.png';
if ($icon != $app['app_type'] && is_file($image))
{
// 'postfix_qshape' -> 'postfix'
// 'exim-mailqueue' -> 'exim'
} else {
$icon = 'apps'; // Generic
$app_types = [];
foreach ($app_list as $app) {
if ($vars['app'] == $app['app_type']) {
$navbar['options'][$app['app_type']]['class'] = 'active';
}
}
$navbar['options'][$app['app_type']]['image'] = 'images/apps/'.$icon.'.png';
if (is_file($config['html_dir'].'/images/apps/'.$icon.'_2x.png'))
{
// HiDPI icon
$navbar['options'][$app['app_type']]['image_2x'] = 'images/apps/'.$icon.'_2x.png';
}
$navbar['options'][$app['app_type']]['url'] = generate_url(['page' => 'apps', 'app' => $app['app_type']]);
$navbar['options'][$app['app_type']]['text'] = nicecase($app['app_type']);
$app_types[$app['app_type']] = array();
// Detect and add application icon
$icon = $app['app_type'];
$image = $config['html_dir'] . '/images/apps/' . $icon . '.png';
if (is_file($image)) {
// Icon found
//$icon = $app['app_type'];
} else {
[$icon] = explode('-', str_replace('_', '-', $app['app_type']));
$image = $config['html_dir'] . '/images/apps/' . $icon . '.png';
if ($icon != $app['app_type'] && is_file($image)) {
// 'postfix_qshape' -> 'postfix'
// 'exim-mailqueue' -> 'exim'
} else {
$icon = 'apps'; // Generic
}
}
$navbar['options'][$app['app_type']]['image'] = 'images/apps/' . $icon . '.png';
if (is_file($config['html_dir'] . '/images/apps/' . $icon . '_2x.png')) {
// HiDPI icon
$navbar['options'][$app['app_type']]['image_2x'] = 'images/apps/' . $icon . '_2x.png';
}
$app_types[$app['app_type']] = [];
}
print_navbar($navbar);
unset($navbar);
if ($vars['app'] && is_alpha($vars['app']))
{
$include = $config['html_dir'].'/pages/apps/'.$vars['app'].'.inc.php';
if (is_file($include))
{
include($include);
} else {
include($config['html_dir'].'/pages/apps/default.inc.php');
}
if ($vars['app'] && is_alpha($vars['app'])) {
$include = $config['html_dir'] . '/pages/apps/' . $vars['app'] . '.inc.php';
if (is_file($include)) {
include($include);
} elseif (dbExist('applications', generate_where_clause([ '`app_type` = ?', generate_query_permitted_ng([ 'devices' ]) ]), [ $vars['app'] ])) {
include($config['html_dir'] . '/pages/apps/default.inc.php');
} else {
print_warning('The application "' . $vars['app'] . '" does not exist.');
}
} else {
include($config['html_dir'].'/pages/apps/overview.inc.php');
include($config['html_dir'] . '/pages/apps/overview.inc.php');
}
register_html_title('Applications');

View File

@ -1,77 +1,62 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @copyright (C) Adam Armstrong
*
*/
$graph_array['to'] = $config['time']['now'];
$graph_array['from'] = $config['time']['day'];
$graph_array['to'] = get_time();
$graph_array['from'] = get_time('day');
//$graph_array_zoom = $graph_array;
//$graph_array_zoom['height'] = "150";
//$graph_array_zoom['width'] = "400";
//$graph_array['legend'] = "no";
$app_devices = array();
foreach (dbFetchRows("SELECT * FROM `applications` WHERE `app_type` = ? ".$GLOBALS['cache']['where']['devices_permitted'], array($vars['app'])) as $app)
{
if (isset($cache['devices']['id'][$app['device_id']]))
{
$app_devices[] = array_merge($app, $cache['devices']['id'][$app['device_id']]);
}
$where_clause = generate_where_clause(['`app_type` = ?', generate_query_permitted_ng(['devices'])]);
// Merge device and app arrays for ease of sorting. This may not scale well to huge numbers of apps.
$devices = [];
foreach (dbFetchRows("SELECT * FROM `applications` " . $where_clause, [$vars['app']]) as $app) {
$devices[$app['app_id']] = array_merge($app, device_by_id_cache($app['device_id']));
}
$app_devices = array_sort_by($app_devices, 'hostname', SORT_ASC, SORT_STRING);
//echo generate_box_open();
// FIXME. Use db query instead
$devices = array_sort_by($devices, 'hostname', SORT_ASC, SORT_STRING);
//echo '<table class="table table-hover table-condensed table-striped ">';
foreach ($devices as $device) {
foreach ($app_devices as $app_device)
{
// Faux $app array for easier code reading
$app = &$device;
echo generate_box_open();
echo generate_box_open();
echo '<table class="table table-hover table-condensed table-striped ">';
echo '<table class="table table-hover table-condensed table-striped ">';
print_device_row($app_device, NULL, array('tab' => 'apps', 'app' => $app['app_type']));
print_device_row($device, NULL, ['tab' => 'apps', 'app' => $app['app_type'], 'instance' => $app['app_id']]);
echo '<tr><td colspan="6">';
echo '<tr><td colspan="6">';
$graph_array['id'] = $app_device['app_id'];
$graph_array['types'] = array();
$graph_array['legend'] = "no";
$graph_array['id'] = $device['app_id'];
$graph_array['types'] = [];
$graph_array['legend'] = "no";
foreach ($config['app'][$vars['app']]['top'] as $graph_type)
{
$graph_array['types'][] = "application_".$vars['app']."_".$graph_type;
}
print_graph_summary_row($graph_array);
foreach ($config['app'][$vars['app']]['top'] as $graph_type) {
$graph_array['types'][] = "application_" . $vars['app'] . "_" . $graph_type;
}
print_graph_summary_row($graph_array);
/*
foreach ($config['app'][$vars['app']]['top'] as $graph_type)
{
$graph_array['type'] = "application_".$vars['app']."_".$graph_type;
$graph_array['id'] = $app_device['app_id'];
$graph_array_zoom['type'] = "application_".$vars['app']."_".$graph_type;
$graph_array_zoom['id'] = $app_device['app_id'];
echo '</td>';
echo '</tr>';
echo '<h3>' . nicecase($graph_type) . '</h3>';
print_graph_row($graph_array);
}
*/
echo '</table>';
echo '</td>';
echo '</tr>';
echo '</table>';
echo generate_box_close();
echo generate_box_close();
}

View File

@ -4,70 +4,95 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$graph_array['width'] = "218";
$graph_array['height'] = "100";
$graph_array['to'] = $config['time']['now'];
$graph_array['from'] = $config['time']['day'];
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$graph_array['legend'] = "no";
foreach (dbFetchRows("SELECT * FROM `applications` WHERE 1 ".generate_query_values_and(array_keys((array)$app_types), 'app_type').$GLOBALS['cache']['where']['devices_permitted'].' ORDER BY `app_type`;') as $app)
{
if (isset($cache['devices']['id'][$app['device_id']]))
{
$app_types[$app['app_type']][] = array_merge($app, $cache['devices']['id'][$app['device_id']]);
}
}
foreach (array_keys($app_types) as $app_type)
{
echo('<div class="row"><div class="col-md-12">');
echo('<h4>'.generate_link(nicecase($app_type),array('page' => 'apps', 'app' => $app_type)).'</h4>');
$app_devices = array_sort_by($app_types[$app_type], 'hostname', SORT_ASC, SORT_STRING);
foreach ($app_devices as $app)
{
$graph_type = $config['app'][$app['app_type']]['top'][0];
$graph_array['type'] = "application_".$app['app_type']."_".$graph_type;
$graph_array['id'] = $app['app_id'];
$graph_array_zoom['type'] = "application_".$app['app_type']."_".$graph_type;
$graph_array_zoom['id'] = $app['app_id'];
$link_array = $graph_array;
$link_array['page'] = "device";
$link_array['device'] = $app['device_id'];
$link_array['tab'] = "apps";
$link_array['app'] = $app['app_type'];
unset($link_array['height'], $link_array['width']);
$overlib_url = generate_url($link_array);
$overlib_link = '<span style="float:left; margin-left: 10px; font-weight: bold;">'.short_hostname($app['hostname'])."</span>";
if (!empty($app['app_instance']))
{
$overlib_link .= '<span style="float:right; margin-right: 10px; font-weight: bold;">'.$app['app_instance']."</span>";
$app['content_add'] = '('.$app['app_instance'].')';
if ($_SESSION['widescreen']) {
if ($config['graphs']['size'] === 'big') {
$width_div = 586;
$width = 508;
$height = 149;
$height_div = 220;
} else {
$width_div = 350;
$width = 276;
$height = 109;
$height_div = 180;
}
} else {
if ($config['graphs']['size'] === 'big') {
$width_div = 614;
$width = 533;
$height = 159;
$height_div = 218;
} else {
$width_div = 302;
$width = 227;
$height = 100;
$height_div = 158;
}
$overlib_link .= "<br/>";
$overlib_link .= generate_graph_tag($graph_array);
$overlib_content = generate_overlib_content($graph_array, $app['hostname'] . " - ". $app['app_type'] . $app['content_add']);
echo("<div style='display: block; padding: 1px; padding-top: 3px; margin: 2px; min-width: ".$width_div."px; max-width:".$width_div."px; min-height:165px; max-height:165px;
text-align: center; float: left; background-color: #f5f5f5;'>");
echo(overlib_link($overlib_url, $overlib_link, $overlib_content));
echo("</div>");
}
echo('</div></div>');
}
$graph_array['height'] = 100;
$graph_array['width'] = 212;
$where_clause = generate_where_clause(generate_query_permitted_ng(['devices']));
$query = "SELECT * FROM `applications` " . $where_clause . " ORDER BY `app_type`;";
foreach (dbFetchRows($query) as $app) {
$app_types[$app['app_type']]['instances'][$app['app_id']] = array_merge($app, device_by_id_cache($app['device_id']));
}
echo '<div class="row">';
foreach ($app_types as $app_type => $app) {
echo '<div class="col-md-12"><div class="box box-solid"><h2>' . generate_link(nicecase($app_type), ['page' => 'apps', 'app' => $app_type]) . '</h2></div><div class="row">';
$app['instances'] = array_sort_by($app['instances'], 'hostname', SORT_ASC, SORT_STRING);
foreach ($app['instances'] as $app_id => $device) {
$app_id = $device['app_id'];
$graph_type = $config['app'][$app_type]['top'][0];
$graph_array['type'] = "application_" . $app_type . "_" . $graph_type;
$graph_array['id'] = $app_id;
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = "no";
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $device['hostname']);
$graph_array['width'] = $width;
$graph_array['height'] = $height;
$graph = generate_graph_tag($graph_array);
echo generate_box_open(['title' => $device['hostname'],
'url' => generate_device_url($device),
'header-border' => TRUE,
'box-style' => 'float: left; margin-left: 10px; margin-bottom: 10px; width:' . $width_div . 'px; min-width: ' . $width_div . 'px; max-width:' . $width_div . 'px; min-height:' . $height_div . 'px; max-height:' . $height_div . ';']);
echo overlib_link($link, $graph, $overlib_content);
echo generate_box_close();
}
echo '</div></div>';
}
echo '</div>';
// EOF

View File

@ -4,56 +4,54 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
include($config['html_dir'].'/includes/user_menu.inc.php');
include($config['html_dir'] . '/includes/user_menu.inc.php');
if ($_SESSION['userlevel'] < 10)
{
print_error_permission();
return;
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
}
$userlist = array();
foreach (dbFetchColumn('SELECT DISTINCT `user` FROM `authlog` WHERE `result` NOT LIKE ? AND `user` != ?;', array('%Fail%', '')) as $user)
{
$user = escape_html($user);
$userlist[$user] = ($user === '' ? '<Anonymous>' : $user);
$userlist = [];
foreach (dbFetchColumn('SELECT DISTINCT `user` FROM `authlog` WHERE `result` NOT LIKE ? AND `user` != ?;', ['%Fail%', '']) as $user) {
$user = escape_html($user);
$userlist[$user] = ($user === '' ? '<Anonymous>' : $user);
}
ksort($userlist);
$form = array('type' => 'rows',
//'space' => '5px',
//'brand' => NULL,
//'class' => 'box box-solid',
'submit_by_key' => TRUE);
//'url' => generate_url($vars)); // Use POST in authlog search
$form = ['type' => 'rows',
//'space' => '5px',
//'brand' => NULL,
//'class' => 'box box-solid',
'submit_by_key' => TRUE];
//'url' => generate_url($vars)); // Use POST in authlog search
// Row
$form['row'][0]['user'] = array(
'type' => 'multiselect',
'name' => 'Select Users',
'width' => '100%',
'value' => $vars['user'],
'values' => $userlist);
$form['row'][0]['result'] = array(
'type' => 'multiselect',
'name' => 'Action',
'width' => '100%',
'value' => $vars['result'],
'values' => array('Logged In' => array('name' =>'Logon', 'class' => ''),
'Logged Out' => array('name' =>'Logout', 'class' => ''),
'Authentication Failure' => array('name' =>'Failed', 'class' => '')));
$form['row'][0]['address'] = array(
'type' => 'text',
'name' => 'Address',
'placeholder' => TRUE,
'width' => '100%',
'value' => $vars['address']);
$form['row'][0]['user'] = [
'type' => 'multiselect',
'name' => 'Select Users',
'width' => '100%',
'value' => $vars['user'],
'values' => $userlist];
$form['row'][0]['result'] = [
'type' => 'multiselect',
'name' => 'Action',
'width' => '100%',
'value' => $vars['result'],
'values' => ['Logged In' => ['name' => 'Logon', 'class' => ''],
'Logged Out' => ['name' => 'Logout', 'class' => ''],
'Authentication Failure' => ['name' => 'Failed', 'class' => '']]];
$form['row'][0]['address'] = [
'type' => 'text',
'name' => 'Address',
'placeholder' => TRUE,
'width' => '100%',
'value' => $vars['address']];
//$form['row'][0]['date'] = array(
// 'type' => 'datetime',
// 'name' => 'Date',
@ -62,12 +60,12 @@ $form['row'][0]['address'] = array(
// 'to' => $vars['date_to'],
// 'from' => $vars['date_from']);
// Search button pull-rigth
$form['row'][0]['search'] = array(
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'right' => TRUE,
);
$form['row'][0]['search'] = [
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'right' => TRUE,
];
print_form($form);
unset($form, $userlist);

File diff suppressed because it is too large Load Diff

View File

@ -6,224 +6,192 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
// Contact display and editing page.
if ($_SESSION['userlevel'] < 7)
{
print_error_permission();
return;
if ($_SESSION['userlevel'] < 7) {
print_error_permission();
return;
}
include($config['html_dir'].'/includes/alerting-navbar.inc.php');
include($config['html_dir'].'/includes/contacts-navbar.inc.php');
include($config['html_dir'] . '/includes/alerting-navbar.inc.php');
include($config['html_dir'] . '/includes/contacts-navbar.inc.php');
?>
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-12">
<?php
<?php
// Hardcode Device sysContact
if (!dbExist('alert_contacts', '`contact_method` = ?', [ 'syscontact' ])) {
$syscontact = [
'contact_descr' => 'Device sysContact',
'contact_method' => 'syscontact',
'contact_endpoint' => '{"syscontact":"device"}',
//'contact_disabled' => '0',
//'contact_disabled_until' => NULL,
//'contact_message_custom' => 0,
//'contact_message_template' => NULL
];
dbInsert($syscontact, 'alert_contacts');
}
// Hardcode Device sysContact
if (!dbExist('alert_contacts', '`contact_method` = ?', [ 'syscontact' ])) {
$syscontact = [
'contact_descr' => 'Device sysContact',
'contact_method' => 'syscontact',
'contact_endpoint' => '{"syscontact":"device"}',
//'contact_disabled' => '0',
//'contact_disabled_until' => NULL,
//'contact_message_custom' => 0,
//'contact_message_template' => NULL
];
dbInsert($syscontact, 'alert_contacts');
}
// FIXME. Show for anyone > 5 (also for non-ADMIN) and any contacts?
$contacts = dbFetchRows('SELECT * FROM `alert_contacts` WHERE 1');
if (isset($vars['sort'])) {
$sort_order = get_sort_order($vars);
switch ($vars['sort']) {
case "id":
case "contact_id":
$sort = generate_query_sort('contact_id', $sort_order);
break;
if (count($contacts)) {
//r($contacts);
// We have contacts, print the table.
echo generate_box_open();
?>
case "transport":
case "method":
$sort = generate_query_sort('contact_method', $sort_order);
break;
<table class="table table-condensed table-striped table-rounded table-hover">
<thead>
<tr>
<th style="width: 1px"></th>
<th style="width: 50px">Id</th>
<th style="width: 100px">Transport</th>
<th style="width: 100px">Description</th>
<th>Destination</th>
<th style="width: 60px">Used</th>
<th style="width: 70px">Status</th>
<th style="width: 30px"></th>
</tr>
</thead>
<tbody>
case "description":
$sort = generate_query_sort('contact_descr', $sort_order);
break;
<?php
case "status":
$sort = generate_query_sort('contact_disabled', $sort_order);
break;
$modals = '';
default:
$sort = generate_query_sort([ 'contact_method', 'contact_descr' ], $sort_order);
}
} else {
$sort = generate_query_sort([ 'contact_method', 'contact_descr' ]);
}
//r($sort);
foreach ($contacts as $contact) {
if ($contact['contact_method'] === 'syscontact' && $config['email']['default_syscontact']) {
$num_assocs = dbFetchCell('SELECT COUNT(*) FROM `alert_tests`') + 0;
$num_assocs += dbFetchCell('SELECT COUNT(*) FROM `syslog_rules`') + 0;
} else {
$num_assocs = dbFetchCell("SELECT COUNT(*) FROM `alert_contacts_assoc` WHERE `contact_id` = ?", array( $contact['contact_id'] )) + 0;
}
$contacts = dbFetchRows('SELECT * FROM `alert_contacts`' . $sort);
if ($contact['contact_disabled'] == 1) { $disabled = ""; }
if (!safe_empty($contacts)) {
//r($contacts);
// We have contacts, print the table.
echo generate_box_open();
// If we have "identifiers" set for this type of transport, use those to print a user friendly destination.
// If we don't, just dump the JSON array as we don't have a better idea what to do right now.
$transport = $contact['contact_method'];
if (isset($config['transports'][$transport]['identifiers'])) {
// Decode JSON for use below
$contact['endpoint_variables'] = json_decode($contact['contact_endpoint'], TRUE);
echo ' <table class="table table-condensed table-striped table-rounded table-hover">' . PHP_EOL;
$cols = [
[ NULL, 'style' => 'width: 1px;' ],
[ 'id' => 'Id', 'style' => 'width: 50px;' ],
[ 'transport' => 'Transport', 'style' => 'width: 100px;' ],
[ 'description' => 'Description', 'style' => 'width: 100px;' ],
[ 'Destination' ],
[ 'Used', 'style' => 'width: 50px;' ],
[ 'status' => 'Status', 'style' => 'width: 70px;' ],
[ NULL, 'style' => 'width: 70px;' ],
];
echo generate_table_header($cols, $vars);
?>
// Add all identifier strings to an array and implode them into the description variable
// We can't just foreach the identifiers array as we don't know what section the variable is in
foreach ($config['transports'][$contact['contact_method']]['identifiers'] as $key) {
foreach ($config['transports'][$contact['contact_method']]['parameters'] as $section => $parameters) {
if (isset($parameters[$key]) && isset($contact['endpoint_variables'][$key])) {
$contact['endpoint_identifiers'][] = escape_html($parameters[$key]['description'] . ': ' . $contact['endpoint_variables'][$key]);
}
}
}
<tbody>
$contact['endpoint_descr'] = implode('<br />', $contact['endpoint_identifiers']);
} else {
$contact['endpoint_descr'] = escape_html($contact['contact_endpoint']);
}
<?php
if ($transport === 'syscontact') {
$transport_name = 'sysContact';
$transport_status = $contact['contact_disabled'] ? '<span class="label label-error">disabled</span>' : '<span class="label label-success">enabled</span>';
$contact['endpoint_descr'] = 'Device specified contact in sysContact field (email only)';
} elseif (!isset($config['transports'][$transport])) {
// Transport undefined (removed or limited to Pro)
$transport_name = nicecase($transport) . ' (Missing)';
$transport_status = '<span class="label">missing</span>';
} else {
$transport_name = $config['transports'][$transport]['name'];
$transport_status = $contact['contact_disabled'] ? '<span class="label label-error">disabled</span>' : '<span class="label label-success">enabled</span>';
}
echo ' <tr>';
echo ' <td></td>';
echo ' <td>'.$contact['contact_id'].'</td>';
echo ' <td><span class="label">'.$transport_name.'</span></td>';
echo ' <td class="text-nowrap">'.escape_html($contact['contact_descr']).'</td>';
echo ' <td><a href="' . generate_url(array('page' => 'contact', 'contact_id' => $contact['contact_id'])) . '">' . $contact['endpoint_descr'] . '</a></td>';
echo ' <td><span class="label label-primary">'.$num_assocs.'</span></td>';
echo ' <td>' . $transport_status . '</td>';
echo ' <td style="text-align: right;">';
if ($_SESSION['userlevel'] >= 10 && $transport !== 'syscontact') {
echo '
<div class="btn-group btn-group-xs" role="group" aria-label="Contact actions">
<a class="btn btn-danger" role="group" title="Delete" href="#modal-contact_delete_' . $contact['contact_id'] . '" data-toggle="modal"><i class="icon-trash"></i></a>
</div>';
}
echo '</td>';
echo ' </tr>';
$modals = '';
/* now in defaults for generate_form_modal()
$modal_args = array(
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
//'class' => 'modal-md',
);
*/
foreach ($contacts as $contact) {
if ($contact['contact_method'] === 'syscontact' && $config['email']['default_syscontact']) {
$num_assocs = dbFetchCell('SELECT COUNT(*) FROM `alert_tests`') + 0;
$num_assocs += dbFetchCell('SELECT COUNT(*) FROM `syslog_rules`') + 0;
} else {
$num_assocs = dbFetchCell("SELECT COUNT(*) FROM `alert_contacts_assoc` WHERE `contact_id` = ?", [$contact['contact_id']]) + 0;
}
$form = array('type' => 'horizontal',
'userlevel' => 10, // Minimum user level for display form
'id' => 'modal-contact_delete_'.$contact['contact_id'],
'title' => 'Delete Contact "' . escape_html($contact['contact_descr']) .
'" (Id: '. $contact['contact_id'] . ', ' . $config['transports'][$contact['contact_method']]['name'] . ')',
//'modal_args' => $modal_args, // modal specific options
//'help' => 'This will delete the selected contact and any alert assocations.',
//'class' => '', // Clean default box class (default for modals)
//'url' => 'delhost/'
);
//$form['fieldset']['body'] = array('class' => 'modal-body'); // Required this class for modal body!
//$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
if ($contact['contact_disabled'] == 1) {
$disabled = "";
}
$form['row'][0]['contact_id'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => $contact['contact_id']);
$form['row'][0]['action'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => 'delete_contact');
// If we have "identifiers" set for this type of transport, use those to print a user friendly destination.
// If we don't, just dump the JSON array as we don't have a better idea what to do right now.
$transport = $contact['contact_method'];
if (isset($config['transports'][$transport]['identifiers'])) {
// Decode JSON for use below
$contact['endpoint_variables'] = safe_json_decode($contact['contact_endpoint']);
$form['row'][6]['confirm_'.$contact['contact_id']] = array(
'type' => 'checkbox',
'fieldset' => 'body',
//'offset' => FALSE,
'name' => 'Confirm',
'placeholder' => 'Yes, please delete this contact!',
'onchange' => "javascript: toggleAttrib('disabled', 'delete_button_".$contact['contact_id']."'); showDiv(!this.checked, 'warning_".$contact['contact_id']."_div');",
'value' => 'confirm');
$form['row'][7]['warning_'.$contact['contact_id']] = array(
'type' => 'html',
'fieldset' => 'body',
'html' => '<h4 class="alert-heading"><i class="icon-warning-sign"></i> Warning!</h4>' .
' Are you sure you want to delete this contact?',
'div_style' => 'display: none', // hide initially
'div_class' => 'alert alert-warning');
// Add all identifier strings to an array and implode them into the description variable
// We can't just foreach the identifiers array as we don't know what section the variable is in
foreach ($config['transports'][$contact['contact_method']]['identifiers'] as $key) {
foreach ($config['transports'][$contact['contact_method']]['parameters'] as $section => $parameters) {
if (isset($parameters[$key], $contact['endpoint_variables'][$key])) {
$contact['endpoint_identifiers'][] = escape_html($parameters[$key]['description'] . ': ' . $contact['endpoint_variables'][$key]);
}
}
}
$form['row'][8]['close'] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => array('data-dismiss' => 'modal', // dismiss modal
'aria-hidden' => 'true')); // do not sent any value
$form['row'][9]['delete_button_'.$contact['contact_id']] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Delete Contact',
'icon' => 'icon-trash icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE,
'value' => 'contact_delete');
$contact['endpoint_descr'] = implode('<br />', (array)$contact['endpoint_identifiers']);
} else {
$contact['endpoint_descr'] = escape_html($contact['contact_endpoint']);
}
$modals .= generate_form_modal($form);
unset($form);
if ($transport === 'syscontact') {
$transport_name = 'sysContact';
$transport_status = $contact['contact_disabled'] ? '<span class="label label-error">disabled</span>' : '<span class="label label-success">enabled</span>';
$contact['endpoint_descr'] = 'Device specified contact in sysContact field (email only)';
} elseif (!isset($config['transports'][$transport])) {
// Transport undefined (removed or limited to Pro)
$transport_name = nicecase($transport) . ' (Missing)';
$transport_status = '<span class="label">missing</span>';
} else {
$transport_name = $config['transports'][$transport]['name'];
$transport_status = $contact['contact_disabled'] ? '<span class="label label-error">disabled</span>' : '<span class="label label-success">enabled</span>';
}
echo ' <tr>';
echo ' <td></td>';
echo ' <td>' . $contact['contact_id'] . '</td>';
echo ' <td><span class="label">' . $transport_name . '</span></td>';
echo ' <td class="text-nowrap">' . escape_html($contact['contact_descr']) . '</td>';
echo ' <td><a href="' . generate_url(['page' => 'contact', 'contact_id' => $contact['contact_id']]) . '">' . $contact['endpoint_descr'] . '</a></td>';
echo ' <td><span class="label label-primary">' . $num_assocs . '</span></td>';
echo ' <td>' . $transport_status . '</td>';
echo ' <td style="text-align: right;">';
if ($_SESSION['userlevel'] >= 10 && $transport !== 'syscontact') {
$buttons = [
[ 'title' => 'Edit', 'event' => 'default', 'url' => generate_url([ 'page' => 'contact' ], [ 'contact_id' => $contact['contact_id'] ]), 'icon' => 'icon-cog text-muted' ],
[ 'event' => 'danger', 'icon' => 'icon-trash',
'url' => generate_url(['page' => 'contacts'], [ 'action' => 'contact_delete', 'contact_id' => $contact['contact_id'], 'confirm_'.$contact['contact_id'] => 'confirm', 'requesttoken' => $_SESSION['requesttoken'] ]),
// confirmation dialog
'attribs' => [
'data-title' => 'Delete Contact ['.$transport_name.'] "'.escape_html($contact['contact_descr']).'"?',
'data-toggle' => 'confirm', // Enable confirmation dialog
'data-placement' => 'left',
'data-content' => '<div class="alert alert-warning"><h4 class="alert-heading"><i class="icon-warning-sign"></i> Warning!</h4>
<span class="text-nowrap">Are you sure you want to delete<br />this contact?</span></div>',
],
],
];
echo PHP_EOL . generate_button_group($buttons, [ 'title' => 'Contact actions' ]);
}
echo '</td>';
echo ' </tr>';
}
}
?>
?>
</tbody>
</table>
</tbody>
</table>
<?php
<?php
echo generate_box_close();
echo generate_box_close();
echo $modals;
unset($modals);
} else {
// We don't have contacts. Say so.
print_warning("There are currently no contacts configured.");
}
} else {
// We don't have contacts. Say so.
print_warning("There are currently no contacts configured.");
}
?>
</div> <!-- col-sm-12 -->
</div> <!-- row -->
?>
</div> <!-- col-sm-12 -->
</div> <!-- row -->
<?php

View File

@ -1,12 +1,12 @@
<?php
/**
* Observium Network Management and Monitoring System
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
@ -15,20 +15,20 @@ register_html_title("Customers");
$navbar['brand'] = "Customers";
$navbar['class'] = "navbar-narrow";
if (isset($vars['customer']) && $vars['customer'] == 'hide') {
if (get_var_false($vars['customer'], 'hide')) {
$navbar['options_right']['cust']['class'] = 'active';
$navbar['options_right']['cust']['url'] = generate_url($vars, array('customer' => NULL));
$navbar['options_right']['cust']['url'] = generate_url($vars, ['customer' => NULL]);
} else {
$navbar['options_right']['cust']['url'] = generate_url($vars, array('customer' => 'hide'));
$navbar['options_right']['cust']['url'] = generate_url($vars, ['customer' => 'hide']);
}
$navbar['options_right']['cust']['text'] = 'Customer Graphs';
$navbar['options_right']['cust']['icon'] = $config['icon']['graphs'];
if (isset($vars['aggregate']) && $vars['aggregate'] == 'show') {
if (get_var_true($vars['aggregate'], 'show')) {
$navbar['options_right']['aggregate']['class'] = 'active';
$navbar['options_right']['aggregate']['url'] = generate_url($vars, array('aggregate' => NULL));
$navbar['options_right']['aggregate']['url'] = generate_url($vars, ['aggregate' => NULL]);
} else {
$navbar['options_right']['aggregate']['url'] = generate_url($vars, array('aggregate' => 'show'));
$navbar['options_right']['aggregate']['url'] = generate_url($vars, ['aggregate' => 'show']);
}
$navbar['options_right']['aggregate']['text'] = 'Aggregate';
$navbar['options_right']['aggregate']['icon'] = $config['icon']['graphs'];
@ -37,28 +37,20 @@ $navbar['options_right']['aggregate']['icon'] = $config['icon']['graphs'];
print_navbar($navbar);
unset($navbar);
$where = generate_where_clause("`port_descr_type` = 'cust'", $cache['where']['ports_permitted']);
/// Generate customer aggregate graph
if (get_var_true($vars['aggregate'], 'show')) {
if (isset($vars['aggregate']) && $vars['aggregate'] == 'show') {
$port_list = implode(',', dbFetchColumn('SELECT `port_id` FROM `ports` ' . $where));
$where = "WHERE `port_descr_type` = 'cust'";
$where .= generate_query_permitted(array('port'));
$ports = dbFetchRows('SELECT `port_id` FROM `ports` ' . $where);
$port_list = array();
foreach ($ports as $port) {
$port_list[] = $port['port_id'];
}
$port_list = implode(',', $port_list);
echo generate_box_open(array('title' => 'Total Customer Traffic'));
echo generate_box_open(['title' => 'Total Customer Traffic']);
if ($port_list) {
$graph_array['type'] = 'multi-port_bits_separate';
$graph_array['to'] = $config['time']['now'];
$graph_array['type'] = 'multi-port_bits_separate';
$graph_array['to'] = get_time();
$graph_array['legend'] = 'no';
$graph_array['id'] = $port_list;
$graph_array['id'] = $port_list;
print_graph_row($graph_array);
@ -85,22 +77,21 @@ echo generate_box_open();
<?php
$customers = [];
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' ORDER BY `port_descr_descr`") as $customer) {
$customers[$customer['port_descr_descr']][] = $customer;
foreach (dbFetchRows("SELECT * FROM `ports` $where ORDER BY `port_descr_descr`") as $customer) {
$customers[$customer['port_descr_descr']][] = $customer;
}
foreach($customers as $customer => $ports) {
foreach ($customers as $customer => $ports) {
$customer_name = $customer; // Set text name to use on first port.
$customer_name = $customer; // Set text name to use on first port.
foreach ($ports as $port) {
$device = device_by_id_cache($port['device_id']);
unset($class);
$ifclass = port_html_class($port['ifOperStatus'], $port['ifAdminStatus'], $port['encrypted']);
//$ifclass = port_html_class($port['ifOperStatus'], $port['ifAdminStatus'], $port['encrypted']);
if ($device['os'] == "ios") {
if ($port['ifTrunk']) {
@ -114,24 +105,24 @@ foreach($customers as $customer => $ports) {
echo('
<tr>
<td style="width: 250px;"><span style="font-weight: bold;" class="interface">' . $customer_name . '</span></td>
<td style="width: 250px;"><span style="font-weight: bold;" class="interface">' . escape_html($customer_name) . '</span></td>
<td style="width: 150px;">' . generate_device_link($device) . '</td>
<td style="width: 100px;">' . generate_port_link_short($port) . '</td>
<td style="width: 100px;">' . $port['port_descr_speed'] . '</td>
<td style="width: 100px;">' . $port['port_descr_circuit'] . '</td>
<td>' . $port['port_descr_notes'] . '</td>
<td>' . escape_html($port['port_descr_notes']) . '</td>
</tr>
');
unset($customer_name);
}
if ($config['int_customers_graphs'] && !(isset($vars['customer']) && $vars['customer'] == "hide")) {
if ($config['ports']['descr_groups']['cust']['graphs'] && !get_var_false($vars['customer'], 'hide')) {
echo('<tr><td colspan="7">');
$graph_array['type'] = "customer_bits";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = '"' . $port['port_descr_descr'] . '"'; // use double quotes for prevent split var by commas
$graph_array['to'] = get_time();
$graph_array['id'] = '"' . escape_html($port['port_descr_descr']) . '"'; // use double quotes for prevent split var by commas
print_graph_row($graph_array);

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -24,8 +24,8 @@ $ua = detect_browser();
if ($ua['browser'] === 'MSIE' ||
($ua['browser'] === 'Firefox' && version_compare($ua['version'], '61', '<'))) // Also for FF ESR60 and older
{
register_html_resource('js', 'js/compat/bluebird.min.js');
register_html_resource('js', 'js/compat/fetch.js');
register_html_resource('js', 'js/compat/bluebird.min.js');
register_html_resource('js', 'js/compat/fetch.js');
}
register_html_resource('js', 'leaflet-realtime.js');
@ -34,115 +34,110 @@ register_html_resource('js', 'ResizeSensor.js');
include_dir($config['html_dir'] . '/includes/widgets/');
if($_SESSION['userlevel'] >= 7 && $vars['reset_dashboard'] == "yes")
{
dbDelete('dashboards', '1');
dbDelete('dash_widgets', '1');
if ($_SESSION['userlevel'] >= 7 && $vars['reset_dashboard'] == "yes") {
dbDelete('dashboards', '1');
dbDelete('dash_widgets', '1');
}
$grid_cell_height = 20;
$grid_h_margin = 100;
$grid_v_margin = 15;
if (!isset($vars['dash']))
{
$vars['dash'] = '1';
if (!isset($vars['dash'])) {
$vars['dash'] = '1';
$dashboard = dbFetchRow("SELECT * FROM `dashboards` WHERE `dash_id` = ?", array($vars['dash']));
$dashboard = dbFetchRow("SELECT * FROM `dashboards` WHERE `dash_id` = ?", [$vars['dash']]);
if (!$dashboard) {
//No dashboard, so generate a standard one
include("includes/dashboard-generate.inc.php");
}
if (!$dashboard) {
//No dashboard, so generate a standard one
include("includes/dashboard-generate.inc.php");
}
}
if (isset($vars['edit']) && $_SESSION['userlevel'] > 7)
{
$is_editing = TRUE;
if (isset($vars['edit']) && $_SESSION['userlevel'] > 7) {
$is_editing = TRUE;
}
$dashboard = dbFetchRow("SELECT * FROM `dashboards` WHERE `dash_id` = ?", array($vars['dash']));
$dashboard = dbFetchRow("SELECT * FROM `dashboards` WHERE `dash_id` = ?", [$vars['dash']]);
if (is_array($dashboard))
{
if (is_array($dashboard)) {
if ($is_editing === TRUE)
{
$form_items = ['types' => array(
'map' => 'Map',
'alert_table' => 'Alert Table',
'alert_boxes' => "Alert Boxes",
'alertlog' => 'Alert Log',
//'graph' => 'Graph', // Doesn't work adding here
'port_percent' => 'Traffic Composition',
'status_summary' => "Status Summary",
'old_status_table' => "Status Table (Old)",
'old_status_boxes' => "Status Boxes (Old)",
//'status_donuts' => "Status Donuts", // broke
'syslog' => 'Syslog',
'syslog_alerts' => 'Syslog Alerts',
//'weathermap' => 'Network Weathermap',
'eventlog' => 'Eventlog')];
if ($is_editing === TRUE) {
$form_items = ['types' => [
'map' => 'Map',
'alert_table' => 'Alert Table',
'alert_boxes' => "Alert Boxes",
'alertlog' => 'Alert Log',
//'graph' => 'Graph', // Doesn't work adding here
'port_percent' => 'Traffic Composition',
'status_summary' => "Status Summary",
'old_status_table' => "Status Table (Old)",
'old_status_boxes' => "Status Boxes (Old)",
//'status_donuts' => "Status Donuts", // broke
'syslog' => 'Syslog',
'syslog_alerts' => 'Syslog Alerts',
//'wmap' => 'Network Weathermap',
'eventlog' => 'Eventlog']];
$form = array('id' => 'add_widget',
'type' => 'rows',
'space' => '5px');
$form = ['id' => 'add_widget',
'type' => 'rows',
'space' => '5px'];
$form['row'][0]['dash_id'] = array(
'type' => 'hidden',
'name' => 'Dashboard Name',
'value' => $dashboard['dash_id'],
'grid' => 0
);
$form['row'][0]['widget_type'] = array(
'type' => 'select',
'name' => 'Widget',
'width' => '100%', //'180px',
'grid' => 2,
//'value' => $vars['widget_type'],
'values' => $form_items['types']);
$form['row'][0]['add'] = array(
'type' => 'submit',
'class' => 'btn-success',
'name' => 'Add Widget',
'width' => '100%', //'180px',
'value' => 'Add Widget',
'icon' => '',
'grid' => 1
);
$form['row'][0]['dash_name'] = array(
'type' => 'text',
'width' => '100%', //'180px',
'placeholder' => 'Dashboard Name',
'value' => $dashboard['dash_name'],
'grid' => 3
);
$form['row'][0]['dash_delete'] = array(
'type' => 'submit',
'class' => 'btn-danger',
'name' => 'Delete Dashboard',
'value' => 'Delete Dashboard',
'icon' => '',
'grid' => 6,
'right' => TRUE,
'onclick' => 'dashDelete();',
// confirmation dialog
'attribs' => array('data-toggle' => 'confirm', // Enable confirmation dialog
'data-confirm-placement' => 'bottom',
'data-confirm-content' => 'Are you sure?',
),
);
print_form($form);
$form['row'][0]['dash_id'] = [
'type' => 'hidden',
'name' => 'Dashboard Name',
'value' => $dashboard['dash_id'],
'grid' => 0
];
$form['row'][0]['widget_type'] = [
'type' => 'select',
'name' => 'Widget',
'width' => '100%', //'180px',
'grid' => 2,
//'value' => $vars['widget_type'],
'values' => $form_items['types']];
$form['row'][0]['add'] = [
'type' => 'submit',
'class' => 'btn-success',
'name' => 'Add Widget',
'width' => '100%', //'180px',
'value' => 'Add Widget',
'icon' => '',
'grid' => 1
];
$form['row'][0]['dash_name'] = [
'type' => 'text',
'width' => '100%', //'180px',
'placeholder' => 'Dashboard Name',
'value' => $dashboard['dash_name'],
'grid' => 3
];
$form['row'][0]['dash_delete'] = [
'type' => 'submit',
'class' => 'btn-danger',
'name' => 'Delete Dashboard',
'value' => 'Delete Dashboard',
'icon' => '',
'grid' => 6,
'right' => TRUE,
'onclick' => 'dashDelete();',
// confirmation dialog
'attribs' => ['data-toggle' => 'confirm', // Enable confirmation dialog
'data-confirm-placement' => 'bottom',
'data-confirm-content' => 'Are you sure?',
],
];
print_form($form);
}
}
echo '<div class="row">';
echo '<div class="grid-stack" id="grid">';
echo '</div>';
echo '</div>';
echo '<div class="row">';
echo '<div class="grid-stack" id="grid">';
echo '</div>';
echo '</div>';
?>
?>
<!--- <textarea id="saved-data" cols="100" rows="20" readonly="readonly"></textarea> -->
@ -150,9 +145,9 @@ if (is_array($dashboard))
var dash_id = <?php echo $dashboard['dash_id']; ?>;
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
$(function () {
var options = {
@ -161,7 +156,11 @@ if (is_array($dashboard))
verticalMargin: <?php echo $grid_v_margin; ?>,
resizable: {
autoHide: true,
handles: <?php if ($is_editing === TRUE) echo "'se, sw'"; else echo "'none'"; ?>
handles: <?php if ($is_editing === TRUE) {
echo "'se, sw'";
} else {
echo "'none'";
} ?>
},
draggable: {
handle: '.drag-handle',
@ -171,21 +170,20 @@ if (is_array($dashboard))
var initial_grid = [
<?php
<?php
$data = array();
$widgets = dbFetchRows("SELECT * FROM `dash_widgets` WHERE `dash_id` = ? ORDER BY `y`,`x`", array($dashboard['dash_id']));
foreach ($widgets AS $widget)
{
$data[] = '{' .
(is_numeric($widget['x']) ? '"x": ' . $widget['x'] . ',' : '') .
(is_numeric($widget['y']) ? '"y": ' . $widget['y'] . ',' : '') .
'"width": ' . $widget['width'] . ', "height": ' . $widget['height'] . ', "id": "' . $widget['widget_id'] . '"}';
}
$data = [];
$widgets = dbFetchRows("SELECT * FROM `dash_widgets` WHERE `dash_id` = ? ORDER BY `y`,`x`", [$dashboard['dash_id']]);
foreach ($widgets as $widget) {
$data[] = '{' .
(is_numeric($widget['x']) ? '"x": ' . $widget['x'] . ',' : '') .
(is_numeric($widget['y']) ? '"y": ' . $widget['y'] . ',' : '') .
'"width": ' . $widget['width'] . ', "height": ' . $widget['height'] . ', "id": "' . $widget['widget_id'] . '"}';
}
echo implode(",", $data);
echo implode(",", $data);
?>
?>
];
@ -255,14 +253,14 @@ if (is_array($dashboard))
this.drawWidget = function (node) {
this.grid.addWidget($('<div><div id="widget-' + node.id + '" class="grid-stack-item-content"></div>' +
<?php if($is_editing == TRUE) { ?>
'<div class="hover-show" style="z-index: 1000; position: absolute; top:0px; right: 10px; padding: 2px 10px; padding-right: 0px; border-bottom-left-radius: 4px; border: 1px solid #e5e5e5; border-right: none; border-top: none; background: white;">' +
' <i style="cursor: pointer; margin: 7px;" class="sprite-refresh" onclick="refreshWidget(' + node.id + ')"></i>' +
' <i style="cursor: pointer; margin: 7px;" class="sprite-tools" onclick="configWidget(' + node.id + ')"></i></i>' +
' <i style="cursor: no-drop; margin: 7px;" class="sprite-cancel" onclick="deleteWidget(' + node.id + ')"></i>' +
' <i style="cursor: move; margin: 7px; margin-right: 20px" class="sprite-move drag-handle"></i>' +
'</div>' +
'<div class="hover-show" style="z-index: 1000; position: absolute; top:0px; right: 10px; padding: 2px 10px; padding-right: 0px; border-bottom-left-radius: 4px; border: 1px solid #e5e5e5; border-right: none; border-top: none; background: white;">' +
' <i style="cursor: pointer; margin: 7px;" class="sprite-refresh" onclick="refreshWidget(' + node.id + ')"></i>' +
' <i style="cursor: pointer; margin: 7px;" class="sprite-tools" onclick="configWidget(' + node.id + ')"></i></i>' +
' <i style="cursor: no-drop; margin: 7px;" class="sprite-cancel" onclick="deleteWidget(' + node.id + ')"></i>' +
' <i style="cursor: move; margin: 7px; margin-right: 20px" class="sprite-move drag-handle"></i>' +
'</div>' +
<?php } ?>
'</div>'),
'</div>'),
node.x, node.y, node.width, node.height, node.autoposition, null, null, null, null, node.id);
};
@ -436,7 +434,7 @@ if (is_array($dashboard))
request.success(function (json) {
if (json.status === 'ok') {
window.setTimeout(window.location.href = '<?php echo generate_url(array('page' => 'dashboard')); ?>', 5000);
window.setTimeout(window.location.href = '<?php echo generate_url(['page' => 'dashboard']); ?>', 5000);
}
});
};
@ -543,7 +541,7 @@ if (is_array($dashboard))
});
new ResizeSensor(jQuery('#main_container'), function(){
new ResizeSensor(jQuery('#main_container'), function () {
//refreshAllUpdatableImages();
//refreshAllUpdatableWidgets();
refreshAllWidgets();
@ -551,9 +549,9 @@ if (is_array($dashboard))
</script>
<?php
<?php
// print_vars($widgets);
?>
?>
<style>
@ -584,34 +582,36 @@ if (is_array($dashboard))
}
.grid-stack tr {
white-space: nowrap; overflow: hidden; text-overflow:ellipsis;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* Fix Z-index breaking dropdowns inside widgets*/
.grid-stack > .grid-stack-item > .grid-stack-item-content
{
z-index: unset!important;
}
/*
.box-content::-webkit-scrollbar-track
{
background-color: #F5F5F5;
.grid-stack > .grid-stack-item > .grid-stack-item-content {
z-index: unset !important;
}
.box-content::-webkit-scrollbar
{
width: 10px;
height: 10px;
background-color: #c5c5c5;
}
/*
.box-content::-webkit-scrollbar-track
{
background-color: #F5F5F5;
}
.box-content::-webkit-scrollbar-thumb
{
border-radius: 10px;
background-color: #d5d5d5;
border: 2px solid #F5F5F5;
}
*/
.box-content::-webkit-scrollbar
{
width: 10px;
height: 10px;
background-color: #c5c5c5;
}
.box-content::-webkit-scrollbar-thumb
{
border-radius: 10px;
background-color: #d5d5d5;
border: 2px solid #F5F5F5;
}
*/
</style>
@ -640,25 +640,24 @@ if (is_array($dashboard))
</div>
<!-- /.modal -->
<?php
<?php
if ($_SESSION['userlevel'] > 7) {
if (isset($vars['edit'])) {
$url = generate_url($vars, array('edit' => NULL));
$text = "Enable Editing Mode";
} else {
$url = generate_url($vars, array('edit' => 'yes'));
$text = "Disable Editing Mode";
if ($_SESSION['userlevel'] > 7) {
if (isset($vars['edit'])) {
$url = generate_url($vars, ['edit' => NULL]);
$text = "Enable Editing Mode";
} else {
$url = generate_url($vars, ['edit' => 'yes']);
$text = "Disable Editing Mode";
}
$footer_entry = '<li><a href="' . $url . '"><i class="sprite-sliders"></i></a></li>';
$footer_entries[] = $footer_entry;
}
$footer_entry = '<li><a href="' .$url. '"><i class="sprite-sliders"></i></a></li>';
$footer_entries[] = $footer_entry;
}
} else {
print_error('Dashboard does not exist!');
print_error('Dashboard does not exist!');
}
// EOF

View File

@ -4,16 +4,15 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
if ($_SESSION['userlevel'] >= 7)
{
$dash_id = dbInsert(array('dash_name' => 'Default Dashboard'), 'dashboards');
dbUpdate( [ 'dash_name' => 'Dashboard '.$dash_id ], 'dashboards', '`dash_id` = ?', [ $dash_id ]);
redirect_to_url(generate_url(['page' => 'dashboard', 'dash' => $dash_id, 'edit' => 'yes', 'action' => NULL]));
if ($_SESSION['userlevel'] >= 7) {
$dash_id = dbInsert(['dash_name' => 'Default Dashboard'], 'dashboards');
dbUpdate(['dash_name' => 'Dashboard ' . $dash_id], 'dashboards', '`dash_id` = ?', [$dash_id]);
redirect_to_url(generate_url(['page' => 'dashboard', 'dash' => $dash_id, 'edit' => 'yes', 'action' => NULL]));
}

View File

@ -4,32 +4,26 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
register_html_title('Deleted ports');
if ($vars['purge'] == 'all')
{
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `deleted` = ?', ['1']) as $port)
{
if (port_permitted($port['port_id'], $port['device_id']))
{
print_message(delete_port($port['port_id']), 'console');
if ($vars['purge'] == 'all') {
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `deleted` = ?', ['1']) as $port) {
if (port_permitted($port['port_id'], $port['device_id'])) {
print_message(delete_port($port['port_id']), 'console');
}
}
} elseif (is_numeric($vars['purge'])) {
$port = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ? AND `deleted` = ?', [$vars['purge'], '1']);
if ($port && port_permitted($port['port_id'], $port['device_id'])) {
print_message(delete_port($port['port_id']), 'console');
}
}
}
else if (is_numeric($vars['purge']))
{
$port = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ? AND `deleted` = ?', [$vars['purge'], '1']);
if ($port && port_permitted($port['port_id'], $port['device_id']))
{
print_message(delete_port($port['port_id']), 'console');
}
}
echo generate_box_open();
@ -40,23 +34,21 @@ echo('<table class="table table-condensed table-striped table-condensed">
<th>Port</th>
<th>Description</th>
<th>Deleted since</th>
<th style="text-align: right;"><a class="btn btn-danger btn-mini" href="'.generate_url(array('page'=>'deleted-ports', 'purge'=>'all')).'" role="button"><i class="icon-remove icon-white"></i> Purge All</a></th>
<th style="text-align: right;"><a class="btn btn-danger btn-mini" href="' . generate_url(['page' => 'deleted-ports', 'purge' => 'all']) . '" role="button"><i class="icon-remove icon-white"></i> Purge All</a></th>
</tr></thead>');
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `deleted` = ?', ['1']) as $port)
{
humanize_port($port);
$since = $config['time']['now'] - strtotime($port['ifLastChange']);
if (port_permitted($port['port_id'], $port['device_id']))
{
echo('<tr class="list">');
echo('<td style="width: 200px;" class="strong">'.generate_device_link($port).'</td>');
echo('<td style="width: 350px;" class="strong">'.generate_port_link($port).'</td>');
echo('<td>'.escape_html($port['ifAlias']).'</td>');
echo('<td>'.format_uptime($since, 'short-2').' ago</td>');
echo('<td style="width: 100px; text-align: right;"><a class="btn btn-danger btn-mini" href="'.generate_url(array('page' => 'deleted-ports', 'purge' => $port['port_id'])).'" role="button"><i class="icon-remove icon-white"></i> Purge</a></td>');
echo(PHP_EOL);
}
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `deleted` = ?', ['1']) as $port) {
humanize_port($port);
$since = get_time('now') - strtotime($port['ifLastChange']);
if (port_permitted($port['port_id'], $port['device_id'])) {
echo('<tr class="list">');
echo('<td style="width: 200px;" class="strong">' . generate_device_link($port) . '</td>');
echo('<td style="width: 350px;" class="strong">' . generate_port_link($port) . '</td>');
echo('<td>' . escape_html($port['ifAlias']) . '</td>');
echo('<td>' . format_uptime($since, 'short-2') . ' ago</td>');
echo('<td style="width: 100px; text-align: right;"><a class="btn btn-danger btn-mini" href="' . generate_url(['page' => 'deleted-ports', 'purge' => $port['port_id']]) . '" role="button"><i class="icon-remove icon-white"></i> Purge</a></td>');
echo(PHP_EOL);
}
}
echo('</table>');

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
@ -20,89 +20,89 @@ if ($_SESSION['userlevel'] < 10) {
register_html_title("Delete devices");
if (is_intnum($vars['id']) && is_entity_write_permitted($vars['id'], 'device')) {
$device = device_by_id_cache($vars['id']);
$device = device_by_id_cache($vars['id']);
if ($device && get_var_true($vars['confirm'], 'confirm')) {
$delete_rrd = get_var_true($vars['deleterrd'], 'confirm');
print_message(delete_device($vars['id'], $delete_rrd), 'console');
//echo('<div class="btn-group ">
// <button type="button" class="btn btn-default"><a href="/"><i class="oicon-globe-model"></i> Overview</a></button>
// <button type="button" class="btn btn-default"><a href="/devices/"><i class="oicon-servers"></i> Devices List</a></button>
// </div>');
} else {
print_warning("Are you sure you want to delete device <strong>" . $device['hostname'] . "</strong>?");
if ($device && get_var_true($vars['confirm'], 'confirm')) {
$delete_rrd = get_var_true($vars['deleterrd'], 'confirm');
print_message(delete_device($vars['id'], $delete_rrd), 'console');
//echo('<div class="btn-group ">
// <button type="button" class="btn btn-default"><a href="/"><i class="oicon-globe-model"></i> Overview</a></button>
// <button type="button" class="btn btn-default"><a href="/devices/"><i class="oicon-servers"></i> Devices List</a></button>
// </div>');
} else {
print_warning("Are you sure you want to delete device <strong>" . $device['hostname'] . "</strong>?");
$form = array('type' => 'horizontal',
'id' => 'delete_host',
//'space' => '20px',
'title' => 'Delete device <strong>'. $device['hostname'] . '</strong>',
//'class' => 'box box-solid',
'url' => 'delhost/');
$form = ['type' => 'horizontal',
'id' => 'delete_host',
//'space' => '20px',
'title' => 'Delete device <strong>' . $device['hostname'] . '</strong>',
//'class' => 'box box-solid',
'url' => 'delhost/'];
$form['row'][0]['id'] = array(
'type' => 'hidden',
'value' => $vars['id']);
$form['row'][4]['deleterrd'] = array(
'type' => 'checkbox',
'name' => 'Delete RRDs',
'value' => (bool)$vars['deleterrd']);
$form['row'][5]['confirm'] = array(
'type' => 'checkbox',
'name' => 'Confirm Deletion',
'onchange' => "javascript: toggleAttrib('disabled', 'delete');",
'value' => 'confirm');
$form['row'][6]['delete'] = array(
'type' => 'submit',
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE);
print_form($form);
unset($form);
}
} elseif ($_SESSION['userlevel'] > 9) {
$form['row'][0]['id'] = [
'type' => 'hidden',
'value' => $vars['id']];
$form['row'][4]['deleterrd'] = [
'type' => 'checkbox',
'name' => 'Delete RRDs',
'value' => (bool)$vars['deleterrd']];
$form['row'][5]['confirm'] = [
'type' => 'checkbox',
'name' => 'Confirm Deletion',
'onchange' => "javascript: toggleAttrib('disabled', 'delete');",
'value' => 'confirm'];
$form['row'][6]['delete'] = [
'type' => 'submit',
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE];
print_form($form);
unset($form);
}
} elseif ($_SESSION['userlevel'] >= 9) {
$form_items['devices'] = generate_form_values('device', NULL, NULL, array('disabled' => TRUE));
$form_items['devices'] = generate_form_values('device', NULL, NULL, [ 'show_disabled' => TRUE ]);
$form = array('type' => 'horizontal',
'id' => 'delete_host',
//'space' => '20px',
'title' => 'Delete device',
//'class' => 'box box-solid',
'url' => 'delhost/'
);
$form = ['type' => 'horizontal',
'id' => 'delete_host',
//'space' => '20px',
'title' => 'Delete device',
//'class' => 'box box-solid',
'url' => 'delhost/'
];
$form['row'][1]['id'] = array(
'type' => 'select',
'name' => 'Device',
'groups' => array('DISABLED', 'DOWN'),
'values' => $form_items['devices']);
$form['row'][4]['deleterrd'] = array(
'type' => 'checkbox',
'name' => 'Delete RRDs',
'onchange' => "javascript: showDiv(this.checked);",
'value' => 'confirm');
$form['row'][5]['confirm'] = array(
'type' => 'checkbox',
'name' => 'Confirm Deletion',
'onchange' => "javascript: toggleAttrib('disabled', 'delete');",
'value' => 'confirm');
$form['row'][6]['delete'] = array(
'type' => 'submit',
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE);
$form['row'][1]['id'] = [
'type' => 'select',
'name' => 'Device',
'groups' => ['DISABLED', 'DOWN'],
'values' => $form_items['devices']];
$form['row'][4]['deleterrd'] = [
'type' => 'checkbox',
'name' => 'Delete RRDs',
'onchange' => "javascript: showDiv(this.checked);",
'value' => 'confirm'];
$form['row'][5]['confirm'] = [
'type' => 'checkbox',
'name' => 'Confirm Deletion',
'onchange' => "javascript: toggleAttrib('disabled', 'delete');",
'value' => 'confirm'];
$form['row'][6]['delete'] = [
'type' => 'submit',
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE];
print_warning("<h4>Warning!</h4>
print_warning("<h4>Warning!</h4>
This will delete this device from Observium including all logging entries, but will not delete the RRDs.");
print_form($form);
unset($form, $form_items);
print_form($form);
unset($form, $form_items);
} else {
print_error_permission();
print_error_permission();
}
// EOF

File diff suppressed because it is too large Load Diff

View File

@ -4,26 +4,30 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$ap = dbFetchRow("SELECT * FROM `accesspoints` LEFT JOIN `accesspoints-state` USING (`accesspoint_id`) WHERE `device_id` = ? AND accesspoints.`accesspoint_id` = ? AND `deleted` = '0' ORDER BY `name`,`radio_number` ASC", array($device['device_id'],$vars['ap']));
$sql = "SELECT * FROM `accesspoints` LEFT JOIN `accesspoints-state` USING (`accesspoint_id`)
WHERE `device_id` = ? AND accesspoints.`accesspoint_id` = ? AND `deleted` = '0'
ORDER BY `name`,`radio_number` ASC";
$ap = dbFetchRow($sql, [$device['device_id'], $vars['ap']]);
if (safe_empty($ap)) {
print_error("No Access Point Found");
return;
print_error("No Access Point Found");
return;
}
echo generate_box_open();
echo '<table class="table table-striped">';
include($config['html_dir'].'/includes/print-accesspoint.inc.php');
include($config['html_dir'] . '/includes/print-accesspoint.inc.php');
echo '</table>' ;
echo '</table>';
echo generate_box_close();

View File

@ -4,37 +4,35 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$i = "1";
$aps = dbFetchRows("SELECT * FROM `accesspoints` LEFT JOIN `accesspoints-state` USING (`accesspoint_id`) WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `name`,`radio_number` ASC", array($device['device_id']));
$aps = dbFetchRows("SELECT * FROM `accesspoints` LEFT JOIN `accesspoints-state` USING (`accesspoint_id`) WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `name`,`radio_number` ASC", [$device['device_id']]);
if(count($aps))
{
if (count($aps)) {
echo generate_box_open();
echo generate_box_open();
echo('<table class="table table-striped table-hover">');
echo('<table class="table table-striped table-hover">');
foreach ($aps as $ap)
{
include($config['html_dir'].'/includes/print-accesspoint.inc.php');
foreach ($aps as $ap) {
include($config['html_dir'] . '/includes/print-accesspoint.inc.php');
$i++;
}
echo('</table>');
$i++;
}
echo('</table>');
echo generate_box_close();
echo generate_box_close();
} else {
print_message('No access points found.', 'warning');
print_message('No access points found.', 'warning');
}

View File

@ -4,231 +4,269 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
// User level 7-9 only can see config
$readonly = $_SESSION['userlevel'] < 8;
if ($entry = get_alert_entry_by_id($vars['alert_entry']))
{
if ($entry['device_id'] != $device['device_id'])
{
print_error("This alert entry id does not match this device.");
} else {
// Run actions
if ($vars['submit'] === 'update-alert-entry' && !$readonly)
{
if (isset($vars['ignore_until_ok']) && ($vars['ignore_until_ok'] == '1' || $entry['ignore_until_ok'] == '1'))
{
$update_state['ignore_until_ok'] = '1';
if ($entry['alert_status'] == 0) { $update_state['alert_status'] = '3'; }
} else {
$update_state['ignore_until_ok'] = '0';
if ($entry = get_alert_entry_by_id($vars['alert_entry'])) {
if ($entry['device_id'] != $device['device_id']) {
print_error("This alert entry id does not match this device.");
return;
}
// 2019-12-05 23:30:00
// Run actions
if ($vars['submit'] === 'update-alert-entry' && !$readonly) {
if (isset($vars['ignore_until']) && $vars['ignore_until_enable'])
{
$vars['ignore_unixtime'] = strtotime($vars['ignore_until']);
$update_state['ignore_until'] = $vars['ignore_until'];
if ($entry['alert_status'] == 0 && $vars['ignore_unixtime'] > time()) { $update_state['alert_status'] = '3'; }
} else {
$update_state['ignore_until'] = array('NULL');
if (isset($vars['ignore_until_ok']) && ($vars['ignore_until_ok'] == '1' || $entry['ignore_until_ok'] == '1')) {
$update_state['ignore_until_ok'] = '1';
if ($entry['alert_status'] == 0) {
$update_state['alert_status'] = '3';
}
} else {
$update_state['ignore_until_ok'] = '0';
}
// 2019-12-05 23:30:00
if (isset($vars['ignore_until']) && $vars['ignore_until_enable']) {
$vars['ignore_unixtime'] = strtotime($vars['ignore_until']);
$update_state['ignore_until'] = $vars['ignore_until'];
if ($entry['alert_status'] == 0 && $vars['ignore_unixtime'] > time()) {
$update_state['alert_status'] = '3';
}
} else {
$update_state['ignore_until'] = ['NULL'];
}
if (is_array($update_state)) {
$up_s = dbUpdate($update_state, 'alert_table', '`alert_table_id` = ?', [$vars['alert_entry']]);
}
// Refresh array because we've changed the database.
$entry = get_alert_entry_by_id($vars['alert_entry']);
}
if (is_array($update_state))
{
$up_s = dbUpdate($update_state, 'alert_table', '`alert_table_id` = ?', array($vars['alert_entry']));
}
// End actions
// Refresh array because we've changed the database.
$entry = get_alert_entry_by_id($vars['alert_entry']);
}
humanize_alert_entry($entry);
// End actions
humanize_alert_entry($entry);
$alert_rules = cache_alert_rules();
$alert = $alert_rules[$entry['alert_test_id']];
$state = safe_json_decode($entry['state']);
$conditions = safe_json_decode($alert['conditions']);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
$alert_rules = cache_alert_rules();
$alert = $alert_rules[$entry['alert_test_id']];
$state = safe_json_decode($entry['state']);
$conditions = safe_json_decode($alert['conditions']);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
// r($entry);
// r($alert);
?>
?>
<div class="row">
<div class="col-md-3">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Alert Details</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed table-striped ">
<tbody>
<tr><th>Type</th><td><?php echo '<i class="' . $config['entities'][$alert['entity_type']]['icon'] . '"></i> ' . nicecase($entry['entity_type']); ?></td></tr>
<tr><th>Entity</th><td><?php echo generate_entity_link($entry['entity_type'], $entry['entity_id'], $entity['entity_name']); ?></td></tr>
<tr><th>Checker</th><td><a href="<?php echo generate_url(array('page' => 'alert_check', 'alert_test_id' => $alert['alert_test_id'])); ?>"><?php echo escape_html($alert['alert_name']); ?></a></td></tr>
<tr><th>Fail Msg</th><td><?php echo escape_html($alert['alert_message']); ?></td></tr>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-3">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Alert Details</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed table-striped ">
<tbody>
<tr>
<th>Type</th>
<td><?php echo get_icon($config['entities'][$alert['entity_type']]['icon']) . nicecase($entry['entity_type']); ?></td>
</tr>
<tr>
<th>Entity</th>
<td><?php echo generate_entity_link($entry['entity_type'], $entry['entity_id'], $entity['entity_name']); ?></td>
</tr>
<tr>
<th>Checker</th>
<td><a
href="<?php echo generate_url(['page' => 'alert_check', 'alert_test_id' => $alert['alert_test_id']]); ?>"><?php echo escape_html($alert['alert_name']); ?></a>
</td>
</tr>
<tr>
<th>Fail Msg</th>
<td><?php echo escape_html($alert['alert_message']); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Status</h3>
</div>
<div class="box-body no-padding">
<div class="col-md-4">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Status</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed">
<tr><th>Status</th><td><span class="<?php echo $entry['class']; ?>"><?php echo $entry['last_message']; ?></span></td></tr>
<tr><th>Last Changed</th><td><?php echo $entry['changed']; ?></td></tr>
<tr><td colspan=2>
<?php
<table class="table table-condensed">
<tr>
<th>Status</th>
<td><span class="<?php echo $entry['class']; ?>"><?php echo $entry['last_message']; ?></span></td>
</tr>
<tr>
<th>Last Changed</th>
<td><?php echo $entry['changed']; ?></td>
</tr>
<tr>
<td colspan=2>
<?php
$state = safe_json_decode($entry['state']);
$state = safe_json_decode($entry['state']);
$alert['state_popup'] = '';
$alert['state_popup'] = '';
// FIXME - rewrite this, it's shit
// FIXME - rewrite this, it's shit
if ($alert['alert_status'] != '1' && safe_count($state['failed']))
{
$alert['state_popup'] .= '<table class="table table-striped table-condensed">';
$alert['state_popup'] .= '<thead><tr><th>Metric</th><th>Cond</th><th>Value</th><th>Measured</th></tr></thead>';
if ($alert['alert_status'] != '1' && safe_count($state['failed'])) {
$alert['state_popup'] .= '<table class="table table-striped table-condensed">';
$alert['state_popup'] .= '<thead><tr><th>Metric</th><th>Cond</th><th>Value</th><th>Measured</th></tr></thead>';
foreach($state['failed'] as $test)
{
$alert['state_popup'] .= '<tr><td><strong>'.$test['metric'].'</strong></td><td>'.$test['condition'].'</td><td>'.format_value($test['value']).'</td><td><i class="red">'.format_value($state['metrics'][$test['metric']]).'</i></td></tr>';
}
$alert['state_popup'] .= '</table>';
foreach ($state['failed'] as $test) {
$metric_def = $config['entities'][$alert['entity_type']]['metrics'][$test['metric']];
} elseif (safe_count($state['metrics'])) {
$alert['state_popup'] .= '<table class="table table-striped table-condensed">';
$alert['state_popup'] .= '<thead><tr><th>Metric</th><th>Value</th></tr></thead>';
foreach($state['metrics'] as $metric => $value)
{
$alert['state_popup'] .= '<tr><td><strong>'.$metric.'</strong></td><td>'.format_value($value).'</td></tr>';
}
$alert['state_popup'] .= '</table>';
$format = NULL;
$symbol = '';
if (!safe_empty($test['value'])) {
if (isset($metric_def['format'])) {
$format = isset($entity[$metric_def['format']]) ? $entity[$metric_def['format']] : $metric_def['format'];
}
if (isset($metric_def['symbol'])) {
$symbol = isset($entity[$metric_def['symbol']]) ? $entity[$metric_def['symbol']] : $metric_def['symbol'];
}
}
}
$alert['state_popup'] .= '<tr><td><strong>' . $test['metric'] . '</strong></td><td>' . $test['condition'] . '</td><td>' .
format_value($test['value'], $entity['entity_format']) . $entity['entity_symbol'] . '</td><td><i class="red">' .
format_value($state['metrics'][$test['metric']], $entity['entity_format']) . $entity['entity_symbol'] . '</i></td></tr>';
}
$alert['state_popup'] .= '</table>';
echo $alert['state_popup'];
} elseif (safe_count($state['metrics'])) {
$alert['state_popup'] .= '<table class="table table-striped table-condensed">';
$alert['state_popup'] .= '<thead><tr><th>Metric</th><th>Value</th></tr></thead>';
foreach ($state['metrics'] as $metric => $value) {
$alert['state_popup'] .= '<tr><td><strong>' . $metric . '</strong></td><td>' . format_value($value, $entity['entity_format']) . $entity['entity_symbol'] . '</td></tr>';
}
$alert['state_popup'] .= '</table>';
?>
</td></tr>
}
<!-- <tr><th>Last Checked</th><td><?php echo $entry['checked']; ?></td></tr>
echo $alert['state_popup'];
?>
</td>
</tr>
<!-- <tr><th>Last Checked</th><td><?php echo $entry['checked']; ?></td></tr>
<tr><th>Last Changed</th><td><?php echo $entry['changed']; ?></td></tr>
<tr><th>Last Alerted</th><td><?php echo $entry['alerted']; ?></td></tr>
<tr><th>Last Recovered</th><td><?php echo $entry['recovered']; ?></td></tr> -->
</table>
</div>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-5">
<?php
<div class="col-md-5">
<?php
$form = array('type' => 'horizontal',
'id' => 'update_alert_entry',
'title' => 'Alert Settings',
//'icon' => 'oicon-gear',
'fieldset' => array('edit' => ''),
);
$form = [
'type' => 'horizontal',
'id' => 'update_alert_entry',
'title' => 'Alert Settings',
//'icon' => 'oicon-gear',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['ignore_until'] = array(
'type' => 'datetime',
//'fieldset' => 'edit',
'name' => 'Ignore Until',
'placeholder' => '',
//'width' => '250px',
'readonly' => $readonly,
'disabled' => empty($entry['ignore_until']),
'min' => 'current',
'value' => ($entry['ignore_until'] ? $entry['ignore_until'] : ''));
$form['row'][1]['ignore_until_enable'] = array(
'type' => 'toggle',
'view' => 'toggle',
'size' => 'big',
'palette' => 'blue',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'ignore_until')",
'value' => !empty($entry['ignore_until']));
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
];
$form['row'][1]['ignore_until'] = [
'type' => 'datetime',
//'fieldset' => 'edit',
'name' => 'Ignore Until',
'placeholder' => '',
//'width' => '250px',
'readonly' => $readonly,
'disabled' => empty($entry['ignore_until']),
'min' => 'current',
'value' => $entry['ignore_until'] ?: ''
];
$form['row'][1]['ignore_until_enable'] = [
'type' => 'toggle',
'view' => 'toggle',
'size' => 'big',
'palette' => 'blue',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'ignore_until')",
'value' => !empty($entry['ignore_until'])
];
$form['row'][2]['ignore_until_ok'] = [
'type' => 'toggle',
'name' => 'Ignore Until OK',
//'fieldset' => 'edit',
'view' => 'toggle',
'size' => 'big',
'palette' => 'blue',
'readonly' => $readonly,
'value' => $entry['ignore_until_ok']
];
$form['row'][2]['ignore_until_ok'] = array(
'type' => 'toggle',
'name' => 'Ignore Until OK',
//'fieldset' => 'edit',
'view' => 'toggle',
'size' => 'big',
'palette' => 'blue',
'readonly' => $readonly,
'value' => $entry['ignore_until_ok']);
if (!$readonly) { // Hide button for readonly
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'div_style' => 'padding-top: 10px; padding-bottom: 10px;',
'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'update-alert-entry'
];
}
if (!$readonly) // Hide button for readonly
{
$form['row'][7]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'div_style' => 'padding-top: 10px; padding-bottom: 10px;',
'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'update-alert-entry');
}
print_form($form);
unset($form);
?>
</div>
print_form($form);
unset($form);
?>
</div>
<div class="col-md-12">
<?php echo generate_box_open(['title' => 'Historical Availability']); ?>
<div class="col-md-12">
<?php echo generate_box_open(array('title' => 'Historical Availability')); ?>
<table class="table table-condensed table-striped">
<table class="table table-condensed table-striped">
<tr>
<td>
<?php
$graph_array['id'] = $entry['alert_table_id'];
$graph_array['type'] = 'alert_status';
print_graph_row($graph_array);
?>
</td>
</tr>
</table>
<?php
<tr><td>
<?php
$graph_array['id'] = $entry['alert_table_id'];
$graph_array['type'] = 'alert_status';
print_graph_row($graph_array);
?>
</td></tr>
</table>
<?php
echo generate_box_close();
echo("</div></div>"); // end row
echo generate_box_close();
echo("</div></div>"); // end row
}
$vars['entity_type'] = $entry['entity_type'];
$vars['entity_id'] = $entry['entity_id'];
$vars['entity_type'] = $entry['entity_type'];
$vars['entity_id'] = $entry['entity_id'];
print_alert_log($vars);
print_alert_log($vars);
} else {
print_error("Unfortunately, this alert entry id does not seem to exist in the database!");
print_error("Unfortunately, this alert entry id does not seem to exist in the database!");
}
// EOF

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,42 +14,54 @@ $alert_rules = cache_alert_rules();
$alert_assoc = cache_alert_assoc();
$alert_table = cache_device_alert_table($device['device_id']);
if (!isset($vars['status'])) { $vars['status'] = 'failed'; }
if (!$vars['entity_type']) { $vars['entity_type'] = 'all'; }
if (!isset($vars['status'])) {
$vars['status'] = 'failed';
}
if (!$vars['entity_type']) {
$vars['entity_type'] = 'all';
}
// Build Navbar
$navbar['class'] = "navbar-narrow";
$navbar['brand'] = "Alert Types";
if ($vars['entity_type'] === 'all') { $navbar['options']['all']['class'] = "active"; }
$navbar['options']['all']['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => 'all'));
if ($vars['entity_type'] === 'all') {
$navbar['options']['all']['class'] = "active";
}
$navbar['options']['all']['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => 'all']);
$navbar['options']['all']['text'] = "All";
foreach ($alert_table as $entity_type => $thing)
{
foreach ($alert_table as $entity_type => $thing) {
if (!$vars['entity_type']) { $vars['entity_type'] = $entity_type; }
if ($vars['entity_type'] == $entity_type) { $navbar['options'][$entity_type]['class'] = "active"; }
if (!$vars['entity_type']) {
$vars['entity_type'] = $entity_type;
}
if ($vars['entity_type'] == $entity_type) {
$navbar['options'][$entity_type]['class'] = "active";
}
$navbar['options'][$entity_type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => $entity_type));
$navbar['options'][$entity_type]['icon'] = $config['entities'][$entity_type]['icon'];
$navbar['options'][$entity_type]['text'] = escape_html(nicecase($entity_type));
$navbar['options'][$entity_type]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => $entity_type]);
$navbar['options'][$entity_type]['icon'] = $config['entities'][$entity_type]['icon'];
$navbar['options'][$entity_type]['text'] = escape_html(nicecase($entity_type));
}
if (isset($config['enable_syslog']) && $config['enable_syslog'] && OBSERVIUM_EDITION != 'community')
{
$entity_type = "syslog";
if (isset($config['enable_syslog']) && $config['enable_syslog'] && OBSERVIUM_EDITION != 'community') {
$entity_type = "syslog";
if (!$vars['entity_type']) { $vars['entity_type'] = 'syslog'; }
if ($vars['entity_type'] === 'syslog') { $navbar['options'][$entity_type]['class'] = "active"; }
if (!$vars['entity_type']) {
$vars['entity_type'] = 'syslog';
}
if ($vars['entity_type'] === 'syslog') {
$navbar['options'][$entity_type]['class'] = "active";
}
$navbar['options'][$entity_type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => $entity_type));
$navbar['options'][$entity_type]['icon'] = $config['icon']['syslog-alerts'];
$navbar['options'][$entity_type]['text'] = 'Syslog';
$navbar['options'][$entity_type]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => $entity_type]);
$navbar['options'][$entity_type]['icon'] = $config['icon']['syslog-alerts'];
$navbar['options'][$entity_type]['text'] = 'Syslog';
}
/* Not required anymore
@ -64,46 +76,44 @@ $navbar['options_right']['filters']['text'] = 'Filter';
$navbar['options_right']['filters']['icon'] = $config['icon']['filter'];
$navbar['options_right']['filters']['link_opts'] = 'data-hover="dropdown" data-toggle="dropdown"';
$filters = array('all' => array('url' => generate_url($vars, array('status' => 'all')),
'url_o' => generate_url($vars, array('status' => 'all')),
'icon' => $config['icon']['info'],
'text' => 'All'),
$filters = ['all' => ['url' => generate_url($vars, ['status' => 'all']),
'url_o' => generate_url($vars, ['status' => 'all']),
'icon' => $config['icon']['info'],
'text' => 'All'],
'failed_delayed' => array('url' => generate_url($vars, array('status' => 'failed_delayed')),
'url_o' => generate_url($vars, array('page' => 'alerts', 'status' => 'all')),
'icon' => $config['icon']['important'],
'text' => 'Failed & Delayed'),
'failed_delayed' => ['url' => generate_url($vars, ['status' => 'failed_delayed']),
'url_o' => generate_url($vars, ['page' => 'alerts', 'status' => 'all']),
'icon' => $config['icon']['important'],
'text' => 'Failed & Delayed'],
'failed' => array('url' => generate_url($vars, array('status' => 'failed')),
'url_o' => generate_url($vars, array('status' => 'all')),
'icon' => $config['icon']['cancel'],
'text' => 'Failed'),
'failed' => ['url' => generate_url($vars, ['status' => 'failed']),
'url_o' => generate_url($vars, ['status' => 'all']),
'icon' => $config['icon']['cancel'],
'text' => 'Failed'],
'suppressed' => array('url' => generate_url($vars, array('status' => 'suppressed')),
'url_o' => generate_url($vars, array('status' => 'all')),
'icon' => $config['icon']['shutdown'],
'text' => 'Suppressed')
);
'suppressed' => ['url' => generate_url($vars, ['status' => 'suppressed']),
'url_o' => generate_url($vars, ['status' => 'all']),
'icon' => $config['icon']['shutdown'],
'text' => 'Suppressed']
];
foreach ($filters as $option => $option_array)
{
foreach ($filters as $option => $option_array) {
$navbar['options_right']['filters']['suboptions'][$option]['text'] = $option_array['text'];
$navbar['options_right']['filters']['suboptions'][$option]['icon'] = $option_array['icon'];
$navbar['options_right']['filters']['suboptions'][$option]['text'] = $option_array['text'];
$navbar['options_right']['filters']['suboptions'][$option]['icon'] = $option_array['icon'];
if ($vars['status'] == $option)
{
$navbar['options_right']['filters']['suboptions'][$option]['class'] = "active";
if ($vars['status'] != "all") {
$navbar['options_right']['filters']['class'] = "active";
if ($vars['status'] == $option) {
$navbar['options_right']['filters']['suboptions'][$option]['class'] = "active";
if ($vars['status'] != "all") {
$navbar['options_right']['filters']['class'] = "active";
}
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url_o'];
$navbar['options_right']['filters']['text'] .= " (" . $option_array['text'] . ")";
$navbar['options_right']['filters']['icon'] = $option_array['icon'];
} else {
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url'];
}
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url_o'];
$navbar['options_right']['filters']['text'] .= " (".$option_array['text'].")";
$navbar['options_right']['filters']['icon'] = $option_array['icon'];
} else {
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url'];
}
}
print_navbar($navbar);
@ -123,9 +133,9 @@ $vars['pagination'] = TRUE;
if ($vars['entity_type'] === "syslog") {
print_logalert_log($vars);
print_logalert_log($vars);
} else {
print_alert_table($vars);
print_alert_table($vars);
}
// EOF

View File

@ -4,165 +4,158 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$link_array = array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps');
$link_array = ['page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps'];
$navbar = array();
$navbar['brand'] = "Apps";
$navbar = [];
$navbar['brand'] = "Applications";
$navbar['class'] = "navbar-narrow";
// Group all apps by app_type in an array
$device_app_types = array();
foreach (dbFetchRows("SELECT * FROM `applications` WHERE `device_id` = ?", array($device['device_id'])) as $app)
{
$device_app_types[$app['app_type']][] = $app;
$device_app_types = [];
foreach (dbFetchRows("SELECT * FROM `applications` WHERE `device_id` = ?", [$device['device_id']]) as $app) {
$device_app_types[$app['app_type']][] = $app;
}
// Iterate through each app type and its apps
foreach ($device_app_types as $type_key => $type_data)
{
foreach ($type_data as $app)
{
// Set default app and instance if none given (ie. when user first visits the device's app tab)
if (!$vars['app']) { $vars['app'] = $app['app_type']; }
$url = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps', 'app' => $app['app_type'], 'instance' => $app['app_id'] ));
// Check if an app name was inserted into mysql->observium.applications.app_name
$name = !empty($app['app_name']) ? $app['app_name'] : nicecase($app['app_type']);
// Determine if this is a named instance of app_type
if (!empty($app['app_instance']))
{
$instance = " (".$app['app_instance'].")";
}
// If there is only one instance of the current app type, simply include it as a standard nav link
if (count($device_app_types[$type_key]) == 1)
{
// If the current page is the app type that's being displayed, highlight the nav link
if ($vars['app'] == $app['app_type'])
{
$navbar['options'][$app['app_type']]['class'] = "active";
}
$navbar['options'][$app['app_type']]['text'] = $name;
$navbar['options'][$app['app_type']]['url'] = $url;
// Detect and add application icon
$icon = $app['app_type'];
$image = $config['html_dir'].'/images/apps/'.$icon.'.png';
if (!is_file($image)) {
list($icon) = explode('-', str_replace('_', '-', $app['app_type']));
$image = $config['html_dir'].'/images/apps/'.$icon.'.png';
if ($icon !== $app['app_type'] && is_file($image)) {
// 'postfix_qshape' -> 'postfix'
// 'exim-mailqueue' -> 'exim'
} else {
$icon = 'apps'; // Generic
foreach ($device_app_types as $type_key => $type_data) {
foreach ($type_data as $app) {
// Set default app and instance if none given (ie. when user first visits the device's app tab)
if (!$vars['app']) {
$vars['app'] = $app['app_type'];
}
}
$navbar['options'][$app['app_type']]['image'] = 'images/apps/'.$icon.'.png';
if (is_file($config['html_dir'].'/images/apps/'.$icon.'_2x.png')) {
// HiDPI icon
$navbar['options'][$app['app_type']]['image_2x'] = 'images/apps/'.$icon.'_2x.png';
}
}
// If there is more than one instance of the current app type we need to determine how to render the navbar
// FIXME -- no icons
else
{
// If the current app type and instance is the one being displayed, highlight the navbar root link and show which app/instance
if ($vars['app'] == $app['app_type'] && $vars['instance'] == $app['app_id'])
{
$navbar['options'][$app['app_type']]['class'] = "active";
$navbar['options'][$app['app_type']]['text'] = $name . $instance;
}
// If the current app type is not active then we need to simply add the root nav link to the bar as inactive
else
{
if (!isset($navbar['options'][$app['app_type']]['text']))
{
$navbar['options'][$app['app_type']]['text'] = $name;
if ($vars['app'] == $app['app_type'] && !isset($vars['instance'])) {
$vars['instance'] = $app['app_id'];
}
}
// Add all instances of the app type under the submenu for the app type
$navbar['options'][$app['app_type']]['suboptions'][$app['app_id']]['text'] = $name . $instance;
$navbar['options'][$app['app_type']]['suboptions'][$app['app_id']]['url'] = $url;
$url = generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps', 'app' => $app['app_type']]);
// Check if an app name was inserted into mysql->observium.applications.app_name
$name = !empty($app['app_name']) ? $app['app_name'] : nicecase($app['app_type']);
// Determine if this is a named instance of app_type
if (!empty($app['app_instance'])) {
$instance = " (" . $app['app_instance'] . ")";
}
// If there is only one instance of the current app type, simply include it as a standard nav link
if (count($device_app_types[$type_key]) == 1) {
// If the current page is the app type that's being displayed, highlight the nav link
if ($vars['app'] == $app['app_type']) {
$navbar['options'][$app['app_type']]['class'] = "active";
}
$navbar['options'][$app['app_type']]['text'] = $name;
$navbar['options'][$app['app_type']]['url'] = $url;
// Detect and add application icon
$icon = $app['app_type'];
$image = $config['html_dir'] . '/images/apps/' . $icon . '.png';
if (!is_file($image)) {
[$icon] = explode('-', str_replace('_', '-', $app['app_type']));
$image = $config['html_dir'] . '/images/apps/' . $icon . '.png';
if ($icon !== $app['app_type'] && is_file($image)) {
// 'postfix_qshape' -> 'postfix'
// 'exim-mailqueue' -> 'exim'
} else {
$icon = 'apps'; // Generic
}
}
$navbar['options'][$app['app_type']]['image'] = 'images/apps/' . $icon . '.png';
if (is_file($config['html_dir'] . '/images/apps/' . $icon . '_2x.png')) {
// HiDPI icon
$navbar['options'][$app['app_type']]['image_2x'] = 'images/apps/' . $icon . '_2x.png';
}
}
// If there is more than one instance of the current app type we need to determine how to render the navbar
// FIXME -- no icons
else {
// If the current app type and instance is the one being displayed, highlight the navbar root link and show which app/instance
if ($vars['app'] == $app['app_type'] && $vars['instance'] == $app['app_id']) {
$navbar['options'][$app['app_type']]['class'] = "active";
$navbar['options'][$app['app_type']]['text'] = $name . $instance;
} // If the current app type is not active then we need to simply add the root nav link to the bar as inactive
else {
if (!isset($navbar['options'][$app['app_type']]['text'])) {
$navbar['options'][$app['app_type']]['text'] = $name;
}
}
// Add all instances of the app type under the submenu for the app type
$navbar['options'][$app['app_type']]['suboptions'][$app['app_id']]['text'] = $name . $instance;
$navbar['options'][$app['app_type']]['suboptions'][$app['app_id']]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps', 'app' => $app['app_type'], 'instance' => $app['app_id']]);
}
}
}
}
print_navbar($navbar);
unset($navbar, $name, $url, $device_app_types);
$where_array = array($device['device_id'], $vars['app']);
if ($vars['instance'])
{
$where = " AND `app_id` = ?";
$where_array[] = $vars['instance'];
$where_array = [$device['device_id'], $vars['app']];
if ($vars['instance']) {
$where = " AND `app_id` = ?";
$where_array[] = $vars['instance'];
}
$app = dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?".$where, $where_array);
$app = dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?" . $where, $where_array);
$app_filename = $config['html_dir'] . '/pages/device/apps/'.$vars['app'].'.inc.php';
if (is_file($app_filename))
{
// Include app code to output data
include($app_filename);
$app_filename = $config['html_dir'] . '/pages/device/apps/' . $vars['app'] . '.inc.php';
if (is_file($app_filename)) {
// Include app code to output data
include($app_filename);
// If an $app_sections array has been returned, build a menu
if (isset($app_sections) && is_array($app_sections))
{
$navbar['brand'] = nicecase($vars['app']);
$navbar['class'] = "navbar-narrow";
// If an $app_sections array has been returned, build a menu
if (isset($app_sections) && is_array($app_sections)) {
$navbar['brand'] = nicecase($vars['app']);
$navbar['class'] = "navbar-narrow";
foreach ($app_sections as $app_section => $text)
{
// Set the chosen app to be this one if it's not already set.
if (!$vars['app_section']) { $vars['app_section'] = $app_section; }
if ($vars['app_section'] == $app_section) { $navbar['options'][$app_section]['class'] = "active"; }
foreach ($app_sections as $app_section => $text) {
// Set the chosen app to be this one if it's not already set.
if (!$vars['app_section']) {
$vars['app_section'] = $app_section;
}
if ($vars['app_section'] == $app_section) {
$navbar['options'][$app_section]['class'] = "active";
}
$navbar['options'][$app_section]['url'] = generate_url($vars, array('app_section' => $app_section));
$navbar['options'][$app_section]['text'] = $text;
$navbar['options'][$app_section]['url'] = generate_url($vars, ['app_section' => $app_section]);
$navbar['options'][$app_section]['text'] = $text;
}
print_navbar($navbar);
unset($navbar);
} else {
// It appears this app doesn't have multiple sections. We set app_section to default here.
$vars['app_section'] = 'default';
}
print_navbar($navbar);
unset($navbar);
} else {
// It appears this app doesn't have multiple sections. We set app_section to default here.
$vars['app_section'] = 'default';
}
// If a matching app_section array exists within app_graphs, print the graphs.
if (isset($app_graphs[$vars['app_section']]) && is_array($app_graphs[$vars['app_section']]))
{
echo generate_box_open();
// If a matching app_section array exists within app_graphs, print the graphs.
if (isset($app_graphs[$vars['app_section']]) && is_array($app_graphs[$vars['app_section']])) {
echo generate_box_open();
echo '<table class="table table-striped table-hover table-condensed">';
echo '<table class="table table-striped table-hover table-condensed">';
foreach ($app_graphs[$vars['app_section']] as $key => $text)
{
$graph_type = $key;
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_".$key;
echo '<tr><td>';
echo '<h3>',$text,'</h4>';
foreach ($app_graphs[$vars['app_section']] as $key => $text) {
$graph_type = $key;
$graph_array['to'] = get_time();
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_" . $key;
echo '<tr><td>';
echo '<h3>', $text, '</h4>';
print_graph_row($graph_array);
print_graph_row($graph_array);
echo '</td></tr>';
echo '</td></tr>';
}
echo '</table>';
generate_box_close();
}
echo '</table>';
generate_box_close();
}
}
register_html_title("Apps");

View File

@ -4,16 +4,16 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('apache_bits' => 'Traffic',
'apache_hits' => 'Hits',
'apache_cpu' => 'CPU Utilisation',
'apache_scoreboard' => 'Scoreboard Statistics');
$app_graphs['default'] = ['apache_bits' => 'Traffic',
'apache_hits' => 'Hits',
'apache_cpu' => 'CPU Utilisation',
'apache_scoreboard' => 'Scoreboard Statistics'];
// EOF

View File

@ -4,22 +4,25 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$navbar['brand'] = nicecase($app['app_type']);
$navbar['class'] = "navbar-narrow";
foreach ($app_sections as $app_section => $app_section_text)
{
if (!$vars['app_section']) { $vars['app_section'] = $app_section; }
$navbar['brand'] = nicecase($app['app_type']);
$navbar['options'][$app_section]['text'] = $app_section_text;
if ($vars['app_section'] == $app_section) { $navbar['options'][$app_section]['class'] = "active"; }
$navbar['options'][$app_section]['url'] = generate_url($vars,array('app_section'=>$app_section));
foreach ($app_sections as $app_section => $app_section_text) {
if (!$vars['app_section']) {
$vars['app_section'] = $app_section;
}
$navbar['brand'] = nicecase($app['app_type']);
$navbar['options'][$app_section]['text'] = $app_section_text;
if ($vars['app_section'] == $app_section) {
$navbar['options'][$app_section]['class'] = "active";
}
$navbar['options'][$app_section]['url'] = generate_url($vars, ['app_section' => $app_section]);
}
print_navbar($navbar);

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('asterisk_peers' => 'Active Peers',
'asterisk_activecall' => 'Active Calls');
$app_graphs['default'] = ['asterisk_peers' => 'Active Peers',
'asterisk_activecall' => 'Active Calls'];
// EOF

View File

@ -4,33 +4,33 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array('stats' => "Server statistics",
'auth' => "Authoritative",
'resolv' => "Resolving",
'queries' => "Queries");
$app_sections = ['stats' => "Server statistics",
'auth' => "Authoritative",
'resolv' => "Resolving",
'queries' => "Queries"];
$app_graphs['stats'] = array('bind_req_in' => "Incoming requests",
'bind_answers' => "Answers Given",
'bind_updates' => "Dynamic Updates",
'bind_req_proto' => "Request protocol details",
'bind_cache' => "Cache content");
$app_graphs['stats'] = ['bind_req_in' => "Incoming requests",
'bind_answers' => "Answers Given",
'bind_updates' => "Dynamic Updates",
'bind_req_proto' => "Request protocol details",
'bind_cache' => "Cache content"];
$app_graphs['auth'] = array('bind_zone_maint' => "Zone maintenance");
$app_graphs['auth'] = ['bind_zone_maint' => "Zone maintenance"];
$app_graphs['resolv'] = array('bind_resolv_queries' => "Queries",
'bind_resolv_errors' => "Errors",
'bind_resolv_rtt' => "Query RTT",
'bind_resolv_dnssec' => "DNSSEC validation");
$app_graphs['resolv'] = ['bind_resolv_queries' => "Queries",
'bind_resolv_errors' => "Errors",
'bind_resolv_rtt' => "Query RTT",
'bind_resolv_dnssec' => "DNSSEC validation"];
$app_graphs['queries'] = array('bind_query_rejected' => "Rejected queries",
'bind_query_in' => "Incoming queries",
'bind_query_out' => "Outgoing queries");
$app_graphs['queries'] = ['bind_query_rejected' => "Rejected queries",
'bind_query_in' => "Incoming queries",
'bind_query_out' => "Outgoing queries"];
// EOF

View File

@ -4,13 +4,13 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('ceph_osd' => 'OSD','ceph_iops' => 'OPS','ceph_speed' => 'Ceph I/O',);
$app_graphs['default'] = ['ceph_osd' => 'OSD', 'ceph_iops' => 'OPS', 'ceph_speed' => 'Ceph I/O',];
// EOF

View File

@ -3,16 +3,16 @@
/**
* Observium Network Management and Monitoring System
*
* @package observium
* @subpackage applications
* @author Sander Steffann <sander@steffann.nl>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Sander Steffann <sander@steffann.nl>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array(
'dhcpkit_packets' => "Packets",
$app_graphs['default'] = [
'dhcpkit_packets' => "Packets",
'dhcpkit_msgtypes' => "Message types",
);
];
/* End of file dhcpkit.inc.php */

View File

@ -4,22 +4,22 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('dovecot_commands' => 'Commands',
'dovecot_connected' => 'Connected sessions',
'dovecot_auth' => 'Auth',
'dovecot_auth_cache' => 'Auth cache hitrate %',
'dovecot_io' => 'IO',
'dovecot_storage' => 'Storage',
'dovecot_cache' => 'Mail cache hits',
'dovecot_usage' => 'Context Switches',
'dovecot_pages' => 'Page Reclaims',
'dovecot_cpu' => 'CPU usage');
$app_graphs['default'] = ['dovecot_commands' => 'Commands',
'dovecot_connected' => 'Connected sessions',
'dovecot_auth' => 'Auth',
'dovecot_auth_cache' => 'Auth cache hitrate %',
'dovecot_io' => 'IO',
'dovecot_storage' => 'Storage',
'dovecot_cache' => 'Mail cache hits',
'dovecot_usage' => 'Context Switches',
'dovecot_pages' => 'Page Reclaims',
'dovecot_cpu' => 'CPU usage'];
// EOF

View File

@ -4,16 +4,16 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('drbd_network_bits' => 'Network Traffic',
'drbd_disk_bits' => 'Disk Traffic',
'drbd_unsynced' => 'Unsynced Data',
'drbd_queue' => 'Queues');
$app_graphs['default'] = ['drbd_network_bits' => 'Network Traffic',
'drbd_disk_bits' => 'Disk Traffic',
'drbd_unsynced' => 'Unsynced Data',
'drbd_queue' => 'Queues'];
// EOF

View File

@ -4,92 +4,90 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array();
$app_modules = array(
"as" => array(
"rrd" => "wmi-app-exchange-as.rrd",
"descr" => "ActiveSync",
"graphs" => array(
$app_sections = [];
$app_modules = [
"as" => [
"rrd" => "wmi-app-exchange-as.rrd",
"descr" => "ActiveSync",
"graphs" => [
'exchange_as_pingcmd' => 'Ping Commands Pending',
'exchange_as_syncmd' => 'Sync Commands Pending',
'exchange_as_syncmd' => 'Sync Commands Pending',
'exchange_as_curreqs' => 'Current Requests'
)
),
"auto" => array(
"rrd" => "wmi-app-exchange-auto.rrd",
"descr" => "Autodiscover",
"graphs" => array(
]
],
"auto" => [
"rrd" => "wmi-app-exchange-auto.rrd",
"descr" => "Autodiscover",
"graphs" => [
'exchange_auto_totalreqs' => 'Total Requests',
'exchange_auto_errors' => 'Total Error Responses'
)
),
"oab" => array(
"rrd" => "wmi-app-exchange-oab.rrd",
"descr" => "Offline Address Book",
"graphs" => array(
'exchange_oab_dlq' => 'Download Tasks Queued',
'exchange_auto_errors' => 'Total Error Responses'
]
],
"oab" => [
"rrd" => "wmi-app-exchange-oab.rrd",
"descr" => "Offline Address Book",
"graphs" => [
'exchange_oab_dlq' => 'Download Tasks Queued',
'exchange_oab_dlcom' => 'Download Tasks Completed'
)
),
"owa" => array(
"rrd" => "wmi-app-exchange-owa.rrd",
"descr" => "Outlook Web App",
"graphs" => array(
]
],
"owa" => [
"rrd" => "wmi-app-exchange-owa.rrd",
"descr" => "Outlook Web App",
"graphs" => [
'exchange_owa_rtime' => 'Response Times',
'exchange_owa_users' => 'Unique Users'
)
),
"trans" => array(
"rrd" => "wmi-app-exchange-tqs.rrd",
"descr" => "Transport Queues",
"graphs" => array(
'exchange_trans_queue' => 'Total Queues',
'exchange_trans_mbque' => 'Active Mailbox Delivery Queues',
]
],
"trans" => [
"rrd" => "wmi-app-exchange-tqs.rrd",
"descr" => "Transport Queues",
"graphs" => [
'exchange_trans_queue' => 'Total Queues',
'exchange_trans_mbque' => 'Active Mailbox Delivery Queues',
'exchange_trans_subque' => 'Submission Queues'
)
),
"smtp" => array(
"rrd" => "wmi-app-exchange-smtp.rrd",
"descr" => "SMTP",
"graphs" => array(
]
],
"smtp" => [
"rrd" => "wmi-app-exchange-smtp.rrd",
"descr" => "SMTP",
"graphs" => [
'exchange_trans_smtp' => "SMTP Connections"
)
),
"is" => array(
"rrd" => "wmi-app-exchange-is.rrd",
"descr" => "Information Store",
"graphs" => array(
]
],
"is" => [
"rrd" => "wmi-app-exchange-is.rrd",
"descr" => "Information Store",
"graphs" => [
'exchange_is_active' => 'Active Connection Count',
'exchange_is_users' => 'Current User Count',
'exchange_is_rpcreq' => 'RPC Requests',
'exchange_is_rpcfail' => 'Failed RPC Requests'
)
),
"mailbox" => array(
"rrd" => "wmi-app-exchange-mailbox.rrd",
"descr" => "Mailbox",
"graphs" => array(
]
],
"mailbox" => [
"rrd" => "wmi-app-exchange-mailbox.rrd",
"descr" => "Mailbox",
"graphs" => [
'exchange_mb_latency' => 'RPC Average Latency',
'exchange_mb_queued' => 'Messages Queued for Submission',
'exchange_mb_msgs' => 'Messages per Second'
)
)
);
]
]
];
foreach ($app_modules as $module => $data)
{
if (is_file(get_rrd_path($device, $data['rrd'])))
{
$app_sections[$module] = $data['descr'];
$app_graphs[$module] = $data['graphs'];
}
foreach ($app_modules as $module => $data) {
if (is_file(get_rrd_path($device, $data['rrd']))) {
$app_sections[$module] = $data['descr'];
$app_graphs[$module] = $data['graphs'];
}
}
unset($app_modules);

View File

@ -4,13 +4,13 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('exim-mailqueue_total' => 'Total mail in queue');
$app_graphs['default'] = ['exim-mailqueue_total' => 'Total mail in queue'];
// EOF

View File

@ -4,15 +4,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('exim_sent' => 'Exim - Sent / Received',
'exim_spam' => 'Exim - Spam / Virus',
'exim_reject' =>'Exim - Rejected / Bounced');
$app_graphs['default'] = ['exim_sent' => 'Exim - Sent / Received',
'exim_spam' => 'Exim - Spam / Virus',
'exim_reject' => 'Exim - Rejected / Bounced'];
// EOF

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('freeradius_authentication' => 'FreeRADIUS Authentication',
'freeradius_accounting' => 'FreeRADIUS Accounting');
$app_graphs['default'] = ['freeradius_authentication' => 'FreeRADIUS Authentication',
'freeradius_accounting' => 'FreeRADIUS Accounting'];
// EOF

View File

@ -4,16 +4,16 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array(
'icecast_current' => 'IceCast - Current',
'icecast_max' => 'IceCast - Maximum'
);
$app_graphs['default'] = [
'icecast_current' => 'IceCast - Current',
'icecast_max' => 'IceCast - Maximum'
];
// EOF

View File

@ -5,15 +5,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('ioping_timing' => 'I/O Timings',
'ioping_speed' => 'Speed',
'ioping_iops' => 'IOPs');
$app_graphs['default'] = ['ioping_timing' => 'I/O Timings',
'ioping_speed' => 'Speed',
'ioping_iops' => 'IOPs'];
// EOF

View File

@ -4,49 +4,49 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2014, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @copyright (C) Adam Armstrong
*
*/
// defines tabs
$app_sections = array(
'memory' => 'Memory',
$app_sections = [
'memory' => 'Memory',
'threads' => 'Threads',
'classes' => 'Classes',
'gc' => 'Garbage Collector',
'system' => 'System Information',
);
'gc' => 'Garbage Collector',
'system' => 'System Information',
];
// defines graphs in memory tab
$app_graphs['memory'] = array(
$app_graphs['memory'] = [
'jvmoverjmx_memory_summary' => 'Memory Summary',
'jvmoverjmx_heap' => 'Heap',
'jvmoverjmx_nonheap' => 'Non Heap',
'jvmoverjmx_eden' => 'Eden Space',
'jvmoverjmx_perm' => 'Permanent Generation',
'jvmoverjmx_old' => 'Old Generation',
);
'jvmoverjmx_heap' => 'Heap',
'jvmoverjmx_nonheap' => 'Non Heap',
'jvmoverjmx_eden' => 'Eden Space',
'jvmoverjmx_perm' => 'Permanent Generation',
'jvmoverjmx_old' => 'Old Generation',
];
// defines graphs in threads tab
$app_graphs['threads'] = array(
$app_graphs['threads'] = [
'jvmoverjmx_threads' => 'Threads',
);
];
$app_graphs['classes'] = array(
$app_graphs['classes'] = [
'jvmoverjmx_classes' => 'Classes',
);
];
$app_graphs['gc'] = array(
'jvmoverjmx_gc_young_time' => 'GC Young Gen Collection Time',
'jvmoverjmx_gc_old_time' => 'GC Old Gen Collection Time',
$app_graphs['gc'] = [
'jvmoverjmx_gc_young_time' => 'GC Young Gen Collection Time',
'jvmoverjmx_gc_old_time' => 'GC Old Gen Collection Time',
'jvmoverjmx_gc_young_count' => 'GC Young Collection Count',
'jvmoverjmx_gc_old_count' => 'GC Old Collection Count',
);
'jvmoverjmx_gc_old_count' => 'GC Old Collection Count',
];
$app_graphs['system'] = array(
$app_graphs['system'] = [
'jvmoverjmx_system_uptime' => 'Uptime',
);
];
// EOF

View File

@ -4,24 +4,24 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2014, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@memetic.org>
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@memetic.org>
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
$app_graphs['default'] = array(
'kamailio_errors' => 'Errors',
'kamailio_shmen' => 'Shared Memory Usage',
'kamailio_core' => 'Core Stats',
'kamailio_registrar' => 'Registrations',
'kamailio_usrloc' => 'Users',
'kamailio_tmx' => 'TMX',
'kamailio_tcp' => 'TCP',
'kamailio_sl123' => 'SL 100 -> 3XX',
'kamailio_sl4' => 'SL 400 -> 4XX',
'kamailio_sl56' => 'SL 500 -> XXX',
);
$app_graphs['default'] = [
'kamailio_errors' => 'Errors',
'kamailio_shmen' => 'Shared Memory Usage',
'kamailio_core' => 'Core Stats',
'kamailio_registrar' => 'Registrations',
'kamailio_usrloc' => 'Users',
'kamailio_tmx' => 'TMX',
'kamailio_tcp' => 'TCP',
'kamailio_sl123' => 'SL 100 -> 3XX',
'kamailio_sl4' => 'SL 400 -> 4XX',
'kamailio_sl56' => 'SL 500 -> XXX',
];
// EOF

View File

@ -5,15 +5,15 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @package observium
* @subpackage applications
* @copyright (C) 2006 - 2013 Adam Armstrong
*
*/
$app_graphs['default'] = array('lighttpd_hits' => 'Hits',
'lighttpd_traffic' => 'Traffic',
'lighttpd_uptime' => 'Lighttpd Uptime',
'lighttpd_servers' => 'Busy / Idle Workers',
'lighttpd_scoreboardstatistics' => 'Scoreboard Statistics');
$app_graphs['default'] = ['lighttpd_hits' => 'Hits',
'lighttpd_traffic' => 'Traffic',
'lighttpd_uptime' => 'Lighttpd Uptime',
'lighttpd_servers' => 'Busy / Idle Workers',
'lighttpd_scoreboardstatistics' => 'Scoreboard Statistics'];

View File

@ -5,13 +5,13 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @package observium
* @subpackage applications
* @copyright (C) 2006 - 2013 Adam Armstrong
*
*/
$app_graphs['default'] = array('lvs_stats_connections' => 'Connections per Second',
'lvs_stats_packets' => 'Packets per Second',
'lvs_stats_bytes' => 'Bytes per Second');
$app_graphs['default'] = ['lvs_stats_connections' => 'Connections per Second',
'lvs_stats_packets' => 'Packets per Second',
'lvs_stats_bytes' => 'Bytes per Second'];

View File

@ -4,15 +4,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('mailscanner_sent' => 'Sent / Received',
'mailscanner_spam' => 'Spam / Virus',
'mailscanner_reject' => 'Rejected / Waiting / Relayed');
$app_graphs['default'] = ['mailscanner_sent' => 'Sent / Received',
'mailscanner_spam' => 'Spam / Virus',
'mailscanner_reject' => 'Rejected / Waiting / Relayed'];
// EOF

View File

@ -4,19 +4,19 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('memcached_bits' => 'Traffic',
'memcached_commands' => 'Commands',
'memcached_data' => 'Data Size',
'memcached_items' => 'Items',
'memcached_uptime' => 'Uptime',
'memcached_threads' => 'Threads',
);
$app_graphs['default'] = ['memcached_bits' => 'Traffic',
'memcached_commands' => 'Commands',
'memcached_data' => 'Data Size',
'memcached_items' => 'Items',
'memcached_uptime' => 'Uptime',
'memcached_threads' => 'Threads',
];
// EOF

View File

@ -4,21 +4,21 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('mongodb_commands' => 'Commands',
'mongodb_queue' => 'Queues',
'mongodb_mem' => 'Memory',
'mongodb_replication' => 'Replication',
'mongodb_wired' => 'Wired Storage Engine',
'mongodb_connections' => 'Connections',
'mongodb_network' => 'Network',
);
$app_graphs['default'] = ['mongodb_commands' => 'Commands',
'mongodb_queue' => 'Queues',
'mongodb_mem' => 'Memory',
'mongodb_replication' => 'Replication',
'mongodb_wired' => 'Wired Storage Engine',
'mongodb_connections' => 'Connections',
'mongodb_network' => 'Network',
];
// EOF

View File

@ -4,35 +4,38 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage applications
* @author Solomon Seal <slm4996+observium@gmail.com> 2014-04
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage applications
* @author Solomon Seal <slm4996+observium@gmail.com> 2014-04
* @copyright (C) Adam Armstrong
*
*/
$sql = "SELECT * FROM `applications-state` WHERE `application_id` = ?";
$app_state = dbFetchRow($sql, array($app['app_id']));
$app_data = safe_unserialize($app_state['app_state']);
$sql = "SELECT * FROM `applications-state` WHERE `application_id` = ?";
$app_state = dbFetchRow($sql, [$app['app_id']]);
$app_data = safe_unserialize($app_state['app_state']);
$app_sections['system'] = "System";
if (!empty($app_data['stats']))
$app_sections['stats'] = "Stats";
if (!empty($app_data['buffer']))
$app_sections['buffers'] = "Buffers";
if (!empty($app_data['stats'])) {
$app_sections['stats'] = "Stats";
}
if (!empty($app_data['buffer'])) {
$app_sections['buffers'] = "Buffers";
}
$app_graphs['system']['mssql_cpu_usage'] = 'Processor';
if (!empty($app_data['memory']))
$app_graphs['system']['mssql_memory_usage'] = 'Memory';
if (!empty($app_data['memory'])) {
$app_graphs['system']['mssql_memory_usage'] = 'Memory';
}
$app_graphs['stats'] = array(
'mssql_stats' => 'Users'
);
$app_graphs['stats'] = [
'mssql_stats' => 'Users'
];
$app_graphs['buffers'] = array(
'mssql_buffer_page' => 'Page Lookups',
'mssql_buffer_pglife' => 'Page Life Expectancy',
'mssql_buffer_stalls' => 'Free List Stalls'
);
$app_graphs['buffers'] = [
'mssql_buffer_page' => 'Page Lookups',
'mssql_buffer_pglife' => 'Page Life Expectancy',
'mssql_buffer_stalls' => 'Free List Stalls'
];
// EOF

View File

@ -4,20 +4,20 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (!safe_empty($app_data['memory'])) {
$memory_used = $app_data['memory']['used'] - $app_data['memory']['cache'];
$memory_used_perc = round(float_div($memory_used, $app_data['memory']['total']) * 100, 2);
$memory_used = $app_data['memory']['used'] - $app_data['memory']['cache'];
$memory_used_perc = round(float_div($memory_used, $app_data['memory']['total']) * 100, 2);
$memory_cached_perc = round(float_div($app_data['memory']['cache'], $app_data['memory']['total']) * 100, 2);
$memory_free = $app_data['memory']['total'] - $app_data['memory']['used'];
$memory_free_perc = round(float_div($memory_free, $app_data['memory']['total']) * 100, 2);
$memory_free = $app_data['memory']['total'] - $app_data['memory']['used'];
$memory_free_perc = round(float_div($memory_free, $app_data['memory']['total']) * 100, 2);
$graph_array = array();
$graph_array = [];
$graph_array['height'] = "100";
$graph_array['width'] = "512";
$graph_array['to'] = get_time();
@ -25,49 +25,49 @@ if (!safe_empty($app_data['memory'])) {
$graph_array['type'] = 'application_mssql_memory_usage';
$graph_array['from'] = get_time('day');
$graph_array['legend'] = "no";
$graph = generate_graph_tag($graph_array);
$graph = generate_graph_tag($graph_array);
$link_array = $graph_array;
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $app['app_instance'] . " - Memory Usage");
$percentage_bar = array();
$percentage_bar = [];
//$percentage_bar['border'] = "#EA8F00";
$percentage_bar['border'] = "#E25A00";
$percentage_bar['bg'] = "#f0f0f0";
$percentage_bar['width'] = "100%";
$percentage_bar['text'] = $memory_free_perc."%";
$percentage_bar['text'] = $memory_free_perc . "%";
$percentage_bar['text_c'] = "#E25A00";
$percentage_bar['bars'][0] = array('percent' => $memory_used_perc, 'colour' => '#EE9955', 'text' => $memory_used_perc.'%');
$percentage_bar['bars'][1] = array('percent' => $memory_cached_perc, 'colour' => '#f0e0a0', 'text' => '');
$percentage_bar['bars'][0] = ['percent' => $memory_used_perc, 'colour' => '#EE9955', 'text' => $memory_used_perc . '%'];
$percentage_bar['bars'][1] = ['percent' => $memory_cached_perc, 'colour' => '#f0e0a0', 'text' => ''];
echo(overlib_link($link, $graph, $overlib_content, NULL));
?>
<div class="box box-solid">
<div class="title"><i class="<?php echo $config['icon']['mempool']; ?>"></i> Memory</div>
<div class="content">
<table width="100%" class="table table-striped table-condensed-more ">
<tr>
<td colspan="7">
<?php echo(percentage_bar($percentage_bar)); ?>
</td>
</tr>
<tr class="small">
<td><i style="font-size: 7px; line-height: 7px; background-color: #EE9955; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Used</td>
<td><?php echo(formatStorage($memory_used).' ('.$memory_used_perc.'%)'); ?></td>
<td><i style="font-size: 7px; line-height: 7px; background-color: #f0e0a0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Cached</td>
<td><?php echo(formatStorage($app_data['memory']['cache']).' ('.$memory_cached_perc.'%)'); ?></td>
<td><i style="font-size: 7px; line-height: 7px; background-color: #f0f0f0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Free</td>
<td><?php echo(formatStorage($memory_free).' ('.$memory_free_perc.'%)'); ?></td>
</tr>
</table>
</div>
</div>
<?php
?>
<div class="box box-solid">
<div class="title"><i class="<?php echo $config['icon']['mempool']; ?>"></i> Memory</div>
<div class="content">
<table width="100%" class="table table-striped table-condensed-more ">
<tr>
<td colspan="7">
<?php echo(percentage_bar($percentage_bar)); ?>
</td>
</tr>
<tr class="small">
<td><i style="font-size: 7px; line-height: 7px; background-color: #EE9955; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Used</td>
<td><?php echo(format_bytes($memory_used) . ' (' . $memory_used_perc . '%)'); ?></td>
<td><i style="font-size: 7px; line-height: 7px; background-color: #f0e0a0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Cached</td>
<td><?php echo(format_bytes($app_data['memory']['cache']) . ' (' . $memory_cached_perc . '%)'); ?></td>
<td><i style="font-size: 7px; line-height: 7px; background-color: #f0f0f0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Free</td>
<td><?php echo(format_bytes($memory_free) . ' (' . $memory_free_perc . '%)'); ?></td>
</tr>
</table>
</div>
</div>
<?php
}
unset($percentage_bar, $graph_array, $overlib_content, $graph, $link, $link_array);

View File

@ -4,51 +4,51 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$cpu_counter = $app_data['cpu']['proc'];
$time_counter = $app_data['cpu']['time'];
$cpu_counter = $app_data['cpu']['proc'];
$time_counter = $app_data['cpu']['time'];
$cpu_load_percent = round(float_div($cpu_counter, $time_counter) * 100, 2);
$background = get_percentage_colours($cpu_load_percent);
$background = get_percentage_colours($cpu_load_percent);
$graph_array = array();
$graph_array = [];
$graph_array['height'] = "100";
$graph_array['width'] = "512";
$graph_array['to'] = $config['time']['now'];
$graph_array['to'] = get_time();
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_mssql_cpu_usage';
$graph_array['from'] = $config['time']['day'];
$graph_array['from'] = get_time('day');
$graph_array['legend'] = "no";
$graph = generate_graph_tag($graph_array);
$graph = generate_graph_tag($graph_array);
$link_array = $graph_array;
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $app['app_instance'] . " - CPU Usage");
$percentage_bar = array();
$percentage_bar['border'] = "#".$background['left'];
$percentage_bar['bg'] = "#".$background['right'];
$percentage_bar = [];
$percentage_bar['border'] = "#" . $background['left'];
$percentage_bar['bg'] = "#" . $background['right'];
$percentage_bar['width'] = "100%";
$percentage_bar['text'] = $cpu_load_percent."%";
$percentage_bar['text'] = $cpu_load_percent . "%";
$percentage_bar['text_c'] = "#FFFFFF";
$percentage_bar['bars'][0] = array('percent' => $cpu_load_percent);
$percentage_bar['bars'][0] = ['percent' => $cpu_load_percent];
echo(overlib_link($link, $graph, $overlib_content, NULL));
?>
<table width="100%" class="table table-striped table-condensed-more ">
<tr>
<td class="entity">Current CPU Load</td>
<td style="width: 90px;"></td>
<td style="width: 200px;"><?php echo percentage_bar($percentage_bar); ?></td>
</tr>
</table>
<table width="100%" class="table table-striped table-condensed-more ">
<tr>
<td class="entity">Current CPU Load</td>
<td style="width: 90px;"></td>
<td style="width: 200px;"><?php echo percentage_bar($percentage_bar); ?></td>
</tr>
</table>
<?php

View File

@ -4,46 +4,46 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array('system' => "System",
'queries' => "Queries",
'innodb' => "InnoDB");
$app_sections = ['system' => "System",
'queries' => "Queries",
'innodb' => "InnoDB"];
$app_graphs['system'] = array(
'mysql_connections' => 'Connections',
'mysql_status' => 'Process List',
'mysql_files_tables' => 'Files and Tables',
'mysql_myisam_indexes' => 'MyISAM Indexes',
'mysql_network_traffic' => 'Network Traffic',
'mysql_table_locks' => 'Table Locks',
'mysql_temporary_objects' => 'Temporary Objects'
);
$app_graphs['system'] = [
'mysql_connections' => 'Connections',
'mysql_status' => 'Process List',
'mysql_files_tables' => 'Files and Tables',
'mysql_myisam_indexes' => 'MyISAM Indexes',
'mysql_network_traffic' => 'Network Traffic',
'mysql_table_locks' => 'Table Locks',
'mysql_temporary_objects' => 'Temporary Objects'
];
$app_graphs['queries'] = array(
'mysql_command_counters' => 'Command Counters',
'mysql_query_cache' => 'Query Cache',
'mysql_query_cache_memory' => 'Query Cache Memory',
'mysql_select_types' => 'Select Types',
'mysql_slow_queries' => 'Slow Queries',
'mysql_sorts' => 'Sorts',
);
$app_graphs['queries'] = [
'mysql_command_counters' => 'Command Counters',
'mysql_query_cache' => 'Query Cache',
'mysql_query_cache_memory' => 'Query Cache Memory',
'mysql_select_types' => 'Select Types',
'mysql_slow_queries' => 'Slow Queries',
'mysql_sorts' => 'Sorts',
];
$app_graphs['innodb'] = array(
'mysql_innodb_buffer_pool' => 'InnoDB Buffer Pool',
'mysql_innodb_buffer_pool_activity' => 'InnoDB Buffer Pool Activity',
'mysql_innodb_insert_buffer' => 'InnoDB Insert Buffer',
'mysql_innodb_io' => 'InnoDB IO',
'mysql_innodb_io_pending' => 'InnoDB IO Pending',
'mysql_innodb_log' => 'InnoDB Log',
'mysql_innodb_row_operations' => 'InnoDB Row Operations',
'mysql_innodb_semaphores' => 'InnoDB semaphores',
'mysql_innodb_transactions' => 'InnoDB Transactions',
);
$app_graphs['innodb'] = [
'mysql_innodb_buffer_pool' => 'InnoDB Buffer Pool',
'mysql_innodb_buffer_pool_activity' => 'InnoDB Buffer Pool Activity',
'mysql_innodb_insert_buffer' => 'InnoDB Insert Buffer',
'mysql_innodb_io' => 'InnoDB IO',
'mysql_innodb_io_pending' => 'InnoDB IO Pending',
'mysql_innodb_log' => 'InnoDB Log',
'mysql_innodb_row_operations' => 'InnoDB Row Operations',
'mysql_innodb_semaphores' => 'InnoDB semaphores',
'mysql_innodb_transactions' => 'InnoDB Transactions',
];
// EOF

View File

@ -5,14 +5,14 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('nfs_nfs2' => 'NFS2',
'nfs_nfs3' => 'NFS3',
'nfs_nfs4' => 'NFS4');
$app_graphs['default'] = ['nfs_nfs2' => 'NFS2',
'nfs_nfs3' => 'NFS3',
'nfs_nfs4' => 'NFS4'];
// EOF

View File

@ -5,17 +5,17 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('nfsd_rc' => 'NFSd RC',
'nfsd_io' => 'NFSd I/O',
'nfsd_net' => 'NFSd Net',
'nfsd_rpc' => 'NFSd RPC',
'nfsd_proc3' => 'NFSd v3'
);
$app_graphs['default'] = ['nfsd_rc' => 'NFSd RC',
'nfsd_io' => 'NFSd I/O',
'nfsd_net' => 'NFSd Net',
'nfsd_rpc' => 'NFSd RPC',
'nfsd_proc3' => 'NFSd v3'
];
// EOF

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('nginx_connections' => 'Connections',
'nginx_req' => 'Requests');
$app_graphs['default'] = ['nginx_connections' => 'Connections',
'nginx_req' => 'Requests'];
// EOF

View File

@ -5,17 +5,17 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array(
'nsd_queries' => 'NSD - DNS traffic',
'nsd_memory' => 'NSD - Memory statistics',
'nsd_qtype' => 'NSD - Queries by Query type',
'nsd_rcode' => 'NSD - Queries by Return code',
'nsd_axfr' => 'NSD - Requests for AXFR',
'nsd_zones' => 'NSD - Zones');
$app_graphs['default'] = [
'nsd_queries' => 'NSD - DNS traffic',
'nsd_memory' => 'NSD - Memory statistics',
'nsd_qtype' => 'NSD - Queries by Query type',
'nsd_rcode' => 'NSD - Queries by Return code',
'nsd_axfr' => 'NSD - Requests for AXFR',
'nsd_zones' => 'NSD - Zones'];

View File

@ -5,13 +5,13 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('ntpclient_stats' => 'Statistics',
'ntpclient_freq' => 'Frequency');
$app_graphs['default'] = ['ntpclient_stats' => 'Statistics',
'ntpclient_freq' => 'Frequency'];
// EOF

View File

@ -4,19 +4,19 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('ntpdserver_stats' => 'Statistics',
'ntpdserver_freq' => 'Frequency',
'ntpdserver_stratum' => 'Stratum',
'ntpdserver_buffer' => 'Buffer',
'ntpdserver_bits' => 'Packets Sent/Received',
'ntpdserver_packets' => 'Packets Dropped/Ignored',
'ntpdserver_uptime' => 'Uptime');
$app_graphs['default'] = ['ntpdserver_stats' => 'Statistics',
'ntpdserver_freq' => 'Frequency',
'ntpdserver_stratum' => 'Stratum',
'ntpdserver_buffer' => 'Buffer',
'ntpdserver_bits' => 'Packets Sent/Received',
'ntpdserver_packets' => 'Packets Dropped/Ignored',
'ntpdserver_uptime' => 'Uptime'];
// EOF

View File

@ -4,37 +4,36 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
// Set variables
$rrd_server = get_rrd_path($device, "app-ntpd-server-".$app['app_id'].".rrd");
$rrd_client = get_rrd_path($device, "app-ntpd-client-".$app['app_id'].".rrd");
$ntpd_type = (is_file($rrd_server) ? "server" : "client");
$rrd_server = get_rrd_path($device, "app-ntpd-server-" . $app['app_id'] . ".rrd");
$rrd_client = get_rrd_path($device, "app-ntpd-client-" . $app['app_id'] . ".rrd");
$ntpd_type = (is_file($rrd_server) ? "server" : "client");
// Test if this is a server or client install and set app_sections accordingly
if ($ntpd_type == "server")
{
$app_sections = array('server' => "System",
'buffer' => "Buffer",
'packets' => "Packets");
if ($ntpd_type == "server") {
$app_sections = ['server' => "System",
'buffer' => "Buffer",
'packets' => "Packets"];
}
$app_graphs['default'] = array('ntpd_stats' => 'NTP Client - Statistics',
'ntpd_freq' => 'NTP Client - Frequency');
$app_graphs['default'] = ['ntpd_stats' => 'NTP Client - Statistics',
'ntpd_freq' => 'NTP Client - Frequency'];
$app_graphs['server'] = array('ntpd_stats' => 'NTPD Server - Statistics',
'ntpd_freq' => 'NTPD Server - Frequency',
'ntpd_uptime' => 'NTPD Server - Uptime',
'ntpd_stratum' => 'NTPD Server - Stratum');
$app_graphs['server'] = ['ntpd_stats' => 'NTPD Server - Statistics',
'ntpd_freq' => 'NTPD Server - Frequency',
'ntpd_uptime' => 'NTPD Server - Uptime',
'ntpd_stratum' => 'NTPD Server - Stratum'];
$app_graphs['buffer'] = array('ntpd_buffer' => 'NTPD Server - Buffer');
$app_graphs['buffer'] = ['ntpd_buffer' => 'NTPD Server - Buffer'];
$app_graphs['packets'] = array('ntpd_bits' => 'NTPD Server - Packets Sent/Received',
'ntpd_packets' => 'NTPD Server - Packets Dropped/Ignored');
$app_graphs['packets'] = ['ntpd_bits' => 'NTPD Server - Packets Sent/Received',
'ntpd_packets' => 'NTPD Server - Packets Dropped/Ignored'];
// EOF

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('openvpn_nclients' => 'Connected Clients',
'openvpn_bits' => 'VPN Traffic');
$app_graphs['default'] = ['openvpn_nclients' => 'Connected Clients',
'openvpn_bits' => 'VPN Traffic'];
// EOF

View File

@ -4,15 +4,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('postfix_mailgraph_sent' => 'Postfix - Sent / Received',
'postfix_mailgraph_spam' => 'Postfix - Spam / Virus',
'postfix_mailgraph_reject' => 'Postfix - Rejected / Bounced');
$app_graphs['default'] = ['postfix_mailgraph_sent' => 'Postfix - Sent / Received',
'postfix_mailgraph_spam' => 'Postfix - Spam / Virus',
'postfix_mailgraph_reject' => 'Postfix - Rejected / Bounced'];
// EOF

View File

@ -1,5 +1,5 @@
<?php
$app_graphs['default'] = array('postfix_qshape_stats' => 'Postfix - Queue Shape');
$app_graphs['default'] = ['postfix_qshape_stats' => 'Postfix - Queue Shape'];
// EOF

View File

@ -4,22 +4,22 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array('stats' => "Stats",
'live' => "Live");
$app_sections = ['stats' => "Stats",
'live' => "Live"];
$app_graphs['stats'] = array('postgresql_xact' => 'Commit Count',
'postgresql_blks' => 'Blocks Count',
'postgresql_tuples' => 'Tuples Count',
'postgresql_tuples_query' => 'Tuples Count per Query');
$app_graphs['stats'] = ['postgresql_xact' => 'Commit Count',
'postgresql_blks' => 'Blocks Count',
'postgresql_tuples' => 'Tuples Count',
'postgresql_tuples_query' => 'Tuples Count per Query'];
$app_graphs['live'] = array('postgresql_connects' => 'Connection Count',
'postgresql_queries' => 'Query Types');
$app_graphs['live'] = ['postgresql_connects' => 'Connection Count',
'postgresql_queries' => 'Query Types'];
// EOF

View File

@ -4,25 +4,25 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('powerdns-recursor_queries' => 'Questions and answers per second',
'powerdns-recursor_tcpqueries' => 'TCP Questions and answers per second, unauthorized packets/s',
'powerdns-recursor_errors' => 'Packet errors per second',
'powerdns-recursor_limits' => 'Limitations per second',
'powerdns-recursor_latency' => 'Questions answered within latency',
'powerdns-recursor_outqueries' => 'Questions vs Outqueries',
'powerdns-recursor_qalatency' => 'Question/Answer latency in ms',
'powerdns-recursor_timeouts' => 'Corrupt / Failed / Timed out',
'powerdns-recursor_cache' => 'Cache sizes',
'powerdns-recursor_load' => 'Concurrent Queries',
/* 'powerdns-recursor_hitrate' => 'Cache hitrate',*/ // FIXME have to fix up the graph def before uncomment
/* 'powerdns-recursor_cpuload' => 'CPU load',*/ // FIXME have to fix up the graph def before uncomment
);
$app_graphs['default'] = ['powerdns-recursor_queries' => 'Questions and answers per second',
'powerdns-recursor_tcpqueries' => 'TCP Questions and answers per second, unauthorized packets/s',
'powerdns-recursor_errors' => 'Packet errors per second',
'powerdns-recursor_limits' => 'Limitations per second',
'powerdns-recursor_latency' => 'Questions answered within latency',
'powerdns-recursor_outqueries' => 'Questions vs Outqueries',
'powerdns-recursor_qalatency' => 'Question/Answer latency in ms',
'powerdns-recursor_timeouts' => 'Corrupt / Failed / Timed out',
'powerdns-recursor_cache' => 'Cache sizes',
'powerdns-recursor_load' => 'Concurrent Queries',
/* 'powerdns-recursor_hitrate' => 'Cache hitrate',*/ // FIXME have to fix up the graph def before uncomment
/* 'powerdns-recursor_cpuload' => 'CPU load',*/ // FIXME have to fix up the graph def before uncomment
];
// EOF

View File

@ -4,19 +4,19 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('powerdns_latency' => 'Latency',
'powerdns_fail' => 'Corrupt / Failed / Timed out',
'powerdns_packetcache' => 'Packet Cache',
'powerdns_querycache' => 'Query Cache',
'powerdns_recursing' => 'Recursing Queries and Answers',
'powerdns_queries' => 'Total UDP/TCP Queries and Answers',
'powerdns_queries_udp' => 'Detail UDP IPv4/IPv6 Queries and Answers');
$app_graphs['default'] = ['powerdns_latency' => 'Latency',
'powerdns_fail' => 'Corrupt / Failed / Timed out',
'powerdns_packetcache' => 'Packet Cache',
'powerdns_querycache' => 'Query Cache',
'powerdns_recursing' => 'Recursing Queries and Answers',
'powerdns_queries' => 'Total UDP/TCP Queries and Answers',
'powerdns_queries_udp' => 'Detail UDP IPv4/IPv6 Queries and Answers'];
// EOF

View File

@ -4,10 +4,10 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
@ -15,70 +15,63 @@
global $config;
$total = true;
$total = TRUE;
$rrddir = $config['rrd_dir']."/".$device['hostname'];
$files = array();
$rrddir = $config['rrd_dir'] . "/" . $device['hostname'];
$files = [];
if ($handle = opendir($rrddir))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." &&
str_starts($file, "app-shoutcast-".$app['app_id']))
{
array_push($files, $file);
if ($handle = opendir($rrddir)) {
while (FALSE !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." &&
str_starts($file, "app-shoutcast-" . $app['app_id'])) {
array_push($files, $file);
}
}
}
}
if (isset($total) && $total == true)
{
$graphs = array(
'shoutcast_multi_bits' => 'Traffic Statistics - Total of all Shoutcast servers',
'shoutcast_multi_stats' => 'Shoutcast Statistics - Total of all Shoutcast servers'
);
if (isset($total) && $total == TRUE) {
$graphs = [
'shoutcast_multi_bits' => 'Traffic Statistics - Total of all Shoutcast servers',
'shoutcast_multi_stats' => 'Shoutcast Statistics - Total of all Shoutcast servers'
];
foreach ($graphs as $key => $text)
{
$graph_type = $key;
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_".$key;
echo('<h3>'.$text.'</h3>');
echo("<tr bgcolor='$row_colour'><td colspan=5>");
foreach ($graphs as $key => $text) {
$graph_type = $key;
$graph_array['to'] = get_time();
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_" . $key;
echo('<h3>' . $text . '</h3>');
echo("<tr bgcolor='$row_colour'><td colspan=5>");
print_graph_row($graph_array);
print_graph_row($graph_array);
echo("</td></tr>");
}
echo("</td></tr>");
}
}
foreach ($files as $id => $file)
{
$hostname = str_replace(['app-shoutcast-'.$app['app_id'].'-', '.rrd'], '', $file);
list($host, $port) = explode('_', $hostname, 2);
$graphs = array(
'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')',
'shoutcast_stats' => 'Shoutcast Statistics - '.$host.' (Port: '.$port.')'
);
foreach ($files as $id => $file) {
$hostname = str_replace(['app-shoutcast-' . $app['app_id'] . '-', '.rrd'], '', $file);
[$host, $port] = explode('_', $hostname, 2);
$graphs = [
'shoutcast_bits' => 'Traffic Statistics - ' . $host . ' (Port: ' . $port . ')',
'shoutcast_stats' => 'Shoutcast Statistics - ' . $host . ' (Port: ' . $port . ')'
];
foreach ($graphs as $key => $text)
{
$graph_type = $key;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_".$key;
$graph_array['hostname'] = $hostname;
echo('<h3>'.$text.'</h3>');
echo("<tr bgcolor='$row_colour'><td colspan=5>");
foreach ($graphs as $key => $text) {
$graph_type = $key;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = get_time();
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_" . $key;
$graph_array['hostname'] = $hostname;
echo('<h3>' . $text . '</h3>');
echo("<tr bgcolor='$row_colour'><td colspan=5>");
print_graph_row($graph_array);
print_graph_row($graph_array);
echo("</td></tr>");
}
echo("</td></tr>");
}
}
// EOF

View File

@ -4,20 +4,20 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('unbound_queries' => 'DNS traffic and cache hits',
'unbound_queue' => 'Queue statistics',
'unbound_memory' => 'Memory statistics',
'unbound_qtype' => 'Queries by Query type',
'unbound_rcode' => 'Queries by Return code',
'unbound_opcode' => 'Queries by Operation code',
'unbound_class' => 'Queries by Query class',
'unbound_flags' => 'Queries by Flags');
$app_graphs['default'] = ['unbound_queries' => 'DNS traffic and cache hits',
'unbound_queue' => 'Queue statistics',
'unbound_memory' => 'Memory statistics',
'unbound_qtype' => 'Queries by Query type',
'unbound_rcode' => 'Queries by Return code',
'unbound_opcode' => 'Queries by Operation code',
'unbound_class' => 'Queries by Query class',
'unbound_flags' => 'Queries by Flags'];
// EOF

View File

@ -4,17 +4,17 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array(
$app_graphs['default'] = [
'varnish_backend' => 'Varnish Backend',
'varnish_cache' => 'Varnish Cache',
'varnish_lru' => 'Varnish LRU',
);
'varnish_cache' => 'Varnish Cache',
'varnish_lru' => 'Varnish LRU',
];
// EOF

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('vmwaretools_mem' => 'Memory Resource Allocation',
'vmwaretools_cpu' => 'CPU Resource Allocation');
$app_graphs['default'] = ['vmwaretools_mem' => 'Memory Resource Allocation',
'vmwaretools_cpu' => 'CPU Resource Allocation'];
// EOF

View File

@ -4,30 +4,30 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array('system' => "System",
'backend' => "Backend",
'jvm' => "Java VM",
);
$app_sections = ['system' => "System",
'backend' => "Backend",
'jvm' => "Java VM",
];
$app_graphs['system'] = array(
'zimbra_fdcount' => 'Open file descriptors',
);
$app_graphs['system'] = [
'zimbra_fdcount' => 'Open file descriptors',
];
$app_graphs['backend'] = array(
'zimbra_mtaqueue' => 'MTA queue size',
'zimbra_connections' => 'Open connections',
'zimbra_threads' => 'Threads',
);
$app_graphs['backend'] = [
'zimbra_mtaqueue' => 'MTA queue size',
'zimbra_connections' => 'Open connections',
'zimbra_threads' => 'Threads',
];
$app_graphs['jvm'] = array(
'zimbra_jvmthreads' => 'JVM Threads',
);
$app_graphs['jvm'] = [
'zimbra_jvmthreads' => 'JVM Threads',
];
// EOF

View File

@ -30,37 +30,43 @@ load_graph_definitions();
/**
* Send back new list content
*
* @items Array of options values to return to browser
* @method Name of Javascript method that will be called to process data
*/
function dhtml_response_list(&$items, $method) {
header("Content-Type: text/xml");
function dhtml_response_list(&$items, $method)
{
header("Content-Type: text/xml");
print('<?xml version="1.0" encoding="utf-8" ?>'."\n");
print("<response>\n");
printf(" <method>%s</method>\n", escape_html($method));
print(" <result>\n");
foreach ($items as &$item)
printf(' <option>%s</option>'."\n", escape_html($item));
print(" </result>\n");
print("</response>");
print('<?xml version="1.0" encoding="utf-8" ?>' . "\n");
print("<response>\n");
printf(" <method>%s</method>\n", escape_html($method));
print(" <result>\n");
foreach ($items as &$item) {
printf(' <option>%s</option>' . "\n", escape_html($item));
}
print(" </result>\n");
print("</response>");
}
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'collectd');
$link_array = ['page' => 'device',
'device' => $device['device_id'],
'tab' => 'collectd'];
$plugins = collectd_list_plugins($device['hostname']);
#$navbar['brand'] = "CollectD";
$navbar['class'] = "navbar-narrow";
foreach ($plugins as &$plugin)
{
if (!$vars['plugin']) { $vars['plugin'] = $plugin; }
if ($vars['plugin'] == $plugin) { $navbar['options'][$plugin]['class'] = "active"; }
$navbar['options'][$plugin]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'collectd', 'plugin' => $plugin));
$navbar['options'][$plugin]['text'] = escape_html(ucwords($plugin));
foreach ($plugins as &$plugin) {
if (!$vars['plugin']) {
$vars['plugin'] = $plugin;
}
if ($vars['plugin'] == $plugin) {
$navbar['options'][$plugin]['class'] = "active";
}
$navbar['options'][$plugin]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'collectd', 'plugin' => $plugin]);
$navbar['options'][$plugin]['text'] = escape_html(ucwords($plugin));
}
print_navbar($navbar);
@ -69,49 +75,51 @@ echo generate_box_open();
echo '<table class="table table-condensed table-striped table-hover">';
$i=0;
$i = 0;
$pinsts = collectd_list_pinsts($device['hostname'], $vars['plugin']);
foreach ($pinsts as &$instance) {
$pinsts = collectd_list_pinsts($device['hostname'], $vars['plugin']);
foreach ($pinsts as &$instance) {
$types = collectd_list_types($device['hostname'], $vars['plugin'], $instance);
foreach ($types as &$type) {
$types = collectd_list_types($device['hostname'], $vars['plugin'], $instance);
foreach ($types as &$type) {
$typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type);
$typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type);
if ($MetaGraphDefs[$type]) { $typeinstances = array($MetaGraphDefs[$type]); }
if ($MetaGraphDefs[$type]) {
$typeinstances = [$MetaGraphDefs[$type]];
}
foreach ($typeinstances as &$tinst) {
$i++;
$row_colour = !is_intnum($i / 2) ? OBS_COLOUR_LIST_A : OBS_COLOUR_LIST_B;
foreach ($typeinstances as &$tinst) {
$i++;
$row_colour = !is_intnum($i / 2) ? OBS_COLOUR_LIST_A : OBS_COLOUR_LIST_B;
echo('<tr><td>');
echo('<h3>'.$graph_title);
echo('<tr><td>');
echo('<h3>' . $graph_title);
if ($tinst) {
echo($vars['plugin']." $instance - $type - $tinst");
} else {
echo($vars['plugin']." $instance - $type");
}
echo('</h3>');
if ($tinst) {
echo($vars['plugin'] . " $instance - $type - $tinst");
} else {
echo($vars['plugin'] . " $instance - $type");
}
echo('</h3>');
$graph_array['type'] = "device_collectd";
$graph_array['device'] = $device['device_id'];
$graph_array['type'] = "device_collectd";
$graph_array['device'] = $device['device_id'];
$graph_array['c_plugin'] = $vars['plugin'];
$graph_array['c_plugin_instance'] = $instance;
$graph_array['c_type'] = $type;
$graph_array['c_type_instance'] = $tinst;
$graph_array['c_plugin'] = $vars['plugin'];
$graph_array['c_plugin_instance'] = $instance;
$graph_array['c_type'] = $type;
$graph_array['c_type_instance'] = $tinst;
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</tr></td>');
}
}
echo('</tr></td>');
}
}
}
echo '</table>';
echo generate_box_close();

View File

@ -6,64 +6,55 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
// Print permission error and exit if the user doesn't have write permissions
if (!is_entity_write_permitted($device['device_id'], 'device'))
{
print_error_permission();
return;
if (!is_entity_write_permitted($device['device_id'], 'device')) {
print_error_permission();
return;
}
$export_device = $device;
if ($config['snmp']['hide_auth'])
{
$params = array('snmp_community', 'snmp_authlevel', 'snmp_authname', 'snmp_authpass', 'snmp_authalgo', 'snmp_cryptopass', 'snmp_cryptoalgo');
foreach ($params as $param)
{
if (strlen($export_device[$param])) { $export_device[$param] = '***'; }
}
}
$export_device = $device;
device_filter_secrets($export_device, $config['snmp']['hide_auth'], '***');
if (get_var_true($vars['saveas']) && $vars['filename']) {
if (get_var_true($vars['saveas']) && $vars['filename']) {
download_as_file(gzencode(safe_json_encode($export_device)), $vars['filename']);
} else {
if ($config['snmp']['hide_auth'])
{
print_warning("NOTE, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>TRUE</strong>, snmp community and snmp v3 auth hidden from output and export.");
} else {
if ($config['snmp']['hide_auth']) {
print_warning("NOTE, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>TRUE</strong>, snmp community and snmp v3 auth hidden from output and export.");
} else {
print_error("WARNING, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>FALSE</strong>, snmp community and snmp v3 auth <strong>NOT hidden</strong> from output and export.");
print_error("WARNING, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>FALSE</strong>, snmp community and snmp v3 auth <strong>NOT hidden</strong> from output and export.");
}
$form = array('type' => 'rows',
'space' => '10px',
'url' => generate_url($vars));
$form = ['type' => 'rows',
'space' => '10px',
'url' => generate_url($vars)];
// Filename
$form['row'][0]['filename'] = array(
'type' => 'text',
'name' => 'Filename',
'value' => $device['hostname'] . '.json.txt.gz',
//'div_class' => 'col-md-8',
'width' => '100%',
'placeholder' => TRUE);
$form['row'][0]['filename'] = [
'type' => 'text',
'name' => 'Filename',
'value' => $device['hostname'] . '.json.txt.gz',
//'div_class' => 'col-md-8',
'width' => '100%',
'placeholder' => TRUE];
// Compress
//$form['row'][0]['compress'] = array(
// 'type' => 'switch',
// 'value' => 1);
// Search button
$form['row'][0]['saveas'] = array(
'type' => 'submit',
'name' => 'Export',
'icon' => 'icon-save',
'right' => TRUE,
'value' => 'yes'
);
$form['row'][0]['saveas'] = [
'type' => 'submit',
'name' => 'Export',
'icon' => 'icon-save',
'right' => TRUE,
'value' => 'yes'
];
print_form($form);
r($export_device);
}
}
unset($export_device, $params, $param);
unset($export_device, $params, $param);
// EOF

View File

@ -6,13 +6,13 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($_SESSION['userlevel'] < 7 && !is_entity_write_permitted($device['device_id'], 'device')) {
print_error_permission();
return;
print_error_permission();
return;
}
// User level 7-9 only can see config
@ -21,94 +21,108 @@ if ($_SESSION['userlevel'] < 7 && !is_entity_write_permitted($device['device_id'
// Allow write for users with write permission to this entity
$readonly = !is_entity_write_permitted($device['device_id'], 'device');
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'edit');
$link_array = ['page' => 'device',
'device' => $device['device_id'],
'tab' => 'edit'];
$panes['device'] = 'Device Settings';
$panes['snmp'] = 'SNMP';
if ($config['geocoding']['enable']) {
$panes['geo'] = 'Geolocation';
}
$panes['mibs'] = 'MIBs';
$panes['graphs'] = 'Graphs';
$panes['alerts'] = 'Alerts';
$panes['ports'] = 'Ports';
if ($health_exist['sensors']) {
$panes['sensors'] = 'Sensors';
}
if ($health_exist['status']) {
$panes['device'] = 'Device Settings';
$panes['snmp'] = 'SNMP';
if ($config['geocoding']['enable']) {
$panes['geo'] = 'Geolocation';
}
$panes['mibs'] = 'MIBs';
$panes['graphs'] = 'Graphs';
$panes['alerts'] = 'Alerts';
$panes['ports'] = 'Ports';
if ($cache['health_exist'][$device['device_id']]['sensors']) {
$panes['sensors'] = 'Sensors';
}
if ($cache['health_exist'][$device['device_id']]['status']) {
$panes['status'] = 'Statuses';
}
if (safe_count($config['os'][$device['os']]['icons']))
{
$panes['icon'] = 'Icon';
}
}
// if ($cache['health_exist'][$device['device_id']]['counter']) {
// $panes['counter'] = 'Counters';
// }
$panes['modules'] = 'Modules';
$panes['modules'] = 'Modules';
//if ($config['enable_services'])
//{
//$panes['services'] = 'Services';
//}
//if ($config['enable_services'])
//{
//$panes['services'] = 'Services';
//}
// $panes['probes'] = 'Probes';
// $panes['probes'] = 'Probes';
if ($device_loadbalancer_count['netscaler_vsvr']) { $panes['netscaler_vsvrs'] = 'NS vServers'; }
if ($device_loadbalancer_count['netscaler_services']) { $panes['netscaler_svcs'] = 'NS Services'; }
if ($device_loadbalancer_count['netscaler_vsvr']) {
$panes['netscaler_vsvrs'] = 'NS vServers';
}
if ($device_loadbalancer_count['netscaler_services']) {
$panes['netscaler_svcs'] = 'NS Services';
}
if ($device['os'] === 'windows') {
$panes['wmi'] = 'WMI';
}
if ($device['os'] === 'windows') {
$panes['wmi'] = 'WMI';
}
if ($config['os'][$device['os']]['ipmi']) {
$panes['ipmi'] = 'IPMI';
}
if (($config['enable_libvirt'] && $device['os'] === 'linux') || // libvirt-vminfo discovery module
$device['os_group'] === 'unix' || is_module_enabled($device, 'unix-agent', 'poller')) { // unix-agent
$panes['ssh'] = 'SSH';
}
if ($device['os_group'] === 'unix' || $device['os'] === 'generic')
{
$panes['agent'] = 'Agent';
}
if ($device['os_group'] === 'unix' || $device['os'] === 'windows')
{
$panes['apps'] = 'Applications'; /// FIXME. Deprecated?
}
if ($config['os'][$device['os']]['ipmi']) {
$panes['ipmi'] = 'IPMI';
}
if (($config['enable_libvirt'] && $device['os'] === 'linux') || // libvirt-vminfo discovery module
$device['os_group'] === 'unix' || is_module_enabled($device, 'unix-agent', 'poller')) { // unix-agent
$panes['ssh'] = 'SSH';
}
if (($device['os_group'] === 'unix' || $device['os'] === 'generic') && (is_module_enabled($device, 'unix-agent', 'poller'))) {
$panes['agent'] = 'Agent';
}
if ($device['os_group'] === 'unix' || $device['os'] === 'windows') {
$panes['apps'] = 'Applications'; /// FIXME. Deprecated?
}
$navbar['brand'] = "Edit";
$navbar['class'] = "navbar-narrow";
if ($_SESSION['userlevel'] >= 9) {
// Detect (possible) duplicates
$duplicates = [];
get_device_duplicated($device, $duplicates);
if (count($duplicates)) {
$panes['duplicates'] = 'Duplicates';
}
}
foreach ($panes as $type => $text)
{
if (!isset($vars['section'])) { $vars['section'] = $type; }
$navbar['brand'] = "Edit";
$navbar['class'] = "navbar-narrow";
if ($vars['section'] == $type) { $navbar['options'][$type]['class'] = "active"; }
$navbar['options'][$type]['url'] = generate_url($link_array,array('section'=>$type));
foreach ($panes as $type => $text) {
if (!isset($vars['section'])) {
$vars['section'] = $type;
}
if ($vars['section'] == $type) {
$navbar['options'][$type]['class'] = "active";
}
$navbar['options'][$type]['url'] = generate_url($link_array, ['section' => $type]);
$navbar['options'][$type]['text'] = $text;
}
$navbar['options_right']['delete']['url'] = generate_url($link_array,array('section'=>'delete'));
$navbar['options_right']['delete']['text'] = 'Delete';
$navbar['options_right']['delete']['icon'] = $config['icon']['device-delete'];
if ($vars['section'] === 'delete') { $navbar['options_right']['delete']['class'] = 'active'; }
print_navbar($navbar);
}
$navbar['options_right']['delete']['url'] = generate_url($link_array, ['section' => 'delete']);
$navbar['options_right']['delete']['text'] = 'Delete';
$navbar['options_right']['delete']['icon'] = ':wastebasket:';//$config['icon']['device-delete'];
if ($vars['section'] === 'delete') {
$navbar['options_right']['delete']['class'] = 'active';
}
print_navbar($navbar);
$filename = $config['html_dir'] . '/pages/device/edit/' . $vars['section'] . '.inc.php';
if (is_file($filename))
{
$vars = get_vars('POST'); // Note, on edit pages use only method POST!
$filename = $config['html_dir'] . '/pages/device/edit/' . $vars['section'] . '.inc.php';
if (is_file($filename)) {
$vars = get_vars('POST'); // Note, on edit pages use only method POST!
$attribs = get_dev_attribs($device['device_id']);
$model = get_model_array($device);
$model = get_model_array($device);
register_html_resource('js', 'js/jquery.serializejson.js');
register_html_resource('js', 'js/jquery.serializejson.min.js');
include($filename);
} else {
} else {
print_error('<h3>Page does not exist</h4>
The requested page does not exist. Please correct the URL and try again.');
}
}
unset($filename, $navbar, $panes, $link_array);
unset($filename, $navbar, $panes, $link_array, $readonly);
register_html_title("Settings");

View File

@ -4,80 +4,70 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$agent_port = $vars['agent_port'];
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$agent_port = $vars['agent_port'];
if ($agent_port == "")
{
del_dev_attrib($device, 'agent_port');
$updated = 1;
$update_message = "Agent settings updated.";
if ($agent_port == "") {
del_dev_attrib($device, 'agent_port');
$updated = 1;
$update_message = "Agent settings updated.";
} elseif (!is_numeric($agent_port)) {
$update_message = "Agent port must be numeric!";
$updated = 0;
} else {
set_dev_attrib($device, 'agent_port', $agent_port);
$updated = 1;
$update_message = "Agent settings updated.";
}
}
elseif (!is_numeric($agent_port))
{
$update_message = "Agent port must be numeric!";
$updated = 0;
}
else
{
set_dev_attrib($device, 'agent_port', $agent_port);
$updated = 1;
$update_message = "Agent settings updated.";
}
}
if ($updated && $update_message)
{
print_message($update_message);
log_event('Device Agent configuration changed.', $device['device_id'], 'device', $device, 5); // severity 5, for logging user info
}
else if ($update_message)
{
print_error($update_message);
}
if ($updated && $update_message) {
print_message($update_message);
log_event('Device Agent configuration changed.', $device['device_id'], 'device', $device, 5); // severity 5, for logging user info
} elseif ($update_message) {
print_error($update_message);
}
}
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", [$device['device_id']]);
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Agent Connectivity',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['agent_port'] = array(
'type' => 'text',
'name' => 'Agent Port',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'agent_port'));
$form['row'][2]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Agent Connectivity',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
print_form($form);
unset($form);
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['agent_port'] = [
'type' => 'text',
'name' => 'Agent Port',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'agent_port')];
$form['row'][2]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);
// EOF

View File

@ -4,158 +4,157 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$override_sysContact_bool = $vars['override_sysContact'];
if (isset($vars['sysContact'])) { $override_sysContact_string = $vars['sysContact']; }
$disable_notify = $vars['disable_notify'];
if ($override_sysContact_bool) {
set_dev_attrib($device, 'override_sysContact_bool', '1');
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
del_dev_attrib($device, 'override_sysContact_bool');
}
if (isset($override_sysContact_string)) {
set_dev_attrib($device, 'override_sysContact_string', $override_sysContact_string);
}
if ($disable_notify) {
set_dev_attrib($device, 'disable_notify', '1');
} else {
del_dev_attrib($device, 'disable_notify');
$override_sysContact_bool = $vars['override_sysContact'];
if (isset($vars['sysContact'])) {
$override_sysContact_string = $vars['sysContact'];
}
$disable_notify = $vars['disable_notify'];
if ($override_sysContact_bool) {
set_dev_attrib($device, 'override_sysContact_bool', '1');
} else {
del_dev_attrib($device, 'override_sysContact_bool');
}
if (isset($override_sysContact_string)) {
set_dev_attrib($device, 'override_sysContact_string', $override_sysContact_string);
}
if ($disable_notify) {
set_dev_attrib($device, 'disable_notify', '1');
} else {
del_dev_attrib($device, 'disable_notify');
}
// 2019-12-05 23:30:00
if (isset($vars['ignore_until']) && $vars['ignore_until_enable']) {
$update['ignore_until'] = $vars['ignore_until'];
$device['ignore_until'] = $vars['ignore_until'];
} else {
$update['ignore_until'] = ['NULL'];
$device['ignore_until'] = '';
}
foreach (['ignore'] as $param) {
if (!in_array($param, ['purpose', 'poller_id'])) {
// Boolean params
$vars[$param] = get_var_true($vars[$param]) ? '1' : '0';
}
if ($vars[$param] != $device[$param]) {
$update[$param] = $vars[$param];
}
}
dbUpdate($update, 'devices', '`device_id` = ?', [$device['device_id']]);
$update_message = "Device alert settings updated.";
$updated = 1;
// Request for clear WUI cache
set_cache_clear('wui');
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", [$device['device_id']]);
}
// 2019-12-05 23:30:00
if (isset($vars['ignore_until']) && $vars['ignore_until_enable']) {
$update['ignore_until'] = $vars['ignore_until'];
$device['ignore_until'] = $vars['ignore_until'];
} else {
$update['ignore_until'] = array('NULL');
$device['ignore_until'] = '';
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
foreach (array('ignore') as $param)
{
if (!in_array($param, array('purpose', 'poller_id')))
{
// Boolean params
$vars[$param] = get_var_true($vars[$param]) ? '1' : '0';
}
if ($vars[$param] != $device[$param])
{
$update[$param] = $vars[$param];
}
}
dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id']));
$update_message = "Device alert settings updated.";
$updated = 1;
// Request for clear WUI cache
set_cache_clear('wui');
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
}
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
}
$override_sysContact_bool = get_dev_attrib($device,'override_sysContact_bool');
$override_sysContact_string = get_dev_attrib($device,'override_sysContact_string');
$disable_notify = get_dev_attrib($device,'disable_notify');
$override_sysContact_bool = get_dev_attrib($device, 'override_sysContact_bool');
$override_sysContact_string = get_dev_attrib($device, 'override_sysContact_string');
$disable_notify = get_dev_attrib($device, 'disable_notify');
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Alert Settings',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Alert Settings',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['ignore'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Ignore Device',
//'fieldset' => 'edit',
'placeholder' => 'Suppresses alerts and notifications. Hides device from some UI elements.',
'readonly' => $readonly,
'value' => $device['ignore']);
$form['row'][1]['ignore'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Ignore Device',
//'fieldset' => 'edit',
'placeholder' => 'Suppresses alerts and notifications. Hides device from some UI elements.',
'readonly' => $readonly,
'value' => $device['ignore']];
$form['row'][2]['ignore_until'] = array(
'type' => 'datetime',
//'fieldset' => 'edit',
'name' => 'Ignore Until',
'placeholder' => '',
//'width' => '250px',
'readonly' => $readonly,
'disabled' => empty($device['ignore_until']),
'min' => 'current',
'value' => $device['ignore_until'] ?: '');
$form['row'][2]['ignore_until_enable'] = array(
'type' => 'toggle',
'size' => 'large',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'ignore_until')",
'value' => !empty($device['ignore_until']));
$form['row'][2]['ignore_until'] = [
'type' => 'datetime',
//'fieldset' => 'edit',
'name' => 'Ignore Until',
'placeholder' => '',
//'width' => '250px',
'readonly' => $readonly,
'disabled' => empty($device['ignore_until']),
'min' => 'current',
'value' => $device['ignore_until'] ?: ''];
$form['row'][2]['ignore_until_enable'] = [
'type' => 'toggle',
'size' => 'large',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'ignore_until')",
'value' => !empty($device['ignore_until'])];
$form['row'][3]['override_sysContact'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Override sysContact',
//'fieldset' => 'edit',
'placeholder' => 'Use custom contact below',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'sysContact')",
'value' => $override_sysContact_bool);
$form['row'][4]['sysContact'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Custom contact',
'placeholder' => '',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$override_sysContact_bool,
'value' => $override_sysContact_string);
$form['row'][5]['disable_notify'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Disable notifications',
//'fieldset' => 'edit',
'placeholder' => 'Don\'t send alert notifications (but write to eventlog)',
'readonly' => $readonly,
'value' => $disable_notify);
$form['row'][7]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form['row'][3]['override_sysContact'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Override sysContact',
//'fieldset' => 'edit',
'placeholder' => 'Use custom contact below',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'sysContact')",
'value' => $override_sysContact_bool];
$form['row'][4]['sysContact'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Custom contact',
'placeholder' => '',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$override_sysContact_bool,
'value' => $override_sysContact_string];
$form['row'][5]['disable_notify'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Disable notifications',
//'fieldset' => 'edit',
'placeholder' => 'Don\'t send alert notifications (but write to eventlog)',
'readonly' => $readonly,
'value' => $disable_notify];
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);
print_form($form);
unset($form);
// EOF

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
@ -15,122 +15,119 @@ print_warning("This page allows you to disable applications for this device that
# Check if the form was POSTed
if ($vars['device']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$updated = 0;
$param[] = $device['device_id'];
$enabled = [];
foreach (array_keys($vars) as $key) {
if (str_starts($key, 'app_')) {
$param[] = substr($key, 4);
$enabled[] = substr($key, 4);
$replace[] = "?";
}
}
if (count($enabled)) {
$updated += dbDelete('applications', "`device_id` = ? AND `app_type` NOT IN (".implode(",",$replace).")", $param);
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$updated += dbDelete('applications', "`device_id` = ?", array($param));
}
$updated = 0;
$param[] = $device['device_id'];
$enabled = [];
foreach (array_keys($vars) as $key) {
if (str_starts($key, 'app_')) {
$param[] = substr($key, 4);
$enabled[] = substr($key, 4);
$replace[] = "?";
}
}
foreach (dbFetchRows( "SELECT `app_type` FROM `applications` WHERE `device_id` = ?", array($device['device_id'])) as $row) {
$app_in_db[] = $row['app_type'];
}
if (count($enabled)) {
$updated += dbDelete('applications', "`device_id` = ? AND `app_type` NOT IN (" . implode(",", $replace) . ")", $param);
} else {
$updated += dbDelete('applications', "`device_id` = ?", [$param]);
}
foreach ($enabled as $app) {
if (!in_array($app, $app_in_db)) {
$updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app), 'applications');
}
}
foreach (dbFetchRows("SELECT `app_type` FROM `applications` WHERE `device_id` = ?", [$device['device_id']]) as $row) {
$app_in_db[] = $row['app_type'];
}
if ($updated) {
print_message("Applications updated!");
} else {
print_message("No changes.");
foreach ($enabled as $app) {
if (!in_array($app, $app_in_db)) {
$updated += dbInsert(['device_id' => $device['device_id'], 'app_type' => $app], 'applications');
}
}
if ($updated) {
print_message("Applications updated!");
} else {
print_message("No changes.");
}
}
}
}
# Show list of apps with checkboxes
$apps_enabled = dbFetchRows("SELECT * from `applications` WHERE `device_id` = ? ORDER BY app_type", array($device['device_id']));
$apps_enabled = dbFetchRows("SELECT * from `applications` WHERE `device_id` = ? ORDER BY app_type", [ $device['device_id'] ]);
if (safe_count($apps_enabled)) {
foreach ($apps_enabled as $application)
{
$app_enabled[] = $application['app_type'];
}
?>
<form id="appedit" name="appedit" method="post" action="" class="form-inline">
<input type="hidden" name="device" value="<?php echo $device['device_id'];?>">
<?php echo generate_box_open(array('title' => 'Applications', 'header-border' => TRUE)); ?>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 100px;">Enable</th>
<th>Application</th>
</tr>
</thead>
<tbody>
<?php
# Load our list of available applications
if ($handle = opendir($config['install_dir'] . "/includes/polling/applications/")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && strstr($file, ".inc.php")) {
$applications[] = str_replace(".inc.php", "", $file);
$app_enabled = [];
foreach ($apps_enabled as $application) {
$app_enabled[] = $application['app_type'];
}
}
closedir($handle);
}
?>
foreach ($applications as $app) {
if (in_array($app, $app_enabled)) {
echo(" <tr>");
//echo(" <td>");
$item = array(
'id' => 'app_' . $app,
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
'on-text' => 'No',
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => 1
);
echo('<td class="text-center">'.generate_form_element($item).'</td>');
//echo(" </td>");
echo(" <td>". nicecase($app) . "</td>");
echo(" </tr>");
<form id="appedit" name="appedit" method="post" action="" class="form-inline">
<input type="hidden" name="device" value="<?php echo $device['device_id']; ?>">
$row++;
}
}
?>
</tbody>
</table>
</div>
<?php echo generate_box_open(['title' => 'Applications', 'header-border' => TRUE]); ?>
<div class="box-footer">
<button type="submit" class="btn btn-primary pull-right" name="submit" value="save"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</div>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 100px;">Enable</th>
<th>Application</th>
</tr>
</thead>
<tbody>
</form>
<?php
<?php
# Load our list of available applications
$applications = [];
foreach (get_recursive_directory_iterator($config['install_dir'] . "/includes/polling/applications/") as $file => $info) {
if (!str_ends_with($info->getFilename(), '.inc.php')) { continue; }
$applications[] = str_replace(".inc.php", "", $info->getFilename());
}
//r($applications);
foreach ($applications as $app) {
if (in_array($app, $app_enabled)) {
echo(" <tr>");
//echo(" <td>");
$item = [
'id' => 'app_' . $app,
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
'on-text' => 'No',
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => 1
];
echo('<td class="text-center">' . generate_form_element($item) . '</td>');
//echo(" </td>");
echo(" <td>" . nicecase($app) . "</td>");
echo(" </tr>");
}
}
?>
</tbody>
</table>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary pull-right" name="submit" value="save"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</div>
</form>
<?php
} else {
print_error("No applications found on this device.");
print_error("No applications found on this device.");
}
// EOF

View File

@ -6,51 +6,53 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
if ($readonly) { // in parent: $readonly = !is_entity_write_permitted($device['device_id'], 'device');
print_error_permission();
return;
}
$form = [
'type' => 'horizontal',
'id' => 'delete_host',
//'space' => '20px',
'title' => 'Delete device',
//'class' => 'box box-solid',
'url' => 'delhost/'
'type' => 'horizontal',
'id' => 'delete_host',
//'space' => '20px',
'title' => 'Delete device',
//'class' => 'box box-solid',
'url' => 'delhost/'
];
$form['row'][0]['id'] = [
'type' => 'hidden',
'value' => $device['device_id']
$form['row'][0]['id'] = [
'type' => 'hidden',
'value' => $device['device_id']
];
$form['row'][4]['deleterrd'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Delete RRDs',
'onchange' => "javascript: showDiv(this.checked);",
'value' => 'confirm'
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Delete RRDs',
'onchange' => "javascript: showDiv(this.checked);",
'value' => 'confirm'
];
$form['row'][5]['confirm'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Confirm Deletion',
'onchange' => "javascript: toggleAttrib('disabled', 'delete');",
'value' => 'confirm'
$form['row'][5]['confirm'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Confirm Deletion',
'onchange' => "javascript: toggleAttrib('disabled', 'delete');",
'value' => 'confirm'
];
$form['row'][6]['delete'] = [
'type' => 'submit',
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE
$form['row'][6]['delete'] = [
'type' => 'submit',
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE
];
print_warning("<h3>Warning!</h4>

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
@ -15,243 +15,264 @@ $override_type_string = get_entity_attrib('device', $device, 'override_type');
$override_type_bool = !empty($override_type_string);
$default_type = $override_type_bool ? $config['os'][$device['os']]['type'] : $device['type'];
$device_types = array();
$device_types = [];
foreach ($config['device_types'] as $type) {
$device_types[$type['type']] = array('name' => nicecase($type['type']), 'icon' => $type['icon']);
if ($type['type'] == $default_type) {
$device_types[$type['type']]['subtext'] = 'Default';
//$device_types[$type['type']]['class'] = 'error';
}
$device_types[$type['type']] = ['name' => nicecase($type['type']), 'icon' => $type['icon']];
if ($type['type'] == $default_type) {
$device_types[$type['type']]['subtext'] = 'Default';
//$device_types[$type['type']]['class'] = 'error';
}
}
if (!array_key_exists($device['type'], $device_types)) {
$device_types[$device['type']] = array('name' => 'Other', 'icon' => $config['icon']['question']);
$device_types[$device['type']] = ['name' => 'Other', 'icon' => $config['icon']['question']];
}
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
print_debug_vars($vars);
$updated = 0;
// Changed sysLocation
$override_sysLocation_bool = $vars['override_sysLocation'];
if (isset($vars['sysLocation'])) {
$override_sysLocation_string = $vars['sysLocation'];
}
if (get_entity_attrib('device', $device, 'override_sysLocation_bool') != $override_sysLocation_bool ||
get_entity_attrib('device', $device, 'override_sysLocation_string') != $override_sysLocation_string) {
$updated = 2;
}
if ($override_sysLocation_bool) {
set_entity_attrib('device', $device, 'override_sysLocation_bool', '1', $device['device_id']);
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
del_entity_attrib('device', $device, 'override_sysLocation_bool');
}
if (isset($override_sysLocation_string)) { set_entity_attrib('device', $device, 'override_sysLocation_string', $override_sysLocation_string); }
print_debug_vars($vars);
$updated = 0;
// Changed Skip ping
$ping_skip_set = isset($vars['ping_skip']) && get_var_true($vars['ping_skip']);
if ($ping_skip != $ping_skip_set)
{
if ($ping_skip_set) { set_entity_attrib('device', $device, 'ping_skip', '1'); }
else { del_entity_attrib('device', $device, 'ping_skip'); }
$ping_skip = get_entity_attrib('device', $device, 'ping_skip');
$updated++;
}
# FIXME needs more sanity checking! and better feedback
# FIXME -- update location too? Need to trigger geolocation!
$update_array = array();
// Changed Type
if ($vars['type'] != $device['type'] && isset($device_types[$vars['type']]))
{
$update_array['type'] = $vars['type'];
if (!$override_type_bool || $override_type_string != $vars['type'])
{
// Type overridden by user..
if ($vars['type'] == $default_type)
{
del_entity_attrib('device', $device, 'override_type');
$override_type_string = NULL;
} else {
set_entity_attrib('device', $device, 'override_type', $vars['type']);
$override_type_string = $vars['type'];
// Changed sysLocation
$override_sysLocation_bool = $vars['override_sysLocation'];
if (isset($vars['sysLocation'])) {
$override_sysLocation_string = $vars['sysLocation'];
}
$override_type_bool = !empty($override_type_string);
}
$updated++;
}
foreach (array('purpose', 'ignore', 'disabled', 'poller_id') as $param)
{
if (!in_array($param, array('purpose', 'poller_id')))
{
// Boolean params
$vars[$param] = get_var_true($vars[$param]) ? '1' : '0';
}
if ($vars[$param] != $device[$param])
{
$update_array[$param] = $vars[$param];
$updated++;
}
}
if (get_entity_attrib('device', $device, 'override_sysLocation_bool') != $override_sysLocation_bool ||
get_entity_attrib('device', $device, 'override_sysLocation_string') != $override_sysLocation_string) {
$updated = 2;
}
if (count($update_array))
{
$rows_updated = dbUpdate($update_array, 'devices', '`device_id` = ?', array($device['device_id']));
}
//r($updated);
//r($update_array);
//r($rows_updated);
if ($updated) {
if ((bool)$vars['ignore'] != (bool)$device['ignore'])
{
log_event('Device '.((bool)$vars['ignore'] ? 'ignored' : 'attended').': '.$device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
if ((bool)$vars['disabled'] != (bool)$device['disabled'])
{
log_event('Device '.((bool)$vars['disabled'] ? 'disabled' : 'enabled').': '.$device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
$update_message = "Device record updated.";
if ($override_sysLocation_bool) { $update_message.= " Please note that the updated sysLocation string will only be visible after the next poll."; }
$updated = 1;
if ($override_sysLocation_bool) {
set_entity_attrib('device', $device, 'override_sysLocation_bool', '1', $device['device_id']);
} else {
del_entity_attrib('device', $device, 'override_sysLocation_bool');
}
if (isset($override_sysLocation_string)) {
set_entity_attrib('device', $device, 'override_sysLocation_string', $override_sysLocation_string);
}
// Request for clear WUI cache
set_cache_clear('wui');
// Changed Skip ping
$ping_skip_set = isset($vars['ping_skip']) && get_var_true($vars['ping_skip']);
if ($ping_skip != $ping_skip_set) {
if ($ping_skip_set) {
set_entity_attrib('device', $device, 'ping_skip', '1');
} else {
del_entity_attrib('device', $device, 'ping_skip');
}
$ping_skip = get_entity_attrib('device', $device, 'ping_skip');
$updated++;
}
# FIXME needs more sanity checking! and better feedback
# FIXME -- update location too? Need to trigger geolocation!
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
$update_array = [];
// Changed Type
if ($vars['type'] != $device['type'] && isset($device_types[$vars['type']])) {
$update_array['type'] = $vars['type'];
if (!$override_type_bool || $override_type_string != $vars['type']) {
// Type overridden by user..
if ($vars['type'] == $default_type) {
del_entity_attrib('device', $device, 'override_type');
$override_type_string = NULL;
} else {
set_entity_attrib('device', $device, 'override_type', $vars['type']);
$override_type_string = $vars['type'];
}
$override_type_bool = !empty($override_type_string);
}
$updated++;
}
foreach (['purpose', 'ignore', 'disabled', 'poller_id', 'force_discovery'] as $param) {
if (!in_array($param, ['purpose', 'poller_id'])) {
// Boolean params
$vars[$param] = get_var_true($vars[$param]) ? '1' : '0';
}
if ($vars[$param] != $device[$param]) {
$update_array[$param] = $vars[$param];
$updated++;
}
}
if (count($update_array)) {
$rows_updated = dbUpdate($update_array, 'devices', '`device_id` = ?', [$device['device_id']]);
}
//r($updated);
//r($update_array);
//r($rows_updated);
if ($updated) {
if ((bool)$vars['ignore'] != (bool)$device['ignore']) {
log_event('Device ' . ((bool)$vars['ignore'] ? 'ignored' : 'attended') . ': ' . $device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
if ((bool)$vars['disabled'] != (bool)$device['disabled']) {
log_event('Device ' . ((bool)$vars['disabled'] ? 'disabled' : 'enabled') . ': ' . $device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
if ((bool)$vars['force_discovery'] != (bool)$device['force_discovery']) {
log_event('Device forced discovery ' . ((bool)$vars['force_discovery'] ? 'enabled' : 'disabled') . ': ' . $device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
$update_message = "Device record updated.";
if ($override_sysLocation_bool) {
$update_message .= " Please note that the updated sysLocation string will only be visible after the next poll.";
}
$updated = 1;
// Request for clear WUI cache
set_cache_clear('wui');
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", [$device['device_id']]);
} elseif ($rows_updated = '-1') {
$update_message = "Device record unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device record update error.";
}
}
else if ($rows_updated = '-1')
{
$update_message = "Device record unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device record update error.";
}
}
}
$override_sysLocation_bool = get_entity_attrib('device', $device, 'override_sysLocation_bool');
$override_sysLocation_string = get_entity_attrib('device', $device, 'override_sysLocation_string');
if ($updated && $update_message) {
print_message($update_message);
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
print_error($update_message);
}
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'General Device Settings',
'icon' => $config['icon']['tools'],
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form = [
'type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'General Device Settings',
'icon' => $config['icon']['tools'],
//'class' => 'box box-solid',
'fieldset' => [ 'edit' => '' ],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['purpose'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Description',
//'class' => 'input-xlarge',
'width' => '500px',
'readonly' => $readonly,
'value' => $device['purpose']);
$form['row'][2]['type'] = array(
'type' => 'select',
//'fieldset' => 'edit',
'name' => 'Type',
'width' => '250px',
'readonly' => $readonly,
'values' => $device_types,
'value' => $device['type']);
/*
$form['row'][2]['reset_type'] = array(
'type' => 'switch',
//'fieldset' => 'edit',
//'onchange' => "toggleAttrib('disabled', 'sysLocation')",
'readonly' => $readonly,
'on-color' => 'danger',
'off-color' => 'primary',
'on-text' => 'Reset',
'off-text' => 'Keep',
'value' => 0);
*/
$form['row'][3]['sysLocation'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Custom location',
'placeholder' => '',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$override_sysLocation_bool,
'value' => $override_sysLocation_string);
$form['row'][3]['override_sysLocation'] = array(
'type' => 'toggle',
'size' => 'large',
//'fieldset' => 'edit',
//'placeholder' => 'Use custom location below.',
'onchange' => "toggleAttrib('disabled', 'sysLocation')",
'readonly' => $readonly,
'value' => $override_sysLocation_bool);
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
];
$form['row'][1]['purpose'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Description',
//'class' => 'input-xlarge',
'width' => '500px',
'readonly' => $readonly,
'value' => $device['purpose']
];
$form['row'][2]['type'] = [
'type' => 'select',
//'fieldset' => 'edit',
'name' => 'Type',
'width' => '250px',
'readonly' => $readonly,
'values' => $device_types,
'value' => $device['type']
];
/*
$form['row'][2]['reset_type'] = array(
'type' => 'switch',
//'fieldset' => 'edit',
//'onchange' => "toggleAttrib('disabled', 'sysLocation')",
'readonly' => $readonly,
'on-color' => 'danger',
'off-color' => 'primary',
'on-text' => 'Reset',
'off-text' => 'Keep',
'value' => 0);
*/
$form['row'][3]['sysLocation'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Custom location',
'placeholder' => '',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$override_sysLocation_bool,
'value' => $override_sysLocation_string
];
$form['row'][3]['override_sysLocation'] = [
'type' => 'toggle',
'size' => 'large',
//'fieldset' => 'edit',
//'placeholder' => 'Use custom location below.',
'onchange' => "toggleAttrib('disabled', 'sysLocation')",
'readonly' => $readonly,
'value' => $override_sysLocation_bool
];
$poller_list = get_pollers();
$form['row'][4]['poller_id'] = array(
'type' => 'select',
'community' => FALSE, // not available on community edition
'name' => 'Poller',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !(count($poller_list) > 1),
'values' => $poller_list,
'value' => $device['poller_id']);
$poller_list = get_pollers();
$form['row'][5]['ping_skip'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Skip ping',
//'fieldset' => 'edit',
'placeholder' => 'Skip ICMP echo checks, only SNMP availability.',
'readonly' => $readonly,
'value' => $ping_skip);
// FIXME (Mike): $device['ignore'] and get_dev_attrib($device,'disable_notify') it is same/redundant options?
$form['row'][6]['ignore'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Device ignore',
//'fieldset' => 'edit',
'placeholder' => 'Suppress alerts and notifications and hide in some UI elements.',
'readonly' => $readonly,
'value' => $device['ignore']);
$form['row'][7]['disabled'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Disable',
//'fieldset' => 'edit',
'placeholder' => 'Disables polling and discovery.',
'readonly' => $readonly,
'value' => $device['disabled']);
$form['row'][8]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form['row'][4]['poller_id'] = [
'type' => 'select',
'community' => FALSE, // not available on community edition
'name' => 'Poller',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !(count($poller_list) > 1),
'values' => $poller_list,
'value' => $device['poller_id']
];
print_form($form);
unset($form);
$form['row'][5]['ping_skip'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Skip ping',
//'fieldset' => 'edit',
'placeholder' => 'Skip ICMP echo checks, only SNMP availability.',
'readonly' => $readonly,
'value' => $ping_skip
];
$form['row'][6]['force_discovery'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'blue',
'name' => 'Force Discovery',
//'fieldset' => 'edit',
'placeholder' => 'Force the device to be rediscovered in the next 5 mins.',
'readonly' => $readonly,
'value' => $device['force_discovery']
];
// FIXME (Mike): $device['ignore'] and get_dev_attrib($device,'disable_notify') it is same/redundant options?
$form['row'][7]['ignore'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Device ignore',
//'fieldset' => 'edit',
'placeholder' => 'Suppress alerts and notifications and hide in some UI elements.',
'readonly' => $readonly,
'value' => $device['ignore']
];
$form['row'][8]['disabled'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Disable',
//'fieldset' => 'edit',
'placeholder' => 'Disables polling and discovery.',
'readonly' => $readonly,
'value' => $device['disabled']
];
$form['row'][9]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
];
print_form($form);
unset($form);
// EOF

View File

@ -0,0 +1,75 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
/** @var array $duplicates */
//r($duplicates);
// Display devices as a list in detailed format
$header = ['state-marker' => '',
'',
['hostname' => 'Hostname', 'domain' => 'Domain', 'location' => 'Location'],
'',
['os' => 'Operating System', 'hardware' => 'Hardware Platform'],
['uptime' => 'Uptime', 'sysName' => 'sysName']];
//r($table_header);
foreach ($duplicates as $case => $entries) {
switch ($case) {
case 'hostname':
$title = 'Same Hostname (' . $entries[0]['hostname'] . ')';
break;
case 'ip_snmp':
$title = 'Same IP (' . $entries[0]['ip'] . ') and SNMP port (' . $entries[0]['snmp_port'] . '). Different SNMP community or auth!';
break;
case 'ip_snmp_v1':
$title = 'Same IP (' . $entries[0]['ip'] . ':' . $entries[0]['snmp_port'] . ') and SNMP v1 community!';
break;
case 'ip_snmp_v2c':
$title = 'Same IP (' . $entries[0]['ip'] . ':' . $entries[0]['snmp_port'] . ') and SNMP v2c community!';
break;
case 'ip_snmp_v3':
$title = 'Same IP (' . $entries[0]['ip'] . ':' . $entries[0]['snmp_port'] . ') and SNMP v3 auth!';
break;
}
echo generate_box_open(['title' => $title, 'icon' => count($entries), 'header-border' => TRUE]);
echo '
<table class="table table-hover table-striped table-condensed">
<thead>
<tr>
<th class="state-marker"></th>
<th></th>
<th>Device / Location</th>
<th>Hardware / Features</th>
<th>Operating System</th>
<th>Uptime / sysName</th>
</tr>
</thead>';
//echo generate_table_header($header, $vars);
$vars['view'] = 'basic';
foreach ($entries as $dup) {
if (device_permitted($dup['device_id'])) {
print_device_row($dup, $vars, ['tab' => 'edit', 'section' => 'duplicates']);
}
}
echo('
</table>');
echo generate_box_close();
}
// EOF

View File

@ -6,232 +6,234 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$updated = 0;
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$updated = 0;
if ($vars['submit'] === 'save') {
if (get_var_true($vars['reset_geolocation'])) {
$updated = dbDelete('devices_locations', '`device_id` = ?', [ $device['device_id'] ]);
} elseif ((bool)$vars['location_manual']) {
// Set manual coordinates if present
$pattern = '/(?:^|[\[(])\s*(?<lat>[+-]?\d+(?:\.\d+)*)\s*[,; ]\s*(?<lon>[+-]?\d+(?:\.\d+)*)\s*(?:[\])]|$)/';
if (preg_match($pattern, $vars['coordinates'], $matches)) {
//r($matches);
if ($matches['lat'] >= -90 && $matches['lat'] <= 90 &&
$matches['lon'] >= -180 && $matches['lon'] <= 180) {
$update_geo['location_lat'] = $matches['lat'];
$update_geo['location_lon'] = $matches['lon'];
$update_geo['location_country'] = '';
$update_geo['location_manual'] = 1;
$updated++;
}
}
if (!$updated) { unset($vars); } // If manual set, but coordinates wrong - reset edit
//r($vars);
}
if ($vars['submit'] === 'save') {
if (get_var_true($vars['reset_geolocation'])) {
$updated = dbDelete('devices_locations', '`device_id` = ?', [ $device['device_id'] ]);
} elseif ((bool)$vars['location_manual']) {
// Set manual coordinates if present
if (preg_match(OBS_PATTERN_LATLON, $vars['coordinates'], $matches) ||
preg_match(OBS_PATTERN_LATLON_ALT, $vars['coordinates'], $matches)) {
//r($matches);
if ($matches['lat'] >= -90 && $matches['lat'] <= 90 &&
$matches['lon'] >= -180 && $matches['lon'] <= 180) {
$update_geo['location_lat'] = $matches['lat'];
$update_geo['location_lon'] = $matches['lon'];
$update_geo['location_country'] = '';
$update_geo['location_manual'] = 1;
$updated++;
}
}
if (!$updated) {
unset($vars);
} // If manual set, but coordinates wrong - reset edit
//r($vars);
}
if ((bool)$device['location_manual'] && !(bool)$vars['location_manual']) {
// Reset manual flag, rediscover geo info
$update_geo['location_lat'] = [ 'NULL' ];
$update_geo['location_lon'] = [ 'NULL' ];
$update_geo['location_manual'] = 0;
$updated++;
}
if ((bool)$device['location_manual'] && !(bool)$vars['location_manual']) {
// Reset manual flag, rediscover geo info
$update_geo['location_lat'] = ['NULL'];
$update_geo['location_lon'] = ['NULL'];
$update_geo['location_manual'] = 0;
$updated++;
}
if ($updated) {
//r($update_geo);
if (!safe_empty($update_geo)) {
dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', [ $device['location_id'] ]);
if ($updated) {
//r($update_geo);
if (!safe_empty($update_geo)) {
dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', [$device['location_id']]);
}
$geo_db = dbFetchRow("SELECT * FROM `devices_locations` WHERE `device_id` = ?", [$device['device_id']]);
if (safe_count($geo_db)) {
if (get_var_true($vars['reset_geolocation'])) {
print_warning("Device Geo location dropped. Country/city will be updated on next poll.");
} else {
print_success("Device Geolocation updated. Country/city will be updated on next poll.");
}
}
$device = array_merge($device, (array)$geo_db);
unset($updated, $update_geo, $geo_db);
} else {
print_warning("Some input data wrong. Device Geolocation not changed.");
}
}
$geo_db = dbFetchRow("SELECT * FROM `devices_locations` WHERE `device_id` = ?", [ $device['device_id'] ]);
if (safe_count($geo_db)) {
if (get_var_true($vars['reset_geolocation'])) {
print_warning("Device Geo location dropped. Country/city will be updated on next poll.");
} else {
print_success("Device Geolocation updated. Country/city will be updated on next poll.");
}
}
$device = array_merge($device, (array)$geo_db);
unset($updated, $update_geo, $geo_db);
} else {
print_warning("Some input data wrong. Device Geolocation not changed.");
}
}
}
}
$location = [ 'location_text' => $device['location'] ];
$location = ['location_text' => $device['location']];
$override_sysLocation_bool = get_dev_attrib($device,'override_sysLocation_bool');
$override_sysLocation_bool = get_dev_attrib($device, 'override_sysLocation_bool');
if ($override_sysLocation_bool) {
$override_sysLocation_string = get_dev_attrib($device,'override_sysLocation_string');
if ($override_sysLocation_string != $device['location']) {
// Device not polled since location override
$location['location_help'] = 'NOTE, device not polled since location overridden, Geolocation is old.';
$location['location_text'] = $override_sysLocation_string;
}
$override_sysLocation_string = get_dev_attrib($device, 'override_sysLocation_string');
if ($override_sysLocation_string != $device['location']) {
// Device not polled since location override
$location['location_help'] = 'NOTE, device not polled since location overridden, Geolocation is old.';
$location['location_text'] = $override_sysLocation_string;
}
}
if (safe_empty($location['location_text'])) { $location['location_text'] = OBS_VAR_UNSET; }
foreach ([ 'location_lat', 'location_lon', 'location_city', 'location_county', 'location_state', 'location_country',
'location_geoapi', 'location_status', 'location_manual', 'location_updated' ] as $param) {
$location[$param] = $device[$param];
if (safe_empty($location['location_text'])) {
$location['location_text'] = OBS_VAR_UNSET;
}
foreach (['location_lat', 'location_lon', 'location_city', 'location_county', 'location_state', 'location_country',
'location_geoapi', 'location_status', 'location_manual', 'location_updated'] as $param) {
$location[$param] = $device[$param];
}
if (is_numeric($location['location_lat']) && is_numeric($location['location_lon'])) {
// Generate link to Google maps
// http://maps.google.com/maps?q=46.090271,6.657248+description+(name)
$location['coordinates'] = $location['location_lat'].','.$location['location_lon'];
$location['coordinates_manual'] = $location['coordinates'];
$location['location_link'] = '<a target="_blank" href="https://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="'.$config['icon']['map'].'"></i> View this location on a map</a>';
$location['location_geo'] = country_from_code($location['location_country']).' (Country), '.$location['location_state'].' (State), ';
$location['location_geo'] .= $location['location_county'] .' (County), ' .$location['location_city'] .' (City)';
switch ($location['location_geoapi']) {
//case 'yandex':
// // Generate link to Yandex maps
// $location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="oicon-map"></i> View this location on a map</a>';
// break;
default:
// Generate link to Google maps
// http://maps.google.com/maps?q=46.090271,6.657248+description+(name)
$location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="'.$config['icon']['map'].'"></i> View this location on a map</a>';
}
// Generate link to Google maps
// http://maps.google.com/maps?q=46.090271,6.657248+description+(name)
$location['coordinates'] = $location['location_lat'] . ',' . $location['location_lon'];
$location['coordinates_manual'] = $location['coordinates'];
$location['location_link'] = '<a target="_blank" href="https://maps.google.com/maps?q=' . urlencode($location['coordinates']) . '"><i class="' . $config['icon']['map'] . '"></i> View this location on a map</a>';
$location['location_geo'] = country_from_code($location['location_country']) . ' (Country), ' . $location['location_state'] . ' (State), ';
$location['location_geo'] .= $location['location_county'] . ' (County), ' . $location['location_city'] . ' (City)';
switch ($location['location_geoapi']) {
//case 'yandex':
// // Generate link to Yandex maps
// $location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="oicon-map"></i> View this location on a map</a>';
// break;
default:
// Generate link to Google maps
// http://maps.google.com/maps?q=46.090271,6.657248+description+(name)
$location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q=' . urlencode($location['coordinates']) . '"><i class="' . $config['icon']['map'] . '"></i> View this location on a map</a>';
}
} else {
$location['coordinates_manual'] = $config['geocoding']['default']['lat'].','.$config['geocoding']['default']['lon'];
$location['coordinates_manual'] = $config['geocoding']['default']['lat'] . ',' . $config['geocoding']['default']['lon'];
}
if ($updated && $update_message) {
print_message($update_message);
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
print_error($update_message);
}
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Geolocation Options',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Geolocation Options',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['sysLocation'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'sysLocation string',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_text']);
if ($location['location_help'])
{
$form['row'][1]['location_help'] = array(
'type' => 'raw',
'value' => '<span class="help-block"><small>'.$location['location_help'].'</small></span>');
}
$form['row'][2]['location_geo'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Location Place',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_geo']);
$form['row'][3]['location_lat'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Latitude/Longitude',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => ($location['location_lat'] ? $location['location_lat'] . ',' . $location['location_lon'] : ''));
if ($location['location_link'])
{
$form['row'][3]['location_link'] = array(
'type' => 'raw',
'value' => '<span class="help-block"><small>'.$location['location_link'].'</small></span>');
}
$form['row'][4]['location_geoapi'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'API used',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => strtoupper($location['location_geoapi']));
$form['row'][4]['help_link'] = array(
'type' => 'raw',
'value' => '<span class="help-inline"><small><a target="_blank" href="' . OBSERVIUM_DOCS_URL . '/config_options/#syslocation-configuration">
<i class="'.$config['icon']['question'].'"></i> View available Geolocation APIs and other configuration options</a></small></span>');
$form['row'][5]['location_updated'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Last updated',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_updated']);
$form['row'][6]['location_status'] = array(
'type' => 'textarea',
//'fieldset' => 'edit',
'name' => 'Last update status',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_status']);
$form['row'][7]['coordinates'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Manual coordinates',
'placeholder' => '',
'width' => '16.6667%',
'readonly' => $readonly,
'disabled' => !$location['location_manual'],
'value' => $location['coordinates_manual']);
$form['row'][7]['location_manual'] = array(
'type' => 'toggle',
'size' => 'large',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'coordinates')",
'value' => $location['location_manual']);
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['sysLocation'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'sysLocation string',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_text']];
if ($location['location_help']) {
$form['row'][1]['location_help'] = [
'type' => 'raw',
'value' => '<span class="help-block"><small>' . $location['location_help'] . '</small></span>'];
}
$form['row'][2]['location_geo'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Location Place',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_geo']];
$form['row'][3]['location_lat'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Latitude/Longitude',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => ($location['location_lat'] ? $location['location_lat'] . ',' . $location['location_lon'] : '')];
if ($location['location_link']) {
$form['row'][3]['location_link'] = [
'type' => 'raw',
'value' => '<span class="help-block"><small>' . $location['location_link'] . '</small></span>'];
}
$form['row'][4]['location_geoapi'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'API used',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => strtoupper($location['location_geoapi'])];
$form['row'][4]['help_link'] = [
'type' => 'raw',
'value' => '<span class="help-inline"><small><a target="_blank" href="' . OBSERVIUM_DOCS_URL . '/config_options/#syslocation-configuration">
<i class="' . $config['icon']['question'] . '"></i> View available Geolocation APIs and other configuration options</a></small></span>'];
$form['row'][5]['location_updated'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Last updated',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_updated']];
$form['row'][6]['location_status'] = [
'type' => 'textarea',
//'fieldset' => 'edit',
'name' => 'Last update status',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_status']];
$form['row'][7]['coordinates'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Manual coordinates',
'placeholder' => '',
'width' => '16.6667%',
'readonly' => $readonly,
'disabled' => !$location['location_manual'],
'value' => $location['coordinates_manual']];
$form['row'][7]['location_manual'] = [
'type' => 'toggle',
'size' => 'large',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'coordinates')",
'value' => $location['location_manual']];
$form['row'][8]['reset_geolocation'] = array(
'type' => 'switch-ng',
'name' => 'Reset GEO location',
//'fieldset' => 'edit',
'size' => 'small',
'readonly' => $readonly,
'on-color' => 'danger',
'off-color' => 'primary',
'on-text' => 'Reset',
'off-text' => 'Keep',
'value' => 0);
$form['row'][8]['reset_geolocation'] = [
'type' => 'switch-ng',
'name' => 'Reset GEO location',
//'fieldset' => 'edit',
'size' => 'small',
'readonly' => $readonly,
'on-color' => 'danger',
'off-color' => 'primary',
'on-text' => 'Reset',
'off-text' => 'Keep',
'value' => 0];
$form['row'][9]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form['row'][9]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);
print_form($form);
unset($form);
// EOF

View File

@ -1,124 +1,120 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
print_message("This page allows you to disable or enable certain Graphs detected for a device.");
$graphs_db = array();
foreach (dbFetchRows("SELECT `graph`,`enabled` FROM `device_graphs` WHERE `device_id` = ?", array($device['device_id'])) as $entry)
{
$graph = $entry['graph'];
$section = $config['graph_types']['device'][$graph]['section'];
$graphs_db[$graph] = (bool)$entry['enabled'];
// Another array sorted by sections
$graphs_sections[$section][$graph] = (bool)$entry['enabled'];
$graphs_db = [];
foreach (dbFetchRows("SELECT `graph`,`enabled` FROM `device_graphs` WHERE `device_id` = ?", [ $device['device_id'] ]) as $entry) {
$graph = $entry['graph'];
$section = $config['graph_types']['device'][$graph]['section'];
$graphs_db[$graph] = (bool)$entry['enabled'];
// Another array sorted by sections
$graphs_sections[$section][$graph] = (bool)$entry['enabled'];
}
if ($vars['submit'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$graph = $vars['toggle_graph'];
if ($graph && isset($graphs_db[$graph]) &&
!in_array($config['graph_types']['device'][$graph]['section'], array('poller', 'system')))
{
$value = (int)!$graphs_db[$graph]; // Toggle current 'enabled' value
$updated = dbUpdate(array('enabled' => $value), 'device_graphs', '`device_id` = ? AND `graph` = ?', array($device['device_id'], $graph));
if ($updated)
{
print_success("Graph '$graph' ".($value ? 'enabled' : 'disabled').'.');
$graphs_sections[$config['graph_types']['device'][$graph]['section']][$graph] = (bool)$value;
}
if ($vars['submit']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$graph = $vars['toggle_graph'];
if ($graph && isset($graphs_db[$graph]) &&
!in_array($config['graph_types']['device'][$graph]['section'], ['poller', 'system'])) {
$value = (int)!$graphs_db[$graph]; // Toggle current 'enabled' value
$updated = dbUpdate(['enabled' => $value], 'device_graphs', '`device_id` = ? AND `graph` = ?', [$device['device_id'], $graph]);
if ($updated) {
print_success("Graph '$graph' " . ($value ? 'enabled' : 'disabled') . '.');
$graphs_sections[$config['graph_types']['device'][$graph]['section']][$graph] = (bool)$value;
}
}
}
}
}
?>
<div class="row"> <!-- begin row -->
<div class="col-md-6"> <!-- begin poller options -->
<div class="row"> <!-- begin row -->
<div class="col-md-6"> <!-- begin poller options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Device Graphs</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Device Graphs</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed-more">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Section</th>
<th style="width: 60px;">Status</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed-more">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Section</th>
<th style="width: 60px;">Status</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
<?php
foreach ($graphs_sections as $section => $entry)
{
foreach ($entry as $graph => $enabled)
{
echo('<tr><td><strong>'.$graph.'</strong></td><td>');
echo($config['graph_types']['device'][$graph]['descr'].'</td><td>');
echo(nicecase($section).'</td><td>');
foreach ($graphs_sections as $section => $entry) {
foreach ($entry as $graph => $enabled) {
echo('<tr><td><strong>' . $graph . '</strong></td><td>');
echo($config['graph_types']['device'][$graph]['descr'] . '</td><td>');
echo(nicecase($section) . '</td><td>');
if (!$enabled)
{
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok';
} else {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
}
if (!$enabled) {
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
} else {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
}
echo($attrib_status.'</td><td>');
echo($attrib_status . '</td><td>');
if (!in_array($section, array('poller', 'system')))
{
$form = array('type' => 'simple');
// Elements
$form['row'][0]['toggle_graph'] = array('type' => 'hidden',
'value' => $graph);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'graph_toggle');
print_form($form); unset($form);
} else {
echo('<button id="submit" name="submit" type="submit" class="btn btn-default btn-mini pull-right disabled text-nowrap" disabled="1" value="Toggle"><i class="icon-lock"></i>&nbsp;Required</button>');
}
if (!in_array($section, ['poller', 'system'])) {
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_graph'] = ['type' => 'hidden',
'value' => $graph];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'graph_toggle'];
print_form($form);
unset($form);
} else {
echo('<button id="submit" name="submit" type="submit" class="btn btn-default btn-mini pull-right disabled text-nowrap" disabled="1" value="Toggle"><i class="icon-lock"></i>&nbsp;Required</button>');
}
echo('</td></tr>');
}
}
?>
</tbody>
</table>
echo('</td></tr>');
}
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end poller options -->
</div>
</div>
</div> <!-- end poller options -->
</div> <!-- end row -->
</div> <!-- end container -->
</div> <!-- end row -->
</div> <!-- end container -->
<?php
// EOF

View File

@ -1,113 +0,0 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
if ($vars['editing'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$param = array('icon' => $vars['icon']);
$rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id']));
if ($rows_updated > 0 || $updated)
{
$update_message = "Device icon updated.";
$updated = 1;
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
}
else if ($rows_updated = '-1')
{
$update_message = "Device icon unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device icon update error.";
}
}
if ($updated && $update_message)
{
print_message($update_message);
}
else if ($update_message)
{
print_error($update_message);
}
}
?>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Device icon</h3>
</div>
<form id="edit" name="edit" method="post" action="" class="form form-inline">
<div class="box-body" style="padding: 10px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<input type="hidden" name="editing" value="yes">
<table border="0">
<tr>
<?php
$numicons = 1;
// Default icon
$icon_default = $config['os'][$device['os']]['icon'];
echo(' <td width="64" align="center"><img src="images/os/' . $icon_default . '.png"><br /><i>' . nicecase($icon_default) . '</i><p />');
echo('<input name="icon" type="radio" value="' . $icon_default . '"' . ($device['icon'] == '' || $device['icon'] == $icon_default ? ' checked="1"' : '') . ' /></td>' . "\n");
foreach ($config['os'][$device['os']]['icons'] as $icon_new)
{
if ($icon_new != $icon)
{
echo(' <td align="center"><img src="images/os/' . $icon_new . '.png"><br /><i>' . ucwords(strtr($icon_new, '_', ' ')) . '</i><p />');
echo('<input name="icon" type="radio" value="' . $icon_new . '"' . ($device['icon'] == $icon_new ? ' checked="1"' : '') . ' /></td>' . "\n");
$numicons++;
}
}
if ($numicons %10 == 0)
{
echo(" </tr>\n");
echo(" <tr>\n");
}
?>
</tr>
</table>
<br />
</td>
</tr>
</table>
</div>
<div id="submit" class="box-footer">
<?php
$item = array('id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary',
'icon' => 'icon-ok icon-white',
'value' => 'save');
echo(generate_form_element($item, 'submit'));
?>
</div>
</form>
</div>
<?php
// EOF

View File

@ -4,129 +4,135 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['ipmi_hostname'] != '') { set_dev_attrib($device, 'ipmi_hostname' , $vars['ipmi_hostname']); } else { del_dev_attrib($device, 'ipmi_hostname'); }
if ($vars['ipmi_username'] != '') { set_dev_attrib($device, 'ipmi_username' , $vars['ipmi_username']); } else { del_dev_attrib($device, 'ipmi_username'); }
if ($vars['ipmi_password'] != '') { set_dev_attrib($device, 'ipmi_password' , $vars['ipmi_password']); } else { del_dev_attrib($device, 'ipmi_password'); }
if (is_numeric($vars['ipmi_port'])) { set_dev_attrib($device, 'ipmi_port' , $vars['ipmi_port']); } else { del_dev_attrib($device, 'ipmi_port'); }
// We check interface & userlevel input from the dropdown against the allowed values in the definition array.
if ($vars['ipmi_interface'] != '' && array_search($vars['ipmi_interface'], array_keys($config['ipmi']['interfaces'])) !== FALSE)
{
set_dev_attrib($device, 'ipmi_interface', $vars['ipmi_interface']);
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
del_dev_attrib($device, 'ipmi_interface');
print_error('Invalid interface specified (' . $vars['ipmi_interface'] . ').');
if ($vars['ipmi_hostname'] != '') {
set_dev_attrib($device, 'ipmi_hostname', $vars['ipmi_hostname']);
} else {
del_dev_attrib($device, 'ipmi_hostname');
}
if ($vars['ipmi_username'] != '') {
set_dev_attrib($device, 'ipmi_username', $vars['ipmi_username']);
} else {
del_dev_attrib($device, 'ipmi_username');
}
if ($vars['ipmi_password'] != '') {
set_dev_attrib($device, 'ipmi_password', $vars['ipmi_password']);
} else {
del_dev_attrib($device, 'ipmi_password');
}
if (is_numeric($vars['ipmi_port'])) {
set_dev_attrib($device, 'ipmi_port', $vars['ipmi_port']);
} else {
del_dev_attrib($device, 'ipmi_port');
}
// We check interface & userlevel input from the dropdown against the allowed values in the definition array.
if ($vars['ipmi_interface'] != '' && array_search($vars['ipmi_interface'], array_keys($config['ipmi']['interfaces'])) !== FALSE) {
set_dev_attrib($device, 'ipmi_interface', $vars['ipmi_interface']);
} else {
del_dev_attrib($device, 'ipmi_interface');
print_error('Invalid interface specified (' . $vars['ipmi_interface'] . ').');
}
if ($vars['ipmi_userlevel'] != '' && array_search($vars['ipmi_userlevel'], array_keys($config['ipmi']['userlevels'])) !== FALSE) {
set_dev_attrib($device, 'ipmi_userlevel', $vars['ipmi_userlevel']);
} else {
del_dev_attrib($device, 'ipmi_userlevel');
print_error('Invalid user level specified (' . $vars['ipmi_userlevel'] . ').');
}
$update_message = "Device IPMI data updated.";
$updated = 1;
}
if ($vars['ipmi_userlevel'] != '' && array_search($vars['ipmi_userlevel'], array_keys($config['ipmi']['userlevels'])) !== FALSE)
{
set_dev_attrib($device, 'ipmi_userlevel', $vars['ipmi_userlevel']);
} else {
del_dev_attrib($device, 'ipmi_userlevel');
print_error('Invalid user level specified (' . $vars['ipmi_userlevel'] . ').');
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
$update_message = "Device IPMI data updated.";
$updated = 1;
}
if ($updated && $update_message)
{
print_message($update_message);
}
else if ($update_message)
{
print_error($update_message);
}
}
if (!file_exists($config['ipmitool']))
{
print_warning("The ipmitool binary was not found at the configured path (" . $config['ipmitool'] . "). IPMI polling will not work.");
if (!file_exists($config['ipmitool'])) {
print_warning("The ipmitool binary was not found at the configured path (" . $config['ipmitool'] . "). IPMI polling will not work.");
}
$ipmi_userlevels = array();
foreach ($config['ipmi']['userlevels'] as $type => $descr)
{
$ipmi_userlevels[$type] = array('name' => $descr['text']);
$ipmi_userlevels = [];
foreach ($config['ipmi']['userlevels'] as $type => $descr) {
$ipmi_userlevels[$type] = ['name' => $descr['text']];
}
$ipmi_interfaces = array();
foreach ($config['ipmi']['interfaces'] as $type => $descr)
{
$ipmi_interfaces[$type] = array('name' => $descr['text']);
$ipmi_interfaces = [];
foreach ($config['ipmi']['interfaces'] as $type => $descr) {
$ipmi_interfaces[$type] = ['name' => $descr['text']];
}
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'IPMI Settings',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'IPMI Settings',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['ipmi_hostname'] = array(
'type' => 'text',
'name' => 'IPMI Hostname',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_hostname'));
$form['row'][2]['ipmi_port'] = array(
'type' => 'text',
'name' => 'IPMI Port',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_port'));
$form['row'][3]['ipmi_username'] = array(
'type' => 'text',
'name' => 'IPMI Username',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_username'));
$form['row'][4]['ipmi_password'] = array(
'type' => 'password',
'name' => 'IPMI Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => get_dev_attrib($device, 'ipmi_password'));
$form['row'][5]['ipmi_userlevel'] = array(
'type' => 'select',
'name' => 'IPMI Userlevel',
'width' => '250px',
'readonly' => $readonly,
'values' => $ipmi_userlevels,
'value' => get_dev_attrib($device, 'ipmi_userlevel'));
$form['row'][6]['ipmi_interface'] = array(
'type' => 'select',
'name' => 'IPMI Interface',
'width' => '250px',
'readonly' => $readonly,
'values' => $ipmi_interfaces,
'value' => get_dev_attrib($device, 'ipmi_interface'));
$form['row'][7]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['ipmi_hostname'] = [
'type' => 'text',
'name' => 'IPMI Hostname',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_hostname')];
$form['row'][2]['ipmi_port'] = [
'type' => 'text',
'name' => 'IPMI Port',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_port')];
$form['row'][3]['ipmi_username'] = [
'type' => 'text',
'name' => 'IPMI Username',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_username')];
$form['row'][4]['ipmi_password'] = [
'type' => 'password',
'name' => 'IPMI Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => get_dev_attrib($device, 'ipmi_password')];
$form['row'][5]['ipmi_userlevel'] = [
'type' => 'select',
'name' => 'IPMI Userlevel',
'width' => '250px',
'readonly' => $readonly,
'values' => $ipmi_userlevels,
'value' => get_dev_attrib($device, 'ipmi_userlevel')];
$form['row'][6]['ipmi_interface'] = [
'type' => 'select',
'name' => 'IPMI Interface',
'width' => '250px',
'readonly' => $readonly,
'values' => $ipmi_interfaces,
'value' => get_dev_attrib($device, 'ipmi_interface')];
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,7 +14,9 @@ include_once($config['install_dir'] . '/includes/polling/functions.inc.php');
// Fetch all MIBs we support for this specific OS
$mibs = [];
foreach (get_device_mibs($device) as $mib) { $mibs[$mib]++; }
foreach (get_device_mibs($device) as $mib) {
$mibs[$mib]++;
}
// Sort alphabetically
ksort($mibs);
@ -22,248 +24,250 @@ ksort($mibs);
$mibs_disabled = get_device_mibs_disabled($device);
if ($vars['submit']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['toggle_mib'] && isset($mibs[$vars['toggle_mib']])) {
$mib = $vars['toggle_mib'];
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['toggle_mib'] && isset($mibs[$vars['toggle_mib']])) {
$mib = $vars['toggle_mib'];
$mib_disabled = in_array($mib, $mibs_disabled);
if (!$config['mibs'][$mib]['enable']) {
// Globally disabled MIB
$where = "`device_id` = ? AND `use` = ? AND `mib` = ?";
$params = [ $device['device_id'], 'mib', $mib ];
$disabled = dbFetchCell("SELECT `disabled` FROM `devices_mibs` WHERE $where", $params);
//r($disabled);
$mib_disabled = $disabled !== '0';
if ($mib_disabled) {
set_device_mib_enable($device, $mib);
} else {
set_device_mib_disable($device, $mib, TRUE); // really just remove
}
} else {
if ($mib_disabled) {
set_device_mib_enable($device, $mib, TRUE); // really just remove
} else {
set_device_mib_disable($device, $mib);
}
}
$mib_disabled = in_array($mib, $mibs_disabled);
if (!$config['mibs'][$mib]['enable']) {
// Globally disabled MIB
$where = "`device_id` = ? AND `use` = ? AND `mib` = ?";
$params = [$device['device_id'], 'mib', $mib];
$disabled = dbFetchCell("SELECT `disabled` FROM `devices_mibs` WHERE $where", $params);
//r($disabled);
$mib_disabled = $disabled !== '0';
if ($mib_disabled) {
set_device_mib_enable($device, $mib);
} else {
set_device_mib_disable($device, $mib, TRUE); // really just remove
}
} else {
if ($mib_disabled) {
set_device_mib_enable($device, $mib, TRUE); // really just remove
} else {
set_device_mib_disable($device, $mib);
}
}
// reload attribs
unset($cache['devices']['mibs_disabled'][$device['device_id']]);
$mibs_disabled = get_device_mibs_disabled($device);
// reload attribs
unset($cache['devices']['mibs_disabled'][$device['device_id']]);
$mibs_disabled = get_device_mibs_disabled($device);
}
}
}
}
// Count critical errors into DB (only for poller)
$mib_grid = 12;
$mib_grid = 12;
$snmp_errors = [];
if ($config['snmp']['errors']) {
//$poll_period = 300;
$error_codes = $GLOBALS['config']['snmp']['errorcodes'];
$poll_period = $GLOBALS['config']['rrd']['step'];
//$poll_period = 300;
$error_codes = $GLOBALS['config']['snmp']['errorcodes'];
$poll_period = $GLOBALS['config']['rrd']['step'];
$sql = 'SELECT * FROM `snmp_errors` WHERE `device_id` = ?;';
foreach (dbFetchRows($sql, [ $device['device_id'] ]) as $entry) {
$timediff = $entry['updated'] - $entry['added'];
$poll_count = round(float_div($timediff, $poll_period)) + 1;
$sql = 'SELECT * FROM `snmp_errors` WHERE `device_id` = ?;';
foreach (dbFetchRows($sql, [$device['device_id']]) as $entry) {
$timediff = $entry['updated'] - $entry['added'];
$poll_count = round(float_div($timediff, $poll_period)) + 1;
$entry['error_rate'] = float_div($entry['error_count'], $poll_count); // calculate error rate
if ($oid = str_decompress($entry['oid'])) {
// 512 long oid strings is compressed
$entry['oid'] = $oid;
$entry['error_rate'] = float_div($entry['error_count'], $poll_count); // calculate error rate
if ($oid = str_decompress($entry['oid'])) {
// 512 long oid strings is compressed
$entry['oid'] = $oid;
}
$snmp_errors[$entry['mib']][] = $entry;
}
$snmp_errors[$entry['mib']][] = $entry;
}
if (count($snmp_errors)) {
ksort($snmp_errors);
$mib_grid = 5;
}
if (count($snmp_errors)) {
ksort($snmp_errors);
$mib_grid = 5;
}
}
print_warning("This page allows you to disable certain MIBs to be polled for a device. This configuration disables all discovery modules using this MIB.");
?>
<div class="row"> <!-- begin row -->
<div class="row"> <!-- begin row -->
<div class="col-md-<?php echo($mib_grid); ?>"> <!-- begin MIB options -->
<div class="col-md-<?php echo($mib_grid); ?>"> <!-- begin MIB options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Device MIBs</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Device MIBs</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed-more">
<thead>
<tr>
<th style="padding: 0px;"></th>
<th style="padding: 0px; width: 60px;"></th>
<th style="padding: 0px; width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed-more">
<thead>
<tr>
<th style="padding: 0px;"></th>
<th style="padding: 0px; width: 60px;"></th>
<th style="padding: 0px; width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
<?php
foreach ($mibs as $mib => $count) {
$mib_disabled = in_array($mib, $mibs_disabled);
$mib_errors = isset($snmp_errors[$mib]);
foreach ($mibs as $mib => $count) {
$mib_disabled = in_array($mib, $mibs_disabled);
$mib_errors = isset($snmp_errors[$mib]);
if (!$config['mibs'][$mib]['enable']) {
// Globally disabled MIB
$where = "`device_id` = ? AND `use` = ? AND `mib` = ?";
$params = [ $device['device_id'], 'mib', $mib ];
$disabled = dbFetchCell("SELECT `disabled` FROM `devices_mibs` WHERE $where", $params);
//r($disabled);
$mib_disabled = $disabled !== '0';
}
if ($mib_disabled) {
$attrib_status = '<span class="label label-error">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$class = ' class="ignore"';
} else {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
$class = $mib_errors ? ' class="error"' : '';
}
if (!$config['mibs'][$mib]['enable']) {
// Globally disabled MIB
$where = "`device_id` = ? AND `use` = ? AND `mib` = ?";
$params = [$device['device_id'], 'mib', $mib];
$disabled = dbFetchCell("SELECT `disabled` FROM `devices_mibs` WHERE $where", $params);
//r($disabled);
$mib_disabled = $disabled !== '0';
}
if ($mib_disabled) {
$attrib_status = '<span class="label label-error">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$class = ' class="ignore"';
} else {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
$class = $mib_errors ? ' class="error"' : '';
}
echo('<tr'. $class . '><td><strong>' . $mib . '</strong></td><td>' . $attrib_status . '</td><td>');
echo('<tr' . $class . '><td><strong>' . $mib . '</strong></td><td>' . $attrib_status . '</td><td>');
$form = [ 'type' => 'simple' ];
// Elements
$form['row'][0]['toggle_mib'] = [ 'type' => 'hidden',
'value' => $mib ];
$form['row'][0]['submit'] = [ 'type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'mib_toggle' ];
print_form($form);
unset($form);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_mib'] = ['type' => 'hidden',
'value' => $mib];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'mib_toggle'];
print_form($form);
unset($form);
echo('</td></tr>');
}
?>
</tbody>
</table>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end MIB options -->
<?php
</div>
</div>
</div> <!-- end MIB options -->
<?php
if (count($snmp_errors))
{
//r($snmp_errors);
if (count($snmp_errors)) {
//r($snmp_errors);
?>
<div class="col-md-7 col-md-pull-0"> <!-- begin Errors options -->
?>
<div class="col-md-7 col-md-pull-0"> <!-- begin Errors options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">SNMP errors</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">SNMP errors</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped-two table-condensed-more ">
<thead>
<tr>
<th style="padding: 0px; width: 40px;"></th>
<th style="padding: 0px;"></th>
<!--<th style="padding: 0px; width: 60px;"></th>-->
</tr>
</thead>
<tbody>
<table class="table table-striped-two table-condensed-more ">
<thead>
<tr>
<th style="padding: 0px; width: 40px;"></th>
<th style="padding: 0px;"></th>
<!--<th style="padding: 0px; width: 60px;"></th>-->
</tr>
</thead>
<tbody>
<?php
<?php
foreach ($snmp_errors as $mib => $entries)
{
$attrib_set = isset($attribs['mib_'.$mib]);
foreach ($snmp_errors as $mib => $entries) {
$attrib_set = isset($attribs['mib_' . $mib]);
echo('<tr><td><span class="label"><i class="icon-bell"></i> ' . count($entries) . '</span></td>');
echo('<tr><td><span class="label"><i class="icon-bell"></i> ' . count($entries) . '</span></td>');
//if ($attrib_set && $attribs['mib_'.$mib] == 0)
//{
// $attrib_status = '<span class="label label-error">disabled</span>';
//} else {
// $attrib_status = '<span class="label label-success">enabled</span>';
//}
//echo(<td>$attrib_status.'</td>');
//if ($attrib_set && $attribs['mib_'.$mib] == 0)
//{
// $attrib_status = '<span class="label label-error">disabled</span>';
//} else {
// $attrib_status = '<span class="label label-success">enabled</span>';
//}
//echo(<td>$attrib_status.'</td>');
echo('<td><strong>'.$mib.'</strong></td></tr>' . PHP_EOL);
echo('<td><strong>' . $mib . '</strong></td></tr>' . PHP_EOL);
// OIDs here
echo('<tr><td colspan="3">
// OIDs here
echo('<tr><td colspan="3">
<table class="table table-condensed-more">');
foreach ($entries as $error_db)
{
// Detect if error rate is exceeded
$error_both = isset($error_codes[$error_db['error_code']]['count']) && isset($error_codes[$error_db['error_code']]['rate']);
$error_count = isset($error_codes[$error_db['error_code']]['count']) && ($error_codes[$error_db['error_code']]['count'] < $error_db['error_count']);
$error_rate = isset($error_codes[$error_db['error_code']]['rate']) && ($error_codes[$error_db['error_code']]['rate'] < $error_db['error_rate']);
if ($error_both) { $error_exceeded = $error_count && $error_rate; }
else { $error_exceeded = $error_count || $error_rate; }
foreach ($entries as $error_db) {
// Detect if error rate is exceeded
$error_both = isset($error_codes[$error_db['error_code']]['count']) && isset($error_codes[$error_db['error_code']]['rate']);
$error_count = isset($error_codes[$error_db['error_code']]['count']) && ($error_codes[$error_db['error_code']]['count'] < $error_db['error_count']);
$error_rate = isset($error_codes[$error_db['error_code']]['rate']) && ($error_codes[$error_db['error_code']]['rate'] < $error_db['error_rate']);
if ($error_both) {
$error_exceeded = $error_count && $error_rate;
} else {
$error_exceeded = $error_count || $error_rate;
}
if ($error_exceeded)
{
$error_class = 'danger';
$error_class2 = 'error';
} else {
$error_class = $error_class2 = 'warning';
}
$text_class = (count(explode(' ', $error_db['oid'])) > 3 ? '' : 'text-nowrap');
echo('<tr width="100%" class="'.$error_class2.'"><td style="width: 50%;" class="'.$text_class.'"><strong><i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;'.$error_db['oid'].'</strong></td>' . PHP_EOL);
echo('<td style="width: 100px; white-space: nowrap; text-align: right;">'.generate_tooltip_time($error_db['updated'], 'ago').'</td>' . PHP_EOL);
echo('<td style="width: 80px; white-space: nowrap;"><span class="text-'.$error_class.'">'.$error_codes[$error_db['error_code']]['reason'].'</span></td>' . PHP_EOL);
echo('<td style="width: 40px; text-align: right;"><span class="label">'.$error_db['error_count'].'</span></td>' . PHP_EOL);
echo('<td style="width: 80px; text-align: right;"><span class="label">'.round($error_db['error_rate'], 2).'/poll</span></td>' . PHP_EOL);
if ($error_exceeded) {
$error_class = 'danger';
$error_class2 = 'error';
} else {
$error_class = $error_class2 = 'warning';
}
$text_class = (count(explode(' ', $error_db['oid'])) > 3 ? '' : 'text-nowrap');
echo('<tr width="100%" class="' . $error_class2 . '"><td style="width: 50%;" class="' . $text_class . '"><strong><i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;' . $error_db['oid'] . '</strong></td>' . PHP_EOL);
echo('<td style="width: 100px; white-space: nowrap; text-align: right;">' . generate_tooltip_time($error_db['updated'], 'ago') . '</td>' . PHP_EOL);
echo('<td style="width: 80px; white-space: nowrap;"><span class="text-' . $error_class . '">' . $error_codes[$error_db['error_code']]['reason'] . '</span></td>' . PHP_EOL);
echo('<td style="width: 40px; text-align: right;"><span class="label">' . $error_db['error_count'] . '</span></td>' . PHP_EOL);
echo('<td style="width: 80px; text-align: right;"><span class="label">' . round($error_db['error_rate'], 2) . '/poll</span></td>' . PHP_EOL);
echo('<td>' . PHP_EOL);
$form = array('type' => 'simple');
// Elements
$form['row'][0]['mib'] = array('type' => 'hidden',
'value' => $mib);
$form['row'][0]['toggle_oid'] = array('type' => 'hidden',
'value' => $error_db['oid']);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => '',
'class' => 'btn-mini btn-'.$error_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => TRUE, // This button disabled for now, because disabling oids in progress
'value' => 'toggle_oid');
print_form($form); unset($form);
echo('</td>' . PHP_EOL);
echo('<td>' . PHP_EOL);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['mib'] = ['type' => 'hidden',
'value' => $mib];
$form['row'][0]['toggle_oid'] = ['type' => 'hidden',
'value' => $error_db['oid']];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => '',
'class' => 'btn-mini btn-' . $error_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => TRUE, // This button disabled for now, because disabling oids in progress
'value' => 'toggle_oid'];
print_form($form);
unset($form);
echo('</td>' . PHP_EOL);
echo('</td></tr>' . PHP_EOL);
}
echo(' </table>
echo('</td></tr>' . PHP_EOL);
}
echo(' </table>
</td></tr>' . PHP_EOL);
}
?>
</tbody>
</table>
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end Errors options -->
</div>
</div>
</div> <!-- end Errors options -->
<?php } ?>
<?php } ?>
</div> <!-- end row -->
</div> <!-- end container -->
</div> <!-- end row -->
</div> <!-- end container -->
<?php
// EOF

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,374 +14,376 @@ include_once($config['install_dir'] . '/includes/polling/functions.inc.php');
include_once($config['install_dir'] . '/includes/discovery/functions.inc.php');
$ports_ignored_count = (int)get_entity_attrib('device', $device, 'ports_ignored_count'); // Cache last ports ignored count
$ports_total_count = $ports_ignored_count + dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `deleted` = ?', array($device['device_id'], 0));
$ports_total_count = $ports_ignored_count + dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `deleted` = ?', [$device['device_id'], 0]);
if ($vars['submit'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['toggle_poller'] && isset($config['poller_modules'][$vars['toggle_poller']]))
{
$module = $vars['toggle_poller'];
if (isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] != $config['poller_modules'][$module])
{
del_dev_attrib($device, 'poll_' . $module);
} elseif ($config['poller_modules'][$module] == 0) {
set_dev_attrib($device, 'poll_' . $module, "1");
} else {
set_dev_attrib($device, 'poll_' . $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
}
if ($vars['submit']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['toggle_poller'] && isset($config['poller_modules'][$vars['toggle_poller']])) {
$module = $vars['toggle_poller'];
if (isset($attribs['poll_' . $module]) && $attribs['poll_' . $module] != $config['poller_modules'][$module]) {
del_dev_attrib($device, 'poll_' . $module);
} elseif ($config['poller_modules'][$module] == 0) {
set_dev_attrib($device, 'poll_' . $module, "1");
} else {
set_dev_attrib($device, 'poll_' . $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
}
if ($vars['toggle_ports'] && isset($config[$vars['toggle_ports']]) && strpos($vars['toggle_ports'], 'enable_ports_') === 0)
{
$module = $vars['toggle_ports'];
$module_name = str_replace('enable_', '', $module);
if (isset($config['os'][$device['os']]['modules'][$module_name]))
{
$config_val = $config['os'][$device['os']]['modules'][$module_name];
} else {
$config_val = $config[$module];
}
if ($vars['submit'] === 'Disable' && $attribs[$module] !== '0')
{
set_dev_attrib($device, $module, "0");
}
elseif (isset($attribs[$module]) && $attribs[$module] != $config_val)
{
del_dev_attrib($device, $module);
} elseif ($config_val == 0) {
set_dev_attrib($device, $module, "1");
} else {
set_dev_attrib($device, $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
}
if ($vars['toggle_ports'] && isset($config[$vars['toggle_ports']]) && str_starts_with($vars['toggle_ports'], 'enable_ports_')) {
$module = $vars['toggle_ports'];
$module_name = str_replace('enable_', '', $module);
if ($vars['toggle_discovery'] && isset($config['discovery_modules'][$vars['toggle_discovery']]))
{
$module = $vars['toggle_discovery'];
if (isset($attribs['discover_'.$module]) && $attribs['discover_'.$module] != $config['discovery_modules'][$module])
{
del_dev_attrib($device, 'discover_' . $module);
} elseif ($config['discovery_modules'][$module] == 0) {
set_dev_attrib($device, 'discover_' . $module, "1");
} else {
set_dev_attrib($device, 'discover_' . $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
del_entity_attrib('device', $device, $module);
$config_val = is_module_enabled($device, $module_name, 'poller'); // Note, it's also with attrib check!
if ($vars['submit'] === 'Disable' && $attribs[$module] !== '0') {
//set_dev_attrib($device, $module, "0");
set_entity_attrib('device', $device, $module, '0');
} elseif (isset($attribs[$module]) && $attribs[$module] != $config_val) {
//del_dev_attrib($device, $module);
} elseif ($config_val == 0) {
//set_dev_attrib($device, $module, "1");
set_entity_attrib('device', $device, $module, '1');
} else {
//set_dev_attrib($device, $module, "0");
set_entity_attrib('device', $device, $module, '0');
}
$attribs = get_entity_attribs('device', $device);
}
if ($vars['toggle_discovery'] && isset($config['discovery_modules'][$vars['toggle_discovery']])) {
$module = $vars['toggle_discovery'];
if (isset($attribs['discover_' . $module]) && $attribs['discover_' . $module] != $config['discovery_modules'][$module]) {
del_dev_attrib($device, 'discover_' . $module);
} elseif ($config['discovery_modules'][$module] == 0) {
set_dev_attrib($device, 'discover_' . $module, "1");
} else {
set_dev_attrib($device, 'discover_' . $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
}
}
}
}
//r($device_state);
?>
<div class="row"> <!-- begin row -->
<div class="row"> <!-- begin row -->
<div class="col-md-6"> <!-- begin poller options -->
<div class="col-md-6"> <!-- begin poller options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Poller Modules</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Poller Modules</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last Poll</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last Poll</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
foreach (array_merge(array('os' => 1, 'system' => 1), $config['poller_modules']) as $module => $module_status)
{
//$module_status = is_module_enabled($device, $module, 'poller');
$attrib_set = isset($attribs['poll_'.$module]);
<?php
foreach (array_merge(['os' => 1, 'system' => 1], $config['poller_modules']) as $module => $module_status) {
//$module_status = is_module_enabled($device, $module, 'poller');
$attrib_set = isset($attribs['poll_' . $module]);
// Last module poll time and row class
$module_row_class = '';
if (!isset($device_state['poller_mod_perf'][$module]))
{
$module_time = '--';
}
elseif ($device_state['poller_mod_perf'][$module] < 0.01)
{
$module_time = $device_state['poller_mod_perf'][$module] . 's';
} else {
$module_time = format_value($device_state['poller_mod_perf'][$module]) . 's';
// Last module poll time and row class
$module_row_class = '';
if (!isset($device_state['poller_mod_perf'][$module])) {
$module_time = '--';
} elseif ($device_state['poller_mod_perf'][$module] < 0.01) {
$module_time = $device_state['poller_mod_perf'][$module] . 's';
} else {
$module_time = format_value($device_state['poller_mod_perf'][$module]) . 's';
if ($device_state['poller_mod_perf'][$module] > 10)
{
$module_row_class = 'error';
}
elseif ($device_state['poller_mod_perf'][$module] > 3)
{
$module_row_class = 'warning';
}
}
if ($device_state['poller_mod_perf'][$module] > 10) {
$module_row_class = 'error';
} elseif ($device_state['poller_mod_perf'][$module] > 3) {
$module_row_class = 'warning';
}
}
echo('<tr class="'.$module_row_class.'"><td><strong>'.$module.'</strong></td>');
echo('<td>'.$module_time.'</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$disabled = FALSE;
if ($module === 'os' || $module === 'system') {
$attrib_status = '<span class="label label-default">locked</span>';
$toggle = "Locked";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (poller_module_excluded($device, $module)) {
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (is_module_enabled($device, $module, 'poller')) {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
} elseif ($module_status) {
// highlight disabled module on device
$module_row_class = 'suppressed';
}
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok';
$disabled = FALSE;
if ($module == 'os' || $module == 'system')
{
$attrib_status = '<span class="label label-default">locked</span>';
$toggle = "Locked"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
}
elseif (poller_module_excluded($device, $module))
{
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
}
//elseif (($attrib_set && $attribs['poll_'.$module]) || (!$attrib_set && $module_status))
elseif (is_module_enabled($device, $module, 'poller'))
{
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
}
echo($attrib_status.'</td><td>');
echo('<tr class="' . $module_row_class . '"><td><strong>' . $module . '</strong></td>');
echo('<td>' . $module_time . '</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
echo($attrib_status . '</td><td>');
$form = array('type' => 'simple');
// Elements
$form['row'][0]['toggle_poller'] = array('type' => 'hidden',
'value' => $module);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => 'Toggle');
print_form($form); unset($form);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_poller'] = ['type' => 'hidden',
'value' => $module];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => 'Toggle'];
print_form($form);
unset($form);
echo('</td></tr>');
}
?>
</tbody>
</table>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end poller options -->
</div>
</div>
</div> <!-- end poller options -->
<div class="col-md-6"> <!-- begin ports options -->
<div class="col-md-6"> <!-- begin ports options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Ports polling options</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Ports polling options</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last Poll</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last Poll</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
foreach (array_keys($config) as $module) {
if (!str_starts($module, 'enable_ports_')) { continue; }
<?php
foreach (array_keys($config) as $module) {
if (!str_starts($module, 'enable_ports_')) {
continue;
}
$attrib_set = isset($attribs[$module]);
$module_name = str_replace('enable_ports_', '', $module);
$module_status = is_module_enabled($device, 'ports_'.$module_name, 'poller', FALSE);
$attrib_set = isset($attribs[$module]);
$module_name = str_replace('enable_ports_', '', $module);
$module_status = is_module_enabled($device, 'ports_' . $module_name, 'poller');
// Last ports module poll time and row class
$module_row_class = '';
if ($module_name === 'separate_walk' || $module_name === '64bit') {
$module_time = ''; // nothing to show for this pseudo-module
} elseif (!isset($device_state['poller_ports_perf'][$module_name])) {
$module_time = '--';
} elseif ($device_state['poller_ports_perf'][$module_name] < 0.01) {
$module_time = $device_state['poller_ports_perf'][$module_name] . 's';
} else {
$module_time = format_value($device_state['poller_ports_perf'][$module_name]) . 's';
// Last ports module poll time and row class
$module_row_class = '';
if ($module_name === 'separate_walk' || $module_name === '64bit') {
$module_time = ''; // nothing to show for this pseudo-module
} elseif (!isset($device_state['poller_ports_perf'][$module_name])) {
$module_time = '--';
} elseif ($device_state['poller_ports_perf'][$module_name] < 0.01) {
$module_time = $device_state['poller_ports_perf'][$module_name] . 's';
} else {
$module_time = format_value($device_state['poller_ports_perf'][$module_name]) . 's';
if ($device_state['poller_ports_perf'][$module_name] > 10) {
$module_row_class = 'error';
} elseif ($device_state['poller_ports_perf'][$module_name] > 3) {
$module_row_class = 'warning';
}
}
if ($device_state['poller_ports_perf'][$module_name] > 10) {
$module_row_class = 'error';
} elseif ($device_state['poller_ports_perf'][$module_name] > 3) {
$module_row_class = 'warning';
}
}
echo('<tr class="'.$module_row_class.'"><td><strong>'.$module_name.'</strong></td>');
echo('<td>'.$module_time.'</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
echo('<tr class="' . $module_row_class . '"><td><strong>' . $module_name . '</strong></td>');
echo('<td>' . $module_time . '</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok';
$value = 'Toggle';
$disabled = FALSE;
if ($module === 'enable_ports_junoseatmvp' && $device['os'] !== 'junose') { /// FIXME. see here includes/discovery/junose-atm-vp.inc.php
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (($attrib_set && $attribs[$module]) || (!$attrib_set && $module_status)) {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
} elseif ($module === 'enable_ports_separate_walk' && !$attrib_set) {
// Model definition can override os definition
$model_separate_walk = isset($model['ports_separate_walk']) && $model['ports_separate_walk'];
if ($model_separate_walk && $ports_total_count > 10) {
$attrib_status = '<span class="label label-warning">FORCED</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
$value = 'Disable';
} elseif ((int)$device['state']['poller_mod_perf']['ports'] < 20 && $ports_total_count <= 10) {
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
}
}
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$value = 'Toggle';
$disabled = FALSE;
if ($module === 'enable_ports_junoseatmvp' && $device['os'] !== 'junose') { /// FIXME. see here includes/discovery/junose-atm-vp.inc.php
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (($attrib_set && $attribs[$module]) || (!$attrib_set && $module_status)) {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
} elseif ($module === 'enable_ports_separate_walk' && !$attrib_set) {
// Model definition can override os definition
$model_separate_walk = isset($model['ports_separate_walk']) && $model['ports_separate_walk'];
if ($model_separate_walk && $ports_total_count > 10) {
$attrib_status = '<span class="label label-warning">FORCED</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
$value = 'Disable';
} elseif ((int)$device['state']['poller_mod_perf']['ports'] < 20 && $ports_total_count <= 10) {
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
}
}
echo($attrib_status . '</td><td>');
echo($attrib_status . '</td><td>');
$form = array('type' => 'simple');
// Elements
$form['row'][0]['toggle_ports'] = array('type' => 'hidden',
'value' => $module);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => $value);
print_form($form); unset($form);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_ports'] = ['type' => 'hidden',
'value' => $module];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => $value];
print_form($form);
unset($form);
echo('</td></tr>');
}
?>
</tbody>
</table>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end ports options -->
</div>
</div>
</div> <!-- end ports options -->
<div class="col-md-6"> <!-- begin discovery options -->
<div class="col-md-6"> <!-- begin discovery options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Discovery Modules</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Discovery Modules</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
foreach ($config['discovery_modules'] as $module => $module_status)
{
//$module_status = is_module_enabled($device, $module, 'discovery');
$attrib_set = isset($attribs['discover_'.$module]);
<?php
foreach ($config['discovery_modules'] as $module => $module_status) {
//$module_status = is_module_enabled($device, $module, 'discovery');
$attrib_set = isset($attribs['discover_' . $module]);
// Last module discovery time and row class
$module_row_class = '';
if (!isset($device_state['discovery_mod_perf'][$module]))
{
$module_time = '--';
}
elseif ($device_state['discovery_mod_perf'][$module] < 0.01)
{
$module_time = $device_state['discovery_mod_perf'][$module] . 's';
} else {
$module_time = format_value($device_state['discovery_mod_perf'][$module]) . 's';
// Last module discovery time and row class
$module_row_class = '';
if (!isset($device_state['discovery_mod_perf'][$module])) {
$module_time = '--';
} elseif ($device_state['discovery_mod_perf'][$module] < 0.01) {
$module_time = $device_state['discovery_mod_perf'][$module] . 's';
} else {
$module_time = format_value($device_state['discovery_mod_perf'][$module]) . 's';
if ($device_state['discovery_mod_perf'][$module] > 10)
{
$module_row_class = 'error';
}
elseif ($device_state['discovery_mod_perf'][$module] > 3)
{
$module_row_class = 'warning';
}
}
if ($device_state['discovery_mod_perf'][$module] > 10) {
$module_row_class = 'error';
} elseif ($device_state['discovery_mod_perf'][$module] > 3) {
$module_row_class = 'warning';
}
}
echo('<tr class="'.$module_row_class.'"><td><strong>'.$module.'</strong></td>');
echo('<td>'.$module_time.'</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
echo('<tr class="' . $module_row_class . '"><td><strong>' . $module . '</strong></td>');
echo('<td>' . $module_time . '</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok';
$disabled = FALSE;
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$disabled = FALSE;
if (in_array($module, (array)$config['os'][$device['os']]['discovery_blacklist']))
{
$attrib_status = '<span class="label label-disabled">excluded</span>';
$toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
}
//elseif (($attrib_set && $attribs['discover_'.$module]) || (!$attrib_set && $module_status))
elseif (is_module_enabled($device, $module, 'discovery'))
{
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
}
if (in_array($module, (array)$config['os'][$device['os']]['discovery_blacklist'])) {
$attrib_status = '<span class="label label-disabled">excluded</span>';
$toggle = "Excluded";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (is_module_enabled($device, $module, 'discovery')) {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
}
echo($attrib_status . '</td><td>');
echo($attrib_status . '</td><td>');
$form = array('type' => 'simple');
// Elements
$form['row'][0]['toggle_discovery'] = array('type' => 'hidden',
'value' => $module);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => 'Toggle');
print_form($form); unset($form);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_discovery'] = ['type' => 'hidden',
'value' => $module];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => 'Toggle'];
print_form($form);
unset($form);
echo('</td></tr>');
}
?>
</tbody>
</table>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end discovery options -->
</div>
</div>
</div> <!-- end discovery options -->
</div> <!-- end row -->
</div> <!-- end row -->
<?php
// EOF

View File

@ -4,102 +4,102 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$svcs = dbFetchRows("SELECT * FROM `netscaler_services` WHERE `device_id` = ? ORDER BY `svc_name`", array($device['device_id']));
$svcs = dbFetchRows("SELECT * FROM `netscaler_services` WHERE `device_id` = ? ORDER BY `svc_name`", [$device['device_id']]);
#print_vars($svcs);
if ($vars['submit'] == "update-svcs")
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
foreach ($svcs as $svc)
{
if ($vars['svcs'][$svc['svc_id']]['svc_ignore'] == 'on' || $vars['svcs'][$svc['svc_id']]['svc_ignore'] == '1') { $vars['svcs'][$svc['svc_id']]['svc_ignore'] = "1"; } else { $vars['svcs'][$svc['svc_id']]['svc_ignore'] = "0"; }
if ($vars['submit'] == "update-svcs") {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
foreach ($svcs as $svc) {
if ($vars['svcs'][$svc['svc_id']]['svc_ignore'] == 'on' || $vars['svcs'][$svc['svc_id']]['svc_ignore'] == '1') {
$vars['svcs'][$svc['svc_id']]['svc_ignore'] = "1";
} else {
$vars['svcs'][$svc['svc_id']]['svc_ignore'] = "0";
}
foreach (array('svc_ignore','svc_limit_low','svc_limit') as $field)
{
if ($vars['svcs'][$svc['svc_id']][$field] != $svc[$field]) { $sup[$field] = $vars['svcs'][$svc['svc_id']][$field]; }
}
foreach (['svc_ignore', 'svc_limit_low', 'svc_limit'] as $field) {
if ($vars['svcs'][$svc['svc_id']][$field] != $svc[$field]) {
$sup[$field] = $vars['svcs'][$svc['svc_id']][$field];
}
}
if (is_array($sup))
{
dbUpdate($sup, 'netscaler_services', '`svc_id` = ?', array($svc['svc_id']));
$did_update = TRUE;
}
unset($sup);
if (is_array($sup)) {
dbUpdate($sup, 'netscaler_services', '`svc_id` = ?', [$svc['svc_id']]);
$did_update = TRUE;
}
unset($sup);
}
$svcs = dbFetchRows("SELECT * FROM `netscaler_services` WHERE `device_id` = ? ORDER BY `svc_label`", [$device['device_id']]);
}
$svcs = dbFetchRows("SELECT * FROM `netscaler_services` WHERE `device_id` = ? ORDER BY `svc_label`", array($device['device_id']));
}
}
?>
<form id='update-svcs' name='update-svcs' method='post' action=''>
<fieldset>
<legend>Netscaler Service Properties</legend>
<form id='update-svcs' name='update-svcs' method='post' action=''>
<fieldset>
<legend>Netscaler Service Properties</legend>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 120px;">Type</th>
<th>Name</th>
<th style="width: 120px;">Status</th>
<th style="width: 80px;">Alerts</th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 120px;">Type</th>
<th>Name</th>
<th style="width: 120px;">Status</th>
<th style="width: 80px;">Alerts</th>
</tr>
</thead>
<tbody>
<?php
$row=1;
foreach ($svcs as $svc)
{
<?php
$row = 1;
foreach ($svcs as $svc) {
echo('<tr>');
echo('<td>'.escape_html($svc['svc_type']).'</td>');
echo('<td>'.escape_html($svc['svc_label']).'</td>');
echo('<td>'.escape_html($svc['svc_state']).'</td>');
$item = array(
'id' => 'svcs['.$svc['svc_id'].'][svc_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $svc['svc_ignore']);
echo('<td>'.generate_form_element($item).'</td>');
echo('</tr>');
}
?>
echo('<tr>');
echo('<td>' . escape_html($svc['svc_type']) . '</td>');
echo('<td>' . escape_html($svc['svc_label']) . '</td>');
echo('<td>' . escape_html($svc['svc_state']) . '</td>');
$item = [
'id' => 'svcs[' . $svc['svc_id'] . '][svc_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $svc['svc_ignore']];
echo('<td>' . generate_form_element($item) . '</td>');
echo('</tr>');
}
?>
</tbody>
</table>
</fieldset>
</tbody>
</table>
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="update-svcs"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</form>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="update-svcs"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</form>
<?php
// EOF

View File

@ -4,102 +4,102 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$vsvrs = dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_label`", array($device['device_id']));
$vsvrs = dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_label`", [$device['device_id']]);
#print_r($vsvrs);
if ($vars['submit'] == "update-vsvrs")
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
foreach ($vsvrs as $vsvr)
{
if ($vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] == 'on' || $vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] == '1') { $vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] = "1"; } else { $vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] = "0"; }
if ($vars['submit'] == "update-vsvrs") {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
foreach ($vsvrs as $vsvr) {
if ($vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] == 'on' || $vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] == '1') {
$vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] = "1";
} else {
$vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] = "0";
}
foreach (array('vsvr_ignore','vsvr_limit_low','vsvr_limit') as $field)
{
if ($vars['vsvrs'][$vsvr['vsvr_id']][$field] != $vsvr[$field]) { $sup[$field] = $vars['vsvrs'][$vsvr['vsvr_id']][$field]; }
}
foreach (['vsvr_ignore', 'vsvr_limit_low', 'vsvr_limit'] as $field) {
if ($vars['vsvrs'][$vsvr['vsvr_id']][$field] != $vsvr[$field]) {
$sup[$field] = $vars['vsvrs'][$vsvr['vsvr_id']][$field];
}
}
if (is_array($sup))
{
dbUpdate($sup, 'netscaler_vservers', '`vsvr_id` = ?', array($vsvr['vsvr_id']));
$did_update = TRUE;
}
unset($sup);
if (is_array($sup)) {
dbUpdate($sup, 'netscaler_vservers', '`vsvr_id` = ?', [$vsvr['vsvr_id']]);
$did_update = TRUE;
}
unset($sup);
}
$vsvrs = dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_label`", [$device['device_id']]);
}
$vsvrs = dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_label`", array($device['device_id']));
}
}
?>
<form id='update-vsvrs' name='update-vsvrs' method='post' action=''>
<fieldset>
<legend>Netscaler vServer Properties</legend>
<form id='update-vsvrs' name='update-vsvrs' method='post' action=''>
<fieldset>
<legend>Netscaler vServer Properties</legend>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 120px;">MIB Type</th>
<th>Name</th>
<th style="width: 60px;">Status</th>
<th style="width: 50px;">Alerts</th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 120px;">MIB Type</th>
<th>Name</th>
<th style="width: 60px;">Status</th>
<th style="width: 50px;">Alerts</th>
</tr>
</thead>
<tbody>
<?php
$row=1;
foreach ($vsvrs as $vsvr)
{
<?php
$row = 1;
foreach ($vsvrs as $vsvr) {
echo('<tr>');
echo('<td>'.escape_html($vsvr['vsvr_type']).'</td>');
echo('<td>'.escape_html($vsvr['vsvr_label']).'</td>');
echo('<td>'.escape_html($vsvr['vsvr_state']).'</td>');
$item = array(
'id' => 'vsvrs['.$vsvr['vsvr_id'].'][vsvr_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $vsvr['vsvr_ignore']);
echo('<td>'.generate_form_element($item).'</td>');
echo('</tr>');
}
?>
echo('<tr>');
echo('<td>' . escape_html($vsvr['vsvr_type']) . '</td>');
echo('<td>' . escape_html($vsvr['vsvr_label']) . '</td>');
echo('<td>' . escape_html($vsvr['vsvr_state']) . '</td>');
$item = [
'id' => 'vsvrs[' . $vsvr['vsvr_id'] . '][vsvr_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $vsvr['vsvr_ignore']];
echo('<td>' . generate_form_element($item) . '</td>');
echo('</tr>');
}
?>
</tbody>
</table>
</fieldset>
</tbody>
</table>
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="update-vsvrs"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</form>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="update-vsvrs"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</form>
<?php
// EOF

View File

@ -6,12 +6,12 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($readonly && $vars['ignoreport']) {
print_error_permission('You have insufficient permissions to edit settings.');
print_error_permission('You have insufficient permissions to edit settings.');
}
?>
@ -26,27 +26,27 @@ if ($readonly && $vars['ignoreport']) {
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element([ 'type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
echo generate_form_element(['type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken']]) . PHP_EOL;
}
$item = [
'id' => 'action',
'id' => 'action',
//'readonly' => $readonly,
'value' => 'ports_update'
];
echo(generate_form_element($item, 'hidden'));
$item = [
'id' => 'ignoreport',
'id' => 'ignoreport',
'readonly' => $readonly,
'value' => 'yes'
'value' => 'yes'
];
echo(generate_form_element($item, 'hidden'));
$item = [
'id' => 'device',
'id' => 'device',
'readonly' => $readonly,
'value' => $device['device_id']
'value' => $device['device_id']
];
echo(generate_form_element($item, 'hidden'));
@ -79,8 +79,8 @@ if ($readonly && $vars['ignoreport']) {
id="alerted-toggle" title="Toggle alerting on all currently-alerted ports">Enabled &
Down
</button>
<button class="btn btn-xs" value="Disabled" id="down-select"
title="Disable alerting on all currently-down ports">Disabled
<button class="btn btn-xs" value="All Down" id="down-select"
title="Disable alerting on all currently-down ports">All Down
</button>
</td>
<td class="text-center">
@ -117,52 +117,52 @@ if ($readonly && $vars['ignoreport']) {
$ports_attribs = get_device_entities_attribs($device['device_id'], 'port'); // Get all attribs
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `deleted` = '0' AND `device_id` = ? ORDER BY `ifIndex` ", array($device['device_id'])) as $port) {
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `deleted` = '0' AND `device_id` = ? ORDER BY CAST(`ifIndex` as SIGNED INTEGER) ", [$device['device_id']]) as $port) {
humanize_port($port);
if (isset($ports_attribs['port'][$port['port_id']])) {
$port = array_merge($port, $ports_attribs['port'][$port['port_id']]);
}
echo('<tr class="' . $port['row_class'] . ' vertical-align">');
echo('<tr class="' . $port['row_class'] . ' vertical-align" data-name="port_' . $port['port_id'] . '">');
echo('<td class="state-marker"></td>');
echo("<td>" . $port['ifIndex'] . "</td>");
echo('<td style="vertical-align: top;"><span class="entity">' . generate_entity_link('port', $port) . '</span><br />' . escape_html($port['ifAlias']) . '</td>');
echo '<td><span class="label label-'.get_type_class($port['ifType']).'">' . $port['human_type'] . '</span><br />';
echo '<td><span class="label label-' . get_type_class($port['ifType']) . '">' . $port['human_type'] . '</span><br />';
//r($port);
echo ('<span class="label label-'.$port['admin_class'].'">' . $port['admin_status'] . '</span>
echo('<span class="label label-' . $port['admin_class'] . '">' . $port['admin_status'] . '</span>
<span data-name="operstatus_' . $port['port_id'] . '" class="label label-' . $port['oper_class'] . '">' . escape_html($port['ifOperStatus']) . '</span></td>');
echo('<td class="text-center">');
$item = array('id' => 'port['.$port['port_id'].']',
'readonly' => $readonly,
'value' => $port['port_id']);
$item = ['id' => 'port[' . $port['port_id'] . ']',
'readonly' => $readonly,
'value' => $port['port_id']];
echo(generate_form_element($item, 'hidden'));
$item = array('id' => 'port[' . $port['port_id'] . '][disabled]',
'size' => 'mini',
'on-text' => 'Disable',
'on-color' => 'danger',
'off-text' => 'Poll',
'off-color' => 'success',
'width' => '58px',
'readonly' => $readonly,
'value' => $port['disabled']);
$item = ['id' => 'port[' . $port['port_id'] . '][disabled]',
'size' => 'mini',
'on-text' => 'Disable',
'on-color' => 'danger',
'off-text' => 'Poll',
'off-color' => 'success',
'width' => '58px',
'readonly' => $readonly,
'value' => $port['disabled']];
echo(generate_form_element($item, 'switch-ng'));
echo("</td>");
echo('<td class="text-center">');
$item = array('id' => 'port[' . $port['port_id'] . '][ignore]',
'size' => 'mini',
'on-text' => 'Ignore',
'on-color' => 'danger',
'off-text' => 'Alerts',
'off-color' => 'success',
'width' => '58px',
'readonly' => $readonly,
'value' => $port['ignore']);
$item = ['id' => 'port[' . $port['port_id'] . '][ignore]',
'size' => 'mini',
'on-text' => 'Ignore',
'on-color' => 'danger',
'off-text' => 'Alerts',
'off-color' => 'success',
'width' => '58px',
'readonly' => $readonly,
'value' => $port['ignore']];
echo(generate_form_element($item, 'switch-ng'));
echo("</td>");
@ -176,27 +176,27 @@ if ($readonly && $vars['ignoreport']) {
// Custom port speed
echo '<td class="text-nowrap">';
$ifSpeed_custom_bool = isset($port['ifSpeed_custom']);
$ifSpeed = $ifSpeed_custom_bool ? $port['ifSpeed_custom'] : $port['ifSpeed'];
$item = array('id' => 'port[' . $port['port_id'] . '][ifSpeed_custom]',
//'name' => 'Group name',
'placeholder' => formatRates($port['ifSpeed'], 4, 4),
'disabled' => !$ifSpeed_custom_bool,
'width' => '75px',
'readonly' => $readonly,
//'ajax' => TRUE,
//'ajax_vars' => array('field' => 'ifspeed'),
'value' => formatRates($ifSpeed, 4, 4));
$ifSpeed = $ifSpeed_custom_bool ? $port['ifSpeed_custom'] : $port['ifSpeed'];
$item = ['id' => 'port[' . $port['port_id'] . '][ifSpeed_custom]',
//'name' => 'Group name',
'placeholder' => format_bps($port['ifSpeed'], 4, 4),
'disabled' => !$ifSpeed_custom_bool,
'width' => '75px',
'readonly' => $readonly,
//'ajax' => TRUE,
//'ajax_vars' => array('field' => 'ifspeed'),
'value' => format_bps($ifSpeed, 4, 4)];
echo(generate_form_element($item, 'text'));
echo('</td>');
echo '<td>';
// Custom port speed toggle switch
$item = array('id' => 'port[' . $port['port_id'] . '][ifSpeed_custom_bool]',
'size' => 'large',
'view' => $locked ? 'lock' : 'square', // note this is data-tt-type, but 'type' key reserved for element type
'onchange' => "toggleAttrib('disabled', obj.attr('data-onchange-id'));",
'onchange-id' => 'port[' . $port['port_id'] . '][ifSpeed_custom]', // target id for onchange, set attrib: data-onchange-id
'value' => (bool)$ifSpeed_custom_bool);
$item = ['id' => 'port[' . $port['port_id'] . '][ifSpeed_custom_bool]',
'size' => 'large',
'view' => $locked ? 'lock' : 'square', // note this is data-tt-type, but 'type' key reserved for element type
'onchange' => "toggleAttrib('disabled', obj.attr('data-onchange-id'));",
'onchange-id' => 'port[' . $port['port_id'] . '][ifSpeed_custom]', // target id for onchange, set attrib: data-onchange-id
'value' => (bool)$ifSpeed_custom_bool];
echo(generate_form_element($item, 'toggle'));
echo '</span>';
@ -206,7 +206,7 @@ if ($readonly && $vars['ignoreport']) {
echo '<td>';
if ($port['port_64bit'] == 1) {
echo '<span class="label label-success">64bit</span>';
} else if ($port['port_64bit'] == 0) {
} elseif ($port['port_64bit'] == 0) {
echo '<span class="label label-warning">32bit</span>';
} else {
echo '<span class="label">Unchecked</span>';
@ -214,7 +214,7 @@ if ($readonly && $vars['ignoreport']) {
echo '</td></tr>' . PHP_EOL;
$row++;
//$row++;
}
?>
</table>
@ -222,12 +222,12 @@ if ($readonly && $vars['ignoreport']) {
<div id="submit" class="box-footer">
<?php
$item = array('id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary pull-right',
'icon' => 'icon-ok icon-white',
'readonly' => $readonly,
'value' => 'save');
$item = ['id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary pull-right',
'icon' => 'icon-ok icon-white',
'readonly' => $readonly,
'value' => 'save'];
echo(generate_form_element($item, 'submit'));
?>
</div>
@ -237,7 +237,7 @@ if ($readonly && $vars['ignoreport']) {
<script type="text/javascript">
$('#disable-toggle').click(function (event) {
// invert selection on all disable buttons
// invert selection on all disabled buttons
event.preventDefault();
$('[name$="[disabled]"]').each(function () {
$(this).bootstrapToggle('toggle');
@ -257,7 +257,8 @@ if ($readonly && $vars['ignoreport']) {
event.preventDefault();
$('.error').each(function () {
var name = $(this).attr('data-name');
if (name) {
if (name.match("^port_")) {
//console.log(name);
// get the interface number from the object name
var port_id = name.split('_')[1];
// find its corresponding checkbox and toggle it

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,7 +14,7 @@ $query = 'SELECT * FROM `sensors`
WHERE `device_id` = ? AND `sensor_deleted` = 0
ORDER BY `sensor_class`,`sensor_type`,`sensor_index`;';
$sensors = dbFetchRows($query, array($device['device_id']));
$sensors = dbFetchRows($query, [$device['device_id']]);
//foreach ($limits_reset_array as $class => $descr)
//{
@ -24,213 +24,214 @@ $sensors = dbFetchRows($query, array($device['device_id']));
?>
<form id="update-sensors">
<form id="update-sensors">
<input type="hidden" name="action" value="sensors_update">
<input type="hidden" name="action" value="sensors_update">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Sensor Properties</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed vertical-align">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Sensor Properties</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed vertical-align">
<thead>
<tr>
<th class="state-marker" rowspan="2"></th>
<th rowspan="2">Description &amp; MIB</th>
<th style="width: 100px;" rowspan="2">Class</th>
<th style="width: 60px;" rowspan="2">Current</th>
<th style="width: 250px; white-space: nowrap;" colspan="6">Limits</th>
<th style="width: 50px;" rowspan="2">Alerts</th>
</tr>
<tr>
<td>[ Min</td>
<td>Min Warn</td>
<td>Max Warn</td>
<td>Max</td>
<td style="width: 4%;">Custom</td>
<td style="width: 4%;">Reset ]</td>
</tr>
</thead>
<thead>
<tr>
<th class="state-marker" rowspan="2"></th>
<th rowspan="2">Description &amp; MIB</th>
<th style="width: 100px;" rowspan="2">Class</th>
<th style="width: 60px;" rowspan="2">Current</th>
<th style="width: 250px; white-space: nowrap;" colspan="6">Limits</th>
<th style="width: 50px;" rowspan="2">Alerts</th>
</tr>
<tr>
<td>[ Min</td>
<td>Min Warn</td>
<td>Max Warn</td>
<td>Max</td>
<td style="width: 4%;">Custom</td>
<td style="width: 4%;">Reset ]</td>
</tr>
</thead>
<tbody>
<tbody>
<?php
<?php
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element([ 'type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
}
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element(['type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken']]) . PHP_EOL;
}
foreach ($sensors as $sensor) {
humanize_sensor($sensor);
foreach ($sensors as $sensor) {
humanize_sensor($sensor);
if ($sensor['sensor_state']) {
$sensor_value = $sensor['state_name'];
$limit_class = 'input-mini hidden';
$limit_switch_class = 'hide';
} else {
$sensor_value = $sensor['human_value'];
$limit_class = 'input-mini';
$limit_switch_class = '';
}
if ($sensor['sensor_state']) {
$sensor_value = $sensor['state_name'];
$limit_class = 'input-mini hidden';
$limit_switch_class = 'hide';
} else {
$sensor_value = $sensor['human_value'];
$limit_class = 'input-mini';
$limit_switch_class = '';
}
echo('<tr class="'.$sensor['row_class'].'">');
echo('<td class="state-marker"></td>');
//echo('<td>'.escape_html($sensor['sensor_index']).'</td>');
echo('<td><span class="entity text-nowrap">'.generate_entity_link('sensor', $sensor).'</span><br /><i>'.$sensor['sensor_type'].'</i></td>');
echo('<td><span class="label label-'.get_type_class($sensor['sensor_class']).'">'.$sensor['sensor_class'].'</span></td>');
echo('<td><span class="'.$sensor['state_class'].'">' . $sensor_value . $sensor['sensor_symbol'] . '</span></td>');
$item = [
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_limit_low]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[".$sensor['sensor_id']."][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_low']
];
echo('<td>'.generate_form_element($item).'</td>');
$item = [
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_limit_low_warn]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[".$sensor['sensor_id']."][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_low_warn']
];
echo('<td>'.generate_form_element($item).'</td>');
$item = [
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_limit_warn]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[".$sensor['sensor_id']."][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_warn']
];
echo('<td>'.generate_form_element($item).'</td>');
$item = [
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_limit]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[".$sensor['sensor_id']."][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit']
];
echo('<td>'.generate_form_element($item).'</td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_low]" size="4" value="'.escape_html($sensor['sensor_limit_low']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_low_warn]" size="4" value="'.escape_html($sensor['sensor_limit_low_warn']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_warn]" size="4" value="'.escape_html($sensor['sensor_limit_warn']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit]" size="4" value="'.escape_html($sensor['sensor_limit']).'" /></td>');
if (OBS_DEBUG) { /*echo('<td>'.$sensor['sensor_multiplier'].'</td>'); */ }
$item = array(
//'id' => 'sensor_custom_limit_'.$sensor['sensor_id'],
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_custom_limit]',
//'type' => 'switch',
'type' => 'switch-ng',
'on-text' => 'Custom',
//'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'off-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'width' => '58px',
//'title' => 'Use custom limits',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_custom_limit']);
echo('<td class="text-center">'.generate_form_element($item).'</td>');
echo('<tr class="' . $sensor['row_class'] . '">');
echo('<td class="state-marker"></td>');
//echo('<td>'.escape_html($sensor['sensor_index']).'</td>');
echo('<td><span class="entity text-nowrap">' . generate_entity_link('sensor', $sensor) . '</span><br /><i>' . $sensor['sensor_type'] . '</i></td>');
echo('<td><span class="label label-' . get_type_class($sensor['sensor_class']) . '">' . $sensor['sensor_class'] . '</span></td>');
echo('<td><span class="' . $sensor['state_class'] . '">' . $sensor_value . $sensor['sensor_symbol'] . '</span></td>');
$item = [
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_limit_low]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[" . $sensor['sensor_id'] . "][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_low']
];
echo('<td>' . generate_form_element($item) . '</td>');
$item = [
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_limit_low_warn]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[" . $sensor['sensor_id'] . "][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_low_warn']
];
echo('<td>' . generate_form_element($item) . '</td>');
$item = [
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_limit_warn]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[" . $sensor['sensor_id'] . "][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_warn']
];
echo('<td>' . generate_form_element($item) . '</td>');
$item = [
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_limit]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[" . $sensor['sensor_id'] . "][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit']
];
echo('<td>' . generate_form_element($item) . '</td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_low]" size="4" value="'.escape_html($sensor['sensor_limit_low']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_low_warn]" size="4" value="'.escape_html($sensor['sensor_limit_low_warn']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_warn]" size="4" value="'.escape_html($sensor['sensor_limit_warn']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit]" size="4" value="'.escape_html($sensor['sensor_limit']).'" /></td>');
if (OBS_DEBUG) { /*echo('<td>'.$sensor['sensor_multiplier'].'</td>'); */
}
$item = [
//'id' => 'sensor_custom_limit_'.$sensor['sensor_id'],
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_custom_limit]',
//'type' => 'switch',
'type' => 'switch-ng',
'on-text' => 'Custom',
//'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'off-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'width' => '58px',
//'title' => 'Use custom limits',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_custom_limit']];
echo('<td class="text-center">' . generate_form_element($item) . '</td>');
$item = array(
//'id' => 'sensor_reset_limit_'.$sensor['sensor_id'],
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_reset_limit]',
//'type' => 'switch',
'type' => 'switch-ng',
'on-text' => 'Reset',
//'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'off-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'class' => 'text-center',
//'width' => '58px',
//'title' => 'Reset limits to auto',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_reset_limit']);
echo('<td class="text-center">'.generate_form_element($item).'</td>');
$item = [
//'id' => 'sensor_reset_limit_'.$sensor['sensor_id'],
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_reset_limit]',
//'type' => 'switch',
'type' => 'switch-ng',
'on-text' => 'Reset',
//'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'off-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'class' => 'text-center',
//'width' => '58px',
//'title' => 'Reset limits to auto',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_reset_limit']];
echo('<td class="text-center">' . generate_form_element($item) . '</td>');
$item = array(
//'id' => 'sensor_ignore_'.$sensor['sensor_id'],
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_ignore']);
echo('<td class="text-center">'.generate_form_element($item).'</td>');
echo('</tr>');
}
$item = [
//'id' => 'sensor_ignore_'.$sensor['sensor_id'],
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_ignore']];
echo('<td class="text-center">' . generate_form_element($item) . '</td>');
echo('</tr>');
}
?>
?>
</tbody>
</table>
</div>
</tbody>
</table>
</div>
<div class="box-footer">
<?php
$item = [
'id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary pull-right',
'icon' => 'icon-ok icon-white',
'readonly' => $readonly,
'value' => 'update-sensors'
];
echo(generate_form_element($item, 'submit'));
?>
</div>
</div>
</form>
<div class="box-footer">
<?php
$item = [
'id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary pull-right',
'icon' => 'icon-ok icon-white',
'readonly' => $readonly,
'value' => 'update-sensors'
];
echo(generate_form_element($item, 'submit'));
?>
</div>
</div>
</form>
<?php

View File

@ -4,201 +4,211 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$ok = FALSE;
if (get_var_true($vars['editing']) && request_token_valid($vars)) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$update = [];
switch ($vars['snmp_version']) {
case 'v3':
switch ($vars['snmp_authlevel']) {
case 'authPriv':
if (is_valid_param($vars['snmp_cryptoalgo'], 'snmp_cryptoalgo')) {
$ok = TRUE;
$update['snmp_cryptoalgo'] = strtoupper($vars['snmp_cryptoalgo']);
$update['snmp_cryptopass'] = $vars['snmp_cryptopass'];
} else {
$error = 'Incorrect SNMP Crypto Algorithm';
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$update = [];
switch ($vars['snmp_version']) {
case 'v3':
switch ($vars['snmp_authlevel']) {
case 'authPriv':
if (is_valid_param($vars['snmp_cryptoalgo'], 'snmp_cryptoalgo')) {
$ok = TRUE;
$update['snmp_cryptoalgo'] = strtoupper($vars['snmp_cryptoalgo']);
$update['snmp_cryptopass'] = $vars['snmp_cryptopass'];
} else {
$error = 'Incorrect SNMP Crypto Algorithm';
}
// no break here
case 'authNoPriv':
if (is_valid_param($vars['snmp_authalgo'], 'snmp_authalgo')) {
$ok = TRUE;
$update['snmp_authalgo'] = strtoupper($vars['snmp_authalgo']);
$update['snmp_authname'] = $vars['snmp_authname'];
$update['snmp_authpass'] = $vars['snmp_authpass'];
} else {
$error = 'Incorrect SNMP Auth parameters';
$ok = FALSE;
}
break;
case 'noAuthNoPriv':
$ok = TRUE;
break;
}
if ($ok) {
$update['snmp_authlevel'] = $vars['snmp_authlevel'];
}
break;
case 'v2c':
case 'v1':
if (is_valid_param($vars['snmp_community'], 'snmp_community')) {
$ok = TRUE;
$update['snmp_community'] = $vars['snmp_community'];
} else {
$error = 'Incorrect SNMP Community';
}
break;
}
if ($ok && $snmpable = trim($vars['snmpable'])) {
$snmp_oids = [];
foreach (explode(' ', $snmpable) as $oid) {
if (preg_match(OBS_PATTERN_SNMP_OID_NUM, $oid)) {
$snmp_oids[] = $oid;
$oid_num = $oid;
} elseif (str_contains($oid, '::') && $oid_num = snmp_translate($oid)) {
// Named MIB::Oid which we can translate
$snmp_oids[] = $oid_num;
} else {
print_warning("Invalid or unknown OID: " . $oid);
break;
}
$data = snmp_get_oid($device, $oid_num);
if (!snmp_status()) {
print_warning("Device currently not respond by OID $oid!");
}
}
// no break here
case 'authNoPriv':
if (is_valid_param($vars['snmp_authalgo'], 'snmp_authalgo')) {
$ok = TRUE;
$update['snmp_authalgo'] = strtoupper($vars['snmp_authalgo']);
$update['snmp_authname'] = $vars['snmp_authname'];
$update['snmp_authpass'] = $vars['snmp_authpass'];
} else {
$error = 'Incorrect SNMP Auth parameters';
$ok = FALSE;
if (empty($snmp_oids)) {
$ok = FALSE;
$error = 'Incorrect or not numeric OIDs passed for check device availability';
}
break;
case 'noAuthNoPriv':
$ok = TRUE;
break;
}
if ($ok) { $update['snmp_authlevel'] = $vars['snmp_authlevel']; }
break;
case 'v2c':
case 'v1':
if (is_valid_param($vars['snmp_community'], 'snmp_community')) {
$ok = TRUE;
$update['snmp_community'] = $vars['snmp_community'];
} else {
$error = 'Incorrect SNMP Community';
if ($ok) {
$update['snmp_version'] = $vars['snmp_version'];
if (in_array($vars['snmp_transport'], $config['snmp']['transports'], TRUE)) {
$update['snmp_transport'] = $vars['snmp_transport'];
} else {
$update['snmp_transport'] = 'udp';
}
if (is_valid_param($vars['snmp_port'], 'port')) {
$update['snmp_port'] = (int)$vars['snmp_port'];
} else {
if (strlen($vars['snmp_port'])) {
print_warning('Passed incorrect SNMP port (' . $vars['snmp_port'] . '). Should be between 1 and 65535.');
}
$update['snmp_port'] = 161;
}
if (is_valid_param($vars['snmp_timeout'], 'snmp_timeout')) {
$update['snmp_timeout'] = (int)$vars['snmp_timeout'];
} else {
if (strlen($vars['snmp_timeout'])) {
print_warning('Passed incorrect SNMP timeout (' . $vars['snmp_timeout'] . '). Should be between 1 and 120 sec.');
}
$update['snmp_timeout'] = ['NULL'];
}
if (is_valid_param($vars['snmp_retries'], 'snmp_retries')) {
$update['snmp_retries'] = (int)$vars['snmp_retries'];
} else {
if (strlen($vars['snmp_retries'])) {
print_warning('Passed incorrect SNMP retries (' . $vars['snmp_retries'] . '). Should be between 1 and 10.');
}
$update['snmp_retries'] = ['NULL'];
}
// SNMPbulk max repetitions, allow 0 for disable snmpbulk(walk|get)
if (is_intnum($vars['snmp_maxrep']) && $vars['snmp_maxrep'] >= 0 && $vars['snmp_maxrep'] <= 500) {
$update['snmp_maxrep'] = (int)$vars['snmp_maxrep'];
} else {
if (strlen($vars['snmp_maxrep'])) {
print_warning('Passed incorrect SNMPbulk max repetitions (' . $vars['snmp_maxrep'] . '). Should be between 0 and 500. When 0 - snmpbulk will disable.');
}
$update['snmp_maxrep'] = ['NULL'];
}
if ($snmpable) {
if ($device['snmpable'] !== $snmpable) {
$update['snmpable'] = $snmpable;
}
} elseif (!empty($device['snmpable'])) {
$update['snmpable'] = ['NULL'];
}
if (strlen(trim($vars['snmp_context']))) {
$update['snmp_context'] = trim($vars['snmp_context']);
} else {
$update['snmp_context'] = ['NULL'];
}
if (dbUpdate($update, 'devices', '`device_id` = ?', [$device['device_id']])) {
print_success("Device SNMP configuration updated");
log_event('Device SNMP configuration changed.', $device['device_id'], 'device', $device['device_id'], 5);
} else {
$ok = FALSE;
print_warning("Device SNMP configuration update is not required");
}
}
break;
if (!$ok) {
if ($error) {
$error = "Device SNMP configuration not updated ($error)";
}
print_error($error);
}
unset($update);
}
if ($ok && $snmpable = trim($vars['snmpable'])) {
$snmp_oids = [];
foreach (explode(' ', $snmpable) as $oid) {
if (preg_match(OBS_PATTERN_SNMP_OID_NUM, $oid)) {
$snmp_oids[] = $oid;
$oid_num = $oid;
} elseif (str_contains($oid, '::') && $oid_num = snmp_translate($oid)) {
// Named MIB::Oid which we can translate
$snmp_oids[] = $oid_num;
} else {
print_warning("Invalid or unknown OID: ".$oid);
break;
}
$data = snmp_get_oid($device, $oid_num);
if (!snmp_status()) {
print_warning("Device currently not respond by OID $oid!");
}
}
if (empty($snmp_oids)) {
$ok = FALSE;
$error = 'Incorrect or not numeric OIDs passed for check device availability';
}
}
if ($ok) {
$update['snmp_version'] = $vars['snmp_version'];
if (in_array($vars['snmp_transport'], $config['snmp']['transports'], TRUE)) {
$update['snmp_transport'] = $vars['snmp_transport'];
} else {
$update['snmp_transport'] = 'udp';
}
if (is_valid_param($vars['snmp_port'], 'port')) {
$update['snmp_port'] = (int)$vars['snmp_port'];
} else {
if (strlen($vars['snmp_port'])) { print_warning('Passed incorrect SNMP port ('.$vars['snmp_port'].'). Should be between 1 and 65535.'); }
$update['snmp_port'] = 161;
}
if (is_valid_param($vars['snmp_timeout'], 'snmp_timeout')) {
$update['snmp_timeout'] = (int)$vars['snmp_timeout'];
} else {
if (strlen($vars['snmp_timeout'])) { print_warning('Passed incorrect SNMP timeout ('.$vars['snmp_timeout'].'). Should be between 1 and 120 sec.'); }
$update['snmp_timeout'] = [ 'NULL' ];
}
if (is_valid_param($vars['snmp_retries'], 'snmp_retries')) {
$update['snmp_retries'] = (int)$vars['snmp_retries'];
} else {
if (strlen($vars['snmp_retries'])) { print_warning('Passed incorrect SNMP retries ('.$vars['snmp_retries'].'). Should be between 1 and 10.'); }
$update['snmp_retries'] = [ 'NULL' ];
}
// SNMPbulk max repetitions, allow 0 for disable snmpbulk(walk|get)
if (is_intnum($vars['snmp_maxrep']) && $vars['snmp_maxrep'] >= 0 && $vars['snmp_maxrep'] <= 500) {
$update['snmp_maxrep'] = (int)$vars['snmp_maxrep'];
} else {
if (strlen($vars['snmp_maxrep'])) { print_warning('Passed incorrect SNMPbulk max repetitions ('.$vars['snmp_maxrep'].'). Should be between 0 and 500. When 0 - snmpbulk will disable.'); }
$update['snmp_maxrep'] = [ 'NULL' ];
}
if ($snmpable) {
if ($device['snmpable'] !== $snmpable) {
$update['snmpable'] = $snmpable;
}
} elseif (!empty($device['snmpable'])) {
$update['snmpable'] = [ 'NULL' ];
}
if (strlen(trim($vars['snmp_context']))) {
$update['snmp_context'] = trim($vars['snmp_context']);
} else {
$update['snmp_context'] = [ 'NULL' ];
}
if (dbUpdate($update, 'devices', '`device_id` = ?', [ $device['device_id'] ])) {
print_success("Device SNMP configuration updated");
log_event('Device SNMP configuration changed.', $device['device_id'], 'device', $device['device_id'], 5);
} else {
$ok = FALSE;
print_warning("Device SNMP configuration update is not required");
}
}
if (!$ok) {
if ($error) {
$error = "Device SNMP configuration not updated ($error)";
}
print_error($error);
}
unset($update);
}
}
$device = device_by_id_cache($device['device_id'], $ok);
$device = device_by_id_cache($device['device_id'], $ok);
$transports = [];
foreach ($config['snmp']['transports'] as $transport) {
$transports[$transport] = strtoupper($transport);
$transports[$transport] = strtoupper($transport);
}
$snmp_version = get_versions('snmp');
if (version_compare($snmp_version, '5.8', '<')) {
$authclass = 'bg-warning';
$authtext = 'Poller required net-snmp >= 5.8';
$authclass = 'bg-warning';
$authtext = 'Poller required net-snmp >= 5.8';
} else {
$authclass = 'bg-success';
$authtext = '';
$authclass = 'bg-success';
$authtext = '';
}
$authalgo = [
'MD5' => [ 'name' => 'MD5' ],
'SHA' => [ 'name' => 'SHA' ],
'SHA-224' => [ 'name' => 'SHA-224', 'class' => $authclass, 'subtext' => $authtext ],
'SHA-256' => [ 'name' => 'SHA-256', 'class' => $authclass, 'subtext' => $authtext ],
'SHA-384' => [ 'name' => 'SHA-384', 'class' => $authclass, 'subtext' => $authtext ],
'SHA-512' => [ 'name' => 'SHA-512', 'class' => $authclass, 'subtext' => $authtext ],
'MD5' => ['name' => 'MD5'],
'SHA' => ['name' => 'SHA'],
'SHA-224' => ['name' => 'SHA-224', 'class' => $authclass, 'subtext' => $authtext],
'SHA-256' => ['name' => 'SHA-256', 'class' => $authclass, 'subtext' => $authtext],
'SHA-384' => ['name' => 'SHA-384', 'class' => $authclass, 'subtext' => $authtext],
'SHA-512' => ['name' => 'SHA-512', 'class' => $authclass, 'subtext' => $authtext],
];
$cryptoalgo = [
'DES' => [ 'name' => 'DES' ],
'AES' => [ 'name' => 'AES' ],
'AES-192' => [ 'name' => 'AES-192', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'AES-192-C' => [ 'name' => 'AES-192 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'AES-256' => [ 'name' => 'AES-256', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'AES-256-C' => [ 'name' => 'AES-256 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'DES' => ['name' => 'DES'],
'AES' => ['name' => 'AES'],
'AES-192' => ['name' => 'AES-192', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes'],
'AES-192-C' => ['name' => 'AES-192 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes'],
'AES-256' => ['name' => 'AES-256', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes'],
'AES-256-C' => ['name' => 'AES-256 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes'],
];
$form = [
'type' => 'horizontal',
'id' => 'edit',
'type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
//'title' => 'General',
//'class' => 'box',
];
// top row div
$form['fieldset']['edit'] = [
$form['fieldset']['edit'] = [
'div' => 'top',
'title' => 'Basic Configuration',
'class' => 'col-md-6'
];
$form['fieldset']['snmpv2'] = [
$form['fieldset']['snmpv2'] = [
'div' => 'top',
'title' => 'SNMP v1/v2c Authentication',
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0'
];
$form['fieldset']['snmpv3'] = [
$form['fieldset']['snmpv3'] = [
'div' => 'top',
'title' => 'SNMP v3 Authentication',
//'right' => TRUE,
@ -219,29 +229,29 @@ $form['fieldset']['submit'] = [
];
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
'type' => 'hidden',
'value' => 'yes'
];
// left fieldset
$form['row'][1]['snmp_version'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'readonly' => $readonly,
'values' => [ 'v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3' ],
'value' => $device['snmp_version']
$form['row'][1]['snmp_version'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'readonly' => $readonly,
'values' => ['v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3'],
'value' => $device['snmp_version']
];
$form['row'][2]['snmp_transport'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'readonly' => $readonly,
'values' => $transports,
'value' => $device['snmp_transport']
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'readonly' => $readonly,
'values' => $transports,
'value' => $device['snmp_transport']
];
$form['row'][3]['snmp_port'] = [
$form['row'][3]['snmp_port'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Port',
@ -250,7 +260,7 @@ $form['row'][3]['snmp_port'] = [
'readonly' => $readonly,
'value' => $device['snmp_port']
];
$form['row'][4]['snmp_timeout'] = [
$form['row'][4]['snmp_timeout'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Timeout',
@ -259,7 +269,7 @@ $form['row'][4]['snmp_timeout'] = [
'readonly' => $readonly,
'value' => $device['snmp_timeout']
];
$form['row'][5]['snmp_retries'] = [
$form['row'][5]['snmp_retries'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Retries',
@ -268,7 +278,7 @@ $form['row'][5]['snmp_retries'] = [
'readonly' => $readonly,
'value' => $device['snmp_retries']
];
$form['row'][6]['snmp_maxrep'] = [
$form['row'][6]['snmp_maxrep'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Max Repetitions',
@ -280,77 +290,77 @@ $form['row'][6]['snmp_maxrep'] = [
// Snmp v1/2c fieldset
$form['row'][7]['snmp_community'] = [
'type' => 'password',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'readonly' => $readonly,
'type' => 'password',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_community'] // FIXME. For passwords we should use filter instead escape!
'value' => $device['snmp_community'] // FIXME. For passwords we should use filter instead escape!
];
// Snmp v3 fieldset
$form['row'][8]['snmp_authlevel'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'readonly' => $readonly,
'values' => [
$form['row'][8]['snmp_authlevel'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'readonly' => $readonly,
'values' => [
'noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'
],
'value' => $device['snmp_authlevel']
'value' => $device['snmp_authlevel']
];
$form['row'][9]['snmp_authname'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'readonly' => $readonly,
$form['row'][9]['snmp_authname'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_authname']
'value' => $device['snmp_authname']
];
$form['row'][10]['snmp_authpass'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'readonly' => $readonly,
$form['row'][10]['snmp_authpass'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_authpass'] // FIXME. For passwords we should use filter instead escape!
'value' => $device['snmp_authpass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][11]['snmp_authalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $authalgo,
'value' => $device['snmp_authalgo']
$form['row'][11]['snmp_authalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $authalgo,
'value' => $device['snmp_authalgo']
];
$form['row'][12]['snmp_cryptopass'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'readonly' => $readonly,
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_cryptopass'] // FIXME. For passwords we should use filter instead escape!
'value' => $device['snmp_cryptopass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][13]['snmp_cryptoalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $cryptoalgo,
'value' => $device['snmp_cryptoalgo']
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $cryptoalgo,
'value' => $device['snmp_cryptoalgo']
];
// Extra fields
$form['row'][14]['snmpable'] = [
$form['row'][14]['snmpable'] = [
'type' => 'text',
'fieldset' => 'snmpextra',
'name' => 'SNMPable OIDs',
@ -360,25 +370,25 @@ $form['row'][14]['snmpable'] = [
'value' => $device['snmpable']
];
$form['row'][15]['snmp_context'] = [
'type' => 'password',
'fieldset' => 'snmpextra',
'name' => 'SNMP Context',
'width' => '250px',
'readonly' => $readonly,
'type' => 'password',
'fieldset' => 'snmpextra',
'name' => 'SNMP Context',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'placeholder' => '(Optional) Context',
'value' => $device['snmp_context'] // FIXME. For passwords we should use filter instead escape!
'placeholder' => '(Optional) Context',
'value' => $device['snmp_context'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][20]['submit'] = [
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
];
print_form_box($form);
@ -386,43 +396,43 @@ unset($form);
?>
<script type="text/javascript">
<!--
$("#snmp_version").change(function() {
var select = this.value;
if (select === 'v3') {
$('#snmpv3').show();
$("#snmpv2").hide();
} else {
$('#snmpv2').show();
$('#snmpv3').hide();
}
}).change();
<script type="text/javascript">
<!--
$("#snmp_version").change(function () {
var select = this.value;
if (select === 'v3') {
$('#snmpv3').show();
$("#snmpv2").hide();
} else {
$('#snmpv2').show();
$('#snmpv3').hide();
}
}).change();
$("#snmp_authlevel").change(function() {
var select = this.value;
if (select === 'authPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').show();
$('[id^="snmp_cryptoalgo"]').show();
} else if (select === 'authNoPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
} else {
$('[id^="snmp_authname"]').hide();
$('[id^="snmp_authpass"]').hide();
$('[id^="snmp_authalgo"]').hide();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
}
}).change();
// -->
</script>
$("#snmp_authlevel").change(function () {
var select = this.value;
if (select === 'authPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').show();
$('[id^="snmp_cryptoalgo"]').show();
} else if (select === 'authNoPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
} else {
$('[id^="snmp_authname"]').hide();
$('[id^="snmp_authpass"]').hide();
$('[id^="snmp_authalgo"]').hide();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
}
}).change();
// -->
</script>
<?php

View File

@ -4,85 +4,80 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$ssh_port = $vars['ssh_port'];
if (!is_numeric($ssh_port))
{
$update_message = "SSH port must be numeric!";
$updated = 0;
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$update = array(
'ssh_port' => $ssh_port
);
$ssh_port = $vars['ssh_port'];
$rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id']));
if (!is_numeric($ssh_port)) {
$update_message = "SSH port must be numeric!";
$updated = 0;
} else {
$update = [
'ssh_port' => $ssh_port
];
if ($rows_updated > 0)
{
$update_message = $rows_updated . " Device record updated.";
$updated = 1;
} elseif ($rows_updated = '-1') {
$update_message = "Device record unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device record update error.";
$updated = 0;
}
$rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', [$device['device_id']]);
if ($rows_updated > 0) {
$update_message = $rows_updated . " Device record updated.";
$updated = 1;
} elseif ($rows_updated = '-1') {
$update_message = "Device record unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device record update error.";
$updated = 0;
}
}
}
}
}
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", [$device['device_id']]);
if ($updated && $update_message)
{
print_message($update_message);
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
print_error($update_message);
}
print_warning("For now this option used only by 'libvirt-vminfo' discovery module (on linux devices).");
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'SSH Connectivity',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['ssh_port'] = array(
'type' => 'text',
'name' => 'SSH Port',
'width' => '250px',
'readonly' => $readonly,
'value' => escape_html($device['ssh_port']));
$form['row'][2]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'SSH Connectivity',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['ssh_port'] = [
'type' => 'text',
'name' => 'SSH Port',
'width' => '250px',
'readonly' => $readonly,
'value' => escape_html($device['ssh_port'])];
$form['row'][2]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);
print_form($form);
unset($form);
// EOF

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,11 +14,11 @@ $query = 'SELECT * FROM `status`
WHERE `device_id` = ? AND `status_deleted` = 0
ORDER BY `status_mib`, `status_type`, `status_index`;';
$statuses = dbFetchRows($query, array($device['device_id']));
$statuses = dbFetchRows($query, [$device['device_id']]);
?>
<form id="update_statuses" class="form form-inline">
<form id="update_statuses" class="form form-inline">
<input type="hidden" name="action" value="statuses_update">
@ -40,47 +40,47 @@ $statuses = dbFetchRows($query, array($device['device_id']));
</thead>
<tbody>
<?php
<?php
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element([ 'type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
}
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element(['type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken']]) . PHP_EOL;
}
foreach ($statuses as $status)
{
humanize_status($status); //r($status);
foreach ($statuses as $status) {
humanize_status($status); //r($status);
echo '<tr class="'.$status['row_class'].'">';
echo '<td class="state-marker"></td>';
//echo('<td>'.escape_html($sensor['sensor_index']).'</td>');
echo '<td><span class="entity text-nowrap">'.generate_entity_link('status', $status).'</span><br /><i>'.$status['status_type'].'</i></td>';
echo '<td><span class="'.$status['event_class'].'">'.$status['status_name'].'</span></td>';
echo '<td><span class="'.$status['event_class'].'">'.$status['status_event'].'</span></td>';
echo '<tr class="' . $status['row_class'] . '">';
echo '<td class="state-marker"></td>';
//echo('<td>'.escape_html($sensor['sensor_index']).'</td>');
echo '<td><span class="entity text-nowrap">' . generate_entity_link('status', $status) . '</span><br /><i>' . $status['status_type'] . '</i></td>';
echo '<td><span class="' . $status['event_class'] . '">' . $status['status_name'] . '</span></td>';
echo '<td><span class="' . $status['event_class'] . '">' . $status['status_event'] . '</span></td>';
$item = [
'id' => 'status['.$status['status_id'].'][status_ignore]',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
'on-text' => 'No',
'size' => 'mini',
'readonly' => $readonly,
'value' => $status['status_ignore']
];
echo '<td class="text-center">'.generate_form_element($item).'</td>';
echo '</tr>';
}
$item = [
'id' => 'status[' . $status['status_id'] . '][status_ignore]',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
'on-text' => 'No',
'size' => 'mini',
'readonly' => $readonly,
'value' => $status['status_ignore']
];
echo '<td class="text-center">' . generate_form_element($item) . '</td>';
echo '</tr>';
}
?>
?>
</tbody>
</table>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary pull-right" name="submit" value="update_statuses"><i class="icon-ok icon-white"></i> Save Changes</button>
<button type="submit" class="btn btn-primary pull-right" name="submit" value="update_statuses"><i class="icon-ok icon-white"></i> Save Changes
</button>
</div>
</div>
</form>

View File

@ -4,32 +4,49 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['wmi_override']) { set_entity_attrib('device', $device, 'wmi_override', $vars['wmi_override']); } else { del_entity_attrib('device', $device, 'wmi_override'); }
if (!empty($vars['wmi_hostname'])) { set_entity_attrib('device', $device, 'wmi_hostname', $vars['wmi_hostname']); } else { del_entity_attrib('device', $device, 'wmi_hostname'); }
if (!empty($vars['wmi_domain'])) { set_entity_attrib('device', $device, 'wmi_domain', $vars['wmi_domain']); } else { del_entity_attrib('device', $device, 'wmi_domain'); }
if (!empty($vars['wmi_username'])) { set_entity_attrib('device', $device, 'wmi_username', $vars['wmi_username']); } else { del_entity_attrib('device', $device, 'wmi_username'); }
if (!empty($vars['wmi_password'])) { set_entity_attrib('device', $device, 'wmi_password', $vars['wmi_password']); } else { del_entity_attrib('device', $device, 'wmi_password'); }
if ($vars['wmi_override']) {
set_entity_attrib('device', $device, 'wmi_override', $vars['wmi_override']);
} else {
del_entity_attrib('device', $device, 'wmi_override');
}
if (!empty($vars['wmi_hostname'])) {
set_entity_attrib('device', $device, 'wmi_hostname', $vars['wmi_hostname']);
} else {
del_entity_attrib('device', $device, 'wmi_hostname');
}
if (!empty($vars['wmi_domain'])) {
set_entity_attrib('device', $device, 'wmi_domain', $vars['wmi_domain']);
} else {
del_entity_attrib('device', $device, 'wmi_domain');
}
if (!empty($vars['wmi_username'])) {
set_entity_attrib('device', $device, 'wmi_username', $vars['wmi_username']);
} else {
del_entity_attrib('device', $device, 'wmi_username');
}
if (!empty($vars['wmi_password'])) {
set_entity_attrib('device', $device, 'wmi_password', $vars['wmi_password']);
} else {
del_entity_attrib('device', $device, 'wmi_password');
}
$update_message = "Device WMI data updated.";
$updated = 1;
$updated = 1;
if ($vars['toggle_poller'] && isset($GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']]))
{
if ($vars['toggle_poller'] && isset($GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']])) {
$module = $vars['toggle_poller'];
if (isset($attribs['wmi_poll_'.$module]) && $attribs['wmi_poll_'.$module] != $GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']])
{
if (isset($attribs['wmi_poll_' . $module]) && $attribs['wmi_poll_' . $module] != $GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']]) {
del_entity_attrib('device', $device, 'wmi_poll_' . $module);
} elseif ($GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']] == 0) {
set_entity_attrib('device', $device, 'wmi_poll_' . $module, "1");
@ -43,29 +60,26 @@ if ($vars['editing']) {
}
if (!$readonly) {
include_once($GLOBALS['config']['install_dir'] . "/includes/wmi.inc.php");
// Validate cmd path
$wmi_ok = TRUE;
if (!is_executable($config['wmic'])) {
if ($config['wmic'] === '/bin/wmic' && is_executable('/usr/bin/wmic')) {
// This path already fixed in poller wmi
} else {
print_warning("The wmic binary was not found at the configured path (" . $config['wmic'] . "). WMI polling will not work.");
$wmi_ok = FALSE;
}
if (!wmi_cmd($device)) {
print_warning("The wmic binary (or script) was not found at the configured path (" . $config['wmic'] . "). WMI polling will not work.");
$wmi_ok = FALSE;
}
// Validate WMI poller module
if ($wmi_ok && !is_module_enabled($device, 'wmi', 'poller')) {
$modules_link = generate_device_link($device, 'only on this device here', [ 'tab' => 'edit', 'section' => 'modules' ]);
$global_link = generate_link('globally here', [ 'page' => 'settings', 'section' => 'polling' ]);
$modules_link = generate_device_link($device, 'only on this device here', ['tab' => 'edit', 'section' => 'modules']);
$global_link = generate_link('globally here', ['page' => 'settings', 'section' => 'polling']);
print_warning("WMI module not enabled. Enable <strong>Poller</strong> module WMI $modules_link, or $global_link.");
//$wmi_ok = FALSE;
}
// Validate WMI access
if ($wmi_ok) {
include_once($GLOBALS['config']['install_dir'] . "/includes/wmi.inc.php");
$wql = "SELECT Name FROM Win32_ComputerSystem";
$wql = "SELECT Name FROM Win32_ComputerSystem";
$wmi_name = wmi_get($device, $wql, "Name");
if (is_null($wmi_name)) {
$docs_link = '<a target="_blank" href="' . OBSERVIUM_DOCS_URL . '/device_windows/' . '">here</a>';
@ -79,150 +93,150 @@ if (!$readonly) {
?>
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<?php
$wmi_override = get_dev_attrib($device, 'wmi_override');
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'WMI Settings',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
<?php
$wmi_override = get_dev_attrib($device, 'wmi_override');
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'WMI Settings',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
];
$form['row'][1]['wmi_override'] = [
'type' => 'toggle',
'name' => 'Override WMI Config',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', [ 'wmi_hostname', 'wmi_domain', 'wmi_username', 'wmi_password' ])",
'value' => $wmi_override
];
$form['row'][2]['wmi_hostname'] = [
'type' => 'text',
'name' => 'WMI Hostname',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_hostname')
];
$form['row'][3]['wmi_domain'] = [
'type' => 'text',
'name' => 'WMI Domain',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_domain')
];
$form['row'][4]['wmi_username'] = [
'type' => 'text',
'name' => 'WMI Username',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_username')
];
$form['row'][5]['wmi_password'] = [
'type' => 'password',
'name' => 'WMI Password',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'show_password' => !$readonly,
'value' => get_dev_attrib($device, 'wmi_password')
];
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
];
$form['row'][1]['wmi_override'] = [
'type' => 'toggle',
'name' => 'Override WMI Config',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', [ 'wmi_hostname', 'wmi_domain', 'wmi_username', 'wmi_password' ])",
'value' => $wmi_override
];
$form['row'][2]['wmi_hostname'] = [
'type' => 'text',
'name' => 'WMI Hostname',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_hostname')
];
$form['row'][3]['wmi_domain'] = [
'type' => 'text',
'name' => 'WMI Domain',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_domain')
];
$form['row'][4]['wmi_username'] = [
'type' => 'text',
'name' => 'WMI Username',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_username')
];
$form['row'][5]['wmi_password'] = [
'type' => 'password',
'name' => 'WMI Password',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'show_password' => !$readonly,
'value' => get_dev_attrib($device, 'wmi_password')
];
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
];
print_form($form);
unset($form);
?>
</div>
<div class="col-md-6">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">WMI Poller Modules</h3>
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
];
print_form($form);
unset($form);
?>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed ">
<thead>
<tr>
<th>Module</th>
<th style="width: 80;">Global</th>
<th style="width: 80;">Device</th>
<th style="width: 80;"></th>
</tr>
</thead>
<tbody>
<?php
<div class="col-md-6">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">WMI Poller Modules</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed ">
<thead>
<tr>
<th>Module</th>
<th style="width: 80;">Global</th>
<th style="width: 80;">Device</th>
<th style="width: 80;"></th>
</tr>
</thead>
<tbody>
<?php
foreach ($GLOBALS['config']['wmi']['modules'] as $module => $module_status) {
echo('<tr><td><b>'.$module.'</b></td><td>');
foreach ($GLOBALS['config']['wmi']['modules'] as $module => $module_status) {
echo('<tr><td><b>' . $module . '</b></td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>' ));
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
echo('</td><td>');
if (isset($attribs['wmi_poll_'.$module])) {
if ($attribs['wmi_poll_'.$module]) {
echo('<span class="label label-success">enabled</span>');
$toggle = "Disable";
$btn_class = "btn-danger";
} else {
echo('<span class="label label-important">disabled</span>');
$toggle = "Enable";
$btn_class = "btn-success";
}
} else {
if ($module_status) {
echo('<span class="label label-success">enabled</span>');
$toggle = "Disable";
$btn_class = "btn-danger";
} else {
echo('<span class="label label-important">disabled</span>');
$toggle = "Enable";
$btn_class = "btn-success";
}
}
if (isset($attribs['wmi_poll_' . $module])) {
if ($attribs['wmi_poll_' . $module]) {
echo('<span class="label label-success">enabled</span>');
$toggle = "Disable";
$btn_class = "btn-danger";
} else {
echo('<span class="label label-important">disabled</span>');
$toggle = "Enable";
$btn_class = "btn-success";
}
} else {
if ($module_status) {
echo('<span class="label label-success">enabled</span>');
$toggle = "Disable";
$btn_class = "btn-danger";
} else {
echo('<span class="label label-important">disabled</span>');
$toggle = "Enable";
$btn_class = "btn-success";
}
}
echo('</td><td>');
$form = [ 'type' => 'simple' ];
// Elements
$form['row'][0]['toggle_poller'] = [ 'type' => 'hidden',
'value' => $module ];
$form['row'][0]['editing'] = [ 'type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
//'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'toggle_poller' ];
print_form($form);
unset($form);
echo('</td><td>');
echo('</td></tr>');
}
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_poller'] = ['type' => 'hidden',
'value' => $module];
$form['row'][0]['editing'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
//'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'toggle_poller'];
print_form($form);
unset($form);
?>
</tbody>
</table>
</div>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<?php
// EOF

View File

@ -4,10 +4,10 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/

View File

@ -6,84 +6,31 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
// Sections are printed in the order they exist in $config['graph_sections']
// Graphs are printed in the order they exist in $config['graph_types']
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'graphs');
$graphs_sections = array();
foreach ($device['graphs'] as $entry)
{
if (isset($entry['enabled']) && !$entry['enabled']) { continue; } // Skip disabled graphs
$section = $config['graph_types']['device'][$entry['graph']]['section'];
if (in_array($section, $config['graph_sections']))
{
// Collect only enabled and exists graphs
//$graphs_sections[$section][$entry['graph']] = $entry['enabled'];
if (isset($config['graph_types']['device'][$entry['graph']]['order']) && is_numeric($config['graph_types']['device'][$entry['graph']]['order']))
{
$order = $config['graph_types']['device'][$entry['graph']]['order'];
} else {
$order = 999; // Set high order for unordered graphs
}
while (isset($graphs_sections[$section][$order]))
{
$order++;
}
$graphs_sections[$section][$order] = $entry['graph'];
}
}
if (OBSERVIUM_EDITION !== 'community') {
// Custom OIDs
$sql = "SELECT * FROM `oids_entries`";
$sql .= " LEFT JOIN `oids` USING(`oid_id`)";
$sql .= " WHERE `device_id` = ?";
$custom_graphs = dbFetchRows($sql, array($device['device_id']));
if (count($custom_graphs))
{
$graphs_sections['custom'] = TRUE;
}
}
$graphs_sections = get_device_graphs_sections($device);
//print_vars($graphs_sections);
// Graphs navbar
$navbar['brand'] = "Graphs";
$navbar['class'] = "navbar-narrow";
foreach ($graphs_sections as $section => $graph) {
$type = strtolower($section);
if (!$vars['group']) {
$vars['group'] = $type;
}
if ($vars['group'] == $type) {
$navbar['options'][$section]['class'] = "active";
}
$navbar['options'][$section]['url'] = generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'graphs', 'group' => $type ]);
$navbar['options'][$section]['text'] = $config['graph_sections'][$section] ?? nicecase($type);
// Set sections order
$graphs_sections_sorted = array();
foreach ($config['graph_sections'] as $section)
{
if (isset($graphs_sections[$section]))
{
$graphs_sections_sorted[$section] = $graphs_sections[$section];
unset($graphs_sections[$section]);
}
}
$graphs_sections = array_merge($graphs_sections_sorted, $graphs_sections);
//print_vars($graphs_sections);
unset($graphs_sections_sorted);
foreach ($graphs_sections as $section => $graph)
{
$type = strtolower($section);
if (empty($config['graph_sections'][$section])) { $text = nicecase($type); } else { $text = $config['graph_sections'][$section]; }
if (!$vars['group']) { $vars['group'] = $type; }
if ($vars['group'] == $type) { $navbar['options'][$section]['class'] = "active"; }
$navbar['options'][$section]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'graphs', 'group' => $type));
$navbar['options'][$section]['text'] = $text;
//print_vars($graph);
//print_vars($graph);
}
print_navbar($navbar);
@ -91,48 +38,52 @@ print_navbar($navbar);
echo generate_box_open();
echo('<table class="table table-condensed table-striped table-hover ">');
if ($vars['group'] === "custom" && $graphs_sections['custom'])
{
foreach ($custom_graphs as $graph)
{
$graph_array = array();
$graph_title = $graph['oid_descr'];
$graph_array['type'] = "customoid_graph";
$graph_array['id'] = $graph['oid_entry_id'];
if ($vars['group'] === "custom" && isset($graphs_sections['custom'])) {
// Custom OIDs
$sql = "SELECT * FROM `oids_entries`";
$sql .= " LEFT JOIN `oids` USING(`oid_id`)";
$sql .= " WHERE `device_id` = ?";
echo('<tr><td>');
$custom_graphs = dbFetchRows($sql, [ $device['device_id'] ]);
echo('<h3>' . $graph_title . '</h4>');
foreach ($custom_graphs as $graph) {
$graph_array = [];
$graph_title = $graph['oid_descr'];
$graph_array['type'] = "customoid_graph";
$graph_array['id'] = $graph['oid_entry_id'];
print_graph_row($graph_array);
echo('<tr><td>');
echo('</td></tr>');
echo('<h3>' . $graph_title . '</h4>');
}
print_graph_row($graph_array);
echo('</td></tr>');
}
} elseif (isset($graphs_sections[$vars['group']])) {
ksort($graphs_sections[$vars['group']], SORT_NUMERIC);
$graph_enable = $graphs_sections[$vars['group']];
ksort($graphs_sections[$vars['group']], SORT_NUMERIC);
$graph_enable = $graphs_sections[$vars['group']];
// print_vars($graph_enable);
foreach ($graph_enable as $graph)
{
$graph_array = array();
//if ($graph_enable[$graph])
//{
$graph_title = $config['graph_types']['device'][$graph]['descr'];
$graph_array['type'] = "device_" . $graph;
$graph_array['device'] = $device['device_id'];
foreach ($graph_enable as $graph) {
$graph_array = [];
//if ($graph_enable[$graph])
//{
$graph_title = $config['graph_types']['device'][$graph]['descr'];
$graph_array['type'] = "device_" . $graph;
$graph_array['device'] = $device['device_id'];
echo('<tr><td>');
echo('<tr><td>');
echo('<h3>' . $graph_title . '</h4>');
echo('<h3>' . $graph_title . '</h4>');
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</td></tr>');
//}
}
echo('</td></tr>');
//}
}
}
echo('</table>');

View File

@ -4,123 +4,73 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$datas = [ 'overview' => [ 'icon' => $config['icon']['overview'] ] ];
if ($health_exist['processors']) { $datas['processor'] = array('icon' => $config['entities']['processor']['icon']); }
if ($health_exist['mempools']) { $datas['mempool'] = array('icon' => $config['entities']['mempool']['icon']); }
if ($health_exist['storage']) { $datas['storage'] = array('icon' => $config['entities']['storage']['icon']); }
if ($health_exist['diskio']) { $datas['diskio'] = array('icon' => $config['icon']['diskio']); }
if ($health_exist['status']) { $datas['status'] = array('icon' => $config['entities']['status']['icon']); }
if ($health_exist['sensors']) {
// Keep sensors order for base types static
$sensor_types = [ 'temperature', 'humidity', 'fanspeed', 'airflow', 'current', 'voltage', 'power', 'apower', 'rpower', 'frequency' ];
$other_types = array_diff(array_keys($config['sensor_types']), $sensor_types);
$sensor_types = array_merge($sensor_types, $other_types);
//r($sensor_types);
$sensors_device = dbFetchColumn("SELECT DISTINCT `sensor_class` FROM `sensors` WHERE `device_id` = ? AND `sensor_deleted` = ?", [ $device['device_id'], 0 ]);
//r($sensors_device);
foreach (array_intersect($sensor_types, $sensors_device) as $sensor_type) {
//if ($sensor['sensor_class'] == 'counter') { continue; } // DEVEL
$datas[$sensor_type] = [ 'icon' => $config['sensor_types'][$sensor_type]['icon'] ];
}
if (!$vars['metric']) {
$vars['metric'] = "overview";
}
// All counters in single page?
if ($health_exist['counter']) { $datas['counter'] = array('icon' => $config['entities']['counter']['icon']); }
/*
if ($health_exist['counter'])
{
$counters_device = dbFetchRows("SELECT DISTINCT `counter_class` FROM `counters` WHERE `device_id` = ? AND `counter_deleted` = ?", array($device['device_id'], 0));
foreach ($counters_device as $counter)
{
$datas[$counter['counter_class']] = array('icon' => $config['counter_types'][$counter['counter_class']]['icon']);
}
if (!$vars['view']) {
$vars['view'] = "details";
}
*/
$link_array = [
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'health'
];
if (!$vars['metric']) { $vars['metric'] = "overview"; }
if (!$vars['view']) { $vars['view'] = "details"; }
$navbar['brand'] = "Health";
$navbar['class'] = "navbar-narrow";
$navbar_count = count($datas);
foreach ($datas as $type => $options)
{
if ($vars['metric'] == $type) { $navbar['options'][$type]['class'] = "active"; }
else if ($navbar_count > 8 && $type != 'overview') { $navbar['options'][$type]['class'] = "icon"; } // Show only icons if too many items in navbar
if (isset($options['icon']))
{
$navbar['options'][$type]['icon'] = $options['icon'];
}
$navbar['options'][$type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => $type));
$navbar['options'][$type]['text'] = nicecase($type);
$navbar['options']['overview']['icon'] = $config['icon']['overview'];
$navbar['options']['overview']['text'] = 'Overview';
$navbar['options']['overview']['url'] = generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'health' ]);
if ($vars['metric'] === 'overview') {
$navbar['options']['overview']['class'] = 'active';
}
$health_menu = navbar_health_menu($device, $vars);
$navbar['options'] = array_merge($navbar['options'], $health_menu);
//$navbar['options']['graphs']['text'] = 'Graphs';
$navbar['options']['graphs']['icon'] = $config['icon']['graphs'];
$navbar['options']['graphs']['right'] = TRUE;
if ($vars['view'] == "graphs")
{
$navbar['options']['graphs']['class'] = 'active';
$navbar['options']['graphs']['url'] = generate_url($vars, array('view' => "detail"));
if ($vars['view'] === "graphs") {
$navbar['options']['graphs']['class'] = 'active';
$navbar['options']['graphs']['url'] = generate_url($vars, ['view' => "detail"]);
} else {
$navbar['options']['graphs']['url'] = generate_url($vars, array('view' => "graphs"));
$navbar['options']['graphs']['url'] = generate_url($vars, ['view' => "graphs"]);
}
print_navbar($navbar);
unset($navbar);
if (isset($config['sensor_types'][$vars['metric']]) || $vars['metric'] == "sensors")
{
include($config['html_dir']."/pages/device/health/sensors.inc.php");
}
elseif (isset($config['counter_types'][$vars['metric']]) || $vars['metric'] == "counter")
{
include($config['html_dir']."/pages/device/health/counter.inc.php");
}
elseif (is_alpha($vars['metric']) && is_file($config['html_dir']."/pages/device/health/".$vars['metric'].".inc.php"))
{
include($config['html_dir']."/pages/device/health/".$vars['metric'].".inc.php");
if (isset($config['sensor_types'][$vars['metric']]) || $vars['metric'] === "sensors") {
include($config['html_dir'] . "/pages/device/health/sensors.inc.php");
} elseif (isset($config['counter_types'][$vars['metric']]) || $vars['metric'] === "counter") {
include($config['html_dir'] . "/pages/device/health/counter.inc.php");
} elseif (is_alpha($vars['metric']) && is_file($config['html_dir'] . "/pages/device/health/" . $vars['metric'] . ".inc.php")) {
include($config['html_dir'] . "/pages/device/health/" . $vars['metric'] . ".inc.php");
} else {
echo generate_box_open();
// Overview
echo generate_box_open();
echo('<table class="table table-condensed table-striped table-hover ">');
echo('<table class="table table-condensed table-striped table-hover ">');
foreach ($datas as $type => $options)
{
if ($type != "overview")
{
$graph_title = nicecase($type);
$graph_array['type'] = "device_".$type;
$graph_array['device'] = $device['device_id'];
foreach ($health_menu as $type => $options) {
$graph_title = $options['text'];
$graph_array['type'] = "device_" . $type;
$graph_array['device'] = $device['device_id'];
echo('<tr><td>');
echo('<h3>' . $graph_title . '</h3>');
print_graph_row($graph_array);
echo('</td></tr>');
echo('<tr><td>');
echo('<h3>' . $graph_title . '</h3>');
print_graph_row($graph_array);
echo('</td></tr>');
}
}
echo('</table>');
echo('</table>');
echo generate_box_close();
echo generate_box_close();
}

View File

@ -5,31 +5,30 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @copyright (C) Adam Armstrong
*
*/
if ($metric != 'counter' && device_permitted($device))
{
if ($metric != 'counter' && device_permitted($device)) {
// Don't show aggregate graphs to people without device permissions, or for "all sensors" view.
// Don't show aggregate graphs to people without device permissions, or for "all sensors" view.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_open($box_args);
echo generate_box_close();
print_graph_row($graph_array);
echo generate_box_close();
}

View File

@ -4,15 +4,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$class = "dbm";
$unit = "dBm";
$class = "dbm";
$unit = "dBm";
$graph_type = "sensor_dbm";
include("sensors.inc.php");

View File

@ -4,33 +4,33 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (device_permitted($device)) {
// Only show aggregate graph if we have access to the entire device.
// Only show aggregate graph if we have access to the entire device.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_diskio_bits";
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_diskio_bits";
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
echo generate_box_open($box_args);
print_graph_row($graph_array);
print_graph_row($graph_array);
$graph_array['type'] = "device_diskio_ops";
print_graph_row($graph_array);
$graph_array['type'] = "device_diskio_ops";
print_graph_row($graph_array);
echo generate_box_close();
echo generate_box_close();
}
@ -43,40 +43,37 @@ echo('<table class="table table-striped table-condensed ">');
// </tr></thead>");
foreach (dbFetchRows("SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr", array($device['device_id'])) as $drive)
{
foreach (dbFetchRows("SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr", [$device['device_id']]) as $drive) {
$fs_url = "device/device=".$device['device_id']."/tab=health/metric=diskio/";
$fs_url = "device/device=" . $device['device_id'] . "/tab=health/metric=diskio/";
$graph_array_zoom['id'] = $drive['diskio_id'];
$graph_array_zoom['type'] = "diskio_ops";
$graph_array_zoom['width'] = "400";
$graph_array_zoom['height'] = "125";
$graph_array_zoom['from'] = $config['time']['twoday'];
$graph_array_zoom['to'] = $config['time']['now'];
$graph_array_zoom['id'] = $drive['diskio_id'];
$graph_array_zoom['type'] = "diskio_ops";
$graph_array_zoom['width'] = "400";
$graph_array_zoom['height'] = "125";
$graph_array_zoom['from'] = get_time('twoday');
$graph_array_zoom['to'] = get_time();
echo("<tr><td><h3>");
echo(overlib_link($fs_url, $drive['diskio_descr'], generate_graph_tag($graph_array_zoom), NULL));
echo("</h3>");
echo("<tr><td><h3>");
echo(overlib_link($fs_url, $drive['diskio_descr'], generate_graph_tag($graph_array_zoom), NULL));
echo("</h3>");
$types = array("diskio_bits", "diskio_ops");
$types = ["diskio_bits", "diskio_ops"];
$rrd_filename = get_rrd_path($device, "diskstat-".$drive['diskio_descr'].".rrd");
if(is_file($rrd_filename))
{
$rrd_filename = get_rrd_path($device, "diskstat-" . $drive['diskio_descr'] . ".rrd");
if (is_file($rrd_filename)) {
$types[] = "diskio_stat";
}
}
foreach ($types as $graph_type)
{
foreach ($types as $graph_type) {
$graph_array = array();
$graph_array['id'] = $drive['diskio_id'];
$graph_array['type'] = $graph_type;
$graph_array = [];
$graph_array['id'] = $drive['diskio_id'];
$graph_array['type'] = $graph_type;
print_graph_row($graph_array);
print_graph_row($graph_array);
}
}
}

View File

@ -4,30 +4,30 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (device_permitted($device)) {
// Only show aggregate graph if we have access to the entire device.
// Only show aggregate graph if we have access to the entire device.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_close();
print_graph_row($graph_array);
echo generate_box_close();
}

View File

@ -4,32 +4,32 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (device_permitted($device)) {
// Only show aggregate graph if we have access to the entire device.
// Only show aggregate graph if we have access to the entire device.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_open($box_args);
$graph_type = "processor_usage";
print_graph_row($graph_array);
echo generate_box_close();
$graph_type = "processor_usage";
echo generate_box_close();
}

Some files were not shown because too many files have changed in this diff Show More