forked from volumio/Volumio2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logsubmit.js
executable file
·46 lines (36 loc) · 1.11 KB
/
logsubmit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Created by Michelangelo on 19/11/2015.
* Modified by André beginning 2016
*/
var exec = require('child_process');
var logglyKey = process.env.logglyKey;
var logglyUrl = "https://logs-01.loggly.com/bulk/" + logglyKey + "/tag/file_upload";
var commandArray = [
"ifconfig",
"iwconfig",
"ps -ef",
"sudo journalctl -p 7"
];
var logFile = "/tmp/logondemand";
// Let's start fresh!
exec.execSync("date >" + logFile);
try {
var args = process.argv.slice(2);
//If description is supplied, add it
exec.execSync("echo " + args[0] + " >>" + logFile);
} catch (e) {}
exec.execSync("cat /tmp/logfields >> " + logFile);
for (var itemN in commandArray) {
var item = commandArray[itemN];
var itemWithoutput = item + " >>" + logFile + " 2>&1"
console.log(item);
exec.execSync(itemWithoutput);
}
var command = "cat logFile";
console.log(command);
exec.execSync(command);
exec.execSync("rm " + logFile);
exec.execSync("rm /tmp/logfields");
function randomIntInc (low, high) {
return Math.floor(Math.random() * (high - low + 1) + low);
}