mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 17:14:46 +00:00
(diagnostics) add system activity
This commit is contained in:
parent
6ea14da0fd
commit
c4beabc659
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2015 Deciso B.V.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
namespace OPNsense\Diagnostics;
|
||||
|
||||
use OPNsense\Base\IndexController;
|
||||
|
||||
/**
|
||||
* Class IndexController
|
||||
* @package OPNsense\Proxy
|
||||
*/
|
||||
class ActivityController extends IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->title = "System Activity";
|
||||
$this->view->pick('OPNsense/Diagnostics/systemactivity');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2015 Deciso B.V.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace OPNsense\Diagnostics\Api;
|
||||
|
||||
use \OPNsense\Base\ApiControllerBase;
|
||||
use \OPNsense\Core\Backend;
|
||||
|
||||
/**
|
||||
* Class ActivityController
|
||||
* @package OPNsense\SystemHealth
|
||||
*/
|
||||
class ActivityController extends ApiControllerBase
|
||||
{
|
||||
/**
|
||||
* retrieve system activity (top)
|
||||
* @return array
|
||||
*/
|
||||
public function getActivityAction()
|
||||
{
|
||||
$backend = new Backend();
|
||||
$response = $backend->configdpRun("system diag activity json");
|
||||
$activity = json_decode($response, true);
|
||||
|
||||
return $activity;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,138 @@
|
||||
{#
|
||||
|
||||
OPNsense® is Copyright © 2014 – 2015 by Deciso B.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#}
|
||||
<script src="/ui/js/moment-with-locales.min.js" type="text/javascript"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$( document ).ready(function() {
|
||||
/**
|
||||
* fetch system activity
|
||||
*/
|
||||
function updateTop() {
|
||||
var gridopt = {
|
||||
ajax: false,
|
||||
selection: true,
|
||||
multiSelect: true
|
||||
};
|
||||
$("#grid-top").bootgrid('destroy');
|
||||
ajaxGet(url = "/api/diagnostics/activity/getActivity",
|
||||
sendData = {}, callback = function (data, status) {
|
||||
if (status == "success") {
|
||||
$("#grid-top > tbody").html('');
|
||||
$.each(data['details'], function (key, value) {
|
||||
var fields = ["PID", "USERNAME", "PRI", "NICE", "SIZE", "RES", "STATE", "C", "TIME", "WCPU", "COMMAND"];
|
||||
tr_str = '<tr>';
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
if (value[fields[i]] != null) {
|
||||
tr_str += '<td>' + value[fields[i]] + '</td>';
|
||||
} else {
|
||||
tr_str += '<td></td>';
|
||||
}
|
||||
}
|
||||
tr_str += '</tr>';
|
||||
$("#grid-top > tbody").append(tr_str);
|
||||
});
|
||||
var header_txt = "";
|
||||
$.each(data['headers'], function (key, value) {
|
||||
header_txt += value;
|
||||
header_txt += "<br/>";
|
||||
});
|
||||
$("#header_data").html(header_txt);
|
||||
$('#header_data').fadeOut('slow');
|
||||
$('#header_data_show').fadeIn('slow');
|
||||
}
|
||||
$("#grid-top").bootgrid(gridopt);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// initial fetch
|
||||
updateTop();
|
||||
|
||||
// hide show header info button
|
||||
$('#header_data_show').hide();
|
||||
$("#refresh").click(updateTop);
|
||||
|
||||
// link show header info
|
||||
$("#header_data_show").click(function(){
|
||||
$('#header_data').fadeIn('slow');
|
||||
$('#header_data_show').hide();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div class="content-box">
|
||||
<div class="content-box-main">
|
||||
<div class="table-responsive">
|
||||
<div class="col-sm-12">
|
||||
<table id="grid-top" class="table table-condensed table-hover table-striped table-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="PID" data-type="numeric" data-identifier="true">{{ lang._('PID') }}</th>
|
||||
<th data-column-id="USERNAME" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('USERNAME') }}</th>
|
||||
<th data-column-id="PRI" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('PRI') }}</th>
|
||||
<th data-column-id="NICE" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('NICE') }}</th>
|
||||
<th data-column-id="SIZE" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('SIZE') }}</th>
|
||||
<th data-column-id="RES" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('RES') }}</th>
|
||||
<th data-column-id="STATE" data-type="string">{{ lang._('STATE') }}</th>
|
||||
<th data-column-id="C" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('C') }}</th>
|
||||
<th data-column-id="TIME" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('TIME') }}</th>
|
||||
<th data-column-id="WCPU" data-type="string">{{ lang._('WCPU') }}</th>
|
||||
<th data-column-id="COMMAND" data-type="string">{{ lang._('COMMAND') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="pull-left" data-toggle="popover">
|
||||
<small id="header_data"></small>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<button id="header_data_show" class="btn btn-default"><i class="fa fa-info-circle"></i></button>
|
||||
<button id="refresh" type="button" class="btn btn-default">
|
||||
<span>{{ lang._('Refresh') }}</span>
|
||||
<span class="fa fa-refresh"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
x
Reference in New Issue
Block a user