2014-02-26 22:33:45 +00:00
|
|
|
<?php
|
|
|
|
|
2019-05-10 11:02:39 -05:00
|
|
|
use LibreNMS\Util\ObjectCache;
|
|
|
|
|
2019-06-03 19:14:35 -05:00
|
|
|
if (ObjectCache::serviceCounts(['total'], $device['device_id'])['total'] > 0) {
|
2022-11-05 10:04:36 +01:00
|
|
|
$colors = new \Illuminate\Support\Collection(['green', 'yellow', 'red']);
|
2019-10-19 05:25:30 +00:00
|
|
|
$output = \App\Models\Service::query()
|
|
|
|
->where('device_id', $device['device_id'])
|
|
|
|
->orderBy('service_type')
|
2022-09-30 10:22:01 +02:00
|
|
|
->get(['service_type', 'service_status', 'service_message', 'service_name'])
|
2019-10-19 05:25:30 +00:00
|
|
|
->map(function ($service) use ($colors) {
|
|
|
|
$message = str_replace(' ', ' ', $service->service_message);
|
|
|
|
$color = $colors->get($service->service_status, 'grey');
|
|
|
|
$type = strtolower($service->service_type);
|
2022-09-30 10:22:01 +02:00
|
|
|
$name = $service->service_name;
|
2022-10-23 20:00:29 +02:00
|
|
|
$name_type = ($name == '' || $name == $type) ? $type : $name . ' (' . $type . ')';
|
2019-10-19 05:25:30 +00:00
|
|
|
|
2022-10-23 20:00:29 +02:00
|
|
|
return "<span title='$message' class='$color'>$name_type</span>";
|
2019-10-19 05:25:30 +00:00
|
|
|
})->implode(', ');
|
2019-05-10 11:02:39 -05:00
|
|
|
|
2019-06-03 19:14:35 -05:00
|
|
|
$services = ObjectCache::serviceCounts(['total', 'ok', 'warning', 'critical'], $device['device_id']); ?>
|
2017-10-30 18:45:58 +01:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div class="panel panel-default panel-condensed">
|
|
|
|
<div class="panel-heading">
|
2019-08-02 22:25:09 +02:00
|
|
|
<?php echo '<a href="device/device=' . $device['device_id'] . '/tab=services">'?><i class="fa fa-cogs fa-lg icon-theme" aria-hidden="true"></i> <strong>Services</strong><?php echo '</a>'?>
|
2017-10-30 18:45:58 +01:00
|
|
|
</div>
|
|
|
|
<table class="table table-hover table-condensed table-striped">
|
|
|
|
<tr>
|
2019-10-19 05:25:30 +00:00
|
|
|
<td title="Total"><i class="fa fa-cog" aria-hidden="true"></i> <?php echo $services['total']?></td>
|
2019-05-10 11:02:39 -05:00
|
|
|
<td title="Status - Ok"><i class="fa fa-cog" style="color:green" aria-hidden="true"></i> <?php echo $services['ok']?></td>
|
|
|
|
<td title="Status - Warning"><i class="fa fa-cog" style="color:orange" aria-hidden="true"></i> <?php echo $services['warning']?></td>
|
|
|
|
<td title="Status - Critical"><i class="fa fa-cog" style="color:red" aria-hidden="true"></i> <?php echo $services['critical']?></td>
|
2017-10-30 18:45:58 +01:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2019-05-10 11:02:39 -05:00
|
|
|
<td colspan='4'><?php echo $output?></td>
|
2017-10-30 18:45:58 +01:00
|
|
|
</tr>
|
|
|
|
</table>
|
2016-03-15 22:16:08 +10:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-04-03 08:41:24 -05:00
|
|
|
<?php
|
2016-05-02 18:43:06 +00:00
|
|
|
}
|