initial commit; version 22.5.12042

This commit is contained in:
2022-12-12 23:28:25 -05:00
commit af1b03d79f
17653 changed files with 22692970 additions and 0 deletions

1
html/pages/.htaccess Normal file
View File

@ -0,0 +1 @@
deny from all

215
html/pages/about.inc.php Normal file
View File

@ -0,0 +1,215 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
?>
<div class="row">
<div class="col-md-6">
<?php
print_versions();
$ua = detect_browser();
//r($ua);
register_html_resource('js', 'moment.min.js');
$tz = get_timezone();
//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 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 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>
</div>
<?php
if (!$_SESSION['user_limited'])
{
$cache_item = get_cache_item('stats');
if (!ishit_cache_item($cache_item))
{
$stats = array();
$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, array('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;">
<?php include($config['install_dir'] . '/LICENSE.' . strtoupper(OBSERVIUM_EDITION)); ?>
</pre></div>
</div>
</div>
</div>
</div>
<?php
// EOF

View File

@ -0,0 +1,493 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Global write permissions required.
if ($_SESSION['userlevel'] < 10)
{
print_error_permission();
return;
}
register_html_resource('css', 'query-builder.default.css');
register_html_resource('js', 'jQuery.extendext.min.js');
register_html_resource('js', 'doT.min.js');
register_html_resource('js', 'query-builder.js');
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");
// print_vars($vars);
if (!isset($vars['entity_type'])) {
print generate_box_open(array('title' => 'Select Alert Checker Entity Type', 'padding' => true, 'header-border' => true));
//echo '<h4>Select Entity Type</h4>';
ksort($config['entities']);
foreach ($config['entities'] as $entity_type => $entity_type_array) {
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(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>';
}
}
echo generate_box_close();
echo '<script type="text/javascript">
$(document).ready(function () {
$("#selection").change(function () {
location = $("#selection option:selected").val();
});
});
</script>';
/*
// 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');
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) {
// Process the alert checker to add classes and colours and count status.
humanize_alert_check($check);
echo('<tr class="' . $check['html_row_class'] . '">');
echo('
<td class="state-marker"></td>
<td style="width: 1px;"></td>');
// 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><i class="' . $config['entities'][$check['entity_type']]['icon'] . '"></i></td>';
echo('</td>');
echo('</tr>');
}
// End loop of associations
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);
?>
<form name="form1" method="post" action="<?php echo(generate_url(array('page' => 'add_alert_check'))); ?>"
class="form-horizontal">
<div class="row">
<div class="col-md-5">
<?php
$box_args = array('title' => 'New Checker Details',
'header-border' => TRUE,
'padding' => TRUE,
);
echo generate_box_open($box_args);
?>
<fieldset>
<!--
<div class="control-group">
<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'));
?>
</div>
</div>
-->
<div id="group_name_div" class="control-group"> <!-- START row-2 -->
<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>'; ?>
</div>
</div>
<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'));
?>
</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'));
?>
</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'));
?>
</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'));
?>
</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'));
?>
</div>
</div>
</fieldset>
<?php echo generate_box_close(); ?>
</div> <!-- col -->
<div class="col-md-7">
<?php
$box_args = array('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"')));
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'));
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 ]
];
$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');
echo('<div class="col-md-12"><b>List of known metrics:</b><br />' . build_table($metrics_list, $metrics_opts) . '</div>');
echo generate_box_close();
$box_args = array('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);
$form_id = 'rules-' . generate_random_string(8);
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'], 'metrics');
$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;
echo generate_box_close(array('footer_content' => $footer_content));
// echo generate_box_close();
?>
</div> <!-- col -->
</div> <!-- row -->
<!--
<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'));
?>
</div>
-->
</form>
<?php
$script
= "<script>
$('#btn-save').on('click', function() {
var result = $('#" . $form_id . "').queryBuilder('getRules');
var div = $('#output');
if (!$.isEmptyObject(result)) {
var formData = JSON.stringify({
action: 'alert_check_add',
alert_assoc: JSON.stringify(result),
entity_type: '" . $vars['entity_type'] . "',
alert_name: document.getElementById('alert_name').value,
alert_message: document.getElementById('alert_message').value,
alert_delay: document.getElementById('alert_delay').value,
alert_send_recovery: document.getElementById('alert_send_recovery').value,
alert_severity: document.getElementById('alert_severity').value,
alert_and: document.getElementById('alert_and').value,
alert_conditions: document.getElementById('alert_conditions').value,
requesttoken: document.getElementById('requesttoken').value
});
var request = $.ajax({
type: 'POST',
url: 'ajax/actions.php',
data: formData,
dataType: 'json',
contentType : 'application/json',
});
request.success( function(json) {
if (json.status === 'ok')
{
div.html('<div class=\"alert alert-success\">Creation Succeeded. Redirecting!</div>')
window.setTimeout(window.location.href = json.redirect,5000);
} else {
div.html('<div class=\"alert alert-warning\">Creation Failed: ' + json.message + '</div>')
}
});
}
});
$('#btn-reset').on('click', function() {
$('#" . $form_id . "').queryBuilder('reset');
});
</script>
";
echo $script;
?>
<div id="tooltip-help-conditions" style="display: none;">
Conditions should be entered in this format
<pre>metric_1 condition value_1
metric_2 condition value_2
metric_3 condition value_3</pre>
For example to alert when an enabled port is down
<pre>ifAdminStatus equals up
ifOperStatus equals down</pre>
</div>
<?php
}
register_html_title('Add alert checker');
// EOF

View File

@ -0,0 +1,151 @@
<?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
*
*/
// Global write permissions required.
if ($_SESSION['userlevel'] < 10)
{
print_error_permission();
return;
}
include($config['html_dir']."/includes/alerting-navbar.inc.php");
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;
}
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';
$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>');
unset($vars['name'], $vars['descr'], $vars['regex']);
set_obs_attrib('syslog_rules_changed', time()); // Trigger reload syslog script
} 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.');
}
}
?>
<div class="row">
<div class="col-md-8">
<?php
$form = array('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');
print_form($form);
unset($form);
?>
</div>
<div class="col-md-4">
<?php
$box_args = array('title' => 'Syslog Regular Expressions',
'header-border' => TRUE,
'padding' => TRUE,
);
echo generate_box_open($box_args);
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>,
<a href="https://www.debuggex.com/cheatsheet/regex/pcre">Debuggex Cheatsheet</a>,
<a href="http://regexr.com/">regexr.com</a> and <a href="http://www.tutorialspoint.com/php/php_regular_expression.htm">Tutorials Point</a>.
There are many other sites with examples which can be found online.
<p>A simple rule to match the word "error" could look like:</p>
<code>/error/</code>
<p>A more complex rule to match SSH authentication failures from PAM for the users root or adama might look like:</p>
<code>/pam.+\(sshd:auth\).+failure.+user\=(root|adama)/</code>
SYSLOG_RULES;
echo generate_box_close();
?>
</div>
</div>
<?php
//EOF

334
html/pages/addhost.inc.php Normal file
View File

@ -0,0 +1,334 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if ($_SESSION['userlevel'] < 10) {
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)) {
if ($result = add_device_vars($vars)) {
$device_url = generate_device_url(array('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");
}
}
} 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];
}
}
register_html_title("Add Device");
// Add form
$transports = array();
foreach ($config['snmp']['transports'] as $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';
} else {
$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 ],
];
$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' ],
];
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
//'title' => 'Add Device',
//'icon' => 'oicon-gear',
);
// top row div
$form['fieldset']['edit'] = array('div' => 'top',
'title' => 'Basic Configuration',
'class' => 'col-md-6');
$form['fieldset']['snmpv2'] = array('div' => 'top',
'title' => 'SNMP v1/v2c Authentication',
'class' => 'col-md-6 col-md-pull-0');
$form['fieldset']['snmpv3'] = array('div' => 'top',
'title' => 'SNMP v3 Authentication',
'class' => 'col-md-6 col-md-pull-0');
$form['fieldset']['extra'] = array('div' => 'top',
'title' => 'Extra Configuration',
'class' => 'col-sm-12 col-md-6 pull-right');
// bottom row div
$form['fieldset']['submit'] = array('div' => 'bottom',
'style' => 'padding: 0px;',
'class' => 'col-md-12');
//$form['row'][0]['editing'] = array(
// 'type' => 'hidden',
// 'value' => 'yes');
// left fieldset
$form['row'][0]['hostname'] = array(
'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';
}
}
$form['row'][1]['poller_id'] = array(
'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']
);
}
$form['row'][2]['ping_skip'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'fieldset' => 'edit',
'name' => 'Skip PING',
'placeholder' => 'Skip ICMP echo checks',
'value' => ''
);
$form['row'][3]['snmp_version'] = array(
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'values' => array('v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3'),
'value' => $vars['snmp_version'] ?: $config['snmp']['version']
);
$form['row'][4]['snmp_transport'] = array(
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'values' => $transports,
'value' => $vars['snmp_transport'] ?: $config['snmp']['transports'][0]
);
$form['row'][5]['snmp_port'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Port',
'placeholder' => '1-65535. Default 161.',
'width' => '250px',
'value' => $vars['snmp_port']
);
$form['row'][6]['snmp_timeout'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Timeout',
'placeholder' => '1-120 sec. Default 1 sec.',
'width' => '250px',
'value' => $vars['snmp_timeout']
);
$form['row'][7]['snmp_retries'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Retries',
'placeholder' => '1-10. Default 5.',
'width' => '250px',
'value' => $vars['snmp_retries']
);
$form['row'][8]['snmp_maxrep'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Max Repetitions',
'width' => '250px',
'placeholder' => '0-500. Default 10. 0 for disable snmpbulk.',
'value' => $vars['snmp_maxrep']
);
$form['row'][9]['ignorerrd'] = array(
'type' => 'checkbox',
'fieldset' => 'edit',
'name' => 'Ignore existing RRDs',
'placeholder' => 'Ignore pre-existing RRD directory and files',
'disabled' => $config['rrd_override'],
'value' => $config['rrd_override']
);
// Snmp v1/2c fieldset
$form['row'][16]['snmp_community'] = array(
'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'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'values' => array('noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'),
'value' => $vars['snmp_authlevel']
);
$form['row'][18]['snmp_authname'] = array(
'type' => 'text',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'value' => $vars['snmp_authname']
);
$form['row'][19]['snmp_authpass'] = array(
'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'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'values' => $authalgo,
'value' => $vars['snmp_authalgo']
);
$form['row'][21]['snmp_cryptopass'] = array(
'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'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'values' => $cryptoalgo,
'value' => $vars['snmp_cryptoalgo']);
$form['row'][25]['snmp_context'] = array(
'type' => 'text',
'fieldset' => 'extra',
'name' => 'SNMP Context',
'width' => '250px',
//'show_password' => !$readonly,
'placeholder' => '(Optional) Context',
'value' => $vars['snmp_context'] // FIXME. For passwords we should use filter instead escape!
);
$form['row'][30]['submit'] = array(
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Add device',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'save'
);
print_form_box($form);
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();
$("#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
// EOF

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,296 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
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");
// 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'));
// 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']);
}
$navbar['class'] = "navbar-narrow";
$navbar['brand'] = "Alert Checks";
$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']['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));
}
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']));
}
$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']['userlevel'] = 7;
// Print out the navbar defined above
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);
}
foreach (dbFetchRows("SELECT * FROM `alert_table`" . $where) as $entry)
{
$alert_table[$entry['alert_test_id']][$entry['alert_table_id']] = $entry;
}
echo generate_box_open();
echo '<table class="table table-striped table-hover">
<thead>
<tr>
<th class="state-marker"></th>
<th style="width: 1px;"></th>
<th style="width: 250px">Name</th>
<th style="width: 40px"></th>
<th style="width: 300px">Tests</th>
<th>Device Match / Entity Match</th>
<th style="width: 40px">Entities</th>
</tr>
</thead>
<tbody>', PHP_EOL;
// FIXME -- make sort order configurable
$alert_check = array_sort($alert_check, 'alert_name');
foreach ($alert_check as $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('
<td class="state-marker"></td>
<td style="width: 1px;"></td>');
// 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><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> '.$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>';
}
echo '</table>';
echo generate_box_close();
register_html_title('Alert checkers');
// EOF

View File

@ -0,0 +1,116 @@
<?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
*
*/
// Alert test display and editing page.
include($config['html_dir']."/includes/alerting-navbar.inc.php");
?>
<div class="row">
<div class="col-md-12">
<?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));
$where = ' WHERE 1 ' . $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);
// 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']);
// Add device_id limit for other fields
if (isset($vars['device_id']))
{
$where .= 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']);
// 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']);
// 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']);
// 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);
print_form($form);
unset($form, $form_items, $form_devices, $form_filter);
// Pagination
$vars['pagination'] = TRUE;
// Print Alert Log
print_alert_log($vars);
register_html_title('Alert Log');
?>
</div> <!-- col-md-12 -->
</div> <!-- row -->
<?php
// EOF

View File

@ -0,0 +1,54 @@
<?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
*
*/
// Global write permissions required.
if ($_SESSION['userlevel'] < 10)
{
print_error_permission();
return;
}
include($config['html_dir']."/includes/alerting-navbar.inc.php");
// Regenerate alerts
echo generate_box_open();
$checkers = cache_alert_rules();
$assocs = cache_alert_assoc();
foreach($assocs as $assoc)
{
$checkers[$assoc['alert_test_id']]['assocs'][] = $assoc;
}
foreach($checkers as $alert)
{
echo '<h3>Updating Alert <b>' . $alert['alert_name'] . '</b></h3>';
echo '<br />';
//r($alert);
update_alert_table($alert);
}
del_obs_attrib('alerts_require_rebuild');
echo generate_box_close();
unset($vars['action']);
// EOF

108
html/pages/alerts.inc.php Normal file
View File

@ -0,0 +1,108 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
include($config['html_dir']."/includes/alerting-navbar.inc.php");
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_count = safe_count($types);
$navbar['options']['all']['url'] = generate_url($vars, array('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));
}
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";
}
$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 out the navbar defined above
print_navbar($navbar);
// Cache the alert_tests table for use later
$alert_rules = cache_alert_rules($vars);
// Print out a table of alerts matching $vars
if ($vars['status'] !== 'failed') {
$vars['pagination'] = TRUE;
}
print_alert_table($vars);
// EOF

73
html/pages/apps.inc.php Normal file
View File

@ -0,0 +1,73 @@
<?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
*
*/
$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
}
}
$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']] = array();
}
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');
}
} else {
include($config['html_dir'].'/pages/apps/overview.inc.php');
}
register_html_title('Applications');
// EOF

View File

@ -0,0 +1,82 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$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";
$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']]);
}
}
$app_devices = array_sort_by($app_devices, 'hostname', SORT_ASC, SORT_STRING);
//echo generate_box_open();
//echo '<table class="table table-hover table-condensed table-striped ">';
foreach ($app_devices as $app_device)
{
echo generate_box_open();
echo '<table class="table table-hover table-condensed table-striped ">';
print_device_row($app_device, NULL, array('tab' => 'apps', 'app' => $app['app_type']));
echo '<tr><td colspan="6">';
$graph_array['id'] = $app_device['app_id'];
$graph_array['types'] = array();
$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['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 '<h3>' . nicecase($graph_type) . '</h3>';
print_graph_row($graph_array);
}
*/
echo '</td>';
echo '</tr>';
echo '</table>';
echo generate_box_close();
}
//echo '</table>';
//echo generate_box_close();
// EOF

View File

@ -0,0 +1,74 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$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(array_keys($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'].')';
}
$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>');
}
// EOF

View File

@ -0,0 +1,82 @@
<?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
*
*/
include($config['html_dir'].'/includes/user_menu.inc.php');
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);
}
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
// 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]['date'] = array(
// 'type' => 'datetime',
// 'name' => 'Date',
// //'min' => dbFetchCell('SELECT `datetime` FROM `authlog`' . $where . ' ORDER BY `datetime` LIMIT 0,1;'),
// //'max' => dbFetchCell('SELECT `datetime` FROM `authlog`' . $where . ' ORDER BY `datetime` DESC LIMIT 0,1;'),
// '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,
);
print_form($form);
unset($form, $userlist);
// Pagination
$vars['pagination'] = TRUE;
print_authlog($vars);
register_html_title('Authlog');
// EOF

613
html/pages/contact.inc.php Normal file
View File

@ -0,0 +1,613 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Contact display and editing page.
if ($_SESSION['userlevel'] < 7) {
// Allowed only secure global read permission
print_error_permission();
return;
}
include($config['html_dir'].'/includes/alerting-navbar.inc.php');
include($config['html_dir'].'/includes/contacts-navbar.inc.php');
if ($contact = get_contact_by_id($vars['contact_id'])) {
?>
<div class="row">
<div class="col-sm-7">
<?php
foreach (safe_json_decode($contact['contact_endpoint']) as $field => $value) {
$contact['endpoint_parameters'][$field] = $value;
}
$transport = $contact['contact_method'];
if ($transport === 'syscontact') {
//$readonly = TRUE;
$data = [
'name' => 'sysContact',
'docs' => $transport
];
} elseif (isset($config['transports'][$transport])) {
$data = $config['transports'][$transport];
} else {
$data = [
'name' => nicecase($transport) . ' (Missing)',
'docs' => $transport
];
}
if (isset($data['docs'])) {
// Known key in docs page (use if transport name is different with docs page)
$docs_link = OBSERVIUM_DOCS_URL . '/alerting_transports/#' . $data['docs'];
} else {
$docs_link = OBSERVIUM_DOCS_URL . '/alerting_transports/#' . str_replace(' ', '-', strtolower($data['name']));
}
if (!safe_count($data['parameters']['global'])) { $data['parameters']['global'] = array(); } // Temporary until we separate "global" out.
// Plan: add defaults for transport types to global settings, which we use by default, then be able to override the settings via this GUI
// This needs supporting code in the transport to check for set variable and if not, use the global default
$form = array('type' => 'horizontal',
'id' => 'update_contact_status',
'title' => 'Contact Information',
'space' => '5px',
//'fieldset' => array('edit' => ''),
);
$row = 0;
$form['row'][++$row]['contact_method'] = array(
'type' => 'html',
//'fieldset' => 'edit',
'name' => 'Transport Method',
'class' => 'label',
'div_style' => 'padding-top: 5px;',
'readonly' => $readonly,
'value' => $data['name']);
$form['row'][++$row]['contact_doc'] = array(
'type' => 'html',
'fieldset' => 'body',
'offset' => TRUE,
'html' => '<a id="contact_doc" href="' . $docs_link . '" target="_blank">See documentation for this Transport (new page)</a>');
$form['row'][++$row]['contact_enabled'] = array(
'type' => 'switch-ng',
//'fieldset' => 'edit',
'name' => 'Contact Status',
'size' => 'small',
'on-color' => 'success',
'off-color' => 'danger',
'on-text' => 'Enabled',
'off-text' => 'Disabled',
'readonly' => $readonly,
'value' => !$contact['contact_disabled']);
$form['row'][++$row]['contact_descr'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Description',
'width' => '80%',
'readonly' => $readonly || $transport === 'syscontact',
'value' => $contact['contact_descr']);
if (safe_count($data['parameters']['required']) || safe_count($data['parameters']['global'])) {
// Pseudo item, just for additional title
$form['row'][++$row]['contact_required'] = array(
'type' => 'html',
//'fieldset' => 'edit',
'html' => '<h3 id="contact_required">Required parameters</h3>');
foreach (array_merge($data['parameters']['required'], $data['parameters']['global']) as $parameter => $param_data) // Temporary merge req & global
{
switch($param_data['type'])
{
case 'enum-freeinput':
$form_param = [
'type' => 'tags',
//'fieldset' => 'edit',
'name' => $param_data['description'],
'width' => '100%',
'readonly' => $readonly,
'value' => $contact['endpoint_parameters'][$parameter],
'values' => $param_data['params']
];
break;
case 'bool':
case 'boolean':
// Boolean type is just select with true/false string
if (!isset($param_data['params']))
{
$param_data['params'] = ['' => 'Unset', 'true' => 'True', 'false' => 'False' ];
}
// do not break here
case 'enum':
if (isset($contact['endpoint_parameters'][$parameter])) {
$value = $contact['endpoint_parameters'][$parameter];
if (isset($param_data['default']) &&
!(isset($param_data['params'][$value]) || in_array($value, (array)$param_data['params']))) {
$value = $param_data['default'];
}
} else {
$value = $param_data['default'];
}
$form_param = [
'type' => 'select',
//'fieldset' => 'edit',
'name' => $param_data['description'],
'width' => '80%',
'readonly' => $readonly,
'value' => $value,
'values' => $param_data['params']
];
break;
case 'textarea':
$form_param = [
'type' => 'textarea',
//'fieldset' => 'edit',
'name' => $param_data['description'],
'width' => '80%',
'rows' => 5,
'readonly' => $readonly,
'value' => $contact['endpoint_parameters'][$parameter]
];
// Prettify JSON
if (isset($param_data['format']) && $param_data['format'] === 'json' &&
$json = safe_json_decode($form_param['value'])) {
$form_param['value'] = safe_json_encode($json, JSON_PRETTY_PRINT);
}
break;
default:
$form_param = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => $param_data['description'],
'width' => '80%',
'readonly' => $readonly,
'value' => $contact['endpoint_parameters'][$parameter]
];
}
$form['row'][++$row]['contact_endpoint_'.$parameter] = $form_param;
if (isset($param_data['tooltip']))
{
$form['row'][$row]['tooltip_'.$parameter] = array(
'type' => 'raw',
//'fieldset' => 'edit',
'readonly' => $readonly,
'html' => generate_tooltip_link(NULL, '<i class="'.$config['icon']['question'].'"></i>', escape_html($param_data['tooltip'])));
}
}
}
if (safe_count($data['parameters']['optional']))
{
// Pseudo item, just for additional title
$form['row'][++$row]['contact_optional'] = array(
'type' => 'html',
//'fieldset' => 'edit',
'html' => '<h3 id="contact_optional">Optional parameters</h3>');
foreach ($data['parameters']['optional'] as $parameter => $param_data)
{
switch($param_data['type'])
{
case 'enum-freeinput':
$form_param = [
'type' => 'tags',
//'fieldset' => 'edit',
'name' => $param_data['description'],
'width' => '100%',
'readonly' => $readonly,
'value' => $contact['endpoint_parameters'][$parameter],
'values' => $param_data['params']
];
break;
case 'bool':
case 'boolean':
// Boolean type is just select with true/false string
if (!isset($param_data['params']))
{
$param_data['params'] = [ '' => 'Unset', 'true' => 'True', 'false' => 'False' ];
}
// do not break here
case 'enum':
if (isset($contact['endpoint_parameters'][$parameter])) {
$value = $contact['endpoint_parameters'][$parameter];
if (isset($param_data['default']) &&
!(isset($param_data['params'][$value]) || in_array($value, (array)$param_data['params']))) {
$value = $param_data['default'];
}
} else {
$value = $param_data['default'];
}
$form_param = [
'type' => 'select',
//'fieldset' => 'edit',
'name' => $param_data['description'],
'width' => '80%',
'readonly' => $readonly,
'value' => $value,
'values' => $param_data['params']
];
break;
case 'textarea':
$form_param = [
'type' => 'textarea',
//'fieldset' => 'edit',
'name' => $param_data['description'],
'width' => '80%',
'rows' => 5,
'readonly' => $readonly,
'value' => $contact['endpoint_parameters'][$parameter]
];
// Prettify JSON
if (isset($param_data['format']) && $param_data['format'] === 'json' &&
$json = safe_json_decode($form_param['value'])) {
$form_param['value'] = safe_json_encode($json, JSON_PRETTY_PRINT);
}
break;
default:
$form_param = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => $param_data['description'],
'width' => '80%',
'readonly' => $readonly,
'value' => $contact['endpoint_parameters'][$parameter]
];
}
$form['row'][++$row]['contact_endpoint_'.$parameter] = $form_param;
if (isset($param_data['tooltip']))
{
$form['row'][$row]['tooltip_'.$parameter] = array(
'type' => 'raw',
//'fieldset' => 'edit',
'readonly' => $readonly,
'html' => generate_tooltip_link(NULL, '<i class="'.$config['icon']['question'].'"></i>', $param_data['tooltip']));
}
}
}
// User defined templates
$message_template = '';
$message_custom = isset($contact['contact_message_custom']) && $contact['contact_message_custom'];
if ($message_custom) {
// user defined
$message_template = $contact['contact_message_template'];
} elseif (isset($data['notification']['message_template'])) {
// file-based template
// template can have tags (ie telegram)
if (str_contains($data['notification']['message_template'], '%')) {
//print_vars($data['notification']['message_template']);
$template = array_tag_replace(generate_transport_tags($transport, $contact['endpoint_parameters']), $data['notification']['message_template']);
$template = strtolower($template);
//print_vars($template);
} else {
$template = $data['notification']['message_template'];
}
$message_template = get_template('notification', $template);
// remove own comments
$message_template = preg_replace('!^\s*/\*[\*\s]+Observium\s.*?\*/(\s*\n)?!is', '', $message_template);
} elseif (isset($data['notification']['message_text'])) {
// definition-based template
$message_template = $data['notification']['message_text'];
}
if (strlen($message_template)) {
// Pseudo item, just for additional title
$form['row'][++$row]['message_title'] = [
'type' => 'html',
//'fieldset' => 'edit',
'html' => '<h3 id="message_title">Notification parameters</h3>'
];
$form['row'][++$row]['contact_message_custom'] = [
'type' => 'toggle',
'name' => 'Custom template',
'view' => 'toggle',
'size' => 'large',
'placeholder' => 'Set custom message, using Mustache formatting.',// : [Notification templates]('.OBSERVIUM_DOCS_URL.'/xxx/){target=_blank}',
//'width' => '250px',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'contact_message_template');",
'value' => $message_custom
];
$form['row'][++$row]['contact_message_template'] = [
'type' => 'textarea',
//'fieldset' => 'edit',
'name' => 'Template',
'rows' => 6,
'class' => 'text-monospace small',
//'style' => 'font-size: 12px;',
'width' => '500px',
//'placeholder' => '1-30. Default 10.',
'readonly' => $readonly,
'disabled' => !$message_custom,
'value' => $message_template
];
}
$form['row'][++$row]['action'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'update_contact'
];
//print_vars($form);
print_form($form);
unset($form, $row);
?>
</div>
<div class="col-sm-5">
<?php
// Alert associations
$assoc_exists = array();
if ($transport === 'syscontact' && $config['email']['default_syscontact']) {
$assocs = dbFetchRows('SELECT * FROM `alert_tests`
ORDER BY `entity_type`, `alert_name` DESC');
} else {
$assocs = dbFetchRows('SELECT * FROM `alert_contacts_assoc` AS A
LEFT JOIN `alert_tests` AS T ON T.`alert_test_id` = A.`alert_checker_id`
WHERE `aca_type` = ? AND `contact_id` = ?
ORDER BY `entity_type`, `alert_name` DESC', [ 'alert', $contact['contact_id'] ]);
}
//r($assocs);
echo generate_box_open(array('title' => 'Associated Alert Checkers', 'header-border' => TRUE));
if (safe_count($assocs)) {
echo('<table class="'. OBS_CLASS_TABLE_STRIPED .'">');
foreach ($assocs as $assoc)
{
$alert_test = get_alert_test_by_id($assoc['alert_test_id']);
$assoc_exists[$assoc['alert_test_id']] = TRUE;
echo('<tr>
<td width="150px"><i class="'.$config['entities'][$alert_test['entity_type']]['icon'].'"></i> '.nicecase($alert_test['entity_type']).'</td>
<td>'.escape_html($alert_test['alert_name']).'</td>
<td width="25px">');
$form = array('type' => 'simple',
//'userlevel' => 10, // Minimum user level for display form
'id' => 'delete_alert_checker_'.$assoc['alert_test_id'],
'style' => 'display:inline;',
);
$form['row'][0]['alert_test_id'] = array(
'type' => 'hidden',
'value' => $assoc['alert_test_id']);
$form['row'][0]['contact_id'] = array(
'type' => 'hidden',
'value' => $contact['contact_id']);
$form['row'][99]['action'] = array(
'type' => 'submit',
'icon_only' => TRUE, // hide button styles
'name' => '',
'icon' => $config['icon']['cancel'],
'readonly' => $transport === 'syscontact',
//'class' => 'btn-small',
// confirmation dialog
'attribs' => array('data-toggle' => 'confirm', // Enable confirmation dialog
'data-confirm-placement' => 'left',
'data-confirm-content' => 'Delete associated checker "'.escape_html($alert_test['alert_name']).'"?',
//'data-confirm-content' => '<div class="alert alert-warning"><h4 class="alert-heading"><i class="icon-warning-sign"></i> Warning!</h4>
// This association will be deleted!</div>'),
),
'value' => 'delete_alert_checker_contact');
print_form($form);
unset($form);
echo('</td>
</tr>');
}
echo('</table>');
} else {
echo('<p class="text-center text-warning bg-warning" style="padding: 10px; margin: 0px;"><strong>This contact is not currently associated with any Alert Checkers</strong></p>');
}
// FIXME -- use NOT IN to mask already associated things.
$alert_tests = dbFetchRows('SELECT * FROM `alert_tests` ORDER BY `entity_type`, `alert_name`');
if (safe_count($alert_tests)) {
foreach ($alert_tests as $alert_test) {
if (!isset($assoc_exists[$alert_test['alert_test_id']])) {
$form_items['alert_checker_id'][$alert_test['alert_test_id']] = [
'name' => $alert_test['alert_name'],
'icon' => $config['entities'][$alert_test['entity_type']]['icon']
];
}
}
$form = array('type' => 'simple',
//'userlevel' => 10, // Minimum user level for display form
'id' => 'associate_alert_check',
'style' => 'padding: 7px; margin: 0px;',
'right' => TRUE,
);
$form['row'][0]['type'] = array(
'type' => 'hidden',
'value' => 'alert');
$form['row'][0]['alert_checker_id'] = array(
'type' => 'select',
'name' => 'Associate Alert Checker',
'live-search' => FALSE,
'width' => '250px',
//'right' => TRUE,
'readonly' => $readonly,
'values' => $form_items['alert_checker_id'],
'value' => $vars['alert_checker_id']);
$form['row'][0]['action'] = array(
'type' => 'submit',
'name' => 'Associate',
'icon' => $config['icon']['plus'],
//'right' => TRUE,
'readonly' => $readonly,
'class' => 'btn-primary',
'value' => 'associate_alert_check');
$box_close['footer_content'] = generate_form($form);
$box_close['footer_nopadding'] = TRUE;
unset($form, $form_items);
} else {
// print_warning('No unassociated alert checkers.');
}
echo generate_box_close($box_close);
// Syslog associations
$assoc_exists = array();
if ($transport === 'syscontact' && $config['email']['default_syscontact']) {
$assocs = dbFetchRows('SELECT * FROM `syslog_rules`
ORDER BY `la_severity`, `la_name` DESC');
} else {
$assocs = dbFetchRows('SELECT * FROM `alert_contacts_assoc` AS A
LEFT JOIN `syslog_rules` AS T ON T.`la_id` = A.`alert_checker_id`
WHERE `aca_type` = ? AND `contact_id` = ?
ORDER BY `la_severity`, `la_name` DESC', [ 'syslog', $contact['contact_id'] ]);
}
//r($assocs);
echo generate_box_open(array('title' => 'Associated Syslog Rules', 'header-border' => TRUE));
if (safe_count($assocs))
{
echo('<table class="'. OBS_CLASS_TABLE_STRIPED .'">');
foreach ($assocs as $assoc)
{
//$alert_test = get_alert_test_by_id($assoc['alert_checker_id']);
$assoc_exists[$assoc['la_id']] = TRUE;
echo('<tr>
<td width="150"><i class="'.$config['icon']['syslog-alerts'].'"></i> '.escape_html($assoc['la_name']).'</td>
<td>'.escape_html($assoc['la_rule']).'</td>
<td width="25">');
$form = array('type' => 'simple',
//'userlevel' => 10, // Minimum user level for display form
'id' => 'delete_syslog_checker_'.$assoc['la_id'],
'style' => 'display:inline;',
);
$form['row'][0]['alert_test_id'] = array(
'type' => 'hidden',
'value' => $assoc['la_id']);
$form['row'][0]['contact_id'] = array(
'type' => 'hidden',
'value' => $contact['contact_id']);
$form['row'][99]['action'] = array(
//$form['row'][99]['submit'] = array(
'type' => 'submit',
'icon_only' => TRUE, // hide button styles
'name' => '',
'icon' => $config['icon']['cancel'],
'readonly' => $transport === 'syscontact',
//'class' => 'btn-small',
// confirmation dialog
'attribs' => array('data-toggle' => 'confirm', // Enable confirmation dialog
'data-confirm-placement' => 'left',
'data-confirm-content' => 'Delete associated rule "'.escape_html($assoc['la_name']).'"?',
//'data-confirm-content' => '<div class="alert alert-warning"><h4 class="alert-heading"><i class="icon-warning-sign"></i> Warning!</h4>
// This association will be deleted!</div>'),
),
'value' => 'delete_syslog_checker_contact');
print_form($form);
unset($form);
echo('</td>
</tr>');
}
echo('</table>');
} else {
echo('<p class="text-center text-warning bg-warning" style="padding: 10px; margin: 0px;"><strong>This contact is not currently associated with any Syslog Rules</strong></p>');
}
$alert_tests = dbFetchRows('SELECT * FROM `syslog_rules` ORDER BY `la_severity`, `la_name`');
if (safe_count($alert_tests)) {
foreach ($alert_tests as $alert_test) {
if (!isset($assoc_exists[$alert_test['la_id']])) {
$form_items['la_id'][$alert_test['la_id']] = [
'name' => $alert_test['la_name'],
'subtext' => $alert_test['la_rule'],
'icon' => $config['icon']['syslog-alerts']
];
}
}
$form = array('type' => 'simple',
//'userlevel' => 10, // Minimum user level for display form
'id' => 'associate_syslog_rule',
'style' => 'padding: 7px; margin: 0px;',
'right' => TRUE,
);
$form['row'][0]['type'] = array(
'type' => 'hidden',
'value' => 'syslog');
$form['row'][0]['la_id'] = array(
'type' => 'select',
'name' => 'Associate Syslog Rule',
'live-search' => FALSE,
'width' => '250px',
//'right' => TRUE,
'readonly' => $readonly,
'values' => $form_items['la_id'],
'value' => $vars['la_id']);
$form['row'][0]['action'] = array(
'type' => 'submit',
'name' => 'Associate',
'icon' => $config['icon']['plus'],
//'right' => TRUE,
'readonly' => $readonly,
'class' => 'btn-primary',
'value' => 'associate_syslog_rule');
$box_close['footer_content'] = generate_form($form);
$box_close['footer_nopadding'] = TRUE;
unset($form, $form_items);
} //else { print_warning('No unassociated syslog rules.'); }
echo generate_box_close($box_close);
echo('</div>');
} else {
print_error("Contact doesn't exist.");
}
// EOF

230
html/pages/contacts.inc.php Normal file
View File

@ -0,0 +1,230 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Contact display and editing page.
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');
?>
<div class="row">
<div class="col-sm-12">
<?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');
}
// FIXME. Show for anyone > 5 (also for non-ADMIN) and any contacts?
$contacts = dbFetchRows('SELECT * FROM `alert_contacts` WHERE 1');
if (count($contacts)) {
//r($contacts);
// We have contacts, print the table.
echo generate_box_open();
?>
<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>
<?php
$modals = '';
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;
}
if ($contact['contact_disabled'] == 1) { $disabled = ""; }
// 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);
// 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]);
}
}
}
$contact['endpoint_descr'] = implode('<br />', $contact['endpoint_identifiers']);
} else {
$contact['endpoint_descr'] = escape_html($contact['contact_endpoint']);
}
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>';
/* now in defaults for generate_form_modal()
$modal_args = array(
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
//'class' => 'modal-md',
);
*/
$form = array('type' => 'horizontal',
'userlevel' => 10, // Minimum user level for display form
'id' => 'modal-contact_delete_'.$contact['contact_id'],
'title' => 'Delete Contact "' . $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!
$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');
$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');
$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');
$modals .= generate_form_modal($form);
unset($form);
}
?>
</tbody>
</table>
<?php
echo generate_box_close();
echo $modals;
unset($modals);
} else {
// We don't have contacts. Say so.
print_warning("There are currently no contacts configured.");
}
?>
</div> <!-- col-sm-12 -->
</div> <!-- row -->
<?php
// EOF

View File

@ -0,0 +1,137 @@
<?php
/**
* Observium Network Management and Monitoring System
*
* @package observium
* @subpackage web
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
register_html_title("Customers");
$navbar['brand'] = "Customers";
$navbar['class'] = "navbar-narrow";
if (isset($vars['customer']) && $vars['customer'] == 'hide') {
$navbar['options_right']['cust']['class'] = 'active';
$navbar['options_right']['cust']['url'] = generate_url($vars, array('customer' => NULL));
} else {
$navbar['options_right']['cust']['url'] = generate_url($vars, array('customer' => 'hide'));
}
$navbar['options_right']['cust']['text'] = 'Customer Graphs';
$navbar['options_right']['cust']['icon'] = $config['icon']['graphs'];
if (isset($vars['aggregate']) && $vars['aggregate'] == 'show') {
$navbar['options_right']['aggregate']['class'] = 'active';
$navbar['options_right']['aggregate']['url'] = generate_url($vars, array('aggregate' => NULL));
} else {
$navbar['options_right']['aggregate']['url'] = generate_url($vars, array('aggregate' => 'show'));
}
$navbar['options_right']['aggregate']['text'] = 'Aggregate';
$navbar['options_right']['aggregate']['icon'] = $config['icon']['graphs'];
print_navbar($navbar);
unset($navbar);
/// Generate customer aggregate graph
if (isset($vars['aggregate']) && $vars['aggregate'] == 'show') {
$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'));
if ($port_list) {
$graph_array['type'] = 'multi-port_bits_separate';
$graph_array['to'] = $config['time']['now'];
$graph_array['legend'] = 'no';
$graph_array['id'] = $port_list;
print_graph_row($graph_array);
}
echo generate_box_close();
}
echo generate_box_open();
?>
<table class="table table-hover table-striped-two table-condensed">
<thead>
<tr>
<th style="width: 250px;"><span style="font-weight: bold;" class="interface">Customer</span></th>
<th style="width: 150px;">Device</th>
<th style="width: 100px;">Interface</th>
<th style="width: 100px;">Speed</th>
<th style="width: 100px;">Circuit</th>
<th>Notes</th>
</tr>
</thead>
<?php
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`") as $customer) {
$customer_name = $customer['port_descr_descr'];
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ?", array($customer['port_descr_descr'])) as $port) {
$device = device_by_id_cache($port['device_id']);
unset($class);
$ifclass = port_html_class($port['ifOperStatus'], $port['ifAdminStatus'], $port['encrypted']);
if ($device['os'] == "ios") {
if ($port['ifTrunk']) {
$vlan = "<span class=small><span class=red>" . $port['ifTrunk'] . "</span></span>";
} elseif ($port['ifVlan']) {
$vlan = "<span class=small><span class=blue>VLAN " . $port['ifVlan'] . "</span></span>";
} else {
$vlan = "";
}
}
echo('
<tr>
<td style="width: 250px;"><span style="font-weight: bold;" class="interface">' . $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>
</tr>
');
unset($customer_name);
}
if ($config['int_customers_graphs'] && !(isset($vars['customer']) && $vars['customer'] == "hide")) {
echo('<tr><td colspan="7">');
$graph_array['type'] = "customer_bits";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = '"' . $customer['port_descr_descr'] . '"'; // use double quotes for prevent split var by commas
print_graph_row($graph_array);
echo("</tr>");
}
}
echo("</table>");
echo generate_box_close();
// EOF

View File

@ -0,0 +1,661 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
register_html_resource('css', 'gridstack.min.css');
register_html_resource('js', 'lodash.min.js');
register_html_resource('js', 'jquery-ui.min.js');
register_html_resource('js', 'gridstack.all.js');
// Load map stuff so that it's available to widgets.
// included in base css to control styles
//register_html_resource('css', 'leaflet.css');
register_html_resource('js', 'leaflet.js');
// IE (pre Edge) js fetch fix
$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', 'leaflet-realtime.js');
// Allows us to detect when things are resized.
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');
}
$grid_cell_height = 20;
$grid_h_margin = 100;
$grid_v_margin = 15;
if (!isset($vars['dash']))
{
$vars['dash'] = '1';
$dashboard = dbFetchRow("SELECT * FROM `dashboards` WHERE `dash_id` = ?", array($vars['dash']));
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;
}
$dashboard = dbFetchRow("SELECT * FROM `dashboards` WHERE `dash_id` = ?", array($vars['dash']));
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')];
$form = array('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);
}
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> -->
<script type="text/javascript">
var dash_id = <?php echo $dashboard['dash_id']; ?>;
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
$(function () {
var options = {
cellHeight: <?php echo $grid_cell_height; ?>,
horizontalMargin: <?php echo $grid_h_margin; ?>,
verticalMargin: <?php echo $grid_v_margin; ?>,
resizable: {
autoHide: true,
handles: <?php if ($is_editing === TRUE) echo "'se, sw'"; else echo "'none'"; ?>
},
draggable: {
handle: '.drag-handle',
}
};
$('.grid-stack').gridstack(options);
var initial_grid = [
<?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'] . '"}';
}
echo implode(",", $data);
?>
];
this.grid = $('.grid-stack').data('gridstack');
var grid = $('.grid-stack').data('gridstack');
///////////////
// LOAD GRID //
///////////////
this.loadGrid = function () {
this.grid.removeAll();
var items = GridStackUI.Utils.sort(initial_grid);
var self = this;
_.each(items, function (node) {
node.autoposition = null;
self.drawWidget(node);
}, this);
return false;
}.bind(this);
///////////////
// SAVE GRID //
///////////////
this.saveGrid = function () {
this.initial_grid = _.map($('.grid-stack > .grid-stack-item:visible'), function (el) {
el = $(el);
var node = el.data('_gridstack_node');
return {
x: node.x,
y: node.y,
width: node.width,
height: node.height,
id: el.attr('data-gs-id'),
};
}, this);
$('#saved-data').val(JSON.stringify(this.initial_grid, null, ' '));
var self = this;
// We need to get a widget id via AJAX
$.ajax({
type: "POST",
url: "ajax/actions.php",
data: {action: 'save_grid', grid: self.initial_grid},
cache: false,
success: function (response) {
//console.log(response);
//console.log(self.initial_grid);
}
});
return false;
}.bind(this);
this.clearGrid = function () {
this.grid.removeAll();
return false;
}.bind(this);
/////////////////////
// DRAW THE WIDGET //
/////////////////////
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>' +
<?php } ?>
'</div>'),
node.x, node.y, node.width, node.height, node.autoposition, null, null, null, null, node.id);
};
////////////////
// ADD WIDGET //
////////////////
addNewWidget = function (type, dash_id) {
// We need to get a widget id via AJAX
$.ajax({
type: "POST",
url: "ajax/actions.php",
data: jQuery.param([{name: 'action', value: 'add_widget'}, {name: "widget_type", value: type}, {name: "dash_id", value: dash_id}]),
cache: false,
success: function (response) {
if (isNumber(response.id)) {
// Create the initial widget array use autoposition and id from ajax
var node = {
width: 4,
height: 3,
autoposition: true,
id: response.id
};
// Draw the widget
self.drawWidget(node);
// Save grid
self.saveGrid();
// Redraw widgets
self.refreshAllWidgets(response.id);
}
console.log(response);
}
});
return false;
}.bind(this);
/////////////////////////
// Refresh All Widgets //
/////////////////////////
refreshAllWidgets = function () {
$('.grid-stack-item').each(function () {
refreshWidget($(this).attr('data-gs-id'));
});
};
refreshAllUpdatableWidgets = function () {
$('.grid-stack-item').each(function () {
// Do not update a widget if its child has the do-not-update class
// Do not update a widget if we're hovering over it with the mouse
if (!$(this).children('div').children('div').hasClass('do-not-update') && !$(this).is(':hover')) {
refreshWidget($(this).attr('data-gs-id'));
}
});
};
refreshAllUpdatableImages = function () {
// Add or replace nocache parameter on image src and then rewrite the image.
var pt = /\&nocache=.+/;
$('.image-refresh').each(function () {
if (this.src) {
pt.test(this.src)
? $(this).attr("src", this.src.replace(pt, "&nocache=" + Date.now()))
: $(this).attr("src", this.src + "&nocache=" + Date.now());
}
// FIXME - find a better way to update srcset
// If it already exists, we update it, if not, we insert it before the space.
if (this.srcset) {
pt.test(this.srcset)
? $(this).attr("srcset", this.srcset.replace(pt, "&nocache=" + Date.now()))
: $(this).attr("srcset", this.srcset.replace(/\ /, "&nocache=" + Date.now() + ' '));
}
});
};
///////////////////////////
// Refresh single widget //
///////////////////////////
refreshWidget = function (id) {
// This is the content div to be updated
var div = $('#widget-' + id);
// Generate array of parameters to send to the server.
var params = {
width: div.innerWidth(),
height: div.innerHeight(),
id: id
};
// Run AJAX query and update div HTML with response.
$.ajax({
type: "POST",
url: "ajax/widget.php",
data: jQuery.param(params),
cache: false,
success: function (response) {
div.html(response);
}
});
};
deleteWidget = function (id) {
var el = $(".grid-stack-item[data-gs-id='" + id + "']");
var params = {
action: 'del_widget',
widget_id: id
};
// Run AJAX query and update div HTML with response.
$.ajax({
type: "POST",
url: "ajax/actions.php",
data: jQuery.param(params),
cache: false,
success: function (response) {
grid.removeWidget(el);
console.log(response);
}
});
};
configWidget = function (id) {
var params = {
action: 'edit_widget',
widget_id: id
};
$.ajax({
type: "POST",
url: "ajax/actions.php",
data: jQuery.param(params),
cache: false,
success: function (response) {
$('#config-modal-body').html(response);
$('#config-modal').modal({show: true});
}
});
};
// Captures Delete Dashboard button.
dashDelete = function () {
var dash_id = $('#dash_id').val();
var params = {
action: 'dash_delete',
dash_id: dash_id
};
// Run AJAX query and update div HTML with response.
var request = $.ajax({
type: "POST",
url: "ajax/actions.php",
data: jQuery.param(params),
cache: false,
});
request.success(function (json) {
if (json.status === 'ok') {
window.setTimeout(window.location.href = '<?php echo generate_url(array('page' => 'dashboard')); ?>', 5000);
}
});
};
/////////////
// Actions //
/////////////
$('#add-new-widget').click(this.addNewWidget);
$('#save-grid').click(this.saveGrid);
$('#load-grid').click(this.loadGrid);
$('#clear-grid').click(this.clearGrid);
$('#refresh-widgets').click(this.refreshAllWidgets);
// Captures Add Widget button.
$("#add_widget").submit(function (event) {
if ($('#widget_type').val()) {
addNewWidget($('#widget_type').val(), $('#dash_id').val());
}
event.preventDefault();
});
// Captures Delete Dashboard button.
/* Moved to onclick for correct confirm
$("#dash_delete").click(function () {
var dash_id = $('#dash_id').val();
var params = {
action: 'dash_delete',
dash_id: dash_id
};
// Run AJAX query and update div HTML with response.
var request = $.ajax({
type: "POST",
url: "ajax/actions.php",
data: jQuery.param(params),
cache: false,
});
request.success(function (json) {
if (json.status === 'ok') {
window.setTimeout(window.location.href = '<?php //echo generate_url(array('page' => 'dashboard')); ?>', 5000);
} else {
}
});
});
*/
// Captures Delete Dashboard button.
$("#dash_name").change(function () {
var dash_id = $('#dash_id').val();
var dash_name = $('#dash_name').val();
var params = {
action: 'dash_rename',
dash_id: dash_id,
dash_name: dash_name
};
// Run AJAX query and update div HTML with response.
var request = $.ajax({
type: "POST",
url: "ajax/actions.php",
data: jQuery.param(params),
cache: false,
});
request.success(function (json) {
if (json.status === 'ok') {
} else {
}
});
});
this.loadGrid();
refreshAllWidgets();
var self = this;
// FIXME - only update changed widgets
$('.grid-stack').on('change', function (event, items) {
items.forEach(function (item) {
refreshWidget(item.el.attr('data-gs-id'));
});
//entity_popups();
//popups_from_data();
self.saveGrid();
});
setInterval(function () {
refreshAllUpdatableWidgets();
}, 20000);
setInterval(function () {
refreshAllUpdatableImages();
}, 15000);
});
new ResizeSensor(jQuery('#main_container'), function(){
//refreshAllUpdatableImages();
//refreshAllUpdatableWidgets();
refreshAllWidgets();
});
</script>
<?php
// print_vars($widgets);
?>
<style>
.grid-stack > .grid-stack-item > .grid-stack-item-content {
overflow-x: visible;
overflow-y: visible;
}
.grid-stack > .grid-stack-item > .grid-stack-item-content:hover {
overflow-x: visible;
overflow-y: visible;
}
.grid-stack > .grid-stack-item:hover .hover-hide {
display: none;
}
.grid-stack > .grid-stack-item .hover-show {
display: none;
}
.grid-stack > .grid-stack-item:hover .hover-show {
display: block;
}
.grid-stack > .grid-stack-item h4 {
margin: 3px 6px;
}
.grid-stack tr {
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;
}
.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>
<!-- Modal -->
<div class="modal fade" id="config-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Configure Widget</h4>
</div>
<div id="config-modal-body" class="modal-body">
<div class="te"></div>
</div>
<!--
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
-->
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<?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"; }
$footer_entry = '<li><a href="' .$url. '"><i class="sprite-sliders"></i></a></li>';
$footer_entries[] = $footer_entry;
}
}
else
{
print_error('Dashboard does not exist!');
}
// EOF

View File

@ -0,0 +1,19 @@
<?php
/**
* 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
*
*/
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]));
}

View File

@ -0,0 +1,66 @@
<?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
*
*/
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');
}
}
}
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();
echo('<table class="table table-condensed table-striped table-condensed">
<thead><tr>
<th>Device</th>
<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>
</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);
}
}
echo('</table>');
echo generate_box_close();
// EOF

105
html/pages/delhost.inc.php Normal file
View File

@ -0,0 +1,105 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Global write permissions required.
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
}
register_html_title("Delete devices");
if (is_intnum($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>?");
$form = array('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);
}
} else {
$form_items['devices'] = generate_form_values('device', NULL, NULL, array('disabled' => TRUE));
$form = array('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);
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);
}
// EOF

848
html/pages/device.inc.php Normal file
View File

@ -0,0 +1,848 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// If we've been given a hostname, try to retrieve the device_id
if (isset($vars['device']) && !is_numeric($vars['device'])) {
$vars['hostname'] = $vars['device'];
unset($vars['device']);
}
if (safe_empty($vars['device']) && !safe_empty($vars['hostname'])) {
$vars['device'] = get_device_id_by_hostname($vars['hostname']);
// If device lookup fails, generate an error.
if (! $vars['device']) {
print_error('<h4>Invalid Hostname</h4>
A device matching the given hostname was not found. Please retype the hostname and try again.');
return;
}
}
// If there is no device specified in the URL, generate an error.
if (safe_empty($vars['device'])) {
print_error('<h4>No device specified</h4>
A valid device was not specified in the URL. Please retype and try again.');
return;
}
// Allow people to see this page if they have permission to see one of the ports, but don't show them tabs.
$permit_tabs = array();
if ($vars['tab'] === "port" && is_numeric($vars['device']) && (isset($vars['port']) || isset($vars['ifdescr']))) {
// If we've been given a 'ifdescr' variable, try to work out the port_id from this
if (!is_numeric($vars['port']) && !empty($vars['ifdescr']))
{
$ifdescr = base64_decode($vars['ifdescr']);
if (!$ifdescr) { $ifdescr = $vars['ifdescr']; }
$vars['port'] = get_port_id_by_ifDescr($vars['device'], $ifdescr);
}
if (port_permitted($vars['port']) && $vars['device'] == get_device_id_by_port_id($vars['port']))
{
$permit_tabs['ports'] = TRUE;
}
}
if ($vars['tab'] === "health" && isset($vars['id']) && is_numeric($vars['id']) &&
is_entity_permitted($vars['id'], 'sensor'))
{
$permit_tabs['health'] = TRUE;
}
//print_vars($permit_tabs);
// If there is no valid device specified in the URL, generate an error.
if (!isset($cache['devices']['id'][$vars['device']]) && !safe_count($permit_tabs))
{
print_error('<h4>No valid device specified</h4>
A valid device was not specified in the URL. Please retype and try again.');
return;
}
// Only show if the user has access to the whole device or a single port.
if (isset($cache['devices']['id'][$vars['device']]) || safe_count($permit_tabs))
{
$selected['iface'] = "active";
$tab = str_replace(".", "", $vars['tab']);
if (!$tab)
{
$tab = "overview";
}
$select[$tab] = "active"; // FIXME. ????
// Populate device array from pre-populated cache
$device = device_by_id_cache($vars['device']);
// Populate the attributes array for this device
$attribs = get_dev_attribs($device['device_id']);
// Populate the entityPhysical state array for this device
$entity_state = get_device_entphysical_state($device['device_id']);
// Populate the device state array from the serialized entry
$device_state = safe_unserialize($device['device_state']);
// Add the device hostname to the page title array
register_html_title(escape_html($device['hostname']));
// If the device's OS type has a group, set the device's os_group
if ($config['os'][$device['os']]['group'])
{
$device['os_group'] = $config['os'][$device['os']]['group'];
}
//// DEV
// Start to cache panel
/* NOTE. Also this panel content can be moved to html/includes/panels/device.inc.php (instead ob_cache() here)
ob_start();
print_device_header($device, array('no_graphs' => TRUE));
include("pages/device/overview/information_extended.inc.php");
echo generate_box_open();
// Only show graphs for device_permitted(), don't show device graphs to users who can only see a single entity.
if (isset($config['os'][$device['os']]['graphs']))
{
$graphs = $config['os'][$device['os']]['graphs'];
}
else if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['graphs']))
{
$graphs = $config['os'][$device['os_group']]['graphs'];
} else {
// Default group
$graphs = $config['os_group']['default']['graphs'];
}
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "213";
$graph_array['to'] = $config['time']['now'];
$graph_array['device'] = $device['device_id'];
$graph_array['type'] = "device_bits";
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no";
$graph_array['bg'] = "FFFFFF00";
// Preprocess device graphs array
$graphs_enabled = [];
foreach ($device['graphs'] as $graph)
{
$graphs_enabled[] = $graph['graph'];
}
echo '<div class="row">';
foreach ($graphs as $entry)
{
if ($entry && in_array(str_replace('device_', '', $entry), $graphs_enabled) !== FALSE)
{
$graph_array['type'] = $entry;
preg_match('/^(?P<type>[a-z0-9A-Z-]+)_(?P<subtype>[a-z0-9A-Z-_]+)/', $entry, $graphtype);
if (isset($graphtype['type']) && isset($graphtype['subtype']))
{
$type = $graphtype['type'];
$subtype = $graphtype['subtype'];
$text = $config['graph_types'][$type][$subtype]['descr'];
} else {
$text = nicecase($subtype); // Fallback to the type itself as a string, should not happen!
}
echo('<div class="col-xl-6">');
echo("<div style='padding: 0px; text-align: center;'><h4>$text</h4></div>");
print_graph_popup($graph_array);
echo("</div>");
}
}
echo '</div>';
echo generate_box_close();
$panel_html = ob_get_clean();
register_html_panel($panel_html);
unset($graph_array, $panel_html);
// End panel */
// Print the device header
//echo '<div class="hidden-xl">';
print_device_header($device, [ 'div-class' => 'hidden-xl' ]);
//echo '</div>';
// Show tabs if the user has access to this device
if (device_permitted($device['device_id'])) {
if ($config['show_overview_tab']) {
$navbar['options']['overview'] = array('text' => 'Overview', 'icon' => $config['icon']['overview']);
}
$navbar['options']['graphs'] = array('text' => 'Graphs', 'icon' => $config['icon']['graphs']);
$health_exist = [
'storage' => dbExist('storage', '`device_id` = ?', array($device['device_id'])),
'diskio' => dbExist('ucd_diskio', '`device_id` = ?', array($device['device_id'])),
'mempools' => dbExist('mempools', '`device_id` = ?', array($device['device_id'])),
'processors' => dbExist('processors', '`device_id` = ?', array($device['device_id'])),
'sensors' => dbExist('sensors', '`device_id` = ? AND `sensor_deleted` = ?', array($device['device_id'], 0)),
'status' => dbExist('status', '`device_id` = ? AND `status_deleted` = ?', array($device['device_id'], 0)),
'counter' => dbExist('counters', '`device_id` = ? AND `counter_deleted` = ?', array($device['device_id'], 0)),
];
//r($health_exist);
$health = $health_exist['storage'] || $health_exist['diskio'] ||
$health_exist['sensors'] || $health_exist['status'] || $health_exist['counter'] ||
$health_exist['mempools'] || $health_exist['processors'];
if ($health) {
$navbar['options']['health'] = array('text' => 'Health', 'icon' => $config['icon']['health']);
}
// Ports submenu
$ports_exist = [
'ports' => dbExist('ports', '`device_id` = ?', array($device['device_id'])),
'ipv4' => dbExist('ipv4_addresses', '`device_id` = ?', array($device['device_id'])),
'ipv6' => dbExist('ipv6_addresses', '`device_id` = ?', array($device['device_id']))
];
$link_array = [
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'ports'
];
// Print the port tab if there are matching entries in the ports table
if ($ports_exist['ports']) {
$navbar['options']['ports'] = array('text' => 'Ports', 'icon' => $config['icon']['port']);
$navbar['options']['ports']['suboptions']['basic']['text'] = 'Basic';
$navbar['options']['ports']['suboptions']['details']['text'] = 'Details';
$navbar['options']['ports']['suboptions']['divider_1']['divider'] = TRUE;
}
$option = 'ipv4';
if ($ports_exist[$option]) {
// Duplicate, because possible IPs without Ports
$navbar['options']['ports']['text'] = 'Ports';
$navbar['options']['ports']['icon'] = $config['icon']['port'];
$navbar['options']['ports']['suboptions'][$option]['text'] = 'IPv4 addresses';
//$navbar['options']['ports']['suboptions'][$option]['url'] = generate_url($link_array, [ 'view' => $option ]);
}
$option = 'ipv6';
if ($ports_exist[$option]) {
// Duplicate, because possible IPs without Ports
$navbar['options']['ports']['text'] = 'Ports';
$navbar['options']['ports']['icon'] = $config['icon']['port'];
$navbar['options']['ports']['suboptions'][$option]['text'] = 'IPv6 addresses';
//$navbar['options']['ports']['suboptions'][$option]['url'] = generate_url($link_array, [ 'view' => $option ]);
}
// Other ports options after Addresses
if ($ports_exist['ports']) {
$filters_array = isset($vars['filters']) ? $vars['filters'] : [ 'deleted' => TRUE ];
$link_array['filters'] = $filters_array;
// FIXME, need add device_id field into table ip_mac
if ($ports_exist['arp'] = dbFetchCell("SELECT COUNT(*) FROM `ip_mac` LEFT JOIN `ports` USING(`port_id`) WHERE `device_id` = ?", [ $device['device_id'] ]))
//if ($ports_exist['arp'] = dbExist('ip_mac', '`device_id` = ?', [ $device['device_id'] ]))
{
$navbar['options']['ports']['suboptions']['arp']['text'] = 'ARP/NDP Table';
}
if ($ports_exist['fdb'] = dbExist('vlans_fdb', '`device_id` = ?', [ $device['device_id'] ]))
{
$navbar['options']['ports']['suboptions']['fdb']['text'] = 'FDB Table';
}
if ($health_exist['sensors'] &&
$ports_exist['sensors'] = dbExist('sensors', '`device_id` = ? AND `measured_class` = ? AND `sensor_deleted` = ?', [ $device['device_id'], 'port', 0 ]))
{
$navbar['options']['ports']['suboptions']['sensors']['text'] = 'Sensors';
}
if ($ports_exist['neighbours'] = dbExist('neighbours', '`device_id` = ?', [ $device['device_id'] ]))
{
$navbar['options']['ports']['suboptions']['neighbours']['text'] = 'Neighbours';
$navbar['options']['ports']['suboptions']['map']['text'] = 'Map';
}
if ($ports_exist['adsl'] = dbExist('ports', '`ifType` = ? AND `device_id` = ?', array('adsl', $device['device_id'])))
{
$navbar['options']['ports']['suboptions']['adsl']['text'] = 'ADSL';
}
}
// Store for ports tab
$ports_exist['navbar'] = $navbar['options']['ports']['suboptions'];
// Ports options urls and active
foreach ($navbar['options']['ports']['suboptions'] as $option => $entry) {
if (!isset($entry['url'])) {
$navbar['options']['ports']['suboptions'][$option]['url'] = generate_url($link_array, [ 'view' => $option ]);
if ($vars['tab'] === 'ports' && $vars['view'] === $option) {
$navbar['options']['ports']['suboptions'][$option]['class'] .= ' active';
}
}
}
//r($ports_exist);
// Print vlans tab if there are matching entries in the vlans table
//if (dbFetchCell('SELECT COUNT(vlan_id) FROM vlans WHERE device_id = ?', array($device['device_id'])) > '0')
if (dbExist('vlans', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['vlans'] = array('text' => 'VLANs', 'icon' => $config['icon']['vlan']);
}
// Print the SLAs tab if there are matching entries in the slas table
//if (dbFetchCell('SELECT COUNT(*) FROM `slas` WHERE `device_id` = ? AND `deleted` = 0', array($device['device_id'])) > '0')
if (dbExist('slas', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['slas'] = array('text' => 'SLAs', 'icon' => $config['icon']['sla']);
}
// Juniper Firewall MIB. Some day generify this stuff.
if (isset($attribs['juniper-firewall-mib'])) {
$navbar['options']['juniper-firewall'] = array('text' => 'Firewall', 'icon' => $config['icon']['firewall']);
}
// Print the p2p radios tab if there are matching entries in the p2p radios
//if (dbFetchCell('SELECT COUNT(radio_id) FROM p2p_radios WHERE device_id = ?', array($device['device_id'])) > '0')
if (dbExist('p2p_radios', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['p2pradios'] = array('text' => 'Radios', 'icon' => $config['icon']['p2pradio']);
}
// Print the access points tab if there are matching entries in the accesspoints table (Aruba Legacy)
//if (dbFetchCell('SELECT COUNT(accesspoint_id) FROM accesspoints WHERE device_id = ?', array($device['device_id'])) > '0')
if (dbExist('accesspoints', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['accesspoints'] = array('text' => 'APs (Legacy)', 'icon' => $config['icon']['wifi']);
}
// Print the wifi tab if wifi things exist
//$device_ap_exist = dbFetchCell('SELECT COUNT(wifi_ap_id) FROM `wifi_aps` WHERE `device_id` = ?', array($device['device_id']));
//$device_radio_exist = dbFetchCell('SELECT COUNT(wifi_radio_id) FROM `wifi_radios` WHERE `device_id` = ?', array($device['device_id']));
//$device_wlan_exist = dbFetchCell('SELECT COUNT(wlan_id) FROM `wifi_wlans` WHERE `device_id` = ?', array($device['device_id']));
$device_ap_exist = dbExist('wifi_aps', '`device_id` = ?', array($device['device_id']));
$device_radio_exist = dbExist('wifi_radios', '`device_id` = ?', array($device['device_id']));
$device_wlan_exist = dbExist('wifi_wlans', '`device_id` = ?', array($device['device_id']));
if ($device_ap_exist || $device_radio_exist || $device_wlan_exist) {
$navbar['options']['wifi'] = array('text' => 'WiFi', 'icon' => $config['icon']['wifi']);
}
// Print applications tab if there are matching entries in `applications` table
//if (dbExist('applications', '`device_id` = ?', array($device['device_id']))) {
if ($apps = dbFetchColumn('SELECT DISTINCT `app_type` FROM `applications` WHERE `device_id` = ?', [ $device['device_id'] ])) {
$navbar['options']['apps'] = [ 'text' => 'Apps', 'icon' => $config['icon']['apps'] ];
$app_array = [ 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps' ];
foreach ($apps as $app_type) {
$navbar['options']['apps']['suboptions'][$app_type]['text'] = nicecase($app_type);
//$url = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps', 'app' => $app['app_type'], 'instance' => $app['app_id'] ));
$navbar['options']['apps']['suboptions'][$app_type]['url'] = generate_url($app_array, [ 'app' => $app_type ]);
if ($vars['tab'] === 'apps' && $vars['app'] === $app_type) {
$navbar['options']['apps']['suboptions'][$app_type]['class'] .= ' active';
}
// Detect and add application icon
$icon = $app_type;
$image = $config['html_dir'].'/images/apps/'.$icon.'.png';
if (!is_file($image)) {
list($icon) = explode('-', str_replace('_', '-', $app_type));
$image = $config['html_dir'].'/images/apps/'.$icon.'.png';
if ($icon !== $app_type && is_file($image)) {
// 'postfix_qshape' -> 'postfix'
// 'exim-mailqueue' -> 'exim'
} else {
$icon = 'apps'; // Generic
}
}
$navbar['options']['apps']['suboptions'][$app_type]['image'] = 'images/apps/'.$icon.'.png';
if (is_file($config['html_dir'].'/images/apps/'.$icon.'_2x.png')) {
// HiDPI icon
$navbar['options']['apps']['suboptions'][$app_type]['image_2x'] = 'images/apps/'.$icon.'_2x.png';
}
}
}
// Print the collectd tab if there is a matching directory
if (isset($config['collectd_dir']) && is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) {
$navbar['options']['collectd'] = array('text' => 'Collectd', 'icon' => $config['icon']['collectd']);
}
// Print the munin tab if there are matchng entries in the munin_plugins table
if (dbExist('munin_plugins', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['munin'] = array('text' => 'Munin', 'icon' => $config['icon']['munin']);
}
// Build array of smokeping files for use in tab building and smokeping page.
if (isset($config['smokeping']['dir'])) {
$smokeping_files = get_smokeping_files();
}
// Print latency tab if there are smokeping files with source or destination matching this hostname
if (safe_count($smokeping_files['incoming'][$device['hostname']]) ||
safe_count($smokeping_files['outgoing'][$device['hostname']])) {
$navbar['options']['latency'] = array('text' => 'Ping', 'icon' => $config['icon']['smokeping']);
}
// Pring Virtual Machines tab if there are matching entries in the vminfo table
//if (dbFetchCell('SELECT COUNT(vm_id) FROM vminfo WHERE device_id = ?', array($device['device_id'])) > '0')
if (dbExist('vminfo', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['vm'] = array('text' => 'VMs', 'icon' => $config['icon']['virtual-machine']);
}
// $loadbalancer_tabs is used in device/loadbalancer/ to build the submenu. we do it here to save queries
// Check for Netscaler vservers and services
if ($device['os'] === "netscaler") { // Netscaler
$device_loadbalancer_count['netscaler_vsvr'] = dbFetchCell("SELECT COUNT(*) FROM `netscaler_vservers` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['netscaler_vsvr']) { $loadbalancer_tabs[] = 'netscaler_vsvr'; }
$device_loadbalancer_count['netscaler_services'] = dbFetchCell("SELECT COUNT(*) FROM `netscaler_services` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['netscaler_services']) { $loadbalancer_tabs[] = 'netscaler_services'; }
$device_loadbalancer_count['netscaler_servicegroupmembers'] = dbFetchCell("SELECT COUNT(*) FROM `netscaler_servicegroupmembers` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['netscaler_servicegroupmembers']) { $loadbalancer_tabs[] = 'netscaler_servicegroupmembers'; }
}
if ($device['os'] === "f5") { // F5
$device_loadbalancer_count['lb_virtuals'] = dbFetchCell("SELECT COUNT(*) FROM `lb_virtuals` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['lb_virtuals']) { $loadbalancer_tabs[] = 'lb_virtuals'; }
$device_loadbalancer_count['lb_pools'] = dbFetchCell("SELECT COUNT(*) FROM `lb_pools` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['lb_pools']) { $loadbalancer_tabs[] = 'lb_pools'; }
$device_loadbalancer_count['lb_snatpools'] = dbFetchCell("SELECT COUNT(*) FROM `lb_snatpools` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['lb_snatpools']) { $loadbalancer_tabs[] = 'lb_snatpools'; }
}
// Check for Cisco ACE vservers
if ($device['os'] === "acsw") { // Cisco ACE
/* FIXME. Undone by adama
$device_loadbalancer_count['slb_vsvrs'] = dbFetchCell("SELECT COUNT(*) FROM `lb_slb_vsvrs` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['slb_vsvrs']) { $loadbalancer_tabs[] = 'slb_vsvrs'; }
$device_loadbalancer_count['slb_rsvrs'] = dbFetchCell("SELECT COUNT(*) FROM `loadbalancer_rservers` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['slb_rsvrs']) { $loadbalancer_tabs[] = 'slb_rsvrs'; }
*/
$device_loadbalancer_count['loadbalancer_vservers'] = dbFetchCell("SELECT COUNT(*) FROM `loadbalancer_vservers` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['loadbalancer_vservers']) { $loadbalancer_tabs[] = 'loadbalancer_vservers'; }
$device_loadbalancer_count['loadbalancer_rservers'] = dbFetchCell("SELECT COUNT(*) FROM `loadbalancer_rservers` WHERE `device_id` = ?", array($device['device_id']));
if ($device_loadbalancer_count['loadbalancer_rservers']) { $loadbalancer_tabs[] = 'loadbalancer_rservers'; }
}
// Print the load balancer tab if the loadbalancer_tabs array has entries.
if (is_array($loadbalancer_tabs)) {
$navbar['options']['loadbalancer'] = array('text' => 'Load Balancer', 'icon' => $config['icon']['loadbalancer'], 'community' => FALSE);
}
// $routing_tabs is used in device/routing/ to build the tabs menu. we build it here to save some queries
$device_routing_count['ipsec_tunnels'] = dbFetchCell("SELECT COUNT(*) FROM `ipsec_tunnels` WHERE `device_id` = ?", array($device['device_id']));
if ($device_routing_count['ipsec_tunnels']) { $routing_tabs[] = 'ipsec_tunnels';
$routing_options[] = array('url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'routing', 'proto' => 'ipsec_tunnels')),
'text' => 'IPSEC Tunnels',
'icon' => $config['icon']['ipsec_tunnel']);
}
$device_routing_count['bgp'] = dbFetchCell("SELECT COUNT(*) FROM `bgpPeers` WHERE `device_id` = ?", array($device['device_id']));
if ($device_routing_count['bgp']) {
$routing_tabs[] = 'bgp';
$routing_options[] = array('url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'routing', 'proto' => 'bgp')),
'text' => 'BGP',
'icon' => $config['icon']['bgp']);
}
//$device_routing_count['ospf'] = dbFetchCell("SELECT COUNT(*) FROM `ospf_instances` WHERE `ospfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id']));
$device_routing_count['ospf'] = dbFetchCell("SELECT COUNT(*) FROM `ospf_instances` WHERE `device_id` = ?", array($device['device_id']));
if ($device_routing_count['ospf']) {
$routing_tabs[] = 'ospf';
$routing_options[] = array('url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'routing', 'proto' => 'ospf')),
'text' => 'OSPF',
'icon' => $config['icon']['ospf']);
}
$device_routing_count['eigrp'] = dbFetchCell("SELECT COUNT(*) FROM `eigrp_ports` WHERE `device_id` = ?", array($device['device_id']));
if ($device_routing_count['eigrp']) {
$routing_tabs[] = 'eigrp';
$routing_options[] = array('url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'routing', 'proto' => 'eigrp')),
'text' => 'EIGRP',
'icon' => $config['icon']['eigrp']);
}
$device_routing_count['cef'] = dbFetchCell("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ?", array($device['device_id']));
if ($device_routing_count['cef']) {
$routing_tabs[] = 'cef';
$routing_options[] = array('url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'routing', 'proto' => 'cef')),
'text' => 'CEF',
'icon' => $config['icon']['cef']);
}
if ($config['enable_vrfs']) {
$device_routing_count['vrf'] = dbFetchCell("SELECT COUNT(*) FROM `vrfs` WHERE `device_id` = ?", array( $device['device_id'] ));
if ($device_routing_count['vrf']) {
$routing_tabs[] = 'vrf';
$routing_options[] = array( 'url' => generate_url(array( 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'routing', 'proto' => 'vrf' )),
'text' => 'VRF',
'icon' => $config['icon']['vrf'] );
}
}
// Print routing tab if any of the routing tables contain matching entries
if (safe_count($routing_tabs)) {
$navbar['options']['routing'] = array('text' => 'Routing', 'icon' => $config['icon']['routing'], 'suboptions' => $routing_options);
}
// Print the pseudowire tab if any of the routing tables contain matching entries
//if (dbFetchCell("SELECT COUNT(*) FROM `pseudowires` WHERE `device_id` = ?", array($device['device_id'])))
if (dbExist('pseudowires', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['pseudowires'] = array('text' => 'Pseudowires', 'icon' => $config['icon']['pseudowire']);
}
// Print the packages tab if there are matching entries in the packages table
//if (dbFetchCell('SELECT COUNT(*) FROM `packages` WHERE `device_id` = ?', array($device['device_id'])) > 0)
if (dbExist('packages', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['packages'] = array('text' => 'Pkgs', 'icon' => $config['icon']['packages']);
}
// Print the Windows Services tab if there are matching entries in the winservices table
//if (dbFetchCell('SELECT COUNT(*) FROM `winservices` WHERE `device_id` = ?', array($device['device_id'])) > 0)
if (dbExist('winservices', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['winservices'] = array('text' => 'Windows Services', 'icon' => $config['icon']['processes']);
}
// Print the inventory tab if inventory is enabled and either entphysical or hrdevice tables have entries
//if (dbFetchCell('SELECT COUNT(*) FROM `entPhysical` WHERE `device_id` = ?', array($device['device_id'])) > 0)
if (dbExist('entPhysical', '`device_id` = ? AND `deleted` IS NULL', [ $device['device_id'] ])) {
$navbar['options']['entphysical'] = array('text' => 'Inventory', 'icon' => $config['icon']['inventory']);
} elseif (dbExist('hrDevice', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['hrdevice'] = array('text' => 'Inventory', 'icon' => $config['icon']['inventory']);
}
if (isset($attribs['ps_list'])) {
$navbar['options']['processes'] = array('text' => 'Processes', 'icon' => $config['icon']['processes']);
}
// Print probes tab if there are entries in the probes table
if (dbExist('probes', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['probes'] = array('text' => 'Probes', 'icon' => $config['icon']['status']);
}
// Print printing tab if there are entries in the printersupplies table
//if (dbFetchCell('SELECT COUNT(*) FROM `printersupplies` WHERE device_id = ?', array($device['device_id'])) > 0)
if (dbExist('printersupplies', '`device_id` = ?', array($device['device_id']))) {
$navbar['options']['printing'] = array('text' => 'Printing', 'icon' => $config['icon']['printersupply']);
// $printing_tabs is used in device/printing/ to build the tabs menu. we build it here to save some queries
/// FIXME. sid3windr, I not see what this query "save" here, must be moved to device/printing.inc.php
$printing_tabs = dbFetchColumn("SELECT DISTINCT `supply_type` FROM `printersupplies` WHERE `device_id` = ?", array($device['device_id']));
}
// Always print logs tab
$navbar['options']['logs'] = array('text' => 'Logs', 'icon' => $config['icon']['logs']);
// Print alerts tab
$navbar['options']['alerts'] = array('text' => 'Alerts', 'icon' => $config['icon']['alert']);
// If the user has secure global read privileges, check for a device config.
if ($_SESSION['userlevel'] >= 7) {
$showconfig = FALSE;
if ($device_config_file = get_rancid_filename($device)) {
// Rancid
$showconfig = TRUE;
}
// Print the config tab if we have a device config
if ($showconfig) {
$navbar['options']['showconfig'] = array('text' => 'Config', 'icon' => $config['icon']['config']);
}
}
/*
// If the user has global read privileges, check for device notes.
if ($_SESSION['userlevel'] >= 5)
{
// Promoted to real tab when notes is filled in, otherwise demoted to icon on the right
$navbar['options']['notes'] = array('text' => ($attribs['notes'] ? 'Notes' : NULL), 'icon' => 'sprite-notes', 'right' => ($attribs['notes'] == ''));
}
*/
// If nfsen is enabled, check for an nfsen file
if ($config['nfsen_enable'] &&
$nfsen_rrd_file = get_nfsen_filename($device['hostname'])) {
// Print the netflow tab if we have an nfsen file
$navbar['options']['nfsen'] = array('text' => 'Netflow', 'icon' => $config['icon']['nfsen']);
}
$navbar['options']['notes'] = array('text' => '', 'icon' => $config['icon']['notes'], 'right' => TRUE, 'class' => "dropdown-toggle");
if (is_array($config['os'][$device['os']]['remote_access'])) {
$connect_entries = array();
foreach ($config['os'][$device['os']]['remote_access'] as $name => $ra_array) {
if (!is_array($ra_array)) {
$name = $ra_array;
$ra_array = array();
}
if (isset($config['remote_access'][$name])) {
$ra_array = array_merge($ra_array, (array)$config['remote_access'][$name]);
}
// Check if a device specific attribute has been set by code
$ra_array['url'] = get_dev_attrib($device, 'ra_url_' . $name);
// If no attribute set, default to protocol://hostname:port
if (safe_empty($ra_array['url'])) {
$ra_array['url'] = $name.'://'.$device['hostname'].':'.$ra_array['port'];
}
$connect_entries[] = [ 'text' => 'Connect via '.$ra_array['name'], 'icon' => $ra_array['icon'], 'url' => $ra_array['url'], 'link_opts' => 'target="_blank"' ];
}
}
// If the user has global write permissions, show them the edit tab
if (is_entity_write_permitted($device['device_id'], 'device')) {
$navbar['options']['tools'] = array('text' => '', 'icon' => $config['icon']['device-tools'], 'url' => '#', 'right' => TRUE, 'class' => "dropdown-toggle");
$navbar['options']['tools']['suboptions']['data'] = array('text' => 'Device Data', 'icon' => $config['icon']['device-data']);
$navbar['options']['tools']['suboptions']['perf'] = array('text' => 'Performance Data', 'icon' => $config['icon']['device-poller']);
if ($config['web_enable_showtech']) {
$navbar['options']['tools']['suboptions']['showtech'] = array('text' => 'Show Tech-Support', 'icon' => $config['icon']['techsupport']);
}
$navbar['options']['tools']['suboptions']['divider_1'] = array('divider' => TRUE);
// Connect menu
$navbar['options']['tools']['suboptions']['connect'] = array('text' => 'Connect', 'icon' => 'sprite-config', 'url' => '#');
$navbar['options']['tools']['suboptions']['connect']['entries'] = $connect_entries;
$navbar['options']['tools']['suboptions']['divider_2'] = array('divider' => TRUE);
$navbar['options']['tools']['suboptions']['delete']['url'] = "#modal-delete_device";
$navbar['options']['tools']['suboptions']['delete']['text'] = 'Delete Device';
$navbar['options']['tools']['suboptions']['delete']['link_opts'] = 'data-toggle="modal"';
$navbar['options']['tools']['suboptions']['delete']['icon'] = $config['icon']['minus'];
$navbar['options']['tools']['suboptions']['divider_3'] = array('divider' => TRUE);
// All properties
$navbar['options']['tools']['suboptions']['edit'] = array('text' => 'Properties', 'icon' => $config['icon']['device-settings']);
} elseif (safe_count($connect_entries)) {
// User-only cog menu
$navbar['options']['tools'] = array('text' => '', 'icon' => $config['icon']['device-tools'], 'url' => '#', 'right' => TRUE, 'class' => "dropdown-toggle");
$navbar['options']['tools']['suboptions']['connect'] = array('text' => 'Connect', 'icon' => 'sprite-config', 'url' => '#');
$navbar['options']['tools']['suboptions']['connect']['entries'] = $connect_entries;
$navbar['options']['tools']['suboptions']['divider_2'] = array('divider' => TRUE);
}
?>
<script>
(function ($) {
$(function() {
// fix sub nav on scroll
var $win = $(window),
$body = $('body'),
$nav = $('.subnav'),
navHeight = $('.navbar').first().height(),
subnavHeight = $('.subnav').first().height(),
subnavTop = $('.subnav').length && $('.subnav').offset().top,
marginTop = parseInt($body.css('margin-top'), 10);
isFixed = 0;
// subnavTop = $('.subnav').length && $('.subnav').offset().top - navHeight,
processScroll();
$win.on('scroll', processScroll);
function processScroll() {
var i, scrollTop = $win.scrollTop();
if (scrollTop >= subnavTop && !isFixed) {
isFixed = 1;
$nav.addClass('subnav-fixed');
$body.css('margin-top', marginTop + subnavHeight + 'px');
} else if (scrollTop <= subnavTop && isFixed) {
isFixed = 0;
$nav.removeClass('subnav-fixed');
$body.css('margin-top', marginTop + 'px');
}
}
});
})(window.jQuery);
// Make Secondary Dropdown on Hover
$('.dropdown-submenu a.dropdown-submenu-toggle').hover(function(){
$('.dropdown-submenu ul').removeAttr('style');
$(this).next('ul').toggle();
});
</script>
<?php
$navbar['class'] = 'navbar-narrow subnav';
$navbar['brand'] = $device['hostname'];
$navbar['brand-class'] = 'fixed-only';
foreach ($navbar['options'] as $option => $array)
{
if (!isset($vars['tab'])) { $vars['tab'] = $option; }
if ($vars['tab'] === $option) { $navbar['options'][$option]['class'] .= " active"; }
if (!isset($navbar['options'][$option]['url'])) {
$navbar['options'][$option]['url'] = generate_device_url($device, array('tab' => $option));
}
if (isset($navbar['options'][$option]['suboptions'])) {
foreach ($navbar['options'][$option]['suboptions'] as $sub_option => $sub_array) {
if (!isset($navbar['options'][$option]['suboptions'][$sub_option]['url'])) {
$navbar['options'][$option]['suboptions'][$sub_option]['url'] = generate_device_url($device, array('tab' => $sub_option));
}
}
}
}
if ($vars['tab'] === 'port') { $navbar['options']['ports']['class'] .= " active"; }
if ($vars['tab'] === 'alert') { $navbar['options']['alerts']['class'] .= " active"; }
if ($vars['tab'] === 'accesspoint') { $navbar['options']['accesspoints']['class'] .= " active"; }
print_navbar($navbar);
unset($navbar);
}
// Delete device modal
$form = array('type' => 'horizontal',
'entity_write_permit' => array('entity_type' => 'device', 'entity_id' => $device['device_id']),
'id' => 'modal-delete_device',
'title' => 'Delete Device "' . $device['hostname'] . '"',
'icon' => $config['icon']['device-delete'],
'url' => 'delhost/'
);
$form['row'][0]['id'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => $device['device_id']);
$form['row'][4]['confirm'] = array(
'type' => 'checkbox',
'fieldset' => 'body',
'name' => 'Confirm Deletion',
'onchange' => "javascript: toggleAttrib('disabled', 'delete_modal');",
'value' => 'confirm');
/*
$form['row'][5]['deleterrd'] = array(
'type' => 'checkbox',
'fieldset' => 'body',
'name' => 'Delete RRDs',
'onchange' => "javascript: showDiv(this.checked, 'warning_".$device['device_id']."_div');",
'value' => 'confirm');
$form['row'][7]['warning_'.$device['device_id']] = array(
'type' => 'html',
'fieldset' => 'body',
'html' => '<h4 class="alert-heading"><i class="icon-warning-sign"></i> Warning!</h4>' .
' This will delete this device from Observium including all logging entries, but will not delete the RRDs.',
//'div_style' => 'display: none', // hide initially
'div_class' => 'alert alert-warning');
*/
$form['row'][9]['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_modal'] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE);
echo generate_form_modal($form);
unset($form);
// Check that the user can view the device, or is viewing a permitted port on the device
if (isset($cache['devices']['id'][$device['device_id']]) || $permit_tabs[$tab])
{
// If this device has never been polled, print a warning here
if (!$device['last_polled'] || $device['last_polled'] == '0000-00-00 00:00:00')
{
print_warning('<h4>Device not yet polled</h4>
This device has not yet been successfully polled. System information and statistics will not be populated and graphs will not draw.
Please wait 5-10 minutes for graphs to draw correctly.');
// Poller info displayed only if device never polled
if ($_SESSION['userlevel'] >= 7)
{
$poller_start = dbFetchCell("SELECT `process_start` FROM `observium_processes` WHERE `device_id` = ? AND `process_name` = ?", array($device['device_id'], 'poller.php'));
//r($poller_start);
if ($poller_start)
{
print_success('<h4>Device poller in progress</h4>
This device is being polled now. Poller started '.format_unixtime($poller_start).' ('.format_uptime(time() - $poller_start).' ago).');
}
}
}
// If this device has never been discovered, print a warning here
if (!$device['last_discovered'] || $device['last_discovered'] == '0000-00-00 00:00:00')
{
print_warning('<h4>Device not yet discovered</h4>
This device has not yet been successfully discovered. System information and statistics will not be populated and graphs will not draw.
This device should be automatically discovered within 10 minutes.');
}
if ($_SESSION['userlevel'] >= 7)
{
$discovery_start = dbFetchCell("SELECT `process_start` FROM `observium_processes` WHERE `device_id` = ? AND `process_name` = ?", array($device['device_id'], 'discovery.php'));
//r($discovery_start);
if ($discovery_start)
{
print_success('<h4>Device discovery in progress</h4>
This device is being discovered now. Discovery started '.format_unixtime($discovery_start).' ('.format_uptime(time() - $discovery_start).' ago).');
}
}
if (is_file($config['html_dir']."/pages/device/".basename($tab).".inc.php"))
{
include($config['html_dir']."/pages/device/".basename($tab).".inc.php");
} else {
print_error('<h4>Tab does not exist</h4>
The requested tab does not exist. Please correct the URL and try again.');
}
} else {
print_error_permission();
}
}
// EOF

View File

@ -0,0 +1,30 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$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']));
if (safe_empty($ap)) {
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');
echo '</table>' ;
echo generate_box_close();
// EOF

View File

@ -0,0 +1,41 @@
<?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
*
*/
$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']));
if(count($aps))
{
echo generate_box_open();
echo('<table class="table table-striped table-hover">');
foreach ($aps as $ap)
{
include($config['html_dir'].'/includes/print-accesspoint.inc.php');
$i++;
}
echo('</table>');
echo generate_box_close();
} else {
print_message('No access points found.', 'warning');
}
// EOF

View File

@ -0,0 +1,234 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// 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';
}
// 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'] = array('NULL');
}
if (is_array($update_state))
{
$up_s = dbUpdate($update_state, 'alert_table', '`alert_table_id` = ?', array($vars['alert_entry']));
}
// Refresh array because we've changed the database.
$entry = get_alert_entry_by_id($vars['alert_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']);
// 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>
</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">
<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']);
$alert['state_popup'] = '';
// 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>';
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>';
} 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>';
}
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>
</div>
</div>
<div class="col-md-5">
<?php
$form = array('type' => 'horizontal',
'id' => 'update_alert_entry',
'title' => 'Alert Settings',
//'icon' => 'oicon-gear',
'fieldset' => array('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'][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'] = 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>
<div class="col-md-12">
<?php echo generate_box_open(array('title' => 'Historical Availability')); ?>
<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
echo generate_box_close();
echo("</div></div>"); // end row
}
$vars['entity_type'] = $entry['entity_type'];
$vars['entity_id'] = $entry['entity_id'];
print_alert_log($vars);
} else {
print_error("Unfortunately, this alert entry id does not seem to exist in the database!");
}
// EOF

View File

@ -0,0 +1,131 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$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'; }
// 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'));
$navbar['options']['all']['text'] = "All";
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"; }
$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));
}
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"; }
$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';
}
/* Not required anymore
$navbar['options_right']['update']['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alerts', 'action'=>'update'));
$navbar['options_right']['update']['text'] = 'Rebuild';
$navbar['options_right']['update']['icon'] = $config['icon']['rebuild'];
if ($vars['action'] === 'update') { $navbar['options_right']['update']['class'] = 'active'; }
*/
$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 = array('all' => array('url' => generate_url($vars, array('status' => 'all')),
'url_o' => generate_url($vars, array('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' => array('url' => generate_url($vars, array('status' => 'failed')),
'url_o' => generate_url($vars, array('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')
);
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";
}
$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);
unset($navbar);
// Run actions
/* Not required anymore
if ($vars['action'] === 'update') {
echo generate_box_open();
update_device_alert_table($device);
$alert_table = cache_device_alert_table($device['device_id']);
echo generate_box_close();
}
*/
$vars['pagination'] = TRUE;
if ($vars['entity_type'] === "syslog") {
print_logalert_log($vars);
} else {
print_alert_table($vars);
}
// EOF

View File

@ -0,0 +1,170 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$link_array = array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps');
$navbar = array();
$navbar['brand'] = "Apps";
$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;
}
// 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
}
}
$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'] = $url;
}
}
}
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'];
}
$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);
// 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"; }
$navbar['options'][$app_section]['url'] = generate_url($vars, array('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';
}
// 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">';
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>';
print_graph_row($graph_array);
echo '</td></tr>';
}
echo '</table>';
generate_box_close();
}
}
register_html_title("Apps");
// EOF

View File

@ -0,0 +1,19 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('apache_bits' => 'Traffic',
'apache_hits' => 'Hits',
'apache_cpu' => 'CPU Utilisation',
'apache_scoreboard' => 'Scoreboard Statistics');
// EOF

View File

@ -0,0 +1,27 @@
<?php
/**
* 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
*
*/
$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));
}
print_navbar($navbar);
// EOF

View File

@ -0,0 +1,17 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('asterisk_peers' => 'Active Peers',
'asterisk_activecall' => 'Active Calls');
// EOF

View File

@ -0,0 +1,36 @@
<?php
/**
* 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
*
*/
$app_sections = array('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['auth'] = array('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['queries'] = array('bind_query_rejected' => "Rejected queries",
'bind_query_in' => "Incoming queries",
'bind_query_out' => "Outgoing queries");
// EOF

View File

@ -0,0 +1,16 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('ceph_osd' => 'OSD','ceph_iops' => 'OPS','ceph_speed' => 'Ceph I/O',);
// EOF

View File

@ -0,0 +1,18 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array(
'dhcpkit_packets' => "Packets",
'dhcpkit_msgtypes' => "Message types",
);
/* End of file dhcpkit.inc.php */

View File

@ -0,0 +1,25 @@
<?php
/**
* 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
*
*/
$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');
// EOF

View File

@ -0,0 +1,19 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('drbd_network_bits' => 'Network Traffic',
'drbd_disk_bits' => 'Disk Traffic',
'drbd_unsynced' => 'Unsynced Data',
'drbd_queue' => 'Queues');
// EOF

View File

@ -0,0 +1,97 @@
<?php
/**
* 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
*
*/
$app_sections = array();
$app_modules = array(
"as" => array(
"rrd" => "wmi-app-exchange-as.rrd",
"descr" => "ActiveSync",
"graphs" => array(
'exchange_as_pingcmd' => 'Ping 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(
'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_oab_dlcom' => 'Download Tasks Completed'
)
),
"owa" => array(
"rrd" => "wmi-app-exchange-owa.rrd",
"descr" => "Outlook Web App",
"graphs" => array(
'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',
'exchange_trans_subque' => 'Submission Queues'
)
),
"smtp" => array(
"rrd" => "wmi-app-exchange-smtp.rrd",
"descr" => "SMTP",
"graphs" => array(
'exchange_trans_smtp' => "SMTP Connections"
)
),
"is" => array(
"rrd" => "wmi-app-exchange-is.rrd",
"descr" => "Information Store",
"graphs" => array(
'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(
'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'];
}
}
unset($app_modules);
// EOF

View File

@ -0,0 +1,16 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('exim-mailqueue_total' => 'Total mail in queue');
// EOF

View File

@ -0,0 +1,18 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('exim_sent' => 'Exim - Sent / Received',
'exim_spam' => 'Exim - Spam / Virus',
'exim_reject' =>'Exim - Rejected / Bounced');
// EOF

View File

@ -0,0 +1,17 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('freeradius_authentication' => 'FreeRADIUS Authentication',
'freeradius_accounting' => 'FreeRADIUS Accounting');
// EOF

View File

@ -0,0 +1,19 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array(
'icecast_current' => 'IceCast - Current',
'icecast_max' => 'IceCast - Maximum'
);
// EOF

View File

@ -0,0 +1,19 @@
<?php
/**
* html/pages/device/apps/ioping.inc.php
* 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
*
*/
$app_graphs['default'] = array('ioping_timing' => 'I/O Timings',
'ioping_speed' => 'Speed',
'ioping_iops' => 'IOPs');
// EOF

View File

@ -0,0 +1,52 @@
<?php
/**
* 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
*
*/
// defines tabs
$app_sections = array(
'memory' => 'Memory',
'threads' => 'Threads',
'classes' => 'Classes',
'gc' => 'Garbage Collector',
'system' => 'System Information',
);
// defines graphs in memory tab
$app_graphs['memory'] = array(
'jvmoverjmx_memory_summary' => 'Memory Summary',
'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(
'jvmoverjmx_threads' => 'Threads',
);
$app_graphs['classes'] = array(
'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',
'jvmoverjmx_gc_young_count' => 'GC Young Collection Count',
'jvmoverjmx_gc_old_count' => 'GC Old Collection Count',
);
$app_graphs['system'] = array(
'jvmoverjmx_system_uptime' => 'Uptime',
);
// EOF

View File

@ -0,0 +1,27 @@
<?php
/**
* 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>
* @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',
);
// EOF

View File

@ -0,0 +1,19 @@
<?php
/**
* Observium
*
* This files is part of Observium.
*
* @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');

View File

@ -0,0 +1,17 @@
<?php
/**
* Observium
*
* This files is part of Observium.
*
* @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');

View File

@ -0,0 +1,18 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('mailscanner_sent' => 'Sent / Received',
'mailscanner_spam' => 'Spam / Virus',
'mailscanner_reject' => 'Rejected / Waiting / Relayed');
// EOF

View File

@ -0,0 +1,22 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('memcached_bits' => 'Traffic',
'memcached_commands' => 'Commands',
'memcached_data' => 'Data Size',
'memcached_items' => 'Items',
'memcached_uptime' => 'Uptime',
'memcached_threads' => 'Threads',
);
// EOF

View File

@ -0,0 +1,24 @@
<?php
/**
* 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
*
*/
$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',
);
// EOF

View File

@ -0,0 +1,38 @@
<?php
/**
* Observium
*
* 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
*
*/
$sql = "SELECT * FROM `applications-state` WHERE `application_id` = ?";
$app_state = dbFetchRow($sql, array($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";
$app_graphs['system']['mssql_cpu_usage'] = 'Processor';
if (!empty($app_data['memory']))
$app_graphs['system']['mssql_memory_usage'] = 'Memory';
$app_graphs['stats'] = array(
'mssql_stats' => 'Users'
);
$app_graphs['buffers'] = array(
'mssql_buffer_page' => 'Page Lookups',
'mssql_buffer_pglife' => 'Page Life Expectancy',
'mssql_buffer_stalls' => 'Free List Stalls'
);
// EOF

View File

@ -0,0 +1,75 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
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_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);
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "512";
$graph_array['to'] = get_time();
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_mssql_memory_usage';
$graph_array['from'] = get_time('day');
$graph_array['legend'] = "no";
$graph = generate_graph_tag($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['border'] = "#EA8F00";
$percentage_bar['border'] = "#E25A00";
$percentage_bar['bg'] = "#f0f0f0";
$percentage_bar['width'] = "100%";
$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' => '');
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
}
unset($percentage_bar, $graph_array, $overlib_content, $graph, $link, $link_array);
// EOF

View File

@ -0,0 +1,57 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$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);
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "512";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_mssql_cpu_usage';
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no";
$graph = generate_graph_tag($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['width'] = "100%";
$percentage_bar['text'] = $cpu_load_percent."%";
$percentage_bar['text_c'] = "#FFFFFF";
$percentage_bar['bars'][0] = array('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>
<?php
unset($percentage_bar, $graph_array, $overlib_content, $graph, $link, $link_array);
// EOF

View File

@ -0,0 +1,49 @@
<?php
/**
* 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
*
*/
$app_sections = array('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['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['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',
);
// EOF

View File

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

View File

@ -0,0 +1,21 @@
<?php
/**
* Observium
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$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'
);
// EOF

View File

@ -0,0 +1,17 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('nginx_connections' => 'Connections',
'nginx_req' => 'Requests');
// EOF

View File

@ -0,0 +1,21 @@
<?php
/**
* Observium
*
* 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
*
*/
$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');

View File

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

View File

@ -0,0 +1,22 @@
<?php
/**
* 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
*
*/
$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');
// EOF

View File

@ -0,0 +1,40 @@
<?php
/**
* 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
*
*/
// 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");
// 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");
}
$app_graphs['default'] = array('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['buffer'] = array('ntpd_buffer' => 'NTPD Server - Buffer');
$app_graphs['packets'] = array('ntpd_bits' => 'NTPD Server - Packets Sent/Received',
'ntpd_packets' => 'NTPD Server - Packets Dropped/Ignored');
// EOF

View File

@ -0,0 +1,17 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('openvpn_nclients' => 'Connected Clients',
'openvpn_bits' => 'VPN Traffic');
// EOF

View File

@ -0,0 +1,18 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('postfix_mailgraph_sent' => 'Postfix - Sent / Received',
'postfix_mailgraph_spam' => 'Postfix - Spam / Virus',
'postfix_mailgraph_reject' => 'Postfix - Rejected / Bounced');
// EOF

View File

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

View File

@ -0,0 +1,25 @@
<?php
/**
* 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
*
*/
$app_sections = array('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['live'] = array('postgresql_connects' => 'Connection Count',
'postgresql_queries' => 'Query Types');
// EOF

View File

@ -0,0 +1,28 @@
<?php
/**
* 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
*
*/
$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
);
// EOF

View File

@ -0,0 +1,22 @@
<?php
/**
* 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
*
*/
$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');
// EOF

View File

@ -0,0 +1,84 @@
<?php
/**
* 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
*
*/
## FIXME -- THIS IS MESSY AND NEEDS TO BE FIXED.
global $config;
$total = true;
$rrddir = $config['rrd_dir']."/".$device['hostname'];
$files = array();
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'
);
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>");
print_graph_row($graph_array);
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 ($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>");
print_graph_row($graph_array);
echo("</td></tr>");
}
}
// EOF

View File

@ -0,0 +1,23 @@
<?php
/**
* 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
*
*/
$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');
// EOF

View File

@ -0,0 +1,20 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array(
'varnish_backend' => 'Varnish Backend',
'varnish_cache' => 'Varnish Cache',
'varnish_lru' => 'Varnish LRU',
);
// EOF

View File

@ -0,0 +1,17 @@
<?php
/**
* 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
*
*/
$app_graphs['default'] = array('vmwaretools_mem' => 'Memory Resource Allocation',
'vmwaretools_cpu' => 'CPU Resource Allocation');
// EOF

View File

@ -0,0 +1,33 @@
<?php
/**
* 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
*
*/
$app_sections = array('system' => "System",
'backend' => "Backend",
'jvm' => "Java VM",
);
$app_graphs['system'] = array(
'zimbra_fdcount' => 'Open file descriptors',
);
$app_graphs['backend'] = array(
'zimbra_mtaqueue' => 'MTA queue size',
'zimbra_connections' => 'Open connections',
'zimbra_threads' => 'Threads',
);
$app_graphs['jvm'] = array(
'zimbra_jvmthreads' => 'JVM Threads',
);
// EOF

View File

@ -0,0 +1,121 @@
<?php // vim:fenc=utf-8:filetype=php:ts=4
/*
* Copyright (C) 2099 Bruno Prémont <bonbons AT linux-vserver.org>
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; only version 2 of the License is applicable.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02150-1301, USA.
*/
error_reporting(E_ALL | E_NOTICE | E_WARNING);
require('includes/collectd/config.php');
require('includes/collectd/functions.php');
require('includes/collectd/definitions.php');
#require('config.php');
#require('functions.php');
#require('definitions.php');
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");
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');
$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));
}
print_navbar($navbar);
echo generate_box_open();
echo '<table class="table table-condensed table-striped table-hover">';
$i=0;
$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) {
$typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type);
if ($MetaGraphDefs[$type]) { $typeinstances = array($MetaGraphDefs[$type]); }
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);
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['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);
echo('</tr></td>');
}
}
}
echo '</table>';
echo generate_box_close();
register_html_title("CollectD");
// EOF

View File

@ -0,0 +1,69 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// 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;
}
$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] = '***'; }
}
}
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 {
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));
// 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);
// 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'
);
print_form($form);
r($export_device);
}
unset($export_device, $params, $param);
// EOF

View File

@ -0,0 +1,116 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if ($_SESSION['userlevel'] < 7 && !is_entity_write_permitted($device['device_id'], 'device'))
{
print_error_permission();
return;
}
// User level 7-9 only can see config
$readonly = $_SESSION['userlevel'] < 10;
// 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');
$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['status'] = 'Statuses';
}
if (safe_count($config['os'][$device['os']]['icons']))
{
$panes['icon'] = 'Icon';
}
$panes['modules'] = 'Modules';
//if ($config['enable_services'])
//{
//$panes['services'] = 'Services';
//}
// $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['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?
}
$navbar['brand'] = "Edit";
$navbar['class'] = "navbar-narrow";
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,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);
$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);
register_html_resource('js', 'js/jquery.serializejson.js');
include($filename);
} 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);
register_html_title("Settings");
// EOF

View File

@ -0,0 +1,83 @@
<?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 {
$agent_port = $vars['agent_port'];
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.";
}
}
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);
}
}
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($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');
print_form($form);
unset($form);
// EOF

View File

@ -0,0 +1,161 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
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');
} 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'] = array('NULL');
$device['ignore_until'] = '';
}
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');
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Alert Settings',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form['row'][0]['editing'] = array(
'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'][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'][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');
print_form($form);
unset($form);
// EOF

View File

@ -0,0 +1,136 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
print_warning("This page allows you to disable applications for this device that were previously enabled. " .
"Observium agent applications are automatically detected by the poller system.");
# 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);
} else {
$updated += dbDelete('applications', "`device_id` = ?", array($param));
}
foreach (dbFetchRows( "SELECT `app_type` FROM `applications` WHERE `device_id` = ?", array($device['device_id'])) as $row) {
$app_in_db[] = $row['app_type'];
}
foreach ($enabled as $app) {
if (!in_array($app, $app_in_db)) {
$updated += dbInsert(array('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']));
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);
}
}
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>");
$row++;
}
}
?>
</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.");
}
// EOF

View File

@ -0,0 +1,62 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
}
$form = [
'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'][4]['deleterrd'] = [
'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'][6]['delete'] = [
'type' => 'submit',
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE
];
print_warning("<h3>Warning!</h4>
This will delete this device from Observium including all logging entries, but will not delete the RRDs.");
print_form($form);
unset($form);
// EOF

View File

@ -0,0 +1,257 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$ping_skip = get_entity_attrib('device', $device, 'ping_skip');
$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();
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';
}
}
if (!array_key_exists($device['type'], $device_types)) {
$device_types[$device['type']] = array('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']);
} 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); }
// 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'];
}
$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 (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;
// Request for clear WUI cache
set_cache_clear('wui');
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
}
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);
} elseif ($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['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);
$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']);
$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');
print_form($form);
unset($form);
// EOF

View File

@ -0,0 +1,254 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if ($vars['editing'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
}
else if (get_db_version() < 169)
{
// FIXME. Remove this block in r7000
print_warning("DB scheme is old, must update first. Device Geolocation not changed.");
} else {
$updated = 0;
if ($vars['submit'] === 'save')
{
if (get_var_true($vars['reset_geolocation'])) {
$updated = dbDelete('devices_locations', '`device_id` = ?', array($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 ((bool)$device['location_manual'] && !(bool)$vars['location_manual'])
{
// Reset manual flag, rediscover geo info
$update_geo['location_lat'] = array('NULL');
$update_geo['location_lon'] = array('NULL');
$update_geo['location_manual'] = 0;
$updated++;
}
if ($updated)
{
//r($update_geo);
dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', array($device['location_id']));
$geo_db = dbFetchRow("SELECT * FROM `devices_locations` WHERE `device_id` = ?", array($device['device_id']));
if (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, $geo_db);
unset($updated, $update_geo, $geo_db);
} else {
print_warning("Some input data wrong. Device Geolocation not changed.");
}
}
}
}
$location = array('location_text' => $device['location']);
$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 overrided
$location['location_help'] = 'NOTE, device not polled since location overridden, Geolocation is old.';
$location['location_text'] = $override_sysLocation_string;
}
}
if ($location['location_text'] == '') { $location['location_text'] = OBS_VAR_UNSET; }
foreach (array('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="http://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'];
}
if ($updated && $update_message)
{
print_message($update_message);
} elseif ($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['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'][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'][9]['submit'] = array(
'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,124 @@
<?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
*
*/
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'];
}
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;
}
}
}
}
?>
<div class="row"> <!-- begin row -->
<div class="col-md-6"> <!-- begin poller options -->
<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">
<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
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';
}
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>');
}
echo('</td></tr>');
}
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end poller options -->
</div> <!-- end row -->
</div> <!-- end container -->
<?php
// EOF

View File

@ -0,0 +1,113 @@
<?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

@ -0,0 +1,133 @@
<?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 {
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 ($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.");
}
$ipmi_userlevels = array();
foreach ($config['ipmi']['userlevels'] as $type => $descr)
{
$ipmi_userlevels[$type] = array('name' => $descr['text']);
}
$ipmi_interfaces = array();
foreach ($config['ipmi']['interfaces'] as $type => $descr)
{
$ipmi_interfaces[$type] = array('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['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');
print_form($form);
unset($form);
// EOF

View File

@ -0,0 +1,270 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
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]++; }
// Sort alphabetically
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'];
$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);
}
}
}
// Count critical errors into DB (only for poller)
$mib_grid = 12;
$snmp_errors = [];
if ($config['snmp']['errors']) {
//$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;
$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;
}
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="col-md-<?php echo($mib_grid); ?>"> <!-- begin MIB options -->
<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">
<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
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"' : '';
}
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);
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end MIB options -->
<?php
if (count($snmp_errors))
{
//r($snmp_errors);
?>
<div class="col-md-7 col-md-pull-0"> <!-- begin Errors options -->
<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">
<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
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>');
//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);
// 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; }
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);
$timediff = $GLOBALS['config']['time']['now'] - $error_db['updated'];
echo('<td style="width: 100px; white-space: nowrap; text-align: right;">'.generate_tooltip_link('', format_uptime($timediff, "short-3").' ago', format_unixtime($error_db['updated'])).'</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></tr>' . PHP_EOL);
}
echo(' </table>
</td></tr>' . PHP_EOL);
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end Errors options -->
<?php } ?>
</div> <!-- end row -->
</div> <!-- end container -->
<?php
// EOF

View File

@ -0,0 +1,387 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
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));
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_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="col-md-6"> <!-- begin poller options -->
<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">
<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]);
// 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';
}
}
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 (($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>');
$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);
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end poller options -->
<div class="col-md-6"> <!-- begin ports options -->
<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">
<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; }
$attrib_set = isset($attribs[$module]);
$module_name = str_replace('enable_ports_', '', $module);
$module_status = is_module_enabled($device, 'ports_'.$module_name, 'poller', FALSE);
// 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';
}
}
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;
}
}
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);
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end ports options -->
<div class="col-md-6"> <!-- begin discovery options -->
<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">
<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]);
// 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';
}
}
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 (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';
}
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);
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end discovery options -->
</div> <!-- end row -->
<?php
// EOF

View File

@ -0,0 +1,105 @@
<?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
*
*/
$svcs = dbFetchRows("SELECT * FROM `netscaler_services` WHERE `device_id` = ? ORDER BY `svc_name`", array($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"; }
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]; }
}
if (is_array($sup))
{
dbUpdate($sup, 'netscaler_services', '`svc_id` = ?', array($svc['svc_id']));
$did_update = TRUE;
}
unset($sup);
}
$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>
<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)
{
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>');
}
?>
</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>
<?php
// EOF

View File

@ -0,0 +1,105 @@
<?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
*
*/
$vsvrs = dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_label`", array($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"; }
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]; }
}
if (is_array($sup))
{
dbUpdate($sup, 'netscaler_vservers', '`vsvr_id` = ?', array($vsvr['vsvr_id']));
$did_update = TRUE;
}
unset($sup);
}
$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>
<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)
{
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>');
}
?>
</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>
<?php
// EOF

View File

@ -0,0 +1,309 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if ($readonly && $vars['ignoreport']) {
print_error_permission('You have insufficient permissions to edit settings.');
}
?>
<form id="ports_update" class="form form-inline"> <!-- onsubmit="processForm()"> -->
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Port Properties</h3>
</div>
<div class="box-body no-padding">
<?php
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element([ 'type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
}
$item = [
'id' => 'action',
//'readonly' => $readonly,
'value' => 'ports_update'
];
echo(generate_form_element($item, 'hidden'));
$item = [
'id' => 'ignoreport',
'readonly' => $readonly,
'value' => 'yes'
];
echo(generate_form_element($item, 'hidden'));
$item = [
'id' => 'device',
'readonly' => $readonly,
'value' => $device['device_id']
];
echo(generate_form_element($item, 'hidden'));
?>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th class="state-marker"></th>
<th style="width: 50px;">ifIndex
</th>
<th>Port</th>
<th style="width: 200px;">ifType / Status</th>
<th style="width: 120px;">Polling (Disable)</th>
<th style="width: 120px;">Alerts (Ignore)</th>
<!-- <th style="width: 110px;">% Threshold</th> -->
<!-- <th style="width: 110px;">BPS Threshold</th> -->
<!-- <th style="width: 110px;">PPS Threshold</th> -->
<th style="width: 90px;">ifSpeed</th>
<th style="width: 45px;"></th>
<th style="width: 70px;">64bit</th>
</tr>
</thead>
<tr>
<td style="padding: 0;"></td>
<td></td>
<td>
<!-- <button class="btn btn-xs btn-danger" type="submit" value="Reset" id="form-reset" title="Reset form to previously-saved settings"><i class="icon-remove icon-white"></i> Reset</button> --></td>
<td>
<button class="btn btn-xs btn-danger" style="margin: 3px;" value="Alerted"
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>
</td>
<td class="text-center">
<button class="btn btn-xs btn-primary" value="Toggle" id="disable-toggle"
title="Toggle polling for all ports">Toggle
</button>
<button class="btn btn-xs btn-default" value="Select" id="disable-select"
title="Disable polling on all ports">All
</button>
</td>
<td class="text-center">
<button class="btn btn-xs btn-primary" value="Toggle" id="ignore-toggle"
title="Toggle alerting for all ports">Toggle
</button>
<button class="btn btn-xs btn-default" value="Select" id="ignore-select"
title="Disable alerting on all ports">All
</button>
</td>
<td></td>
<td></td>
<td>
<button class="btn btn-xs btn-primary" value="Save"
title="Save current port disable/ignore settings"><i class="icon-ok icon-white"></i>
Save
</button>
</td>
<!-- <th></th>
<th></th>
<td></th> -->
</tr>
<?php
$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) {
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('<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 />';
//r($port);
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']);
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']);
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']);
echo(generate_form_element($item, 'switch-ng'));
echo("</td>");
# echo('<td> <input class="input-mini" name="threshold_perc_in-'.$port['port_id'].'" size="3" value="'.$port['threshold_perc_in'].'"></input>');
# echo('<br /><input class="input-mini" name="threshold_perc_out-'.$port['port_id'].'" size="3" value="'.$port['threshold_perc_out'].'"></input></td>');
# echo('<td> <input class="input-mini" name="threshold_bps_in-'.$port['port_id'].'" size="3" value="'.$port['threshold_bps_in'].'"></input>');
# echo('<br /><input class="input-mini" name="threshold_bps_out-'.$port['port_id'].'" size="3" value="'.$port['threshold_bps_out'].'"></input></td>');
# echo('<td> <input class="input-mini" name="threshold_pps_in-'.$port['port_id'].'" size="3" value="'.$port['threshold_pps_in'].'"></input>');
# echo('<br /><input class="input-mini" name="threshold_pps_out-'.$port['port_id'].'" size="3" value="'.$port['threshold_pps_out'].'"></input></td>');
// 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));
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);
echo(generate_form_element($item, 'toggle'));
echo '</span>';
echo('</td>');
echo '<td>';
if ($port['port_64bit'] == 1) {
echo '<span class="label label-success">64bit</span>';
} else if ($port['port_64bit'] == 0) {
echo '<span class="label label-warning">32bit</span>';
} else {
echo '<span class="label">Unchecked</span>';
}
echo '</td></tr>' . PHP_EOL;
$row++;
}
?>
</table>
</div>
<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');
echo(generate_form_element($item, 'submit'));
?>
</div>
</form>
<script type="text/javascript">
$('#disable-toggle').click(function (event) {
// invert selection on all disable buttons
event.preventDefault();
$('[name$="[disabled]"]').each(function () {
$(this).bootstrapToggle('toggle');
});
});
$('#ignore-toggle').click(function (event) {
// invert selection on all ignore buttons
event.preventDefault();
$('[name$="[ignore]"]').each(function () {
$(this).bootstrapToggle('toggle');
});
});
$('#alerted-toggle').click(function (event) {
// toggle ignore buttons for all ports which are in class red
event.preventDefault();
$('.error').each(function () {
var name = $(this).attr('data-name');
if (name) {
// get the interface number from the object name
var port_id = name.split('_')[1];
// find its corresponding checkbox and toggle it
$('[name="port[' + port_id + '][ignore]"]').bootstrapToggle('on');
}
});
});
$('#disable-select').click(function (event) {
// select all disable buttons
event.preventDefault();
$('[name$="[disabled]"]').bootstrapToggle('on');
});
$('#ignore-select').click(function (event) {
// select all ignore buttons
event.preventDefault();
$('[name$="[ignore]"]').bootstrapToggle('on');
});
$('#down-select').click(function (event) {
// select ignore buttons for all ports which are down
event.preventDefault();
$('[data-name^="operstatus_"]').each(function () {
var name = $(this).attr('data-name');
var text = $(this).text();
if (name && text === 'down' || name && text === 'lowerLayerDown') {
// get the interface number from the object name
var port_id = name.split('_')[1];
// find its corresponding checkbox and toggle it
$('[name="port[' + port_id + '][ignore]"]').bootstrapToggle('on');
}
});
});
$('#form-reset').click(function (event) {
// reset objects in the form to their previous values
event.preventDefault();
$('#ports_update')[0].reset();
});
$('#ports_update').submit(processAjaxForm);
</script>
<?php
// EOF

View File

@ -0,0 +1,239 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$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']));
//foreach ($limits_reset_array as $class => $descr)
//{
// print_warning('Reset limits for ' . nicecase($class) . ' sensor' . (count($descr) > 1 ? 's' : '') . ' "' . implode('", "',$descr) . '"; they will be recalculated on the next discovery run.');
//}
//unset($limits_reset_array);
?>
<form id="update-sensors">
<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">
<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>
<?php
// 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);
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>');
$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 = 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>');
}
?>
</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>
<?php
register_html_resource('script', '$("#update-sensors").submit(processAjaxForm);');
// EOF

View File

@ -0,0 +1,361 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$ok = FALSE;
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$update = array();
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) {
$update['snmp_version'] = $vars['snmp_version'];
if (in_array($vars['snmp_transport'], $config['snmp']['transports'])) {
$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'] = array('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'] = array('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 (strlen(trim($vars['snmp_context']))) {
$update['snmp_context'] = trim($vars['snmp_context']);
} else {
$update['snmp_context'] = [ 'NULL' ];
}
if (dbUpdate($update, 'devices', '`device_id` = ?', array($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);
$transports = array();
foreach ($config['snmp']['transports'] as $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';
} else {
$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 ],
];
$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' ],
];
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
//'title' => 'General',
//'class' => 'box',
);
// top row div
$form['fieldset']['edit'] = array('div' => 'top',
'title' => 'Basic Configuration',
'class' => 'col-md-6');
$form['fieldset']['snmpv2'] = array('div' => 'top',
'title' => 'SNMP v1/v2c Authentication',
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0');
$form['fieldset']['snmpv3'] = array('div' => 'top',
'title' => 'SNMP v3 Authentication',
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0');
$form['fieldset']['snmpextra'] = array('div' => 'top',
'title' => 'Extra Configuration',
//'right' => TRUE,
'class' => 'col-sm-12 col-md-6 pull-right');
// bottom row div
$form['fieldset']['submit'] = array('div' => 'bottom',
'style' => 'padding: 0px;',
'class' => 'col-md-12');
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
// left fieldset
$form['row'][1]['snmp_version'] = array(
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'readonly' => $readonly,
'values' => array('v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3'),
'value' => $device['snmp_version']);
$form['row'][2]['snmp_transport'] = array(
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'readonly' => $readonly,
'values' => $transports,
'value' => $device['snmp_transport']);
$form['row'][3]['snmp_port'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Port',
'width' => '250px',
'placeholder' => '1-65535. Default 161.',
'readonly' => $readonly,
'value' => $device['snmp_port']);
$form['row'][4]['snmp_timeout'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Timeout',
'width' => '250px',
'placeholder' => '1-120 sec. Default 1 sec.',
'readonly' => $readonly,
'value' => $device['snmp_timeout']);
$form['row'][5]['snmp_retries'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Retries',
'width' => '250px',
'placeholder' => '1-10. Default 5.',
'readonly' => $readonly,
'value' => $device['snmp_retries']);
$form['row'][6]['snmp_maxrep'] = array(
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Max Repetitions',
'width' => '250px',
'placeholder' => '0-500. Default 10. 0 for disable snmpbulk.',
'readonly' => $readonly,
'value' => $device['snmp_maxrep']);
// Snmp v1/2c fieldset
$form['row'][7]['snmp_community'] = array(
'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!
// Snmp v3 fieldset
$form['row'][8]['snmp_authlevel'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'readonly' => $readonly,
'values' => array('noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'),
'value' => $device['snmp_authlevel']);
$form['row'][9]['snmp_authname'] = array(
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_authname']);
$form['row'][10]['snmp_authpass'] = array(
'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!
$form['row'][11]['snmp_authalgo'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $authalgo,
'value' => $device['snmp_authalgo']);
$form['row'][12]['snmp_cryptopass'] = array(
'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!
$form['row'][13]['snmp_cryptoalgo'] = array(
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $cryptoalgo,
'value' => $device['snmp_cryptoalgo']);
$form['row'][15]['snmp_context'] = array(
'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!
$form['row'][20]['submit'] = array(
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
print_form_box($form);
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();
$("#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
// EOF

View File

@ -0,0 +1,88 @@
<?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 {
$ssh_port = $vars['ssh_port'];
if (!is_numeric($ssh_port))
{
$update_message = "SSH port must be numeric!";
$updated = 0;
} else {
$update = array(
'ssh_port' => $ssh_port
);
$rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($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']));
if ($updated && $update_message)
{
print_message($update_message);
} elseif ($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');
print_form($form);
unset($form);
// EOF

View File

@ -0,0 +1,92 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$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']));
?>
<form id="update_statuses" class="form form-inline">
<input type="hidden" name="action" value="statuses_update">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Status Properties</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed vertical-align">
<thead>
<tr>
<th class="state-marker"></th>
<!-- <th style="width: 60px;">Index</th> -->
<th>Description & MIB</th>
<th style="width: 100px;">Value</th>
<th style="width: 60px;">Event</th>
<th style="width: 50px;">Alerts</th>
</tr>
</thead>
<tbody>
<?php
// 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);
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>';
}
?>
</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>
</div>
</div>
</form>
<?php
register_html_resource('script', '$("#update_statuses").submit(processAjaxForm);');
// EOF

View File

@ -0,0 +1,228 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
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'); }
$update_message = "Device WMI data updated.";
$updated = 1;
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']])
{
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");
} else {
set_entity_attrib('device', $device, 'wmi_poll_' . $module, "0");
}
}
$attribs = get_entity_attribs('device', $device['device_id'], TRUE);
}
}
if (!$readonly) {
// 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;
}
}
// 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' ]);
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";
$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>';
print_error("Invalid security credentials or insufficient WMI security permissions. Read documentation $docs_link.");
$wmi_ok = FALSE;
} else {
print_success("WMI successfully connected, remote device name is: <strong>$wmi_name<strong>.");
}
}
}
?>
<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' => ''),
);
$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>
</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>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>' ));
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";
}
}
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></tr>');
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php
// EOF

View File

@ -0,0 +1,18 @@
<?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
*
*/
print_inventory($vars);
register_html_title("Inventory");
// EOF

View File

@ -0,0 +1,143 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// 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;
}
}
$navbar['brand'] = "Graphs";
$navbar['class'] = "navbar-narrow";
// 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_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'];
echo('<tr><td>');
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']];
// 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'];
echo('<tr><td>');
echo('<h3>' . $graph_title . '</h4>');
print_graph_row($graph_array);
echo('</td></tr>');
//}
}
}
echo('</table>');
echo generate_box_close();
register_html_title("Graphs");
// EOF

View File

@ -0,0 +1,122 @@
<?php
/**
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$datas = array('overview' => array('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'])
{
$sensors_device = dbFetchRows("SELECT DISTINCT `sensor_class` FROM `sensors` WHERE `device_id` = ? AND `sensor_deleted` = ?", array($device['device_id'], 0));
foreach ($sensors_device as $sensor)
{
if ($sensor['sensor_class'] == 'counter') { continue; } // DEVEL
$datas[$sensor['sensor_class']] = array('icon' => $config['sensor_types'][$sensor['sensor_class']]['icon']);
}
}
// 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']);
}
}
*/
$link_array = 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']['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"));
} else {
$navbar['options']['graphs']['url'] = generate_url($vars, array('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");
} else {
echo generate_box_open();
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'];
echo('<tr><td>');
echo('<h3>' . $graph_title . '</h3>');
print_graph_row($graph_array);
echo('</td></tr>');
}
}
echo('</table>');
echo generate_box_close();
}
register_html_title("Health");
// EOF

View File

@ -0,0 +1,38 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
if ($metric != 'counter' && device_permitted($device))
{
// 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';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_close();
}
print_counter_table($vars);
// EOF

View File

@ -0,0 +1,20 @@
<?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
*
*/
$class = "dbm";
$unit = "dBm";
$graph_type = "sensor_dbm";
include("sensors.inc.php");
// EOF

View File

@ -0,0 +1,88 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if (device_permitted($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';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
echo generate_box_open($box_args);
print_graph_row($graph_array);
$graph_array['type'] = "device_diskio_ops";
print_graph_row($graph_array);
echo generate_box_close();
}
echo generate_box_open();
echo('<table class="table table-striped table-condensed ">');
//echo("<thead><tr>
// <th>Device</th>
// </tr></thead>");
foreach (dbFetchRows("SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr", array($device['device_id'])) as $drive)
{
$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'];
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");
$rrd_filename = get_rrd_path($device, "diskstat-".$drive['diskio_descr'].".rrd");
if(is_file($rrd_filename))
{
$types[] = "diskio_stat";
}
foreach ($types as $graph_type)
{
$graph_array = array();
$graph_array['id'] = $drive['diskio_id'];
$graph_array['type'] = $graph_type;
print_graph_row($graph_array);
}
}
echo "</td></tr>";
echo "</table>";
echo generate_box_close();
// EOF

View File

@ -0,0 +1,36 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if (device_permitted($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';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_close();
}
print_mempool_table($vars);
// EOF

View File

@ -0,0 +1,38 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if (device_permitted($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';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
echo generate_box_open($box_args);
print_graph_row($graph_array);
$graph_type = "processor_usage";
echo generate_box_close();
}
print_processor_table($vars);
// EOF

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