From S23Wiki
Jump to: navigation, search

A Mediawiki plugin for Munin.


  1. !/usr/bin/php


  1. mediawiki plugin for munin
  2. reads number of edits,views,articles,pages,users,admins and images from a Mediawiki
  3. |
  4. by mutante of S23 |
  5. 2007-02-12 | greets to hundfred
  1. Needs a valid mysql user to connect to the wiki database


  1. I include the database settings from elsewhere, so i dont have to show the password in /usr/share/..
  2. I also set "[mediawiki] user mutante" in plugin-conf.d/ so that my user can read the config
  3. alternatively set them in here like:
  1. $dbhost="localhost";
  2. $dbname="wikidb";
  3. $dbuser="wikiuser";
  4. $dbpass="yourpassword";

switch ($argv[1]) { case config:

print <<<CONFIG graph_title Mediawiki graph_vlabel number graph_args --base 1000 -l 0 graph_scale no graph_category wiki graph_info Reads number of edits,views,articles,pages,users,admins and images from a Mediawiki Total number of page views views.label views views.type COUNTER Total number of page edits edits.label edits edits.type COUNTER Total number of 'good' pages (articles) articles.label articles Total number of all pages pages.label pages Total number of user accounts users.label users Total number of admins (sysops) admins.label admins Total number of uploaded images images.label images\n CONFIG; break;


mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error());

$query="select * from site_stats"; $result = mysql_query("$query") or die(mysql_error()); $row = mysql_fetch_array( $result );

print <<<OUTPUT views.value {$row['ss_total_views']} edits.value {$row['ss_total_edits']} articles.value {$row['ss_good_articles']} pages.value {$row['ss_total_pages']} users.value {$row['ss_users']} admins.value {$row['ss_admins']} images.value {$row['ss_images']}\n OUTPUT;

} ?> </HighlightSyntax>