Munin/mediawiki

From S23Wiki
Jump to: navigation, search

A Mediawiki plugin for Munin.

<HighlightSyntax>

  1. !/usr/bin/php

<?php

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

require_once("/home/mutante/wiki_mysql_conf.php");

  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 views.info Total number of page views views.label views views.type COUNTER edits.info Total number of page edits edits.label edits edits.type COUNTER articles.info Total number of 'good' pages (articles) articles.label articles pages.info Total number of all pages pages.label pages users.info Total number of user accounts users.label users admins.info Total number of admins (sysops) admins.label admins images.info Total number of uploaded images images.label images\n CONFIG; break;

default:

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>