Advertisement
riccefarias76

Untitled

Apr 17th, 2024
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var spawn = require('child_process').spawn;
  2. var filename = '/opt/traccar-59/logs/tracker-server.log';
  3.  
  4. console.log("Starting logger service...");
  5.  
  6. var tail = spawn("tail", ["-f", filename]);
  7.  
  8. const imeiBindings = {};
  9. const hashBindings = {};
  10.  
  11. tail.stdout.on("data", function (data) {
  12.  
  13.     const text = data.toString();
  14.     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);
  15.  
  16.  
  17.     for(m of matches){
  18.  
  19.  
  20.  
  21.         if(m[7]){
  22.             if(!imeiBindings[m[7]]){
  23.                 imeiBindings[m[7]] = {};
  24.             }
  25.  
  26.             if(!hashBindings[m[2]]){
  27.                 hashBindings[m[2]] = {};
  28.             }
  29.  
  30.             imeiBindings[m[7]][m[2]] = 1;
  31.             hashBindings[m[2]]= m[7];
  32.         }
  33.  
  34.         if(hashBindings[m[2]]){
  35.             console.log("IMEI: "+hashBindings[m[2]],m);
  36.         }else{
  37.  
  38.         }
  39.     }
  40.  
  41.  
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement