Diverse nya plugins

This commit is contained in:
2013-06-12 07:26:23 +00:00
parent 2ed0dff658
commit 449d3a61ca
3 changed files with 165 additions and 0 deletions

61
monit Executable file
View File

@@ -0,0 +1,61 @@
#!/usr/bin/python
# Monit status parser plugin for munin
# This is very raw, but it should work for you out of the box. You of course
# need to have monit configured such that the 'monit status' command works.
# Todd Troxell <ttroxell@debian.org>
STATUS_CMD = "/usr/sbin/monit status"
import sys
import re
from commands import getstatusoutput
def sanitize(s):
OK_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789"
out = str()
for char in s:
if char.lower() in OK_CHARS:
out += char
return out
procs = dict()
status, output = getstatusoutput(STATUS_CMD)
if status != 0:
print "Errror running status command: %s" % (output)
sys.exit(status)
output = output.split('\n')
cur_proc = None
for line in output:
m = re.match("^Process '(.*)'.*$", line)
if m:
cur_proc = sanitize(m.group(1))
try:
procs[cur_proc]
except KeyError:
procs[cur_proc] = dict()
continue
m = re.match(" memory kilobytes total\s+([0-9]+).*$", line)
if m:
procs[cur_proc]["total_memory"] = m.group(1)
continue
m = re.match(" cpu percent total\s+([.0-9]+)%.*$", line)
if m:
procs[cur_proc]["total_cpu"] = m.group(1)
continue
if len(sys.argv) > 1 and sys.argv[1] == 'config':
print 'graph_title Per process stats from Monit'
print 'graph_vlabel numbers'
print 'graph_category monit'
for process in procs:
for stat in procs[process]:
print "monit_%s_%s.label %s.%s" % (process, stat, process, stat)
sys.exit(0)
for process in procs:
for stat in procs[process]:
print "monit_%s_%s.value %s" % (process, stat, procs[process][stat])

47
multimemory Executable file
View File

@@ -0,0 +1,47 @@
#!/bin/sh
# -*- sh -*-
MUNIN_LIBDIR=/usr/share/munin/
if [ -z "$MUNIN_LIBDIR" ]; then
MUNIN_LIBDIR="`dirname $(dirname "$0")`"
fi
. $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ -z "$names" -o -z "$os" ]; then
echo "Configuration required"
exit 1
fi
if [ "$1" = "config" ]; then
echo graph_title Total memory usage
echo 'graph_category processes'
echo 'graph_args --base 1024 --vertical-label memory -l 0'
for name in $names; do
fieldname=$(clean_fieldname $name)
REGEX='\<'"$name"'\>'
echo "$fieldname.label $name"
echo "$fieldname.draw LINE2"
echo "$fieldname.info Processes matching this regular expression: /$REGEX/"
done
exit 0
fi
for name in $names; do
fieldname=$(clean_fieldname $name)
printf "$fieldname.value "
if [ "$os" = "freebsd" ]; then
ps awxo rss,command | grep -w $name | grep -v grep | /usr/bin/awk '{ total += $1 } END { print total * 1024 }'
else
ps auxww | grep -w $name | grep -v grep | sed -re 's/[ ]{1,}/ /g' | /usr/bin/cut -d ' ' -f 6 | /usr/bin/awk '{ total = total + $1 } END { print total * 1024 }'
fi
done

57
tinyrss_feeds Executable file
View File

@@ -0,0 +1,57 @@
#!/usr/bin/env python
# CFG
url = 'http://tinyrss.wahlberg.se/'
usr = 'admin'
pwd = 'unionen'
import sys
from ttrss.client import TTRClient
def autoconf():
print "yes"
def count():
client = TTRClient(url, usr, pwd)
client.login()
unread = client.get_unread_count()
hls = client.get_headlines(feed_id=-3)
fresh = 0
for article in hls:
fresh = fresh + 1
print "unread.value %s" % unread
print "fresh.value %s" % fresh
def config():
print """
graph_title Tiny Tiny RSS
graph_args -l 0 --base 1000
graph_args --base 1000
graph_vlabel Articles
graph_category Apps
graph_period second
graph_info This graph shows the current number RSS articles for Fredrik
unread.label Unread
unread.colour 663399
unread.max 10000
unread.min 0
unread.info The number of unread articles.
fresh.label Fresh
fresh.colour 336600
fresh.max 10000
fresh.min 0
fresh.info The number of articles within the last 24 hrs
"""
if len(sys.argv) > 1:
if sys.argv[1] == "autoconf":
autoconf()
elif sys.argv[1] == "config":
config()
else:
count()