mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +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" },
 | 
			
		||||
        "syslogauth": { "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": {
 | 
			
		||||
          "type": "object",
 | 
			
		||||
          "additionalProperties": false,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -659,7 +659,7 @@ function CreateMeshCentralServer(config, args) {
 | 
			
		|||
        //var wincmd = require('node-windows');
 | 
			
		||||
        //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 (config.settings.syslog === true) { config.settings.syslog = 'meshcentral'; }
 | 
			
		||||
            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");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        // 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
 | 
			
		||||
        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
 | 
			
		||||
        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.syslogtcp && event.msg) { obj.syslogtcp.log(event.msg, obj.syslogtcp.LOG_INFO); }
 | 
			
		||||
 | 
			
		||||
        obj.debug('dispatch', 'DispatchEvent', ids);
 | 
			
		||||
        if ((typeof event == 'object') && (!event.nolog)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -3229,6 +3241,7 @@ function mainStart() {
 | 
			
		|||
 | 
			
		||||
        // Syslog support
 | 
			
		||||
        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
 | 
			
		||||
        // https://www.arbazsiddiqui.me/a-practical-guide-to-memory-leaks-in-nodejs/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,6 +77,7 @@
 | 
			
		|||
    "_syslog": "meshcentral",
 | 
			
		||||
    "_syslogauth": "meshcentral-auth",
 | 
			
		||||
    "_syslogjson": "meshcentral-json",
 | 
			
		||||
    "_syslogtcp": "localhost:514",
 | 
			
		||||
    "_webrtcConfig": {
 | 
			
		||||
      "iceServers": [
 | 
			
		||||
        { "urls": "stun:stun.services.mozilla.com" },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue