mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
security/etpro-telemetry - prepare for 24.7 and replace dashboard widget with minimalistic new version.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
PLUGIN_NAME= etpro-telemetry
|
||||
PLUGIN_VERSION= 1.6
|
||||
PLUGIN_REVISION= 4
|
||||
PLUGIN_VERSION= 1.7
|
||||
#PLUGIN_REVISION= 1
|
||||
PLUGIN_COMMENT= ET Pro Telemetry Edition
|
||||
PLUGIN_MAINTAINER= ad@opnsense.org
|
||||
PLUGIN_WWW= https://docs.opnsense.org/manual/etpro_telemetry.html
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.
|
||||
*/
|
||||
|
||||
import BaseTableWidget from "./BaseTableWidget.js";
|
||||
|
||||
export default class ETProTelemetry extends BaseTableWidget {
|
||||
constructor() {
|
||||
super();
|
||||
this.tickTimeout = 3600000;
|
||||
}
|
||||
|
||||
getMarkup() {
|
||||
let $container = $('<div></div>');
|
||||
let $ETProTelemetrytable = this.createTable('ETProTelemetry-table', {
|
||||
headerPosition: 'left',
|
||||
});
|
||||
$container.append($ETProTelemetrytable);
|
||||
return $container;
|
||||
}
|
||||
|
||||
async onWidgetTick() {
|
||||
await ajaxGet('/api/diagnostics/proofpoint_et/status', {}, (data, status) => {
|
||||
if (data['sensor_status'] == 'active') {
|
||||
$('#etpro_sensor_status').text(data['sensor_status']);
|
||||
$('#etpro_event_received').text(data['event_received']);
|
||||
$('#etpro_last_rule_download').text(data['last_rule_download']);
|
||||
$('#etpro_last_heartbeat').text(data['last_heartbeat']);
|
||||
} else {
|
||||
$('#etpro_sensor_status').text('-');
|
||||
$('#etpro_event_received').text('-');
|
||||
$('#etpro_last_rule_download').text('-');
|
||||
$('#etpro_last_heartbeat').text('-');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async onMarkupRendered() {
|
||||
await ajaxGet('/api/core/system/systemInformation', {}, (data, status) => {
|
||||
let rows = [];
|
||||
rows.push([['<img src="/ui/img/proofpoint.svg" style="height:30px;" class="image_invertible">'], '']);
|
||||
rows.push([[this.translations['sensor_status']], $('<span id="etpro_sensor_status">').prop('outerHTML')]);
|
||||
rows.push([[this.translations['event_received']], $('<span id="etpro_event_received">').prop('outerHTML')]);
|
||||
rows.push([[this.translations['last_rule_download']], $('<span id="etpro_last_rule_download">').prop('outerHTML')]);
|
||||
rows.push([[this.translations['last_heartbeat']], $('<span id="etpro_last_heartbeat">').prop('outerHTML')]);
|
||||
|
||||
super.updateTable('ETProTelemetry-table', rows);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<metadata>
|
||||
<etpro_telemetry>
|
||||
<filename>ETProTelemetry.js</filename>
|
||||
<endpoints>
|
||||
<endpoint>/api/diagnostics/proofpoint_et/status</endpoint>
|
||||
</endpoints>
|
||||
<translations>
|
||||
<title>Telemetry status</title>
|
||||
<sensor_status>Status</sensor_status>
|
||||
<event_received>Last event</event_received>
|
||||
<last_rule_download>Last rule download</last_rule_download>
|
||||
<last_heartbeat>Last heartbeat</last_heartbeat>
|
||||
</translations>
|
||||
</etpro_telemetry>
|
||||
</metadata>
|
||||
@@ -1,2 +0,0 @@
|
||||
<?php
|
||||
$proofpoint_et_title = gettext('Telemetry status');
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (C) 2018-2019 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.
|
||||
*/
|
||||
?>
|
||||
|
||||
<style>
|
||||
.proofpoint_logo {
|
||||
height: 30px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.proofpoint_status_div {
|
||||
padding: 2px;
|
||||
border: 2px solid black;
|
||||
white-space: nowrap;
|
||||
display: inline;
|
||||
}
|
||||
</style>
|
||||
<script src="/ui/js/moment-with-locales.min.js"></script>
|
||||
<script>
|
||||
$(window).on("load", function() {
|
||||
ajaxGet("/api/diagnostics/proofpoint_et/status", {}, function(data){
|
||||
$("#proofpoint_status").removeClass("fa-spin");
|
||||
$("#proofpoint_status").removeClass("fa-spinner");
|
||||
if (data.status == 'ok' && data.sensor_status == 'ACTIVE') {
|
||||
$("#proofpoint_status").addClass("fa-check");
|
||||
} else {
|
||||
$("#proofpoint_status").addClass("fa-close");
|
||||
}
|
||||
|
||||
if (data.status == 'ok') {
|
||||
var props = {
|
||||
sensor_status: "<?=html_safe(gettext('Status'));?>",
|
||||
event_received: "<?=html_safe(gettext('Last event'));?>",
|
||||
last_rule_download: "<?=html_safe(gettext('Last rule download'));?>",
|
||||
last_heartbeat: "<?=html_safe(gettext('Last heartbeat'));?>"
|
||||
};
|
||||
|
||||
$("#proofpoint_status_table > tbody").empty();
|
||||
for (var idx in props) {
|
||||
if (idx === 'sensor_status') {
|
||||
var content = data[idx];
|
||||
} else {
|
||||
var content = moment(data[idx]).format('ddd MMM D HH:mm:ss ZZ YYYY')
|
||||
}
|
||||
$("#proofpoint_status_table > tbody").append(
|
||||
$("<tr/>")
|
||||
.append($("<td style='width:30%'/>").text(props[idx]))
|
||||
.append($("<td/>").text(content))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<table class="table table-striped table-condensed" id="proofpoint_status_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
<img src="/ui/img/proofpoint.svg" class="proofpoint_logo image_invertible">
|
||||
<div class="proofpoint_status_div pull-right">
|
||||
<i class="fa fa-spinner fa-2x fa-spin" style="vertical-align: middle;" id="proofpoint_status"></i>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<?=gettext("For more information, please visit");?>
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://docs.opnsense.org/manual/etpro_telemetry.html">docs.opnsense.org</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
Reference in New Issue
Block a user