コード例 #1
0
ファイル: testMonitor.php プロジェクト: DBezemer/server
        return array_slice(self::$sum, 0, $limit, true);
    }
    public static function getTotal()
    {
        return count(self::$sum);
    }
}
$duration = 60;
if (isset($argv[1]) && is_numeric($argv[1])) {
    $duration = $argv[1];
}
$end = time() + $duration;
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$sent = 0;
while (time() < $end) {
    $data = array('server' => TestServer::get(), 'address' => TestIpAddress::get(), 'partner' => TestPartner::get(), 'action' => TestAction::get(), 'cached' => (bool) rand(0, 1), 'sessionType' => rand(-1, 2));
    $msg = json_encode($data);
    socket_sendto($sock, $msg, strlen($msg), 0, '127.0.0.1', 6005);
    usleep(10);
    $sent++;
}
echo "Sent {$sent} messages\n";
$total = TestServer::getTotal();
echo "Servers [{$total}]\n";
$max = TestServer::getMax(6);
foreach ($max as $key => $value) {
    echo "\t{$key}\t - {$value}\n";
}
echo "\n";
$total = TestIpAddress::getTotal();
echo "Addresses [{$total}]\n";