Warning: session_start(): open(/var/lib/php/sessions/sess_taft97tlet15elspqr03ehpbqd, 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
cmodule RebootConsciousness > DynPrintLogAndEnabled {
DoubleRange typicalTimeToReboot = new(1000, 0);
start-thread {
// extract typicalTimeToReboot
/*for (PairS p : overlappingPairs(asList(linesFromFile(rebootLogFile()))))
analyzeLines(pairToList(p)); // TODO: don't log stuff
clearPrintLog();
print(+typicalTimeToReboot);*/
theTest();
watchQuotedLog_future(rebootLogFile(), 1000, voidfunc(S s) {
new Matches m;
if "* Rebooting computer"
predict("A reboot will happen in between "
+ formatDouble(typicalTimeToReboot.start, 1) + " and "
+ formatDouble(typicalTimeToReboot.end, 1) + " seconds");
});
}
void theTest {
LS lastLines = unquoteAll(lastNLines(2, rebootLogFile()));
pnl(lastLines);
analyzeLines(lastLines);
}
void analyzeLines(LS lastLines) {
if (empty(lastLines)) ret;
if (l(lastLines) == 1) ret with confused("Only one event: " + lastLines);
S line1 = first(lastLines), line2 = second(lastLines);
new Matches m;
new Matches m2;
if (match("* Rebooting computer", line1, m)
&& match("* Boot timestamp changed from * to *", line2, m2)) {
long ts1 = parseLong(m.get(0)), ts2 = parseLong(m2.get(2));
if (ts2 > ts1) {
notConfused("All OK! A reboot happened after my reboot command");
double timeToReboot = toSeconds(ts2-ts1);
setField(typicalTimeToReboot := DoubleRange(
min(typicalTimeToReboot.start, timeToReboot),
max(typicalTimeToReboot.end, timeToReboot));
} else
confused("Timestamps are weird: " + lastLines);
} else
confused("Was expecting reboot cmd & then reboot effect: " + lastLines);
}
void confused(S msg) {
printAndProgramLog("Confused: " + msg);
}
void notConfused(S msg) {
printAndProgramLog("I am very satisfied. " + msg);
}
void predict(S msg) {
printAndProgramLog("I predict: " + msg);
dm_sayInEnglish(msg);
}
}