scripts/munin/wiki_pages
Nicolas Dandrimont 7e1a4bb1fe [munin/wiki_*] Le wiki n'est plus sur rouge
Ignore-this: 90eda6d1c9f5a747116287bcd9dcb7c6

darcs-hash:20090328153342-ffbb2-2aab6e3dfbd38991b208695a3fdbe74317a44e44.gz
2009-03-28 16:33:42 +01:00

50 lines
1.3 KiB
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
FICHIER_MUNIN = '/var/lib/munin/tmp/wiki_pages'
import shutil
import sys
import tempfile
try :
arg = sys.argv[1]
except :
arg = ''
if arg == "config" :
print 'host_name web.wiki'
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" :
from MoinMoin.request.request_cli import Request
sys.path.insert(0, '/etc/moin')
request = Request(u"wiki.crans.org/")
request.form = request.args = request.setup_args()
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]
tmpfile = tempfile.NamedTemporaryFile()
tmpfile.write("total.value %d\n" % pages.__len__())
tmpfile.write("orphelines.value %d\n" % orphaned.__len__())
tmpfile.flush()
shutil.copy(tmpfile.name, FICHIER_MUNIN)
tmpfile.close()
else:
sys.stdout.write(open(FICHIER_MUNIN).read())