Warning: session_start(): open(/var/lib/php/sessions/sess_j1phvm1peanmu32brugejfm1fj, 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
// works with certain versions of vnstat. Try apt-get install vnstat
module EstimatedMonthlyTrafficPercentage > DynBigNumber {
start {
doEvery(0.0, 10*60.0, r updateStats);
}
void updateStats enter {
if (getMonthlyTrafficLimit() == 0)
setValue("Please set traffic limit");
else if (!isOnPATH('vnstat))
setValue("vnstat not installed");
else {
S s = regexpReplaceWithNothing(",\\d+", parse_vnstat(backtick('vnstat)).thisMonthEstimated);
long mb;
if (s.endsWith("MiB")) mb = parseFirstLong(s);
else if (s.endsWith("GiB")) mb = parseFirstLong(s)*1024;
else ret with setValue("(?) " + s);
setValue(intPercentRatio(mb, getMonthlyTrafficLimit()*1024) + " %");
}
}
afterVisualize {
componentPopupMenuItem(label, "Set traffic limit...", r setLimit);
onLeftClick(label, r setLimit);
}
enhanceFrame {
internalFramePopupMenuItem(f, "Set traffic limit...", r setLimit);
}
void setLimit enter {
inputText("Monthly traffic limit (GB, 0 for unknown)", str(getMonthlyTrafficLimit()), voidfunc(S s) {
setMonthlyTrafficLimit(parseLong(s));
updateStats();
});
}
}