; Netsplit detector
; By Joshua
; Detects a netsplit. Writes a little notification in status and in a custom window
; Setup initialization
on *:start: {
.hmake NetSplits 1000
if ($isfile(netsplits.hsh)) { .hload NetSplits netsplits.hsh }
if (!$hget(NetSplits,$+($network,.start))) { .hadd -m NetSplits $+($network,.start) $ctime }
if (!$hget(NetSplits,$+($network,.people))) { .hadd -m NetSplits $+($network,.people) 0 }
if (!$hget(NetSplits,$+($network,.last))) { .hadd -m NetSplits $+($network,.last) $ctime }
if (!$hget(NetSplits,$+($network,.netsplits))) { .hadd -m NetSplits $+($network,.netsplits) 0 }
}
on *:
disconnect:
{ .
hsave NetSplits netsplits.
hsh }
on *:
exit:
{ .
hsave NetSplits netsplits.
hsh }
; Monitor netsplits
if ($1 == *.net) && ($2 == *.split) || (*.*.* iswm $1 && *.*.* iswm $2) {
if (!%netsplit) {
echo 9
-tg [NETSPLIT
] Netsplit detected between
$1 and
$2
if (!
$window(@NetSplit)) { window -xnthez @NetSplit }
aline -pa @NetSplit $timestamp $+($chr(91),NETSPLIT - $network,$chr(93)) $+($1,$chr(32),$chr(60),$chr(45),$chr(62),$2)
.hinc -m NetSplits $+($network,.netsplits) 1
.set -u60 %netsplit 1
.hadd -m NetSplits $+($network,.last) $ctime
}
elseif (%netsplit) {
.hinc -m NetSplits $+($network,.people) 1
}
}
}
}
alias netsplit {
if ($1 == -p) {
msg $active $logo(NetSplits
) I have seen
$cc2($bytes($hget(NetSplits,$+
($network,.
netsplits)),bd
)) netsplits on
$cc2($network) $+ .
$cc2($bytes($hget(NetSplits,$+
($network,.
people)),bd
)) people affected, with the last split being on
$cc2($asctime($hget(NetSplits,$+
($network,.
last))))
}
else {
echo 14
-ga $logo(NetSplits
) I have seen
$cc2($bytes($hget(NetSplits,$+
($network,.
netsplits)),bd
)) netsplits on
$cc2($network) $+ .
$cc2($bytes($hget(NetSplits,$+
($network,.
people)),bd
)) people affected, with the last split being on
$cc2($asctime($hget(NetSplits,$+
($network,.
last))))
}
}
;Required identifiers
;alias cc1 { return $+($chr(03),13,$chr(02),$1-,$chr(15)) }
;alias cc2 { return $+($chr(03),10,$1-,$chr(03)) }
;alias logo { return $+($chr(03),14,$chr(91),$chr(03),11,$1-,$chr(93),$chr(03)) }