diff --git a/munin/wiki_pages b/munin/wiki_pages index 6544f1d5..80347c7d 100755 --- a/munin/wiki_pages +++ b/munin/wiki_pages @@ -1,15 +1,65 @@ -#!/bin/sh +#!/usr/bin/env python +# -*- coding: utf-8 -*- -if [ "$1" = "config" ]; then +fichier = '/var/lib/munin/tmp/wiki_pages' - echo 'host_name web.rouge' - echo 'graph_category wiki' - echo 'graph_title Nombres de pages' - echo 'graph_args --base 1000 --lower-limit 0' - echo 'graph_vlabel nombre de pages' - echo 'total.label Total' - echo 'total.draw AREA' - exit 0 -fi -echo "total.value" `find /var/local/wiki/data/pages/ -mindepth 2 -maxdepth 2 -name "current" | wc -l` +import sys,os +from MoinMoin.request import RequestCLI + +sys.path.insert(0, '/etc/moin') + +try : + arg = sys.argv[1] +except : + arg = '' + +if arg == "config" : + print 'host_name web.rouge' + print 'graph_category wiki' + print 'graph_title Nombres de pages' + print 'graph_args --base 1000 --lower-limit 0' + print 'graph_vlabel nombre de pages' + print 'total.label Total' + print 'total.draw AREA' + print 'orphelines.label Pages orphelines' + print 'orphelines.draw AREA' + +elif arg == "fichier" : + file = open('%s.next' % fichier,'w') + + request = RequestCLI(u"wiki.crans.org/") + request.form = request.args = request.setup_args() + + _ = request.getText + + #if request.mode_getpagelinks: # prevent recursion + #return '' + + # find root page. + #from MoinMoin.Page import Page + #rootpage = Page(request, u"FrontPage", is_rootpage=1) + # delete all linked pages from a dict of all pages + #print request.cfg.__dict__ + pages = request.rootpage.getPageDict(user='') + orphaned = {} + orphaned.update(pages) + for page in pages.values(): + links = page.getPageLinks(request) + for link in links: + if link in orphaned: + del orphaned[link] + + + # return a list of page links + print + + + file.write("total.value %d\n" % pages.__len__()) + + file.write("orphelines.value %d\n" % orphaned.__len__()) + + file.close() + os.system('mv %s.next %s' % (fichier, fichier)) +else : + os.system('cat %s' % fichier)