Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var spawn = require('child_process').spawn;
- var filename = '/opt/traccar-59/logs/tracker-server.log';
- console.log("Starting logger service...");
- var tail = spawn("tail", ["-f", filename]);
- const imeiBindings = {};
- const hashBindings = {};
- tail.stdout.on("data", function (data) {
- const text = data.toString();
- const matches = text.matchAll(/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} (.*?): \[([A-Za-z0-9]*)(: [A-Za-z0-9]* (>|<) ([A-Za-z0-9.]*))?\] ([A-Za-z0-9]*|id: (.*?), (.*?))\n/g);
- for(m of matches){
- if(m[7]){
- if(!imeiBindings[m[7]]){
- imeiBindings[m[7]] = {};
- }
- if(!hashBindings[m[2]]){
- hashBindings[m[2]] = {};
- }
- imeiBindings[m[7]][m[2]] = 1;
- hashBindings[m[2]]= m[7];
- }
- if(hashBindings[m[2]]){
- console.log("IMEI: "+hashBindings[m[2]],m);
- }else{
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement