Warning: session_start(): open(/var/lib/php/sessions/sess_cqcssdnmbvh3pvuglltsr36s8f, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
// only from machines that run #1020927 with postToServer=true
cmodule ServerLoadsTrayIcon > DynPrintLog {
int size = goodSystemTrayIconSize().x; // icon width+height
transient double expiryTime = 10.0;
transient TrayIcon trayIcon;
transient Map loads = expiringMap(expiryTime);
transient LS colors = ll("FF0000", "00FF00", "0000FF");
transient S status;
srecord Load(int cores, double percent) {}
start {
ownResource(tempTrayIcon(trayIcon = installTrayIcon(whiteImage(size, size), "Server CPUs", rThread dm_activateOSAndModule)));
doEvery(1.0, r updateIcon);
dm_onRemoteSystemStatusPosted((computerID, msg) -> {
LS l = regexpFirstGroupsIC([[System CPU: (\d+)% \((\d+) core]], msg);
if (l == null) ret;
loads.put(computerID, new Load(parseInt(second(l)), parseInt(first(l))));
});
}
void updateIcon enter {
Map map = cloneMap(loads);
setField(status := joinMap(", ", map, (server, load)
-> server + ": " + iround(load.percent/load.cores) + "%"));
int cores = 0;
for (Load l : values(map)) cores += l.cores;
BufferedImage img;
double totalLoad = 0;
if (cores == 0) img = whiteImage(1, 1);
else {
img = whiteImage(cores, size);
int x = 0, i = 0;
// go alphabetical in computer IDs
for (Load l : valuesSortedByKeys(map)) {
totalLoad += l.percent;
Color color = colorFromHex(colors.get((i++) % l(colors)));
int h = iround(l.percent/l.cores/100*size);
fillRect(img, x, size-h, l.cores, h, color);
x += l.cores;
}
}
setTrayIconImage(trayIcon, resizeImage(img, size, size));
trayIcon.setToolTip(nServers(map) + ", " + nCores(cores) + ", " + "total load: " + iround(totalLoad/cores) + "%");
}
visual centerAndSouthWithMargins(super, jCenteredSection("Server loads", dm_fieldLabel status()));
}