#!/usr/bin/php , where type can be one of: views, edits, articles, pages, users, images or admins.\n ERROR; } break; default: # Default Output # The different methods to grab stats .. switch ($getmethod) { case mysql: 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 ); $views=$row['ss_total_views']; $edits=$row['ss_total_edits']; $articles=$row['ss_good_articles']; $pages=$row['ss_total_pages']; $users=$row['ss_users']; $images=$row['ss_images']; break; case curl: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "$statsurl"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_HEADER, false); $buffer = curl_exec($ch); curl_close($ch); break; case fopen: $buffer = fopen($statsurl,"r"); break; case file_get_contents: $buffer = file_get_contents($statsurl); break; case fgets: $buffer = fgets($statsurl); break; case lynx: $buffer = `lynx -dump "$statsurl"`; break; default: $buffer = file_get_contents($statsurl); } # Parse $buffer=trim($buffer); list($total,$good,$views,$edits,$users,$images,$admins) = parsebuffer($buffer); # Output # Check the filename suffix _ (from the symlink) to decide which value to output # symlink the file for each value you want displayed # example: ln -s /usr/share/munin/plugins/mediawiki /etc/munin/plugins/mediawiki_views $basename = preg_replace( '/^.+[\\\\\\/]/', '', $_SERVER['PHP_SELF'] ); $suffix=explode("_",$basename); $suffix=$suffix[1]; switch ($suffix) { case views: print "views.value $views\n"; break; case edits: print "edits.value $edits\n"; break; case articles: print "articles.value $good\n"; break; case pages: print "pages.value $total\n"; break; case users: print "users.value $users\n"; break; case images: print "images.value $images\n"; break; case admins: print "admins.value $admins\n"; default: print "link me as mediawiki_, where type can be one of: views, edits, articles, pages, users, images or admins. \n"; } } ?>