Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Use MRTG to graph new posts and online users! Details »»
Use MRTG to graph new posts and online users!
Version: 1.00, by discore discore is offline
Developer Last Online: Nov 2014 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 10-27-2002 Last Update: Never Installs: 5
 
No support by the author.

Well this isn't really a hack so let's post it here.

If you're the type of person who would prefer everything had a graph, this "hack" is for you.

Example: http://flamevault.com/mrtg/board

The installation of this is a bit hardcore if you don't have MRTG, Perl, or a common Perl module (DBI) installed. A bit of Unix background could help too (oh yeh, it only works on Unix/Linux/etc servers for now).

See attachment for scripts, mrtg config, and installation instructions. I'll help as much as I can if you're having trouble installing so feel free to ask.

Updated 12-01-03 to fix errors discussed below!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 11-30-2003, 03:55 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave#
I know - I wish I knew why the online users graph data is wrong

Anybody heard from the author?


Wish I have time to look into this... I'm in the middle of law exams... try emailing the author - he may not visit here for a while...
Reply With Quote
  #13  
Old 12-01-2003, 09:49 AM
Dave# Dave# is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Erwin
Wish I have time to look into this... I'm in the middle of law exams... try emailing the author - he may not visit here for a while...
yeah - have emailed him.

I amm just looking over the code and I still can't work out what the issue is

here is the query

Quote:
"SELECT DISTINCT COUNT(*) FROM session LEFT JOIN user ON (user.userid=session.userid) WHERE session.userid>0 AND session.lastactivity>900"
This is giving me a result of 156 when there are infact 240 users online
Reply With Quote
  #14  
Old 12-01-2003, 11:42 AM
discore discore is offline
 
Join Date: Jun 2002
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi! Glad to see some people are enjoying this little hack. Now if only it worked correctly!

I reviewed the script and figured out major flaw #1: It wasn't calculating guests, only registered users. That is now fixed, all online users are accounted for.

The second flaw is more complex. vB's "Who's Online" uses the Cookie Timeout from your vB options to decide who is currently online. This is by default set at 900 seconds (15 minutes). MRTG by nature runs every 5 minutes (300 seconds). To get truely accurate graphs you should set $cookie_expire in the .pl script to 300 seconds, hence only counting users who have been active in the last 5 minutes. This will report considerably less users than vB does, simply because you limit the time range. Alternately, to report what vB's "Who's Online" says, set this to whatever your Cookie Timeout is. It's up to you. Personally I prefer accuracy and use 300 seconds.

Furthermore, it's still slightly inaccurate if you set $cookie_timeout to your vB setting. I was testing it with $cookie_timeout set at 900 seconds (my vB setting) and Who's Online showed 13-15 users, but the .pl script reported 16-17. The query the .pl script uses to get these numbers is so straightforward it seems hard to make a mistake. Maybe a true vB guru can comment on who Who's Online numbers are gathered vs how the .pl script gets them.

At least it's much more accurate now that guests are counted

Here is an updated copy of the .pl script. If you already had this working, this is the only file changed. I also fixed some typos in the other scripts and rewrote parts of the README file to be clearer for anyone who chooses to install this in the future. The attachment in the first post has been updated.

I'll keep an eye on this thread, but feel free to email too.
Reply With Quote
  #15  
Old 12-01-2003, 12:08 PM
Dave# Dave# is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the update - have put your updated code in the script - will see how that pans out.

Couple of comments now we have your attention

The script only allows one value for $data and this gets passed to mrtg - this is fine but I have modified your script to graph some other data like registered users, totposts and total threads

http://www.fu-1.net/mrtg/regusers.html
http://www.fu-1.net/mrtg/totposts.html
http://www.fu-1.net/mrtg/totthreads.html

I'd like to be able to graph threads/posts on the same graph but am struggling with the Perl

Also do you know how to to stop MRTG converting values into K ie 6.4K rather than 6,400?

Finally I am using this remotely so your script calls uptime on the box running mrtg not the mysql box

Again - thanks for doing this - VERY cool
Reply With Quote
  #16  
Old 12-01-2003, 02:05 PM
discore discore is offline
 
Join Date: Jun 2002
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave#
The script only allows one value for $data and this gets passed to mrtg - this is fine but I have modified your script to graph some other data like registered users, totposts and total threads

http://www.fu-1.net/mrtg/regusers.html
http://www.fu-1.net/mrtg/totposts.html
http://www.fu-1.net/mrtg/totthreads.html

I'd like to be able to graph threads/posts on the same graph but am struggling with the Perl
2 things is no problem. MRTG can't graph more than 2 things at a time (as far as I know). Maybe other graphing programs like Cricket are more flexible, not sure.

But we can at least combine Total Posts/Threads. Use this script which adds a new "totaltp" section and makes displaying 2 numbers possible. Then add this to your MRTG config file:

Code:
# Total threads/posts
Target[totaltp]: `/etc/mrtg/vB.pl totaltp`
MaxBytes[totaltp]: 10000000
Title[totaltp]: Total Threads/Posts
PageTop[totaltp]: <H1>Total Threads/Posts</H1>
ShortLegend[totaltp]: Threads/Posts
YLegend[totaltp]: Threads/Posts
Legend1[totaltp]: Total Threads
Legend2[totaltp]: Total Posts
LegendI[totaltp]: Threads
LegendO[totaltp]: Posts
Options[totaltp]: growright,nopercent,gauge
Changing the the path to vB.pl of course. That will give you graphs that look like this. Doesn't look that great with my board's 1:20ish thread to post ratio, but the new code and configuration should make further modifications easier.

Quote:
Originally Posted by Dave#
Also do you know how to to stop MRTG converting values into K ie 6.4K rather than 6,400?
The best way I've found is by adding:

Code:
kMG[totaltp]: ,,
To the MRTG config. "totaltp" gets replaced by whatever label is appropiate. This doesn't change the digits on the YLegend (left side digits on the graphic), probably because they'd get too big to fit in the image. All of the configuration directives can be found here. Maybe there's a better way.

Quote:
Originally Posted by Dave#
Finally I am using this remotely so your script calls uptime on the box running mrtg not the mysql box
Hehe, you could maybe run SNMP on the database server and rewrite the script to get date/time of remote machine via SNMP, but that's quite a bit of work for something as arbitrary as uptime. You're probably best off simply adding "noinfo" to the Options for each label to supress the whole bit about uptime.
Reply With Quote
  #17  
Old 12-02-2003, 12:21 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I still think this qualifies as a hack. I am moving it...
Reply With Quote
  #18  
Old 12-02-2003, 10:17 AM
Dave# Dave# is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
I still think this qualifies as a hack. I am moving it..
Now it takes me 10 minutes to find the thread

These forums really are sunforum hell

discore - many thanks for the update - this is really great

http://www.fu-1.net/mrtg/
Reply With Quote
  #19  
Old 12-03-2003, 12:29 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looks great Dave.

Use the "Old Layout" link from the homepage.
Reply With Quote
  #20  
Old 12-03-2003, 04:55 AM
Weasel's Avatar
Weasel Weasel is offline
 
Join Date: Dec 2001
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This hack does not take into consideration TABLE_PREFIX. booo.

Also anyone know what this means?

It still creates the log files and images though, I'm not sure if they work though because the images dont have any data to plot so far.

Code:
Rateup WARNING: /usr/bin/rateup could not read the primary log file for posts
Rateup WARNING: /usr/bin/rateup The backup log file for posts was invalid as wel
l
Rateup WARNING: /usr/bin/rateup Can't remove posts.old updating log file
Rateup WARNING: /usr/bin/rateup Can't rename posts.log to posts.old updating log
 file
Rateup WARNING: /usr/bin/rateup could not read the primary log file for users
Rateup WARNING: /usr/bin/rateup The backup log file for users was invalid as wel
l
Rateup WARNING: /usr/bin/rateup Can't remove users.old updating log file
Rateup WARNING: /usr/bin/rateup Can't rename users.log to users.old updating log
 file
Reply With Quote
  #21  
Old 12-03-2003, 06:42 AM
Dave# Dave# is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The rateup warning will happen the first time you run the script when the log files are first populated - it's normal
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:10 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07355 seconds
  • Memory Usage 2,324KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_code
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete