mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-14 12:01:52 +00:00
Added TCP syslog support.
This commit is contained in:
parent
c63344e217
commit
eb160fa583
3 changed files with 16 additions and 1 deletions
|
@ -151,6 +151,7 @@
|
||||||
"syslog": { "type": "string" },
|
"syslog": { "type": "string" },
|
||||||
"syslogauth": { "type": "string" },
|
"syslogauth": { "type": "string" },
|
||||||
"syslogjson": { "type": "string" },
|
"syslogjson": { "type": "string" },
|
||||||
|
"syslogtcp": { "type": "string", "default": null, "description": "Send syslog events over the network (RFC3164) to a target hostname:port. For example: localhost:514" },
|
||||||
"webrtcConfig": {
|
"webrtcConfig": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|
|
@ -659,7 +659,7 @@ function CreateMeshCentralServer(config, args) {
|
||||||
//var wincmd = require('node-windows');
|
//var wincmd = require('node-windows');
|
||||||
//wincmd.list(function (svc) { console.log(svc); }, true);
|
//wincmd.list(function (svc) { console.log(svc); }, true);
|
||||||
|
|
||||||
// Setup syslog support
|
// Setup syslog support. Not supported on Windows.
|
||||||
if ((require('os').platform() != 'win32') && ((config.settings.syslog != null) || (config.settings.syslogjson != null) || (config.settings.syslogauth != null))) {
|
if ((require('os').platform() != 'win32') && ((config.settings.syslog != null) || (config.settings.syslogjson != null) || (config.settings.syslogauth != null))) {
|
||||||
if (config.settings.syslog === true) { config.settings.syslog = 'meshcentral'; }
|
if (config.settings.syslog === true) { config.settings.syslog = 'meshcentral'; }
|
||||||
if (config.settings.syslogjson === true) { config.settings.syslogjson = 'meshcentral-json'; }
|
if (config.settings.syslogjson === true) { config.settings.syslogjson = 'meshcentral-json'; }
|
||||||
|
@ -684,6 +684,17 @@ function CreateMeshCentralServer(config, args) {
|
||||||
obj.syslogauth.log(obj.syslogauth.LOG_INFO, "MeshCentral v" + getCurrentVersion() + " Server Start");
|
obj.syslogauth.log(obj.syslogauth.LOG_INFO, "MeshCentral v" + getCurrentVersion() + " Server Start");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Setup TCP syslog support, this works on all OS's.
|
||||||
|
if (config.settings.syslogtcp != null) {
|
||||||
|
const syslog = require('syslog');
|
||||||
|
if (config.settings.syslogtcp === true) {
|
||||||
|
obj.syslogtcp = syslog.createClient(514, 'localhost');
|
||||||
|
} else {
|
||||||
|
const sp = config.settings.syslogtcp.split(':');
|
||||||
|
obj.syslogtcp = syslog.createClient(parseInt(sp[1]), sp[0]);
|
||||||
|
}
|
||||||
|
obj.syslogtcp.log("MeshCentral v" + getCurrentVersion() + " Server Start", obj.syslogtcp.LOG_INFO);
|
||||||
|
}
|
||||||
|
|
||||||
// Check top level configuration for any unreconized values
|
// Check top level configuration for any unreconized values
|
||||||
if (config) { for (var i in config) { if ((typeof i == 'string') && (i.length > 0) && (i[0] != '_') && (['settings', 'domaindefaults', 'domains', 'configfiles', 'smtp', 'letsencrypt', 'peers', 'sms', 'sendgrid', 'firebase', 'firebaserelay', '$schema'].indexOf(i) == -1)) { addServerWarning('Unrecognized configuration option \"' + i + '\".'); } } }
|
if (config) { for (var i in config) { if ((typeof i == 'string') && (i.length > 0) && (i[0] != '_') && (['settings', 'domaindefaults', 'domains', 'configfiles', 'smtp', 'letsencrypt', 'peers', 'sms', 'sendgrid', 'firebase', 'firebaserelay', '$schema'].indexOf(i) == -1)) { addServerWarning('Unrecognized configuration option \"' + i + '\".'); } } }
|
||||||
|
@ -1945,6 +1956,7 @@ function CreateMeshCentralServer(config, args) {
|
||||||
// Send event to syslog if needed
|
// Send event to syslog if needed
|
||||||
if (obj.syslog && event.msg) { obj.syslog.log(obj.syslog.LOG_INFO, event.msg); }
|
if (obj.syslog && event.msg) { obj.syslog.log(obj.syslog.LOG_INFO, event.msg); }
|
||||||
if (obj.syslogjson) { obj.syslogjson.log(obj.syslogjson.LOG_INFO, JSON.stringify(event)); }
|
if (obj.syslogjson) { obj.syslogjson.log(obj.syslogjson.LOG_INFO, JSON.stringify(event)); }
|
||||||
|
if (obj.syslogtcp && event.msg) { obj.syslogtcp.log(event.msg, obj.syslogtcp.LOG_INFO); }
|
||||||
|
|
||||||
obj.debug('dispatch', 'DispatchEvent', ids);
|
obj.debug('dispatch', 'DispatchEvent', ids);
|
||||||
if ((typeof event == 'object') && (!event.nolog)) {
|
if ((typeof event == 'object') && (!event.nolog)) {
|
||||||
|
@ -3229,6 +3241,7 @@ function mainStart() {
|
||||||
|
|
||||||
// Syslog support
|
// Syslog support
|
||||||
if ((require('os').platform() != 'win32') && (config.settings.syslog || config.settings.syslogjson)) { modules.push('modern-syslog'); }
|
if ((require('os').platform() != 'win32') && (config.settings.syslog || config.settings.syslogjson)) { modules.push('modern-syslog'); }
|
||||||
|
if (config.settings.syslogtcp) { modules.push('syslog'); }
|
||||||
|
|
||||||
// Setup heapdump support if needed, useful for memory leak debugging
|
// Setup heapdump support if needed, useful for memory leak debugging
|
||||||
// https://www.arbazsiddiqui.me/a-practical-guide-to-memory-leaks-in-nodejs/
|
// https://www.arbazsiddiqui.me/a-practical-guide-to-memory-leaks-in-nodejs/
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
"_syslog": "meshcentral",
|
"_syslog": "meshcentral",
|
||||||
"_syslogauth": "meshcentral-auth",
|
"_syslogauth": "meshcentral-auth",
|
||||||
"_syslogjson": "meshcentral-json",
|
"_syslogjson": "meshcentral-json",
|
||||||
|
"_syslogtcp": "localhost:514",
|
||||||
"_webrtcConfig": {
|
"_webrtcConfig": {
|
||||||
"iceServers": [
|
"iceServers": [
|
||||||
{ "urls": "stun:stun.services.mozilla.com" },
|
{ "urls": "stun:stun.services.mozilla.com" },
|
||||||
|
|
Loading…
Reference in a new issue