Add debugging output to server bootup - Fix DHCP Lease option array logic
This commit is contained in:
parent
4de691f66a
commit
82c39d3d72
11
app.js
11
app.js
|
@ -103,6 +103,7 @@ fs.readFile(glass_config.leases_file, 'utf8', function (err,data) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lease_parser.parse(data);
|
lease_parser.parse(data);
|
||||||
|
console.log("[Glass Server] Leases file loaded");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -193,7 +194,6 @@ leases_per_minute_counter_timer = setInterval(function(){
|
||||||
/**
|
/**
|
||||||
* Poll: CPU Utilization
|
* Poll: CPU Utilization
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cpu_utilization_poll = setInterval(function(){
|
cpu_utilization_poll = setInterval(function(){
|
||||||
cpu_utilization = parseFloat(execSync("top -bn 1 | awk 'NR>7{s+=$9} END {print s/4}'").toString())
|
cpu_utilization = parseFloat(execSync("top -bn 1 | awk 'NR>7{s+=$9} END {print s/4}'").toString())
|
||||||
}, (15 * 1000));
|
}, (15 * 1000));
|
||||||
|
@ -221,6 +221,7 @@ fs.watch('config/glass_config.json', function (event, filename) {
|
||||||
if (filename) {
|
if (filename) {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
glass_config = json_file.readFileSync('config/glass_config.json');
|
glass_config = json_file.readFileSync('config/glass_config.json');
|
||||||
|
console.log("[Glass Server] Config Loaded");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} else {
|
} else {
|
||||||
console.log('filename not provided');
|
console.log('filename not provided');
|
||||||
|
@ -371,7 +372,9 @@ function slack_message(message) {
|
||||||
alert_status = [];
|
alert_status = [];
|
||||||
alert_status['leases_per_minute'] = 0;
|
alert_status['leases_per_minute'] = 0;
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
alert_check_timer = setInterval(function(){
|
console.log("[Glass Server] Alert loop started");
|
||||||
|
|
||||||
|
alert_check_timer = setInterval(function(){
|
||||||
console.log("[Timer] Alert Timer check");
|
console.log("[Timer] Alert Timer check");
|
||||||
if(glass_config.leases_per_minute_threshold > 0) {
|
if(glass_config.leases_per_minute_threshold > 0) {
|
||||||
console.log("[Timer] lpm: %s lpm_th: %s", leases_per_minute, glass_config.leases_per_minute_threshold);
|
console.log("[Timer] lpm: %s lpm_th: %s", leases_per_minute, glass_config.leases_per_minute_threshold);
|
||||||
|
@ -471,4 +474,6 @@ setTimeout(function(){
|
||||||
function round(num, places) {
|
function round(num, places) {
|
||||||
var multiplier = Math.pow(10, places);
|
var multiplier = Math.pow(10, places);
|
||||||
return Math.round(num * multiplier) / multiplier;
|
return Math.round(num * multiplier) / multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("[Glass Server] Bootup complete");
|
|
@ -92,11 +92,12 @@ module.exports = {
|
||||||
if (typeof dhcp_lease_data[ip_address]['options'] === "undefined")
|
if (typeof dhcp_lease_data[ip_address]['options'] === "undefined")
|
||||||
dhcp_lease_data[ip_address]['options'] = [];
|
dhcp_lease_data[ip_address]['options'] = [];
|
||||||
}
|
}
|
||||||
if (/}/i.test(lines[l]) && typeof dhcp_lease_data[ip_address]['options'] !== "undefined"){
|
if (lines[l].charAt(0) == "}" && typeof dhcp_lease_data[ip_address]['options'] !== "undefined"){
|
||||||
if (option_data.length > 0)
|
if (typeof option_data !== 'undefined') {
|
||||||
dhcp_lease_data[ip_address]['options'].push(option_data);
|
dhcp_lease_data[ip_address]['options'] = option_data;
|
||||||
|
}
|
||||||
|
|
||||||
option_data = {};
|
option_data = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ router.get('/', function(req, res, next) {
|
||||||
table_row = table_row + '<td>' + (dhcp_lease_data[key].host ? dhcp_lease_data[key].host : '') + '</td>';
|
table_row = table_row + '<td>' + (dhcp_lease_data[key].host ? dhcp_lease_data[key].host : '') + '</td>';
|
||||||
table_row = table_row + '<td>' + human_time(dhcp_lease_data[key].start * 1000) + '</td>';
|
table_row = table_row + '<td>' + human_time(dhcp_lease_data[key].start * 1000) + '</td>';
|
||||||
table_row = table_row + '<td>' + human_time(dhcp_lease_data[key].end * 1000) + '</td>';
|
table_row = table_row + '<td>' + human_time(dhcp_lease_data[key].end * 1000) + '</td>';
|
||||||
table_row = table_row + '<td></td>';
|
table_row = table_row + '<td>' + </td>';
|
||||||
|
|
||||||
table_data = table_data + '<tr>' + table_row + '</tr>';
|
table_data = table_data + '<tr>' + table_row + '</tr>';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue