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 {
|
||||
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
|
||||
*/
|
||||
|
||||
cpu_utilization_poll = setInterval(function(){
|
||||
cpu_utilization = parseFloat(execSync("top -bn 1 | awk 'NR>7{s+=$9} END {print s/4}'").toString())
|
||||
}, (15 * 1000));
|
||||
|
@ -221,6 +221,7 @@ fs.watch('config/glass_config.json', function (event, filename) {
|
|||
if (filename) {
|
||||
setTimeout(function(){
|
||||
glass_config = json_file.readFileSync('config/glass_config.json');
|
||||
console.log("[Glass Server] Config Loaded");
|
||||
}, 1000);
|
||||
} else {
|
||||
console.log('filename not provided');
|
||||
|
@ -371,7 +372,9 @@ function slack_message(message) {
|
|||
alert_status = [];
|
||||
alert_status['leases_per_minute'] = 0;
|
||||
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");
|
||||
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);
|
||||
|
@ -471,4 +474,6 @@ setTimeout(function(){
|
|||
function round(num, places) {
|
||||
var multiplier = Math.pow(10, places);
|
||||
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")
|
||||
dhcp_lease_data[ip_address]['options'] = [];
|
||||
}
|
||||
if (/}/i.test(lines[l]) && typeof dhcp_lease_data[ip_address]['options'] !== "undefined"){
|
||||
if (option_data.length > 0)
|
||||
dhcp_lease_data[ip_address]['options'].push(option_data);
|
||||
if (lines[l].charAt(0) == "}" && typeof dhcp_lease_data[ip_address]['options'] !== "undefined"){
|
||||
if (typeof option_data !== 'undefined') {
|
||||
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>' + 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></td>';
|
||||
table_row = table_row + '<td>' + </td>';
|
||||
|
||||
table_data = table_data + '<tr>' + table_row + '</tr>';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue