mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-25 11:48:21 +01:00
Add server log monitoring tols
This commit is contained in:
parent
f453769944
commit
ecc54322a3
9
ServerLogClient/README.md
Normal file
9
ServerLogClient/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Server log monitor
|
||||||
|
This application allows to monitor Server Syslog
|
||||||
|
using Antunnel protocol. Features:
|
||||||
|
* Realtime log monitoring
|
||||||
|
* Filter logs by pattern (regular expression), severity
|
||||||
|
* Recording last n log messages
|
||||||
|
|
||||||
|
## Change logs
|
||||||
|
* v0.1.0-b first beta version
|
71
ServerLogClient/build.json
Normal file
71
ServerLogClient/build.json
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
"name": "ServerLogClient",
|
||||||
|
"targets":{
|
||||||
|
"clean": {
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"name": "vfs-rm",
|
||||||
|
"data": ["build/debug","build/release"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"build": {
|
||||||
|
"require": ["ts"],
|
||||||
|
"jobs":[
|
||||||
|
{
|
||||||
|
"name": "vfs-mkdir",
|
||||||
|
"data": ["build","build/debug","build/release"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ts-import",
|
||||||
|
"data": ["sdk://core/ts/core.d.ts", "sdk://core/ts/jquery.d.ts","sdk://core/ts/antos.d.ts"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ts-compile",
|
||||||
|
"data": {
|
||||||
|
"src": ["main.ts"],
|
||||||
|
"dest": "build/debug/main.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"uglify": {
|
||||||
|
"require": ["terser"],
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"name":"terser-uglify",
|
||||||
|
"data": ["build/debug/main.js"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"copy": {
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"name": "vfs-cp",
|
||||||
|
"data": {
|
||||||
|
"src": [
|
||||||
|
"scheme.html",
|
||||||
|
"package.json",
|
||||||
|
"README.md",
|
||||||
|
"main.css"
|
||||||
|
],
|
||||||
|
"dest":"build/debug"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"depend": ["clean","build","uglify", "copy"],
|
||||||
|
"require": ["zip"],
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"name": "zip-mk",
|
||||||
|
"data": {
|
||||||
|
"src":"build/debug",
|
||||||
|
"dest":"build/release/ServerLogClient.zip"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
ServerLogClient/build/debug/README.md
Normal file
9
ServerLogClient/build/debug/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Server log monitor
|
||||||
|
This application allows to monitor Server Syslog
|
||||||
|
using Antunnel protocol. Features:
|
||||||
|
* Realtime log monitoring
|
||||||
|
* Filter logs by pattern (regular expression), severity
|
||||||
|
* Recording last n log messages
|
||||||
|
|
||||||
|
## Change logs
|
||||||
|
* v0.1.0-b first beta version
|
55
ServerLogClient/build/debug/main.css
Normal file
55
ServerLogClient/build/debug/main.css
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
afx-app-window[data-id="ServerLogClient"] p {
|
||||||
|
margin: 0;
|
||||||
|
padding: 5px;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
font-family: "Courier New";
|
||||||
|
border-bottom: 1px solid gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p:hover {
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.debug{
|
||||||
|
color:green;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.notice, afx-app-window[data-id="ServerLogClient"] p.info{
|
||||||
|
color:green;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.warning {
|
||||||
|
color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.err {
|
||||||
|
color: orangered;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.crit, afx-app-window[data-id="ServerLogClient"] p.alert {
|
||||||
|
color: orangered;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.emerg {
|
||||||
|
color: red;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
afx-app-window[data-id="ServerLogClient"] input {
|
||||||
|
height: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] afx-hbox[data-id="top-header"] {
|
||||||
|
border-bottom: 1px solid gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] afx-hbox[data-id="top-header"] afx-label.field-label{
|
||||||
|
text-align: right;
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] afx-hbox[data-id="top-header"] afx-label.field-label i.label-text{
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
1
ServerLogClient/build/debug/main.js
Normal file
1
ServerLogClient/build/debug/main.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
var OS;!function(t){let e;!function(t){class e extends t.BaseApplication{constructor(t){super("ServerLogClient",t)}check(t){return!(!this.filter.record||!this.filter[t.severity_label]||this.filter.pattern&&!t.message.match(this.filter.pattern))}log(t){if(this.check(t)){if(this.logs.length>=this.filter.max_log){let t=this.logs.shift();$(t.el).remove()}t.el=$("<p />").addClass(t.severity_label),t.el.text(t.message),$(this.log_container).append(t.el),this.log_container.scrollTop=this.log_container.scrollHeight,this.logs.push(t)}}openSession(){this.sub=new Antunnel.Subscriber(this.setting.topic),this.sub.onopen=()=>{console.log("Subscribed")},this.sub.onerror=t=>{this.error(__("Unable to connect to: syslog"),t),this.sub=void 0},this.sub.onmessage=t=>{if(t.data){let e=JSON.parse(new TextDecoder("utf-8").decode(t.data));e.priority&&(e.priority=parseInt(e.priority)),e.severity&&(e.severity=parseInt(e.severity)),e.facility&&(e.facility=parseInt(e.facility)),this.log(e)}},this.sub.onclose=()=>{this.sub=void 0,this.notify(__("Connection closed")),this.quit(!0)},this.tunnel.subscribe(this.sub)}cleanup(){this.sub&&this.sub.close()}checklib(){Antunnel.tunnel?(this.tunnel=Antunnel.tunnel,this.openSession()):this._gui.pushService("Antunnel/AntunnelService").then(t=>{let e=this.systemsetting.system.tunnel_uri;e||(this.error(__("Unable to connect to the tunnel")),this.quit(!0)),Antunnel.init(e).then(t=>{this.notify(__("Tunnel now connected to the server at: {0}",e)),this.tunnel=Antunnel.tunnel,this.openSession()}).catch(t=>{Antunnel.tunnel&&(Antunnel.tunnel.close(),this.error(__("Unable to connect to the tunnel: {0}",t.toString()),t),this.quit(!0))})}).catch(t=>{this.error(__("Unable to run Antunnel service: {0}",t.toString()),t),this.quit(!0)})}main(){if(!Antunnel)return this.error(__("Antunnel library is not available")),void this.quit(!0);this.log_container=this.find("log-container"),this.logs=[],$(this.log_container).css("overflow-y","auto"),this.find("menu-level").items=[{text:__("Default level"),nodes:[{text:__("Debug"),switch:!0,checked:!0,severity:"debug"},{text:__("Notice"),switch:!0,checked:!0,severity:"notice"},{text:__("Info"),switch:!0,checked:!0,severity:"info"},{text:__("Warning"),switch:!0,checked:!0,severity:"warning"},{text:__("Error"),switch:!0,checked:!0,severity:"err"},{text:__("Critical"),switch:!0,checked:!0,severity:"crit"},{text:__("Alert"),switch:!0,checked:!0,severity:"alert"},{text:__("Emergency"),switch:!0,checked:!0,severity:"emerg"}],onchildselect:t=>{let e=t.data.item.data;this.filter[e.severity]=e.checked}}],this.filter={max_log:500,err:!0,emerg:!0,debug:!0,info:!0,notice:!0,warning:!0,crit:!0,alert:!0,pattern:void 0,record:!0};let t=this.find("txt-n-log");t.value=this.filter.max_log.toString(),$(t).on("keyup",e=>{if("Enter"===e.key){let e=parseInt(t.value);if(!isNaN(e))for(this.filter.max_log=e;this.logs.length>e;)this.logs.shift().el.remove();t.value=this.filter.max_log.toString()}}),this.find("btn-clear").onbtclick=()=>{this.logs=[],$(this.log_container).empty()};let e=this.find("txt-reg");$(e).on("keyup",t=>{if("Enter"===t.key){if(""===e.value.trim())return this.filter.pattern=void 0;try{this.filter.pattern=new RegExp(e.value,"g")}catch(t){this.error(__("Invalid regular expression: {0}",t.toString()),t),this.filter.pattern=void 0,e.value=""}}}),this.find("sw-record").onswchange=t=>{this.filter.record=t.data},this.setting.topic?this.checklib():this._gui.openDialog("PromptDialog",{title:__("Enter topic name"),label:__("Please enter Antunnel topic name")}).then(t=>{this.setting.topic=t,this.checklib()})}}t.ServerLogClient=e,e.dependencies=["pkg://Antunnel/main.js"],e.singleton=!0}(e=t.application||(t.application={}))}(OS||(OS={}));
|
18
ServerLogClient/build/debug/package.json
Normal file
18
ServerLogClient/build/debug/package.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"pkgname": "ServerLogClient",
|
||||||
|
"app":"ServerLogClient",
|
||||||
|
"name":"Server log monitor",
|
||||||
|
"description":"Client for server Syslog monitoring",
|
||||||
|
"info":{
|
||||||
|
"author": "",
|
||||||
|
"email": ""
|
||||||
|
},
|
||||||
|
"version":"0.0.1-b",
|
||||||
|
"category":"System",
|
||||||
|
"iconclass":"bi bi-receipt-cutoff",
|
||||||
|
"mimes":["none"],
|
||||||
|
"dependencies": [
|
||||||
|
"Antunnel@0.1.8-a"
|
||||||
|
],
|
||||||
|
"locale": {}
|
||||||
|
}
|
17
ServerLogClient/build/debug/scheme.html
Normal file
17
ServerLogClient/build/debug/scheme.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<afx-app-window apptitle="__(Server system log)" width="600" height="400" data-id="ServerLogClient">
|
||||||
|
<afx-vbox >
|
||||||
|
<afx-hbox data-height="25" data-id="top-header">
|
||||||
|
<afx-button data-height="25" text="__(Clear)" data-id="btn-clear" data-width="60"></afx-button>
|
||||||
|
<afx-menu data-id="menu-level" data-width="100"></afx-menu>
|
||||||
|
<afx-label class="field-label" text="__(Filter)" data-width="50"></afx-label>
|
||||||
|
<input type="text" data-id="txt-reg"></input>
|
||||||
|
<afx-label class="field-label" text="__(Keep upto)" data-width="70"></afx-label>
|
||||||
|
<input type="text" data-width="50" data-id="txt-n-log"></input>
|
||||||
|
<afx-label class="field-label" text="__(Record)" data-width="50"></afx-label>
|
||||||
|
<afx-switch swon="true" data-id="sw-record" data-width="30"></afx-switch>
|
||||||
|
</afx-hbox>
|
||||||
|
<div data-id="log-container">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</afx-vbox>
|
||||||
|
</afx-app-window>
|
BIN
ServerLogClient/build/release/ServerLogClient.zip
Normal file
BIN
ServerLogClient/build/release/ServerLogClient.zip
Normal file
Binary file not shown.
55
ServerLogClient/main.css
Normal file
55
ServerLogClient/main.css
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
afx-app-window[data-id="ServerLogClient"] p {
|
||||||
|
margin: 0;
|
||||||
|
padding: 5px;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
font-family: "Courier New";
|
||||||
|
border-bottom: 1px solid gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p:hover {
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.debug{
|
||||||
|
color:green;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.notice, afx-app-window[data-id="ServerLogClient"] p.info{
|
||||||
|
color:green;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.warning {
|
||||||
|
color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.err {
|
||||||
|
color: orangered;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.crit, afx-app-window[data-id="ServerLogClient"] p.alert {
|
||||||
|
color: orangered;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
afx-app-window[data-id="ServerLogClient"] p.emerg {
|
||||||
|
color: red;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
afx-app-window[data-id="ServerLogClient"] input {
|
||||||
|
height: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] afx-hbox[data-id="top-header"] {
|
||||||
|
border-bottom: 1px solid gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] afx-hbox[data-id="top-header"] afx-label.field-label{
|
||||||
|
text-align: right;
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id="ServerLogClient"] afx-hbox[data-id="top-header"] afx-label.field-label i.label-text{
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
335
ServerLogClient/main.ts
Normal file
335
ServerLogClient/main.ts
Normal file
@ -0,0 +1,335 @@
|
|||||||
|
namespace OS {
|
||||||
|
|
||||||
|
export namespace application {
|
||||||
|
declare var Antunnel: any;
|
||||||
|
interface SyslogMessage {
|
||||||
|
timestamp: string;
|
||||||
|
tag: string;
|
||||||
|
severity_label: string;
|
||||||
|
severity: number;
|
||||||
|
relayip?: string;
|
||||||
|
relayhost?: string;
|
||||||
|
program: string;
|
||||||
|
priority: number;
|
||||||
|
message: string;
|
||||||
|
logsource?: string;
|
||||||
|
hostname?: string;
|
||||||
|
facility_label: string;
|
||||||
|
facility: number;
|
||||||
|
end_msg?: string;
|
||||||
|
type?: string;
|
||||||
|
el: JQuery<HTMLElement>;
|
||||||
|
};
|
||||||
|
interface SyslogFilter {
|
||||||
|
max_log: number;
|
||||||
|
err: boolean;
|
||||||
|
debug: boolean;
|
||||||
|
info: boolean;
|
||||||
|
notice: boolean;
|
||||||
|
warning: boolean;
|
||||||
|
crit: boolean;
|
||||||
|
alert: boolean;
|
||||||
|
emerg: boolean;
|
||||||
|
pattern?: RegExp;
|
||||||
|
record: boolean;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @class ServerLogClient
|
||||||
|
* @extends {BaseApplication}
|
||||||
|
*/
|
||||||
|
export class ServerLogClient extends BaseApplication {
|
||||||
|
private tunnel: any;
|
||||||
|
private sub: GenericObject<any>;
|
||||||
|
private log_container: HTMLDivElement;
|
||||||
|
private filter: SyslogFilter;
|
||||||
|
private logs: SyslogMessage[];
|
||||||
|
constructor(args: AppArgumentsType[]) {
|
||||||
|
super("ServerLogClient", args);
|
||||||
|
}
|
||||||
|
private check(msg: SyslogMessage): boolean
|
||||||
|
{
|
||||||
|
if(!this.filter.record)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// filter by severity
|
||||||
|
if(!this.filter[msg.severity_label])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// filter by regex
|
||||||
|
if(this.filter.pattern)
|
||||||
|
{
|
||||||
|
if(msg.message.match(this.filter.pattern))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private log(msg: SyslogMessage): void {
|
||||||
|
if(!this.check(msg))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// if the log
|
||||||
|
if(this.logs.length >= this.filter.max_log)
|
||||||
|
{
|
||||||
|
let logel = this.logs.shift();
|
||||||
|
$(logel.el).remove();
|
||||||
|
}
|
||||||
|
msg.el = $("<p />").addClass(msg.severity_label);
|
||||||
|
msg.el.text(msg.message);
|
||||||
|
$(this.log_container).append(msg.el);
|
||||||
|
this.log_container.scrollTop = this.log_container.scrollHeight;
|
||||||
|
this.logs.push(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private openSession(): void {
|
||||||
|
this.sub = new Antunnel.Subscriber(this.setting.topic);
|
||||||
|
this.sub.onopen = () => {
|
||||||
|
console.log("Subscribed");
|
||||||
|
};
|
||||||
|
|
||||||
|
this.sub.onerror = (e) => {
|
||||||
|
this.error(__("Unable to connect to: syslog"), e);
|
||||||
|
this.sub = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sub.onmessage = (e: GenericObject<any>) => {
|
||||||
|
if(e.data)
|
||||||
|
{
|
||||||
|
let data = JSON.parse(new TextDecoder("utf-8").decode(e.data));
|
||||||
|
if(data.priority)
|
||||||
|
{
|
||||||
|
data.priority = parseInt(data.priority);
|
||||||
|
}
|
||||||
|
if(data.severity)
|
||||||
|
{
|
||||||
|
data.severity = parseInt(data.severity);
|
||||||
|
}
|
||||||
|
if(data.facility)
|
||||||
|
{
|
||||||
|
data.facility = parseInt(data.facility);
|
||||||
|
}
|
||||||
|
this.log(data as SyslogMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sub.onclose = () =>
|
||||||
|
{
|
||||||
|
this.sub = undefined;
|
||||||
|
this.notify(__("Connection closed"));
|
||||||
|
this.quit(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tunnel.subscribe(this.sub);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup(): void {
|
||||||
|
if(this.sub)
|
||||||
|
this.sub.close();
|
||||||
|
}
|
||||||
|
private checklib(): void {
|
||||||
|
if(!Antunnel.tunnel)
|
||||||
|
{
|
||||||
|
this._gui
|
||||||
|
.pushService("Antunnel/AntunnelService")
|
||||||
|
.then((d) => {
|
||||||
|
let uri = (this.systemsetting.system as any).tunnel_uri as string;
|
||||||
|
if(!uri)
|
||||||
|
{
|
||||||
|
this.error(__("Unable to connect to the tunnel"));
|
||||||
|
this.quit(true);
|
||||||
|
}
|
||||||
|
Antunnel
|
||||||
|
.init(uri)
|
||||||
|
.then((t) =>{
|
||||||
|
this.notify(__("Tunnel now connected to the server at: {0}", uri));
|
||||||
|
this.tunnel = Antunnel.tunnel;
|
||||||
|
this.openSession();
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
if(Antunnel.tunnel)
|
||||||
|
{
|
||||||
|
Antunnel.tunnel.close();
|
||||||
|
this.error(__("Unable to connect to the tunnel: {0}", e.toString()), e);
|
||||||
|
this.quit(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
this.error(__("Unable to run Antunnel service: {0}",e.toString()),e);
|
||||||
|
this.quit(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.tunnel = Antunnel.tunnel;
|
||||||
|
this.openSession();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main(): void {
|
||||||
|
if(!Antunnel)
|
||||||
|
{
|
||||||
|
this.error(__("Antunnel library is not available"));
|
||||||
|
this.quit(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.log_container = this.find("log-container") as HTMLDivElement;
|
||||||
|
this.logs = [];
|
||||||
|
$(this.log_container)
|
||||||
|
.css("overflow-y", "auto");
|
||||||
|
let menu = this.find("menu-level") as GUI.tag.MenuTag;
|
||||||
|
menu.items = [
|
||||||
|
{
|
||||||
|
text: __("Default level"),
|
||||||
|
nodes: [
|
||||||
|
{
|
||||||
|
text: __("Debug"),
|
||||||
|
switch: true,
|
||||||
|
checked: true,
|
||||||
|
severity: "debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: __("Notice"),
|
||||||
|
switch: true,
|
||||||
|
checked: true,
|
||||||
|
severity: "notice"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: __("Info"),
|
||||||
|
switch: true,
|
||||||
|
checked: true,
|
||||||
|
severity: "info"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: __("Warning"),
|
||||||
|
switch: true,
|
||||||
|
checked: true,
|
||||||
|
severity: "warning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: __("Error"),
|
||||||
|
switch: true,
|
||||||
|
checked: true,
|
||||||
|
severity: "err"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: __("Critical"),
|
||||||
|
switch: true,
|
||||||
|
checked: true,
|
||||||
|
severity: "crit"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: __("Alert"),
|
||||||
|
switch: true,
|
||||||
|
checked: true,
|
||||||
|
severity: "alert"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: __("Emergency"),
|
||||||
|
switch: true,
|
||||||
|
checked: true,
|
||||||
|
severity: "emerg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
onchildselect: (e) => {
|
||||||
|
let data = e.data.item.data;
|
||||||
|
this.filter[data.severity] = data.checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
this.filter = {
|
||||||
|
max_log: 500,
|
||||||
|
err: true,
|
||||||
|
emerg: true,
|
||||||
|
debug: true,
|
||||||
|
info: true,
|
||||||
|
notice: true,
|
||||||
|
warning: true,
|
||||||
|
crit: true,
|
||||||
|
alert: true,
|
||||||
|
pattern: undefined,
|
||||||
|
record: true
|
||||||
|
};
|
||||||
|
let txtnlog = this.find("txt-n-log") as HTMLInputElement;
|
||||||
|
txtnlog.value = this.filter.max_log.toString();
|
||||||
|
$(txtnlog).on("keyup", (e) =>{
|
||||||
|
if(e.key === "Enter")
|
||||||
|
{
|
||||||
|
let val = parseInt(txtnlog.value);
|
||||||
|
if(!isNaN(val))
|
||||||
|
{
|
||||||
|
this.filter.max_log = val;
|
||||||
|
// truncate the log
|
||||||
|
while(this.logs.length > val)
|
||||||
|
{
|
||||||
|
let m = this.logs.shift();
|
||||||
|
m.el.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
txtnlog.value = this.filter.max_log.toString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let btn = this.find("btn-clear") as GUI.tag.ButtonTag;
|
||||||
|
btn.onbtclick = () => {
|
||||||
|
this.logs = [];
|
||||||
|
$(this.log_container).empty();
|
||||||
|
};
|
||||||
|
let txtreg = this.find("txt-reg") as HTMLInputElement;
|
||||||
|
$(txtreg).on("keyup", (e) => {
|
||||||
|
if(e.key === "Enter")
|
||||||
|
{
|
||||||
|
if(txtreg.value.trim() === "")
|
||||||
|
{
|
||||||
|
return this.filter.pattern = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
this.filter.pattern = new RegExp(txtreg.value,"g");
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
this.error(__("Invalid regular expression: {0}", e.toString()),e);
|
||||||
|
this.filter.pattern = undefined;
|
||||||
|
txtreg.value = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let sw = this.find("sw-record") as GUI.tag.SwitchTag;
|
||||||
|
sw.onswchange = (e) => {
|
||||||
|
this.filter.record = e.data;
|
||||||
|
}
|
||||||
|
if(!this.setting.topic)
|
||||||
|
{
|
||||||
|
this._gui.openDialog("PromptDialog", {
|
||||||
|
title: __("Enter topic name"),
|
||||||
|
label: __("Please enter Antunnel topic name")
|
||||||
|
})
|
||||||
|
.then((v) =>
|
||||||
|
{
|
||||||
|
this.setting.topic = v;
|
||||||
|
this.checklib();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.checklib();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ServerLogClient.dependencies = [
|
||||||
|
"pkg://Antunnel/main.js"
|
||||||
|
];
|
||||||
|
ServerLogClient.singleton = true;
|
||||||
|
}
|
||||||
|
}
|
18
ServerLogClient/package.json
Normal file
18
ServerLogClient/package.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"pkgname": "ServerLogClient",
|
||||||
|
"app":"ServerLogClient",
|
||||||
|
"name":"Server log monitor",
|
||||||
|
"description":"Client for server Syslog monitoring",
|
||||||
|
"info":{
|
||||||
|
"author": "",
|
||||||
|
"email": ""
|
||||||
|
},
|
||||||
|
"version":"0.0.1-b",
|
||||||
|
"category":"System",
|
||||||
|
"iconclass":"bi bi-receipt-cutoff",
|
||||||
|
"mimes":["none"],
|
||||||
|
"dependencies": [
|
||||||
|
"Antunnel@0.1.8-a"
|
||||||
|
],
|
||||||
|
"locale": {}
|
||||||
|
}
|
17
ServerLogClient/scheme.html
Normal file
17
ServerLogClient/scheme.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<afx-app-window apptitle="__(Server system log)" width="600" height="400" data-id="ServerLogClient">
|
||||||
|
<afx-vbox >
|
||||||
|
<afx-hbox data-height="25" data-id="top-header">
|
||||||
|
<afx-button data-height="25" text="__(Clear)" data-id="btn-clear" data-width="60"></afx-button>
|
||||||
|
<afx-menu data-id="menu-level" data-width="100"></afx-menu>
|
||||||
|
<afx-label class="field-label" text="__(Filter)" data-width="50"></afx-label>
|
||||||
|
<input type="text" data-id="txt-reg"></input>
|
||||||
|
<afx-label class="field-label" text="__(Keep upto)" data-width="70"></afx-label>
|
||||||
|
<input type="text" data-width="50" data-id="txt-n-log"></input>
|
||||||
|
<afx-label class="field-label" text="__(Record)" data-width="50"></afx-label>
|
||||||
|
<afx-switch swon="true" data-id="sw-record" data-width="30"></afx-switch>
|
||||||
|
</afx-hbox>
|
||||||
|
<div data-id="log-container">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</afx-vbox>
|
||||||
|
</afx-app-window>
|
@ -329,6 +329,16 @@
|
|||||||
"dependencies": ["libwvnc@0.1.2-a"],"category":"Internet","icon":"icon.png","mimes":["none"],
|
"dependencies": ["libwvnc@0.1.2-a"],"category":"Internet","icon":"icon.png","mimes":["none"],
|
||||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/RemoteDesktop/build/release/RemoteDesktop.zip"
|
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/RemoteDesktop/build/release/RemoteDesktop.zip"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"pkgname": "ServerLogClient",
|
||||||
|
"name": "Server log monitor",
|
||||||
|
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ServerLogClient/README.md",
|
||||||
|
"category": "System",
|
||||||
|
"author": "",
|
||||||
|
"version": "0.0.1-b",
|
||||||
|
"dependencies": ["Antunnel@0.1.8-a"],
|
||||||
|
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ServerLogClient/build/release/ServerLogClient.zip"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"pkgname": "ShaderPlayground",
|
"pkgname": "ShaderPlayground",
|
||||||
"name": "OpenGL Shader Playground",
|
"name": "OpenGL Shader Playground",
|
||||||
|
Loading…
Reference in New Issue
Block a user