<?php
-/********************************* PHP-P10 ******************************
- * P10 uplink class by pk910 (c)2011 pk910 *
- ************************************************************************
- * Version 2 (OOP) *
+/******************************* PHP-P10 v2 *****************************
+ * Copyright (C) 2011 Philipp Kreil (pk910) *
* *
- * PHP-P10 is free software; you can redistribute it and/or modify *
+ * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
+ * the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
- * *
+ * *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
- * along with PHP-P10; if not, write to the Free Software Foundation, *
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
************************************************************************
*
die();
}
}
+ if(!file_exists("db/network-peruser.rrd")) {
+ $fname = "db/network-peruser.rrd";
+ $opts = array(
+ "--step", "300", "--start", "0",
+ "DS:userperchan:GAUGE:600:0:U",
+ "DS:chanperuser: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());
}
"opers" => 0,
"total" => 0,
"away" => 0,
- "here" => 0
+ "here" => 0,
+ "chansperuser" => 0,
+ "usersperchan" => 0
);
- foreach(P10_User::getAllUsers() as $num => $user) {
+ foreach(P10_User::getAllUsers() as $user) {
$stats['total']++;
+ $stats['chansperuser'] += $user->getChannelCount();
if($user->isAway()) $stats['away']++;
else $stats['here']++;
if($user->getModes()->hasMode('o')) $stats['opers']++;
}
+ $stats['chansperuser'] = $stats['chansperuser'] / $stats['total'];
$channels = P10_Channel::getChannelCount();
+ foreach(P10_Channel::getChannels() as $channel) {
+ $stats['usersperchan'] += $channel->getUserCount();
+ }
+ $stats['usersperchan'] = $stats['usersperchan'] / $channels;
$servers = P10_Server::getServerCount();
rrd_update("db/network.rrd", time().":".$stats['total'].":".$channels.":".$stats['opers'].":".$servers);
rrd_update("db/network-away.rrd", time().":".$stats['away'].":".$stats['here']);
- foreach(uplink::$uplink->servers as $snum => $server) {
+ rrd_update("db/network-peruser.rrd", time().":".$stats['usersperchan'].":".$stats['chansperuser']);
+ foreach(P10_Server::getServers() as $snum => $server) {
$count = $server->getUserCount();
$fname="db/".$server->getName().".rrd";
if(!file_exists($fname)) {