Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

103 lines
4.9 KiB
PHP
Raw Permalink Normal View History

2020-02-12 08:26:02 +01:00
<?php
2021-01-27 22:08:42 -06:00
$app = \App\Models\Application::query()->where('device_id', $device['device_id'])->where('app_type', 'puppet-agent')->first();
2020-02-12 08:26:02 +01:00
// show only if Puppet Agent Application discovered
2021-01-27 22:08:42 -06:00
if ($app) {
2020-02-12 08:26:02 +01:00
$params = [];
2021-01-27 22:08:42 -06:00
$sql = 'SELECT `metric`, `value` FROM `application_metrics` WHERE `app_id` =' . $app->app_id;
2020-02-12 08:26:02 +01:00
$metrics = dbFetchKeyValue($sql, $params); ?><div class='row'>
<div class='col-md-12'>
<div class='panel panel-default panel-condensed device-overview'>
<div class='panel-heading'>
<a href="device/device=<?php echo $device['device_id']?>/tab=apps/app=puppet-agent/">
<i class="fa fa-cogs fa-lg icon-theme" aria-hidden="true"></i>
<strong>Puppet Agent</strong>
</a>
</div>
<div class="panel-body">
<?php
$graph_array = [];
$graph_array['height'] = '100';
$graph_array['width'] = '210';
$graph_array['to'] = \LibreNMS\Config::get('time.now');
2021-01-27 22:08:42 -06:00
$graph_array['id'] = $app->app_id;
2020-02-12 08:26:02 +01:00
$graph_array['from'] = \LibreNMS\Config::get('time.day');
$graph_array['legend'] = 'no';
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
// graph last run
$title_last_run = 'Last run';
$graph_array_last_run = $graph_array;
$graph_array_last_run['type'] = 'application_puppet-agent_last_run';
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
$link_array_last_run = $graph_array_last_run;
$link_array_last_run['page'] = 'graphs';
unset($link_array_last_run['height'], $link_array_last_run['width'], $link_array_last_run['legend']);
2021-03-28 17:25:30 -05:00
$link_last_run = \LibreNMS\Util\Url::generate($link_array_last_run);
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
$overlib_content_last_run = generate_overlib_content($graph_array_last_run, $device['hostname'] . ' - ' . $title_last_run);
2021-03-28 17:25:30 -05:00
$overlib_link_last_run = \LibreNMS\Util\Url::overlibLink($link_last_run, 'Last run', $overlib_content_last_run);
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
// graph runtime
$title_runtime = 'Runtime';
$graph_array_runtime = $graph_array;
$graph_array_runtime['type'] = 'application_puppet-agent_time';
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
$link_array_runtime = $graph_array_runtime;
$link_array_runtime['page'] = 'graphs';
unset($link_array_runtime['height'], $link_array_runtime['width'], $link_array_runtime['legend']);
2021-03-28 17:25:30 -05:00
$link_runtime = \LibreNMS\Util\Url::generate($link_array_runtime);
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
$overlib_content_runtime = generate_overlib_content($graph_array_runtime, $device['hostname'] . ' - ' . $title_runtime);
2021-03-28 17:25:30 -05:00
$overlib_link_runtime = \LibreNMS\Util\Url::overlibLink($link_runtime, $title_runtime, $overlib_content_runtime);
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
// graph resources
$title_resources = 'Resources';
$graph_array_resources = $graph_array;
$graph_array_resources['type'] = 'application_puppet-agent_resources';
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
$link_array_resources = $graph_array_resources;
$link_array_resources['page'] = 'graphs';
unset($link_array_resources['height'], $link_array_resources['width'], $link_array_resources['legend']);
2021-03-28 17:25:30 -05:00
$link_resources = \LibreNMS\Util\Url::generate($link_array_resources);
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
$overlib_content_resources = generate_overlib_content($graph_array_resources, $device['hostname'] . ' - ' . $title_resources);
2021-03-28 17:25:30 -05:00
$overlib_link_resources = \LibreNMS\Util\Url::overlibLink($link_resources, $title_resources, $overlib_content_resources);
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
// graph events
$title_events = 'Change Events';
$graph_array_events = $graph_array;
$graph_array_events['type'] = 'application_puppet-agent_events';
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
$link_array_events = $graph_array_events;
$link_array_events['page'] = 'graphs';
unset($link_array_events['height'], $link_array_events['width'], $link_array_events['legend']);
2021-03-28 17:25:30 -05:00
$link_events = \LibreNMS\Util\Url::generate($link_array_events);
2020-09-21 15:40:17 +02:00
2020-02-12 08:26:02 +01:00
$overlib_content_events = generate_overlib_content($graph_array_events, $device['hostname'] . ' - ' . $title_events);
2021-03-28 17:25:30 -05:00
$overlib_link_events = \LibreNMS\Util\Url::overlibLink($link_events, $title_events, $overlib_content_events);
2020-02-12 08:26:02 +01:00
echo '<div class="row">
<div class="col-sm-4">Summary</div>
<div class="col-sm-8">
<table width=100%><tr>
<td><span>' . $overlib_link_last_run . ': ' . $metrics['last_run_last_run'] . 'min</span></td>
<td><span>' . $overlib_link_runtime . ': ' . $metrics['time_total'] . 's</span></td>
<td><span>' . $overlib_link_resources . ': ' . $metrics['resources_total'] . '</span></td>
</tr></table>
</div>
<div class="col-sm-4">' . $overlib_link_events . '</div>
<div class="col-sm-8">
<table width=100%><tr>
<td><span ' . ($metrics['events_success'] ? 'class="blue"' : '') . '>Success: ' . $metrics['events_success'] . '</span></td>
<td><span ' . ($metrics['events_failure'] ? 'class="red"' : '') . '>Failure: ' . $metrics['events_failure'] . '</span></td>
<td><span>Total: ' . $metrics['events_total'] . '</span></td>
</tr></table>
</div>
</div>
</div>
</div>
</div>
</div>';
}