PDA

View Full Version : How to track number users online in vBulletin


eWebtricity
01-05-2005, 16:01
What's the best way to go about tracking the number of users online in vBulletin in a graph. Just like in the admin control panel where it tells you how many users are online, we'd like to put that in zabbix.

eWebtricity
27-05-2005, 05:57
So I've hacked vb to use some php to count the sessions, but I can't seem to parse out what I need. Any suggestions?


<?php


// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('cphome');

// ########################## REQUIRE BACK-END ############################
require_once('./global-zabbix.php');

if ($stats = @exec('uptime 2>&1') AND trim($stats) != '')
{
if (preg_match("#: ([\d.,]+),\s+([\d.,]+),\s+([\d.,]+)$#", $stats, $regs))
{

$datecut = TIMENOW - $vboptions['cookietimeout'];
$guestsarry = $DB_site->query_first("SELECT COUNT(host) AS sessions FROM " . TABLE_PREFIX . "session WHERE userid = 0 AND lastactivity > $datecut");
$membersarry = $DB_site->query("SELECT DISTINCT userid FROM " . TABLE_PREFIX . "session WHERE userid <> 0 AND lastactivity > $datecut");

$guests = intval($guestsarry['sessions']);
$members = intval($DB_site->num_rows($membersarry));

$regs[1] = vb_number_format($regs[1], 2);
$regs[2] = vb_number_format($regs[2], 2);
$regs[3] = vb_number_format($regs[3], 2);

// ### MAX LOGGEDIN USERS ################################
$maxusers = unserialize($datastore['maxloggedin']);
if (intval($maxusers['maxonline']) <= ($guests + $members))
{
$maxusers['maxonline'] = $guests + $members;
$maxusers['maxonlinedate'] = TIMENOW;
build_datastore('maxloggedin', serialize($maxusers));
}

// Echo the total number of users online
echo $guests + $members;

}
}

?>


This code outputs the following, but I'm back to my same problem as qmail. How do I grab the results and feed it to the Zabbix Agentd?


[root@server admincp]# php vbusers-online.php
Content-type: text/html
X-Powered-By: PHP/4.3.10
Set-Cookie: bblastvisit=1117166197; expires=Sat, 27-May-06 03:56:37 GMT; path=/
Set-Cookie: bblastactivity=1117165743; expires=Sat, 27-May-06 03:56:37 GMT; path=/

108[root@server admincp]#


The number 108 is the total users online that I'm after. Any thoughts?

Wolfgang
27-05-2005, 14:00
I think you did most of the work already. Why don't you create / modify the script to just return the number you are looking for, and then create a userdefined item for it.

Maybe this thread will help (setting up a custom script):

http://www.zabbix.com/forum/showthread.php?t=821

P.S. It might be that you have to use the 1.1Alpha release.

eWebtricity
28-05-2005, 21:31
I can't seem to suppress the headers when running from the command line, so cut and wc are becoming difficult to use to parse out the returned value. This is where I'm struggling