2016-08-09 14:48:57 +00:00
|
|
|
var time_since_last_pastes_num;
|
|
|
|
|
|
|
|
//If we do not received info from global, set pastes_num to 0
|
|
|
|
function checkIfReceivedData(){
|
|
|
|
if ((new Date().getTime() - time_since_last_pastes_num) > 45*1000)
|
|
|
|
window.paste_num_tabvar = 0;
|
|
|
|
setTimeout(checkIfReceivedData, 45*1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(checkIfReceivedData, 45*1000);
|
|
|
|
|
2016-07-21 12:53:34 +00:00
|
|
|
function initfunc( csvay, scroot) {
|
|
|
|
window.csv = csvay;
|
|
|
|
window.scroot = scroot;
|
|
|
|
};
|
|
|
|
|
|
|
|
function update_values() {
|
|
|
|
$SCRIPT_ROOT = window.scroot ;
|
|
|
|
$.getJSON($SCRIPT_ROOT+"/_stuff",
|
|
|
|
function(data) {
|
|
|
|
window.glob_tabvar = data;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-07-13 13:57:33 +00:00
|
|
|
// Plot and update the number of processed pastes
|
|
|
|
$(function() {
|
|
|
|
var data = [];
|
2016-07-15 07:47:00 +00:00
|
|
|
var default_minute = (typeof window.default_minute !== "undefined") ? parseInt(window.default_minute) : 10;
|
|
|
|
var totalPoints = 60*parseInt(default_minute); //60s*minute
|
2016-07-13 13:57:33 +00:00
|
|
|
var curr_max = 0;
|
|
|
|
|
|
|
|
function getData() {
|
2016-07-21 12:45:41 +00:00
|
|
|
if (data.length > 0){
|
|
|
|
var data_old = data[0];
|
|
|
|
data = data.slice(1);
|
|
|
|
curr_max = curr_max == data_old ? Math.max.apply(null, data) : curr_max;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (data.length < totalPoints) {
|
|
|
|
var y = (typeof window.paste_num_tabvar !== "undefined") ? parseInt(window.paste_num_tabvar) : 0;
|
|
|
|
curr_max = y > curr_max ? y : curr_max;
|
|
|
|
data.push(y);
|
|
|
|
}
|
|
|
|
// Zip the generated y values with the x values
|
|
|
|
var res = [];
|
|
|
|
for (var i = 0; i < data.length; ++i) {
|
|
|
|
res.push([i, data[i]])
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
var updateInterval = 1000;
|
|
|
|
var options = {
|
|
|
|
series: { shadowSize: 1 },
|
|
|
|
lines: { fill: true, fillColor: { colors: [ { opacity: 1 }, { opacity: 0.1 } ] }},
|
|
|
|
yaxis: { min: 0, max: 40 },
|
|
|
|
colors: ["#a971ff"],
|
|
|
|
grid: {
|
|
|
|
tickColor: "#dddddd",
|
|
|
|
borderWidth: 0
|
|
|
|
},
|
|
|
|
};
|
|
|
|
var plot = $.plot("#realtimechart", [ getData() ], options);
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
plot.setData([getData()]);
|
|
|
|
plot.getOptions().yaxes[0].max = curr_max;
|
|
|
|
plot.setupGrid();
|
|
|
|
plot.draw();
|
|
|
|
setTimeout(update, updateInterval);
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
});
|
|
|
|
|
2014-08-06 09:43:40 +00:00
|
|
|
function initfunc( csvay, scroot) {
|
|
|
|
window.csv = csvay;
|
|
|
|
window.scroot = scroot;
|
|
|
|
};
|
|
|
|
|
|
|
|
function update_values() {
|
|
|
|
$SCRIPT_ROOT = window.scroot ;
|
|
|
|
$.getJSON($SCRIPT_ROOT+"/_stuff",
|
|
|
|
function(data) {
|
|
|
|
window.glob_tabvar = data;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var source = new EventSource('/_logs');
|
|
|
|
|
|
|
|
source.onmessage = function(event) {
|
|
|
|
var feed = jQuery.parseJSON( event.data );
|
2016-08-22 14:25:52 +00:00
|
|
|
create_log_table(feed);
|
2014-08-06 09:43:40 +00:00
|
|
|
};
|
|
|
|
|
2014-08-12 14:11:11 +00:00
|
|
|
function pad_2(number)
|
|
|
|
{
|
|
|
|
return (number < 10 ? '0' : '') + number;
|
|
|
|
}
|
|
|
|
|
2014-08-06 09:43:40 +00:00
|
|
|
function create_log_table(obj_json) {
|
|
|
|
tableBody = document.getElementById("tab_body")
|
|
|
|
var tr = document.createElement('TR')
|
2014-08-11 14:29:38 +00:00
|
|
|
var time = document.createElement('TD')
|
2014-08-06 09:43:40 +00:00
|
|
|
var chan = document.createElement('TD')
|
|
|
|
var level = document.createElement('TD')
|
|
|
|
var scrpt = document.createElement('TD')
|
|
|
|
var src = document.createElement('TD')
|
|
|
|
var pdate = document.createElement('TD')
|
|
|
|
var nam = document.createElement('TD')
|
|
|
|
var msage = document.createElement('TD')
|
|
|
|
|
|
|
|
var chansplit = obj_json.channel.split('.');
|
|
|
|
var parsedmess = obj_json.data.split(';');
|
|
|
|
|
2016-08-09 14:48:57 +00:00
|
|
|
|
2016-07-13 13:57:33 +00:00
|
|
|
if (parsedmess[0] == "Global"){
|
|
|
|
var paste_processed = parsedmess[4].split(" ")[2];
|
|
|
|
window.paste_num_tabvar = paste_processed;
|
2016-08-09 14:48:57 +00:00
|
|
|
time_since_last_pastes_num = new Date().getTime();
|
2016-07-13 13:57:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-06 09:43:40 +00:00
|
|
|
if( chansplit[1] == "INFO" ){
|
|
|
|
tr.className = "info";
|
|
|
|
}
|
|
|
|
else if ( chansplit[1] == "WARNING" ){
|
|
|
|
tr.className = "warning";
|
|
|
|
}
|
2014-08-11 13:06:38 +00:00
|
|
|
else if ( chansplit[1] == "CRITICAL"){
|
2014-08-12 09:41:56 +00:00
|
|
|
tr.className = "danger"
|
2014-08-11 13:06:38 +00:00
|
|
|
}
|
2014-08-06 09:43:40 +00:00
|
|
|
|
|
|
|
source_link = document.createElement("A");
|
|
|
|
if (parsedmess[1] == "slexy.org"){
|
|
|
|
soruce_url = "http://"+parsedmess[1]+"/view/"+parsedmess[3].split(".")[0];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
source_url = "http://"+parsedmess[1]+"/"+parsedmess[3].split(".")[0];
|
|
|
|
}
|
|
|
|
source_link.setAttribute("HREF",source_url);
|
|
|
|
source_link.setAttribute("TARGET", "_blank")
|
|
|
|
source_link.appendChild(document.createTextNode(parsedmess[1]));
|
|
|
|
|
|
|
|
src.appendChild(source_link);
|
|
|
|
|
2014-08-11 14:29:38 +00:00
|
|
|
var now = new Date();
|
2014-08-12 14:11:11 +00:00
|
|
|
var timepaste = pad_2(now.getHours()) + ":" + pad_2(now.getMinutes()) + ":" + pad_2(now.getSeconds());
|
2014-08-11 14:29:38 +00:00
|
|
|
|
|
|
|
time.appendChild(document.createTextNode(timepaste));
|
2014-08-06 09:43:40 +00:00
|
|
|
chan.appendChild(document.createTextNode(chansplit[0]));
|
|
|
|
level.appendChild(document.createTextNode(chansplit[1]));
|
|
|
|
|
|
|
|
scrpt.appendChild(document.createTextNode(parsedmess[0]));
|
|
|
|
pdate.appendChild(document.createTextNode(parsedmess[2]));
|
|
|
|
nam.appendChild(document.createTextNode(parsedmess[3]));
|
2014-08-12 14:11:11 +00:00
|
|
|
|
|
|
|
var iconspan = document.createElement('SPAN');
|
|
|
|
if (parsedmess[4].split(" ")[0] == "Detected"){
|
|
|
|
iconspan.className = "glyphicon glyphicon-eye-open";
|
|
|
|
}
|
|
|
|
else if (parsedmess[4].split(" ")[0] == "Checked"){
|
|
|
|
iconspan.className = "glyphicon glyphicon-thumbs-up";
|
|
|
|
}
|
|
|
|
iconspan.innerHTML = " ";
|
|
|
|
msage.appendChild(iconspan);
|
2014-08-13 08:59:47 +00:00
|
|
|
var message = parsedmess[4].split(" ");
|
|
|
|
message.shift();
|
|
|
|
|
|
|
|
msage.appendChild(document.createTextNode(message.join(" ")));
|
2014-08-06 09:43:40 +00:00
|
|
|
|
2014-08-11 14:29:38 +00:00
|
|
|
tr.appendChild(time)
|
2014-08-06 09:43:40 +00:00
|
|
|
tr.appendChild(chan);
|
|
|
|
tr.appendChild(level);
|
|
|
|
tr.appendChild(scrpt);
|
|
|
|
tr.appendChild(src);
|
|
|
|
tr.appendChild(pdate);
|
|
|
|
tr.appendChild(nam);
|
|
|
|
tr.appendChild(msage);
|
|
|
|
|
2014-08-11 13:06:38 +00:00
|
|
|
if (tr.className == document.getElementById("checkbox_log_info").value && document.getElementById("checkbox_log_info").checked == true) {
|
2014-08-29 17:37:56 +00:00
|
|
|
tableBody.appendChild(tr);
|
2014-08-11 13:06:38 +00:00
|
|
|
}
|
|
|
|
if (tr.className == document.getElementById("checkbox_log_warning").value && document.getElementById("checkbox_log_warning").checked == true) {
|
|
|
|
tableBody.appendChild(tr);
|
|
|
|
}
|
|
|
|
if (tr.className == document.getElementById("checkbox_log_critical").value && document.getElementById("checkbox_log_critical").checked == true) {
|
|
|
|
tableBody.appendChild(tr);
|
|
|
|
};
|
|
|
|
|
2014-08-06 09:43:40 +00:00
|
|
|
var sel = document.getElementById("log_select")
|
|
|
|
if (tableBody.rows.length > sel.options[sel.options.selectedIndex].value){
|
|
|
|
while (tableBody.rows.length != sel.options[sel.options.selectedIndex].value){
|
|
|
|
tableBody.deleteRow(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_queue_table() {
|
|
|
|
document.getElementById("queueing").innerHTML = "";
|
|
|
|
var Tablediv = document.getElementById("queueing")
|
|
|
|
var table = document.createElement('TABLE')
|
|
|
|
table.className = "table table-bordered table-hover table-striped";
|
|
|
|
var tableHead = document.createElement('THEAD')
|
|
|
|
var tableBody = document.createElement('TBODY')
|
|
|
|
|
|
|
|
table.appendChild(tableHead);
|
|
|
|
table.appendChild(tableBody);
|
|
|
|
var heading = new Array();
|
|
|
|
heading[0] = "Queue Name"
|
|
|
|
heading[1] = "Amount"
|
|
|
|
var tr = document.createElement('TR');
|
|
|
|
tableHead.appendChild(tr);
|
|
|
|
|
|
|
|
for (i = 0; i < heading.length; i++) {
|
|
|
|
var th = document.createElement('TH')
|
|
|
|
th.width = '100';
|
|
|
|
th.appendChild(document.createTextNode(heading[i]));
|
|
|
|
tr.appendChild(th);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < (glob_tabvar.row1).length;i++){
|
|
|
|
var tr = document.createElement('TR')
|
2016-08-24 16:00:05 +00:00
|
|
|
for(j = 0; j < 2; j++){
|
2014-08-06 09:43:40 +00:00
|
|
|
var td = document.createElement('TD')
|
2016-08-25 14:27:32 +00:00
|
|
|
var moduleNum = j == 0 ? "." + glob_tabvar.row1[i][3] : "";
|
|
|
|
td.appendChild(document.createTextNode(glob_tabvar.row1[i][j] + moduleNum));
|
2014-08-06 09:43:40 +00:00
|
|
|
tr.appendChild(td)
|
|
|
|
}
|
2016-08-26 08:28:35 +00:00
|
|
|
// Used to decide the color of the row
|
|
|
|
// We have glob_tabvar.row1[][j] with:
|
|
|
|
// - j=0: ModuleName
|
|
|
|
// - j=1: queueLength
|
|
|
|
// - j=2: LastProcessedPasteTime
|
|
|
|
// - j=3: Number of the module belonging in the same category
|
2016-08-25 09:09:31 +00:00
|
|
|
if (parseInt(glob_tabvar.row1[i][2]) > 60*2 && parseInt(glob_tabvar.row1[i][1]) > 2)
|
2016-08-24 16:00:05 +00:00
|
|
|
tr.className += " danger";
|
|
|
|
else if (parseInt(glob_tabvar.row1[i][2]) > 60*1)
|
|
|
|
tr.className += " warning";
|
|
|
|
else
|
|
|
|
tr.className += " success";
|
2014-08-06 09:43:40 +00:00
|
|
|
tableBody.appendChild(tr);
|
|
|
|
}
|
|
|
|
Tablediv.appendChild(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
2016-08-02 14:39:57 +00:00
|
|
|
if (typeof glob_tabvar == "undefined")
|
|
|
|
location.reload();
|
|
|
|
if (typeof glob_tabvar.row1 == "undefined")
|
|
|
|
location.reload();
|
|
|
|
|
2014-08-06 09:43:40 +00:00
|
|
|
var data = [];
|
2014-08-12 14:44:35 +00:00
|
|
|
var data2 = [];
|
2014-08-12 12:00:00 +00:00
|
|
|
var tmp_tab = [];
|
2014-08-12 14:44:35 +00:00
|
|
|
var tmp_tab2 = [];
|
2014-08-12 12:00:00 +00:00
|
|
|
var curves_labels = [];
|
2014-08-12 14:44:35 +00:00
|
|
|
var curves_labels2 = [];
|
2014-08-06 09:43:40 +00:00
|
|
|
var x = new Date();
|
2014-08-29 17:37:56 +00:00
|
|
|
|
2014-08-12 12:00:00 +00:00
|
|
|
for (i = 0; i < glob_tabvar.row1.length; i++){
|
2014-08-29 17:37:56 +00:00
|
|
|
if (glob_tabvar.row1[i][0] == 'Categ' || glob_tabvar.row1[i][0] == 'Curve'){
|
2014-08-12 14:44:35 +00:00
|
|
|
tmp_tab2.push(0);
|
|
|
|
curves_labels2.push(glob_tabvar.row1[i][0]);
|
|
|
|
}
|
2014-08-29 17:37:56 +00:00
|
|
|
else {
|
|
|
|
tmp_tab.push(0);
|
|
|
|
curves_labels.push(glob_tabvar.row1[i][0]);
|
|
|
|
}
|
2014-08-12 12:00:00 +00:00
|
|
|
}
|
|
|
|
tmp_tab.unshift(x);
|
2014-08-12 14:44:35 +00:00
|
|
|
tmp_tab2.unshift(x);
|
2014-08-12 12:00:00 +00:00
|
|
|
curves_labels.unshift("date");
|
2014-08-12 14:44:35 +00:00
|
|
|
curves_labels2.unshift("date");
|
2014-08-12 12:00:00 +00:00
|
|
|
data.push(tmp_tab);
|
2014-08-12 14:44:35 +00:00
|
|
|
data2.push(tmp_tab2);
|
2014-08-29 17:37:56 +00:00
|
|
|
|
2014-08-06 09:43:40 +00:00
|
|
|
var g = new Dygraph(document.getElementById("Graph"), data,
|
|
|
|
{
|
2014-08-12 12:00:00 +00:00
|
|
|
labels: curves_labels,
|
2014-08-06 09:43:40 +00:00
|
|
|
drawPoints: false,
|
|
|
|
showRoller: true,
|
2014-08-13 15:32:24 +00:00
|
|
|
rollPeriod: 30,
|
2014-08-06 09:43:40 +00:00
|
|
|
labelsKMB: true,
|
|
|
|
logscale: true,
|
2014-08-12 13:42:16 +00:00
|
|
|
//drawGapEdgePoints: true,
|
|
|
|
//legend: "always",
|
|
|
|
//connectSeparatedPoints: true,
|
2014-08-12 13:48:53 +00:00
|
|
|
stackedGraph: true,
|
2014-08-06 09:43:40 +00:00
|
|
|
fillGraph: true,
|
|
|
|
includeZero: true,
|
|
|
|
});
|
2014-08-29 17:37:56 +00:00
|
|
|
|
2014-08-12 14:44:35 +00:00
|
|
|
var g2 = new Dygraph(document.getElementById("Graph2"), data2,
|
|
|
|
{
|
|
|
|
labels: curves_labels2,
|
|
|
|
drawPoints: false,
|
|
|
|
showRoller: true,
|
2014-08-13 15:32:24 +00:00
|
|
|
rollPeriod: 30,
|
2014-08-12 14:44:35 +00:00
|
|
|
labelsKMB: true,
|
|
|
|
logscale: true,
|
|
|
|
//drawGapEdgePoints: true,
|
|
|
|
//legend: "always",
|
|
|
|
//connectSeparatedPoints: true,
|
|
|
|
stackedGraph: true,
|
|
|
|
fillGraph: true,
|
|
|
|
includeZero: true,
|
|
|
|
});
|
|
|
|
|
2014-08-06 09:43:40 +00:00
|
|
|
|
2014-08-12 09:41:56 +00:00
|
|
|
var interval = 1000; //number of mili seconds between each call
|
|
|
|
var refresh = function() {
|
2014-08-29 17:37:56 +00:00
|
|
|
|
2014-08-12 09:41:56 +00:00
|
|
|
$.ajax({
|
|
|
|
url: "",
|
|
|
|
cache: false,
|
|
|
|
success: function(html) {
|
|
|
|
$('#server-name').html(html);
|
|
|
|
setTimeout(function() {
|
|
|
|
var x = new Date();
|
2014-08-12 14:44:35 +00:00
|
|
|
var tmp_values = [];
|
2014-08-29 17:37:56 +00:00
|
|
|
var tmp_values2 = [];
|
2014-08-12 09:41:56 +00:00
|
|
|
refresh();
|
|
|
|
update_values();
|
2016-08-17 11:46:01 +00:00
|
|
|
|
2016-08-20 16:14:19 +00:00
|
|
|
if($('#button-toggle-queues').prop('checked')){
|
2016-08-17 11:46:01 +00:00
|
|
|
create_queue_table();
|
2016-08-20 16:14:19 +00:00
|
|
|
}
|
|
|
|
else{
|
2016-08-17 11:46:01 +00:00
|
|
|
$("#queueing").html('');
|
2016-08-20 16:14:19 +00:00
|
|
|
}
|
2014-08-29 17:37:56 +00:00
|
|
|
|
|
|
|
|
2014-08-12 09:41:56 +00:00
|
|
|
for (i = 0; i < (glob_tabvar.row1).length; i++){
|
2014-08-29 17:37:56 +00:00
|
|
|
if (glob_tabvar.row1[i][0] == 'Categ' || glob_tabvar.row1[i][0] == 'Curve'){
|
|
|
|
tmp_values2.push(glob_tabvar.row1[i][1]);
|
2014-08-12 14:44:35 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-08-29 17:37:56 +00:00
|
|
|
tmp_values.push(glob_tabvar.row1[i][1]);
|
2014-08-12 14:44:35 +00:00
|
|
|
}
|
2014-08-12 09:41:56 +00:00
|
|
|
}
|
2014-08-12 12:00:00 +00:00
|
|
|
tmp_values.unshift(x);
|
|
|
|
data.push(tmp_values);
|
2014-08-29 17:37:56 +00:00
|
|
|
|
2014-08-12 14:44:35 +00:00
|
|
|
tmp_values2.unshift(x);
|
|
|
|
data2.push(tmp_values2);
|
2014-08-12 09:41:56 +00:00
|
|
|
|
|
|
|
if (data.length > 1800) {
|
|
|
|
data.shift();
|
2014-08-12 14:44:35 +00:00
|
|
|
data2.shift();
|
2014-08-12 09:41:56 +00:00
|
|
|
}
|
|
|
|
g.updateOptions( { 'file': data } );
|
2014-08-12 14:44:35 +00:00
|
|
|
g2.updateOptions( { 'file': data2 } );
|
2014-08-29 17:37:56 +00:00
|
|
|
|
|
|
|
|
2014-08-13 15:32:24 +00:00
|
|
|
// TagCanvas.Reload('myCanvas');
|
2014-08-12 09:41:56 +00:00
|
|
|
|
|
|
|
}, interval);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
refresh();
|
2014-08-13 15:32:24 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
var options = {
|
|
|
|
weight:true,
|
|
|
|
weightMode:"both",
|
|
|
|
noMouse:true,
|
|
|
|
textColour: '#2E9AFE'
|
|
|
|
}
|
|
|
|
TagCanvas.Start('myCanvas','',options);
|
|
|
|
TagCanvas.SetSpeed('myCanvas', [0.05, -0.15]);
|
|
|
|
} catch(e) {
|
|
|
|
// something went wrong, hide the canvas container
|
|
|
|
document.getElementById('myCanvasContainer').style.display = 'none';
|
|
|
|
}
|
|
|
|
|
2014-08-06 09:43:40 +00:00
|
|
|
});
|
2016-07-13 13:57:33 +00:00
|
|
|
|
|
|
|
|