Commit 84f4fca2 authored by 's avatar
Browse files

packetloss:

 for new gui added cofiguration file and config reader (beta but working)
 everything should be backward-compatible with original commandline arguments
 if NEWGUIONLY is not defined

 configuration in file: hosts can be disabled, max. number of flows
 can be limited, timestamp difference among host can be tuned 

 reconnection can be turned on on-demand (SIGUSR1, NEWGUIONLY) becouse
 if trying every loop it seems to be more time consuming than acceptable

 reconnection was not tested with --enable-reconnect mapi mechanism as
 it was originally based just on retrieving NULL from mapi_read_result,
 however it should work as I modified it with respect to previous commit
 from AK

 stats can be cleared (SIGUSR2)

 unified reporting of application state

 commandline options (NEWGUIONLY)
 
gui:
 enabled use of rrd server
 improved error reporting



git-svn-id: file:///home/svn/mapi/trunk@1384 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 9f4ff1ed
CC = gcc
CFLAGS = -g -O2 -W -Wall
CFLAGS_APPMON = -g -W -Wall -Wshadow -Wcast-align -Wpointer-arith
LDFLAGS = -lmapi -lcurses -lrrd
BINS_PACKETLOSS = packetloss
CFLAGS_APPMON = -g -W -Wall -Wshadow -Wcast-align -Wpointer-arith
LDFLAGS_APPMON = -lmapi -lrrd -lcgic
BINS_APPMON = appmon appform.cgi
SOURCES=$(wildcard *.c)
TARGETS=$(SOURCES:.c=)
all: $(BINS_PACKETLOSS) $(BINS_APPMON)
all: $(TARGETS) $(BINS_APPMON)
.PHONY: clean run
# packetloss
packetloss: packetloss.o pl_conf.o pl_misc.o
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
packetloss.o: packetloss.c cgi_headers_packetloss.h pl_conf.h pl_misc.h
$(CC) $(CFLAGS) -c -o $@ $<
pl_conf.o: pl_conf.c pl_conf.h pl_misc.h
$(CC) $(CFLAGS) -c -o $@ $<
pl_misc.o: pl_misc.c pl_misc.h
$(CC) $(CFLAGS) -c -o $@ $<
# appmon
appmon: appmon.o util.o anon_prefix_preserving.o
$(CC) $(CFLAGS_APPMON) $^ -o $@ -lrrd -lmapi
$(CC) $(CFLAGS_APPMON) $^ -o $@ $(LDFLAGS_APPMON)
appform.cgi: appform.o util.o
$(CC) $(CFLAGS_APPMON) $^ -o $@ -lcgic
$(CC) $(CFLAGS_APPMON) $^ -o $@ $(LDFLAGS_APPMON)
appmon.o: ../appmon/appmon.c cgi_headers.h
$(CC) $(CFLAGS_APPMON) -c ../appmon/appmon.c -o $@ -include cgi_headers.h
......@@ -27,12 +46,7 @@ anon_prefix_preserving.o: ../appmon/anon_prefix_preserving.c
appform.o: ../appmon/appform.c
$(CC) $(CFLAGS_APPMON) -c $^ -o $@
packetloss: packetloss.o
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
packetloss.o: packetloss.c cgi_headers_packetloss.h
$(CC) $(CFLAGS) -c packetloss.c -o $@
clean:
@echo 'Cleaning up ...'
rm -rf $(TARGETS) $(BINS_APPMON) appmon_top.html appmon_top_private.html appmon.cgi packetcount.cgi packetloss.cgi *.log *.o
rm -rf $(BINS_PACKETLOSS) $(BINS_APPMON) appmon_top.html appmon_top_private.html appmon.cgi packetcount.cgi packetloss.cgi *.log *.o
......@@ -10,11 +10,13 @@ body {
color: black;
background-color: #E0E0E0;
font-size: 0.8em;
font-size-adjust: 0.545;
font-family: Verdana, lucida, helvetica, arial, sans-serif;
}
h1, h2, h3, h4, h5 {
margin: 0em 0em 0.15em 0em;
font-size-adjust: 0.545;
font-family: Verdana, lucida, helvetica, arial, sans-serif;
}
......@@ -76,6 +78,7 @@ table summary {
th {
text-align: center;
font-size-adjust: 0.545;
font-family: Verdana, lucida, helvetica, arial, sans-serif;
font-weight: bold;
/*font-size: 10pt;*/
......@@ -83,11 +86,13 @@ th {
td {
border: 1px solid black;
font-size-adjust: 0.545;
font-family: Verdana, lucida, helvetica, arial, sans-serif;
text-align: center;
}
tr:hover, .tr:hover {
color: #990000;
background-color: #FFFFFF;
}
......@@ -115,6 +120,18 @@ form textarea.focused {
background-color: yellow;
}
form input.button,
form input.submit {
color: #666666;
font-weight: bold;
}
form input.button:hover,
form input.submit:hover {
color: black;
font-weight: bold;
}
fieldset {
border-width: 1px;
border-color: black;
......@@ -133,6 +150,8 @@ label {
pre, code, tt, .tt {
font-size: 110%;
font-size-adjust: 0.423;
font-family: "Courier New", Courier, FixedSys, System, monospace;
font-family: monospace; /* NN4 */
white-space: pre;
}
......
<?php
# File name: packetloss_startlog.php
# Date: 2008/02/09
# Author: Ales Friedl <ales.friedl@email.cz>
# Includes {{{
$DIR = "../";
require_once "${DIR}lib/expire.php";
require_once "${DIR}lib/config.php";
# }}}
header("Content-Type: text/plain");
readfile($config->abspath($config->packetloss_home, $config->packetloss_startlog));
//$content = "";
//$fp = fopen($config->abspath($config->packetloss_home, $config->packetloss_status), "r");
//while (!feof($fp)) $content .= fgets($fp, 4096);
//echo $content;
//fclose($fp);
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
?>
......@@ -8,6 +8,7 @@ require_once "${DIR}lib/config.php";
# }}}
header("Content-Type: text/plain");
readfile($config->abspath($config->packetloss_home, $config->packetloss_status));
//$content = "";
//$fp = fopen($config->abspath($config->packetloss_home, $config->packetloss_status), "r");
......
......@@ -5,20 +5,28 @@
packetloss_home = "/path/to/packetloss"
# packetloss restart command
packetloss_restart = "/path/to/packetloss.sh restart '%filter%'"
#packetloss_restart = /usr/bin/ssh -f packetloss@localhost "/path/to/packetloss/bin/packetloss.sh restart '%filter%' >/dev/null 2>&1"
#packetloss_reset = /usr/bin/ssh -f packetloss@localhost "/path/to/packetloss/bin/packetloss.sh reset >/dev/null 2>&1"
packetloss_restart = "/path/to/packetloss.sh restart '%filter%' >/dev/null 2>&1"
packetloss_reset = "/path/to/packetloss.sh reset >/dev/null 2>&1"
# rrd server
#rrdsrv = "localhost:13900"
# rrdtool binary
rrdtool = "rrdtool"
# rrdtool log file
rrdtool_error_log = "log/packetloss_rrdtool_error.log"
# rrdtool log file (if commented out and php gb present, errors will be printed into image)
#rrdtool_error_log = "log/packetloss_rrdtool_error.log"
# rrds
packetloss_rrd = "packetloss.rrd"
packetcount_rrd = "packetloss_packets.rrd"
flows_rrd = "packetloss_flows.rrd"
# packetloss status file
packetloss_status = "packetloss_status.csv"
# packetloss files
packetloss_status = "packetloss_status.csv"
packetloss_starts = "packetloss_starts.csv"
packetloss_startlog = "packetloss_start.log"
# enable or disable status
enable_packetloss_status
......
<?php
# File name: flows.php
# Date: 2008/02/09 17:18
# Author: Ales Friedl <ales.friedl@email.cz>
# Includes {{{
$DIR="../";
require_once "${DIR}lib/expire.php";
require_once "${DIR}lib/graph.php";
# }}}
$allowed_args = ",host0rrddsid,host0rrddsid,start,end,step,avg,max,min,width,height,upperLimit,lowerLimit,onlyGraph,title,info,withstarts,";
foreach(array_keys($_GET) as $key) {
if(strpos($allowed_args,",$key,") !== false) {
$$key = $_GET[$key];
}
}
$graph = new Graph("flows", array($host0rrddsid, $host1rrddsid), $start, $end, $step, $avg, $max, $min, $width, $height, $title, $info, $withstarts);
//$graph->dry_run();
$graph->flush();
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
?>
......@@ -8,7 +8,7 @@ require_once "${DIR}lib/graph.php";
# }}}
$allowed_args = ",host0rrddsid,host1rrddsid,start,end,step,avg,max,min,width,height,upperLimit,lowerLimit,onlyGraph,title,info,";
$allowed_args = ",host0rrddsid,host1rrddsid,start,end,step,avg,max,min,width,height,upperLimit,lowerLimit,onlyGraph,title,info,withstarts,";
foreach(array_keys($_GET) as $key) {
if(strpos($allowed_args,",$key,") !== false) {
......@@ -16,7 +16,7 @@ foreach(array_keys($_GET) as $key) {
}
}
$graph = new Graph("packetcount", $host0rrddsid, $host1rrddsid, $start, $end, $step, $avg, $max, $min, $width, $height, $title, $info);
$graph = new Graph("packetcount", array($host0rrddsid, $host1rrddsid), $start, $end, $step, $avg, $max, $min, $width, $height, $title, $info, $withstarts);
//$graph->dry_run();
$graph->flush();
......
......@@ -8,7 +8,7 @@ require_once "${DIR}lib/graph.php";
# }}}
$allowed_args = ",host0rrddsid,host1rrddsid,start,end,step,avg,max,min,width,height,upperLimit,lowerLimit,onlyGraph,title,info,";
$allowed_args = ",host0rrddsid,host1rrddsid,start,end,step,avg,max,min,width,height,upperLimit,lowerLimit,onlyGraph,title,info,withstarts,";
foreach(array_keys($_GET) as $key) {
if(strpos($allowed_args,",$key,") !== false) {
......@@ -16,7 +16,7 @@ foreach(array_keys($_GET) as $key) {
}
}
$graph = new Graph("packetloss", $host0rrddsid, $host1rrddsid, $start, $end, $step, $avg, $max, $min, $width, $height, $title, $info);
$graph = new Graph("packetloss", array($host0rrddsid, $host1rrddsid), $start, $end, $step, $avg, $max, $min, $width, $height, $title, $info, $withstarts);
//$graph->dry_run();
$graph->flush();
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ document.createHTMLElement = function(name, attrarr) {
switch (i) {
case "text": elem.appendChild(document.createTextNode(attrarr[i])); break;
case "smarttext": { // visualise line-breaks and html eventually
if(attrarr[i].search("\n") !== false) elem.innerHTML = attrarr[i].replace(/\n/g, "<br />");
if(attrarr[i].search("\n") != -1) elem.innerHTML = attrarr[i].replace(/\n/g, "<br />");
else elem.appendChild(document.createTextNode(attrarr[i]));
break;
}
......
......@@ -26,22 +26,32 @@ var packetlossStatus = {
if(packetlossStatus.exists) return false;
packetlossStatus.exists = true;
this.logger = typeof(logger) != "undefined" ? logger : null;
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Initialized...");
if(packetlossStatus.autorun) packetlossStatus.start();
packetlossStatus.logger = typeof(logger) != "undefined" ? logger : null;
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Initialized...");
if(packetlossStatus.autorun) { packetlossStatus.SSSInit(); packetlossStatus.start(); }
},
request: null,
loop: true,
////loop: true,
delay: 10000, // 10s
delayAuto: false,
delayFollow: 10000,
tid: 0,
threadid: 0,
counter: 0,
threadid: -1,
epoch: 0,
epoch_ts_changed_last: -3,
signalize_uptodate: 0,
last_ts: parseInt((new Date()).getTime() / 1000),
last_ts_startuptolerance: 60, // server-client startup tolerance
uptodate: 0,
rslash: "↻*↻*",
rqmark: "?¿?¿",
////last_ts_startuptolerance: 60, // server-client startup tolerance
//rslash: "↻*↻*",
rslash: "*.*.",
//rqmark: "?¿?¿",
rqmark: "????",
packetloss_restarting: 0,
packetloss_resetting: 0,
packetloss_restarting_expect_cycles: 2,
packetloss_warmup_cycles: 0,
objarr: Array(),
......@@ -52,47 +62,72 @@ var packetlossStatus = {
hostarr: Array(),
start: function() {
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Started...");
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Started...");
packetlossStatus.running = true;
packetlossStatus.threadid++;
packetlossStatus.refresh();
packetlossStatus.buildHostArr();
//packetlossStatus.buildHostArr();
},
stop: function() {
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Stopped...");
if(packetlossStatus.tid) {
clearTimeout(packetlossStatus.tid);
packetlossStatus.tid = null;
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Some thread killed while sleeping ;)");
}
packetlossStatus.threadid++;
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Stopped...");
packetlossStatus.running = false;
packetlossStatus.threadid++;
packetlossStatus.killUpdatingThread();
},
restart: function() {
packetlossStatus.stop();
packetlossStatus.start();
//packetlossStatus.stop();
//packetlossStatus.start();
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Restarted...");
packetlossStatus.threadid++;
packetlossStatus.killUpdatingThread();
packetlossStatus.running = true;
packetlossStatus.refresh();
},
setRefreshDelay: function(delay) {
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Changed refresh delay to " + delay + "...");
if(delay == 0)
packetlossStatus.stop();
else {
packetlossStatus.delay = delay;
if(delay == "auto") {
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Changed refresh delay to " + delay + "...");
packetlossStatus.delay = 10;
packetlossStatus.delayAuto = true;
packetlossStatus.restart();
}
else {
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Changed refresh delay to " + delay + "...");
packetlossStatus.delayAuto = false;
if(delay == 0)
packetlossStatus.stop();
else {
packetlossStatus.delay = delay;
packetlossStatus.restart();
}
}
},
setUpToDate: function(ts) {
////if((ts + packetlossStatus.last_ts_startuptolerance) > packetlossStatus.last_ts)
if(ts > packetlossStatus.last_ts) {
packetlossStatus.epoch_ts_changed_last = packetlossStatus.epoch;
if(packetlossStatus.packetloss_restarting > 0) packetlossStatus.packetloss_restarting = 0;
if(packetlossStatus.packetloss_resetting > 0) packetlossStatus.packetloss_resetting = 0;
}
////packetlossStatus.last_ts_startuptolerance = 0;
packetlossStatus.last_ts = ts;
if(packetlossStatus.packetloss_restarting > 0) packetlossStatus.packetloss_restarting--;
if(packetlossStatus.packetloss_resetting > 0) packetlossStatus.packetloss_resetting--;
},
isUpToDate: function() {
return (packetlossStatus.epoch - packetlossStatus.epoch_ts_changed_last) < 3;
},
refresh: function() {
packetlossStatus.__file2buffer();
packetlossStatus.__buffer2arr();
},
__file2buffer: function() {
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Reading file...");
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Requesting file...");
packetlossStatus.request = new Request();
packetlossStatus.request.request(packetlossStatus.statusfilename, {}, packetlossStatus.rhandler_closure()); // continue async
},
......@@ -113,11 +148,12 @@ var packetlossStatus = {
var label = record[8];
var value = record[9];
var unit = record[10];
var ct = record[11];
var alarm = record[12];
if(id == "ts") {
packetlossStatus.uptodate = (parseInt(value) + packetlossStatus.last_ts_startuptolerance) > packetlossStatus.last_ts;
packetlossStatus.last_ts_startuptolerance = 0;
packetlossStatus.last_ts = parseInt(value);
packetlossStatus.setUpToDate(parseInt(value));
packetlossStatus.showUpToDateState();
}
if(id == "ts" || id == "starttime") {
var d = new Date();
......@@ -144,7 +180,7 @@ var packetlossStatus = {
var upss = value;
value = "";
if(upd) {
value += upd == 1 ? upd + " day, " : " days, ";
value += (upd == 1 ? upd + " day, " : upd + " days, ");
}
if(upd || uphh) {
value += uphh + ":";
......@@ -156,27 +192,32 @@ var packetlossStatus = {
value += (upmm ? upss.zero() : upss);
}
}
if(id == "loop_busytime") {
if(parseInt(value) >= 10)
packetlossStatus.delayFollow = parseInt(value) + "000";
}
packetlossStatus.arr.push({category: category, h0: h0, d0: d0, relation: relation, h1: h1, d1: d1, id: id, label: label, value: value, unit: unit});
packetlossStatus.arr.push({category: category, h0: h0, d0: d0, relation: relation, h1: h1, d1: d1, id: id, label: label, value: value, unit: unit, ct: ct, alarm: alarm});
}
if(packetlossStatus.debug && packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Stored " + packetlossStatus.arr.length + " records");
if(packetlossStatus.debug && packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Stored " + packetlossStatus.arr.length + " records");
},
buildHostArr: function() {
for(var i = 0; i < packetlossStatus.arr.length; i++) {
var record = packetlossStatus.arr[i];
if(record["id"] == "hostname" && record["h0"] != "*") {
var h0 = record["h0"];
var value = record["value"];
packetlossStatus.hostarr.push({
h0: h0,
value: value,
});
}
}
},
// buildHostArr: function() {
// for(var i = 0; i < packetlossStatus.arr.length; i++) {
// var record = packetlossStatus.arr[i];
// if(record["id"] == "hostname" && record["h0"] != "*") {
// var h0 = record["h0"];
// var value = record["value"];
// packetlossStatus.hostarr.push({
// h0: h0,
// value: value,
// });
// }
// }
// },
__writearr: function() {
var upToDateSign = packetlossStatus.getUpToDateSign();
for(var i = 0; i < packetlossStatus.arr.length; i++) {
var record = packetlossStatus.arr[i];
var category = record["category"];
......@@ -189,56 +230,102 @@ var packetlossStatus = {
var label = record["label"];
var value = record["value"];
var unit = record["unit"];
var ct = record["ct"];
var alarm = record["alarm"];
var uid = ("id_" + h0 + d0 + relation + h1 + d1 + id).replace(/\*/g, "_");
if(!packetlossStatus.objarr[uid]) {
packetlossStatus.objarr[uid] = document.getElementById(uid);
}
element = packetlossStatus.objarr[uid];
//if(packetlossStatus.debug && packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Updating " + uid + " found " + element);
//if(packetlossStatus.debug && packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Updating " + uid + " found " + element);
if(element) {
if(element.textContent) {
element.textContent = packetlossStatus.addSlash(value);
element.textContent = value + upToDateSign;
}
else {
element.innerText = packetlossStatus.addSlash(value);
element.innerText = value + upToDateSign;
}
//if(packetlossStatus.debug && packetlossStatus.logging) logger.smartlog("packetlossStatus.js: Updated " + uid + " to " + value);
if(alarm) element.className = "alarm" + alarm;
else element.className = "";
}
}
},
rhandler_closure: function() { // async
//var pStatus = this;
var threadid = packetlossStatus.threadid;
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Update thread " + threadid + " brought up...");
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Thread " + threadid + " delegated...");
return function(request) {
if(packetlossStatus.threadid != threadid) {
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Update thread " + threadid + " returned and killed...");
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Thread " + threadid + " received data, but was killed... Thread " + packetlossStatus.threadid + " took over.");
return false;
}
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Update thread " + threadid + " updating data...");
packetlossStatus.counter++;
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Thread " + threadid + " updating data...");
packetlossStatus.epoch++;
packetlossStatus.bufferarr = request.connection.responseText.split("\n");
if(packetlossStatus.debug && packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Received " + packetlossStatus.bufferarr.length + " records");
if(packetlossStatus.debug && packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Received " + packetlossStatus.bufferarr.length + " records");
packetlossStatus.__buffer2arr();
packetlossStatus.__writearr();
if(packetlossStatus.loop) {
//if(packetlossStatus.counter > 100) packetlossStatus.stop(); // XXX
if(packetlossStatus.logging) if(this.logger) this.logger.smartlog("packetlossStatus.js: Update thread " + threadid + " sleeping for " + packetlossStatus.delay + " s...");
if(packetlossStatus.running) packetlossStatus.tid = setTimeout("packetlossStatus.refresh()", packetlossStatus.delay);
////if(packetlossStatus.loop) {
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Thread " + threadid + " in epoch " + packetlossStatus.epoch + " sleeping for " + (packetlossStatus.delayAuto && packetlossStatus.delayFollow >= 10000 ? packetlossStatus.delayFollow : packetlossStatus.delay) + " s...");
if(packetlossStatus.running) packetlossStatus.createUpdatingThread();
////}
}
},
createUpdatingThread: function() {
packetlossStatus.tid = setTimeout("packetlossStatus.refresh()", packetlossStatus.delayAuto && packetlossStatus.delayFollow >= 10000 ? packetlossStatus.delayFollow : packetlossStatus.delay);
},
killUpdatingThread: function() {
if(packetlossStatus.tid) {
clearTimeout(packetlossStatus.tid);
packetlossStatus.tid = null;
if(packetlossStatus.logging) if(packetlossStatus.logger) packetlossStatus.logger.smartlog("packetlossStatus.js: Some thread killed while sleeping ;)");
}
},
getUpToDateSign: function() {
if(!packetlossStatus.isUpToDate())
return " " + packetlossStatus.rqmark.charAt(packetlossStatus.epoch % 4);
else if(packetlossStatus.signalize_uptodate)
return " " + packetlossStatus.rslash.charAt(packetlossStatus.epoch % 4);
else return "";
},
showUpToDateState: function() {
element = document.getElementById("state");
if(packetlossStatus.packetloss_restarting > 0) message = "RESTARTING (ready in " + packetlossStatus.packetloss_restarting + "0 s)";
else if(packetlossStatus.packetloss_resetting > 0) message = "RESETTING STATS (ready in " + packetlossStatus.packetloss_resetting + "0 s)";
else message = packetlossStatus.isUpToDate() ? "UP and RUNNING" : "DOWN";
if(element) {
if(element.textContent) {
element.textContent = message;
}
else {
element.innerText = message;
}
if(packetlossStatus.packetloss_restarting > 0) element.className = "alarm1";
else if(packetlossStatus.packetloss_resetting > 0) element.className = "alarm1";
else {
if(packetlossStatus.isUpToDate()) element.className = "noalarm";