mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Component Update - Status
- Align the component status field with the Nagios standard 0=ok, 1=warning, 2=critical - Modify existing modules to report these status' (Cisco-OTV) - Add/Modify Alerting Macros to use these status' - Add the a component status widget - update edit page to report these status'
This commit is contained in:
41
html/includes/common/component-status.inc.php
Normal file
41
html/includes/common/component-status.inc.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
require_once "../includes/component.php";
|
||||
$OBJCOMP = new component();
|
||||
|
||||
$common_output[] = '
|
||||
<div>
|
||||
<table id="component-status" class="table table-hover table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="status" data-order="desc">Status</th>
|
||||
<th data-column-id="count">Count</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
foreach ($OBJCOMP->getComponentStatus() as $k => $v) {
|
||||
if ($k == 0) {
|
||||
$status = 'Ok';
|
||||
$color = 'green';
|
||||
}
|
||||
elseif ($k == 1) {
|
||||
$status = 'Warning';
|
||||
$color = 'grey';
|
||||
}
|
||||
else {
|
||||
$status = 'Critical';
|
||||
$color = 'red';
|
||||
}
|
||||
$common_output[] .= '
|
||||
<tr>
|
||||
<td><p class="text-left '.$color.'">'.$status.'</p></td>
|
||||
<td><p class="text-left '.$color.'">'.$v.'</p></td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
$common_output[] .= '
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
';
|
||||
@@ -34,17 +34,30 @@ $COMPONENTS = $OBJCOMP->getComponents($device_id,$options);
|
||||
$response[] = array(
|
||||
'id' => '<button type="submit" id="save-form" class="btn btn-success btn-sm" title="Save current component disable/ignore settings">Save</button><button type="submit" id="form-reset" class="btn btn-danger btn-sm" title="Reset form to when the page was loaded">Reset</button>',
|
||||
'label' => ' ',
|
||||
'status' => '<button type="submit" id="alert-select" class="btn btn-default btn-sm" title="Disable alerting on all currently-alerting components">Alerting</button>',
|
||||
'status' => '<button type="submit" id="warning-select" class="btn btn-default btn-sm" title="Disable alerting on all currently warning components">Warning</button> <button type="submit" id="critical-select" class="btn btn-default btn-sm" title="Disable alerting on all currently critical components">Critical</button>',
|
||||
'disable' => '<button type="submit" id="disable-toggle" class="btn btn-default btn-sm" title="Toggle polling for all components">Toggle</button><button type="button" id="disable-select" class="btn btn-default btn-sm" title="Disable polling on all components">Select All</button>',
|
||||
'ignore' => '<button type="submit" id="ignore-toggle" class="btn btn-default btn-sm" title="Toggle alerting for all components">Toggle</button><button type="button" id="ignore-select" class="btn btn-default btn-sm" title="Disable alerting on all components">Select All</button>',
|
||||
);
|
||||
|
||||
foreach ($COMPONENTS[$device_id] as $ID => $AVP) {
|
||||
if ($AVP['status'] == 0) {
|
||||
$class = "green";
|
||||
$status = "Ok";
|
||||
}
|
||||
elseif ($AVP['status'] == 1) {
|
||||
$class = "grey";
|
||||
$status = "Warning";
|
||||
}
|
||||
else {
|
||||
// Critical
|
||||
$class = "red";
|
||||
$status = "Critical";
|
||||
}
|
||||
$response[] = array(
|
||||
'id' => $ID,
|
||||
'type' => $AVP['type'],
|
||||
'label' => $AVP['label'],
|
||||
'status' => ($AVP['status'] ? "<span name='status_".$ID."' class='green'>Normal</span>" : "<span name='status_".$ID."' class='red'>Alert</span>"),
|
||||
'status' => "<span name='status_".$ID."' class='".$class."'>".$status."</span>",
|
||||
'disable' => '<input type="checkbox" class="disable-check" name="dis_'.$ID.'"'.($AVP['disabled'] ? 'checked' : '').'>',
|
||||
'ignore' => '<input type="checkbox" class="ignore-check" name="ign_'.$ID.'"'.($AVP['ignore'] ? 'checked' : '').'>',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user