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.
Ad Widget
Collapse
How to track number users online in vBulletin
Collapse
X
-
Tags: None
-
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?
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?Code:<?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; } } ?>
The number 108 is the total users online that I'm after. Any thoughts?[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]# -
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):
P.S. It might be that you have to use the 1.1Alpha release.http://www.intellitrend.de
Specialised in monitoring large environments and Zabbix API programming.Comment
-
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 strugglingComment
Comment