die();
}
}
+ if(!file_exists("db/network-connections.rrd")) {
+ $fname = "db/network-connections.rrd";
+ $opts = array(
+ "--step", "300", "--start", "0",
+ "DS:localhost:GAUGE:600:0:U",
+ "DS:ipv4:GAUGE:600:0:U",
+ "DS:ipv6:GAUGE:600:0:U",
+ "RRA:AVERAGE:0.5:1:600",
+ "RRA:AVERAGE:0.5:6:700",
+ "RRA:AVERAGE:0.5:24:775",
+ "RRA:AVERAGE:0.5:288:797",
+ "RRA:MAX:0.5:1:600",
+ "RRA:MAX:0.5:6:700",
+ "RRA:MAX:0.5:24:775",
+ "RRA:MAX:0.5:288:797"
+ );
+ $ret = rrd_create($fname, $opts, count($opts));
+ if(!$ret) {
+ $err = rrd_error();
+ echo "Create error: $err\n";
+ die();
+ }
+ }
$this->timer = timer(5,array(&$this,"create_stats"),array());
}
"away" => 0,
"here" => 0,
"chansperuser" => 0,
- "usersperchan" => 0
+ "usersperchan" => 0,
+ "local" => 0,
+ "ipv4" => 0,
+ "ipv6" => 0
);
foreach(P10_User::getAllUsers() as $user) {
$stats['total']++;
if($user->isAway()) $stats['away']++;
else $stats['here']++;
if($user->getModes()->hasMode('o')) $stats['opers']++;
+ if($user->getIP()->isLocalAddress(true)) $stats['local']++;
+ if($user->getIP()->isIPv6()) $stats['ipv6']++;
+ else $stats['ipv4']++;
}
$stats['chansperuser'] = $stats['chansperuser'] / $stats['total'];
$channels = P10_Channel::getChannelCount();
rrd_update("db/network.rrd", time().":".$stats['total'].":".$channels.":".$stats['opers'].":".$servers);
rrd_update("db/network-away.rrd", time().":".$stats['away'].":".$stats['here']);
rrd_update("db/network-peruser.rrd", time().":".$stats['usersperchan'].":".$stats['chansperuser']);
+ rrd_update("db/network-connections.rrd", time().":".$stats['local'].":".$stats['ipv4'].":".$stats['ipv6']);
foreach(P10_Server::getServers() as $snum => $server) {
$count = $server->getUserCount();
$fname="db/".$server->getName().".rrd";