From f637dc37d96a1715634734c5ef9d7d5ecd13a447 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 30 Jan 2008 21:37:34 +0000 Subject: rearranged some stuff git-svn-id: https://svn/ipuppet/trunk/modules/munin@607 d66ca3ae-40d7-4aa7-90d4-87d79ca94279 --- files/plugins/gentoo_lastupdated | 71 ++++++++++++++++++++++ files/plugins/selinux_avcstats | 111 ++++++++++++++++++++++++++++++++++ files/plugins/selinuxenforced | 32 ++++++++++ files/plugins/xen | 52 ++++++++++++++++ files/plugins/xen-cpu | 125 +++++++++++++++++++++++++++++++++++++++ files/plugins/xen_memory | 63 ++++++++++++++++++++ files/plugins/xen_vbd | 109 ++++++++++++++++++++++++++++++++++ 7 files changed, 563 insertions(+) create mode 100755 files/plugins/gentoo_lastupdated create mode 100755 files/plugins/selinux_avcstats create mode 100755 files/plugins/selinuxenforced create mode 100755 files/plugins/xen create mode 100755 files/plugins/xen-cpu create mode 100755 files/plugins/xen_memory create mode 100755 files/plugins/xen_vbd (limited to 'files') diff --git a/files/plugins/gentoo_lastupdated b/files/plugins/gentoo_lastupdated new file mode 100755 index 0000000..42fd362 --- /dev/null +++ b/files/plugins/gentoo_lastupdated @@ -0,0 +1,71 @@ +#!/usr/bin/perl +# -*- perl -*- +# +# (C) 2007 immerda project +# +# Plugin to monitor the last update of the gentoo +# +# Parameters: +# +# config +# autoconf +# +# $Id: users.in 1212 2006-10-29 20:11:58Z janl $ +# +#%# family=auto +#%# capabilities=autoconf + +# update /etc/munin/plugin-conf.d/munin-node with: +# [gentoo_*] +# user root +# env.logfile /var/log/emerge.log +# env.tail /usr/bin/tail +# env.grep /bin/grep + +my $logfile = $ENV{'logfile'} || '/var/log/emerge.log'; +my $grep = $ENV{'grep'} || `which grep`; +my $date = $ENV{'date'} || `which date`; +my $tail = $ENV{'tail'} || `which tail`; +chomp($grep); +chomp($date); +chomp($tail); + +if ( defined($ARGV[0])) { + if ($ARGV[0] eq 'autoconf') { + print "yes\n"; + exit 0; + } + + if ( $ARGV[0] eq "config" ) { + print "graph_title Gentoo: Last update X days ago\n"; + #print "graph_args --base 1000 -l 0\n"; + print "graph_vlabel days\n"; + print "graph_scale no\n"; + print "graph_category system\n"; + #print "graph_printf %.1lf\n"; + print "lastupdated.label last updated [d ago]\n"; + print "lastupdated.type GAUGE\n"; + #print "tty.draw AREASTACK\n"; + #print "tty.colour 00FF00\n"; + exit 0; + } +} + +$days = 0; +$last = 0; +$now = 0; + +$l=`$grep "emerge" $logfile | $grep world | $grep -v fetchonly | tail -1`; + +($last,$rest) = split /:/,$l; +$now = `$date +%s`; +if($last eq "" or $last == 0 or $now == 0 or $date eq ""){ + $days = ""; +}else{ + $days=($now-$last)/60/60/24; # in tagen +} + +print "lastupdated.value $days\n"; + +# vim:syntax=perl + diff --git a/files/plugins/selinux_avcstats b/files/plugins/selinux_avcstats new file mode 100755 index 0000000..9687be0 --- /dev/null +++ b/files/plugins/selinux_avcstats @@ -0,0 +1,111 @@ +#!/bin/sh +# +# Plugin to monitor SELinux's Access Vector Cache (AVC). +# +# config (required) +# autoconf (optional - used by munin-config) +# +# Lars Strand, 2007 +# +# +# Magic markers (used by munin-config and some installation scripts (i.e. +# optional)): +#%# family=auto +#%# capabilities=autoconf + + +AVCSTATS="/selinux/avc/cache_stats" + +if [ "$1" = "autoconf" ]; then + if [ -r $AVCSTATS ]; then + echo yes + exit 0 + else + echo no + exit 1 + fi +fi + +if [ "$1" = "config" ]; then + + echo "graph_title SELinux's Access Vector Cache" + echo 'graph_args -l 0 --base 1000' + echo 'graph_vlabel AVC operations' + echo 'graph_category system' + + echo 'lookups.label lookups' + echo 'lookups.type DERIVE' + echo 'lookups.min 0' + echo 'lookups.max 1000000000' + echo 'lookups.draw AREA' + echo 'lookups.colour ff0000' # Red + echo 'lookups.info Number of access vector lookups. This number is a good indicator of the load beeing placed on the AVC.' + + echo 'hits.label hits' + echo 'hits.type DERIVE' + echo 'hits.min 0' + echo 'hits.max 1000000000' + echo 'hits.draw STACK' + echo 'hits.colour 0022ff' # Blue + echo 'hits.info Number of access vector hits.' + + echo 'misses.label misses' + echo 'misses.type DERIVE' + echo 'misses.min 0' + echo 'misses.max 1000000000' + echo 'misses.draw STACK' + echo 'misses.colour 990000' # Darker red + echo 'misses.info Number of cache misses.' + + echo 'allocations.label allocations' + echo 'allocations.type DERIVE' + echo 'allocations.min 0' + echo 'allocations.max 100000000' + echo 'allocations.draw STACK' + echo 'allocations.colour ffa500' # Orange + echo 'allocations.info Number of AVC entries allocated.' + + echo 'reclaims.label reclaims' + echo 'reclaims.type DERIVE' + echo 'reclaims.min 0' + echo 'reclaims.max 1000000000' + echo 'reclaims.draw STACK' + echo 'reclaims.colour 00aaaa' # Darker turquoise + echo 'reclaims.info Number of current total reclaimed AVC entries. If this keeps changing, you may need to increase the cache size (/selinux/avc/cache_threshold).' + + echo 'frees.label frees' + echo 'frees.type DERIVE' + echo 'frees.min 0' + echo 'frees.max 1000000000' + echo 'frees.draw STACK' + echo 'frees.colour 00ff7f' # Spring green + echo 'frees.info Number of free AVC entries.' + + exit 0 +fi + +if [ -r $AVCSTATS ]; then + awk ' NR > 1 { + lookups += $1; + hits += $2; + misses += $3; + allocations += $4; + reclaims += $5; + frees += $6; + } END { + print "lookups.value " lookups; + print "hits.value " hits; + print "misses.value " misses; + print "allocations.value " allocations; + print "reclaims.value " reclaims; + print "frees.value " frees; + } ' < $AVCSTATS +else + echo "lookups.value U" + echo "hits.value U" + echo "misses.value U" + echo "allocations.value U" + echo "reclaims.value U" + echo "frees.value U" +fi + diff --git a/files/plugins/selinuxenforced b/files/plugins/selinuxenforced new file mode 100755 index 0000000..2f88b9b --- /dev/null +++ b/files/plugins/selinuxenforced @@ -0,0 +1,32 @@ +#!/bin/sh +# -*- sh -*- +# +# Plugin to count the daily amount of Virii (qmailscan) +# +# Contributed by David Obando (david@cryptix.de) - 03.12.2005 +# + +# define the logfiles. when you rotate them at any other time than 00:00 you have to define two logfiles: +#LOG0=/var/spool/qmailscan/quarantine.log +#LOG1=/var/spool/qmailscan/quarantine.log.1 + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + echo 'graph_title enforced amount' + echo 'graph_args --upper-limit 1 -l 0 ' + echo 'graph_vlabel Is the system selinux enforced?' + echo 'graph_scale no\n'; + echo 'graph_category selinux' + echo 'enforced.label IsEnforced' + #echo 'enforced.draw AREA' + echo 'enforced.draw LINE2' + + exit 0 +fi + +echo -n "enforced.value " && cat /selinux/enforce + diff --git a/files/plugins/xen b/files/plugins/xen new file mode 100755 index 0000000..575cd3b --- /dev/null +++ b/files/plugins/xen @@ -0,0 +1,52 @@ +#!/bin/sh +# +# Script to monitor CPU usage of Xen domains +# +# Parameters understood: +# +# conifg (required) +# autoconf (optinal - used by munin-config) +# + +MAXDOMAINS=16 + +if [ "$1" = "autoconf" ]; then + if which xm > /dev/null ; then + echo yes + exit 0 + fi + echo "no (xm not found)" + exit 1 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title Xen Domain Utilerisation' + echo 'graph_args --base 1000 -l 0' + echo 'graph_scale no' + echo 'graph_vlabel mS' + echo 'graph_category xen' + echo 'graph_info This graph shows of many mS wall time where used by a domain' + /usr/sbin/xm list | grep -v "^Name .* Console$" | \ + while read name domid mem cpu state time console; do + name=`echo $name | sed -e"s/-/_/"` + echo "$name.label $name" + echo "$name.type COUNTER" +# if [ "$name" = "Domain_0" ]; then +# echo "$name.draw AREA" +# else +# echo "$name.draw STACK" +# fi + echo "$name.min 0" + echo "$name.info Wall clock time spend for $name" + done + exit 0 +fi + +/usr/sbin/xm list | grep -v "^Name" | grep -v "^Name .* Console$" | \ +while read name domid mem cpu state time console; do + name=`echo $name | sed -e"s/-/_/"` + time=`echo $time | sed -e "s/\.//"` + echo "$name.value $time" +done + diff --git a/files/plugins/xen-cpu b/files/plugins/xen-cpu new file mode 100755 index 0000000..0ef301e --- /dev/null +++ b/files/plugins/xen-cpu @@ -0,0 +1,125 @@ +#!/usr/bin/perl -wT +# +# Script to minitor the cpu usage of Xen domains +# +# Author: Adam Crews shroom com> +# +# License: GPL +# Based on the origional xen script from Matthias Pfafferodt, syntron at web.de +# +# Note: Your munin config must run this as root. +# +# Parameters +# config (required) +# autoconf (optional - used by munin-config) +# +#%# family=auto +#%# capabilities=autoconf + +# Define where to find xm tools +my $XM = '/usr/sbin/xm'; +my $XMTOP = '/usr/sbin/xentop'; + +############## +# You should not need to edit anything below here +# + +use strict; + +$ENV{PATH} = '/bin:/usr/bin:/usr/sbin'; + +my $arg; undef($arg); +if (defined($ARGV[0])) { + $arg = 'config' if ($ARGV[0] eq 'config'); + $arg = 'autoconf' if ($ARGV[0] eq 'autoconf'); + + if ( "$arg" eq 'autoconf') { + if ( -e $XM && -e $XMTOP ) { + print "yes\n"; + exit 0; + } else { + print "no ($XM and/or $XMTOP not found\n"; + exit 1; + } + } + + if ( "$arg" eq 'config') { + my %cnf; undef(%cnf); + %cnf = ( + 'graph_title' => 'Xen Domain CPU Usage', + 'graph_args' => '--base 1000 -l 0 --upper-limit 100 --rigid', + 'graph_vlabel' => 'Percent (%)', + 'graph_category' => 'xen', + 'graph_info' => 'Display the % of CPU Usage for each domain', + ); + + my @domains = `$XM list`; + shift(@domains); # we dont need the header line + my $cnt = "0"; + foreach my $domain ( @domains ) { + my ($dom,undef) = split(/\s/, $domain, 2); + # we need to change - and . to _ or things get weird with the graphs + # some decent quoting would probably fix this, but this works for now + $dom =~ s/[-.]/_/g; + + $cnf{ "$dom" . '.label' } = "$dom"; + $cnf{ "$dom" . '.draw' } = 'STACK'; + $cnf{ "$dom" . '.min' } = '0'; + $cnf{ "$dom" . '.max' } = '100'; + $cnf{ "$dom" . '.info' } = '% CPU used for ' . "$dom"; + + if ( "$cnt" == "0") { $cnf{$dom.'.draw'} = 'AREA'; } + $cnt++; + } + + foreach my $key (sort(keys(%cnf))) { + print "$key $cnf{$key}\n"; + } + exit 0; + } +} + +# Nothing was passed as an argument, so let's just return the proper values + +my @chunks; undef(@chunks); + +{ + # run the xentop command a few times because the first reading is not always accurate + local $/ = undef; + @chunks = split(/^xentop - .*$/m, `$XMTOP -b -i2 -d2`); +} + +# Take only the last run of xentop +my @stats = split (/\n/,pop(@chunks)); + +# remove the first 4 items that are junk that we don't need. +shift(@stats); +shift(@stats); +shift(@stats); +shift(@stats); + +my %vals; undef(%vals); + +foreach my $domain (@stats) { + # trim the leading whitespace + $domain =~ s/^\s+//; + my @v_tmp = split(/\s+/, $domain); + + # we need to change - and . to _ or things get weird with the graphs + # some decent quoting would probably fix this, but this works for now + $v_tmp[0] =~ s/[-.]/_/g; + + $vals{$v_tmp[0]}{'cpu_percent'} = $v_tmp[3]; + $vals{$v_tmp[0]}{'vcpu'} = $v_tmp[8]; + if ( $vals{$v_tmp[0]}{'vcpu'} =~ m/n\/a/ ) { + my $cpu = `grep -c "processor" < /proc/cpuinfo`; + if ( $cpu =~ m/^(\d+)$/ ) { + $vals{$v_tmp[0]}{'vcpu'} = $1; + } + } +} + +foreach my $key (sort(keys(%vals))) { + print "$key.value " . ($vals{$key}{'cpu_percent'}/$vals{'Domain_0'}{'vcpu'}), "\n"; +} + diff --git a/files/plugins/xen_memory b/files/plugins/xen_memory new file mode 100755 index 0000000..90bc705 --- /dev/null +++ b/files/plugins/xen_memory @@ -0,0 +1,63 @@ +#!/bin/sh +# +# Script to monitor memory status of the xen host +# +# Parameters understood: +# +# config (required) +# autoconf (optional - used by munin-config) +# + +MAXDOMAINS=16 + +if [ "$1" = "autoconf" ]; then + if which xm > /dev/null ; then + echo yes + exit 0 + fi + echo "no (xm not found)" + exit 1 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title Xen Memory' + echo 'graph_args --base 1000 -l 0' + echo 'graph_scale no' + echo 'graph_vlabel MB' + echo 'graph_category xen' + echo 'graph_info This graph shows of many mS wall time where used by a domain' + # xm info | while read name bla value; do echo "$name $value"; done + /usr/sbin/xm info | while read name bla value; do + #total_memory 2047 + #free_memory 1476 + name=`echo $name | sed -e"s/-/_/"` + + if [ "$name" = "total_memory" ]; then + echo "$name.label $name" + echo "$name.type GAUGE" + echo "$name.min 0" + echo "$name.info total memory" + fi + if [ "$name" = "free_memory" ]; then + echo "$name.label $name" + echo "$name.type GAUGE" + echo "$name.draw AREA" +# echo "$name.draw STACK" + echo "$name.min 0" + echo "$name.info free memory" + fi + done + exit 0 +fi + +/usr/sbin/xm info | while read name bla value; do + name=`echo $name | sed -e"s/-/_/"` + if [ "$name" = "total_memory" ]; then + echo "$name.value $value" + fi + if [ "$name" = "free_memory" ]; then + echo "$name.value $value" + fi +done + diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd new file mode 100755 index 0000000..238bf08 --- /dev/null +++ b/files/plugins/xen_vbd @@ -0,0 +1,109 @@ +#!/usr/bin/perl +# +# 2007-06-01 Zoltan HERPAI +# +# Credits goes for: +# Adam Crews for his xen_cpu plugin +# Mario Manno for his xen_traffic_all plugin +# +# Script to monitor the I/O usage of Xen domains +# Version 0.1 +# +#%# family=auto +#%# capabilities=autoconf + +# Location of xm tools +$XM = '/usr/sbin/xm'; +$XMTOP = '/usr/sbin/xentop'; + +# ah, parameters coming in +if ( defined($ARGV[0])) +{ + if ($ARGV[0] eq 'config') { $arg = 'config'; } + if ($ARGV[0] eq 'autoconf') { $arg = 'autoconf'; } + + if ( $arg eq 'autoconf' ) + { + if ( -e $XM && -e $XMTOP ) + { + print "yes\n"; + exit 0; + } + else + { + print "no ($XM and/or $XMTOP not found\n"; + exit 0; + } + } + + if ( $arg eq 'config' ) + { + %cnf = ( + 'graph_title' => 'Xen Domain I/O usage', + 'graph_args' => '--base 1024 -l 0', + 'graph_vlabel' => 'read (-), write (+)', + 'graph_category' => 'xen', + 'graph_info' => 'Display the I/O operations for each domain', + ); + + @domains = `$XM list`; + shift(@domains); # we don't need the header line + + foreach $domain ( @domains ) + { + ($dom, undef) = split(/\s/, $domain); + $dom =~ s/[-.]/_/g; + + $cnf{ $dom.'RD' . '.label' } = 'read'; + $cnf{ $dom.'RD' . '.type' } = 'COUNTER'; + $cnf{ $dom.'RD' . '.graph' } = 'no'; + $cnf{ $dom.'RD' . '.cdef' } = $dom.'RD,8,*'; + + $cnf{ $dom.'WR' . '.label' } = $dom; + $cnf{ $dom.'WR' . '.type' } = 'COUNTER'; + $cnf{ $dom.'WR' . '.negative' } = $dom.'RD'; + $cnf{ $dom.'WR' . '.cdef' } = $dom.'WR,8,*'; + + if ( "$cnt" == "0" ) + { + $cnf { "$dom" . '.draw' } = 'AREA'; + } + $cnt++; + } + + foreach $key ( sort(keys(%cnf)) ) + { + print "$key $cnf{$key}\n"; + } + exit 0; + + } +} + + +# No args, get rolling +# NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR SSID +$tmpfile = "/tmp/munin_xen_vbd_tmp"; + +system("$XMTOP -b -i1 > $tmpfile"); +open(I,"$tmpfile"); +while(){ + chomp; + s/^\s*//g; + @tmp=split(/\s+/, $_); + next if $tmp[0] eq "NAME"; + + $domname = $tmp[0]; + $domname =~ s/[-.]/_/g; + $vbdrd = $tmp[14]; + $vbdwr = $tmp[15]; + + $vals{$domname."RD"}{'value'} = $vbdrd; + $vals{$domname."WR"}{'value'} = $vbdwr; +} + +foreach $key ( sort(keys(%vals)) ) +{ + print "$key.value " . ($vals{$key}{'value'}) . "\n"; +} + -- cgit v1.2.3 From 62f6d972b6ca769bf7b75e78615bc0f3ffbbb081 Mon Sep 17 00:00:00 2001 From: am Date: Thu, 31 Jan 2008 16:18:21 +0000 Subject: =?UTF-8?q?tinydns=20munin=20modul=20f=C3=BCr=20immer1-4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn/ipuppet/trunk/modules/munin@635 d66ca3ae-40d7-4aa7-90d4-87d79ca94279 --- files/plugins/tinydns | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100755 files/plugins/tinydns (limited to 'files') diff --git a/files/plugins/tinydns b/files/plugins/tinydns new file mode 100755 index 0000000..0fb78ff --- /dev/null +++ b/files/plugins/tinydns @@ -0,0 +1,172 @@ +#!/usr/bin/perl -T + +# tinydns-munin-plugin + +# Copyright (C) 2007 admin at immerda.ch +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# with the HELP of +# tinygraph -- a RRDtool frontend for tinydns statistics +# Copyright (C) 2005 Ulrich Zehl + +#use strict; # to activate .... + + +#use Time::TAI64 qw(tai2unix); + +$A = 0; +$NS = 0; +$CNAME = 0; +$SOA = 0; +$PTR = 0; +$HINFO = 0; +$MX = 0; +$TXT = 0; +$RP = 0; +$SIG = 0; +$KEY = 0; +$AAAA = 0; +$A6 = 0; +$IXFR = 0; +$AXFR = 0; +$ANY = 0; + +$logfile = $ENV{logdir} || "/var/tinydns/log/main/current"; + +if ( $ARGV[0] and $ARGV[0] eq "config" ) +{ + print "host_name $ENV{FQDN}\n"; + print "graph_title tinydns\n"; + print "graph_args --base 1000 -l 0\n"; + print "graph_category DNS\n"; + print "a.type COUNTER\n"; + print "mx.type COUNTER\n"; + + print "a.label A\n"; + print "ns.label NS\n"; + print "cname.label CNAME\n"; + print "soa.label SOA\n"; + print "ptr.label PTR\n"; + print "mx.label MX\n"; + print "aaaa.label AAAA\n"; + print "any.label ANY\n"; + print "hinfo.label HINFO\n"; + print "txt.label TXT\n"; + print "rp.label RP\n"; + print "sig.label SIG\n"; + print "key.label KEY\n"; + print "a6.label A6\n"; + print "ixfr.label IXFR\n"; + print "axfr.label AXFR\n"; + + print "a.type COUNTER\n"; + print "ns.type COUNTER\n"; + print "cname.type COUNTER\n"; + print "soa.type COUNTER\n"; + print "ptr.type COUNTER\n"; + print "mx.type COUNTER\n"; + print "aaaa.type COUNTER\n"; + print "any.type COUNTER\n"; + print "hinfo.type COUNTER\n"; + print "txt.type COUNTER\n"; + print "rp.type COUNTER\n"; + print "sig.type COUNTER\n"; + print "key.type COUNTER\n"; + print "a6.type COUNTER\n"; + print "ixfr.type COUNTER\n"; + print "axfr.type COUNTER\n"; + exit 0; +} + +my %querytypes = ( + '0001' => 'A', + '0002' => 'NS', + '0005' => 'CNAME', + '0006' => 'SOA', + '000c' => 'PTR', + '000d' => 'HINFO', + '000f' => 'MX', + '0010' => 'TXT', + '0011' => 'RP', + '0018' => 'SIG', + '0019' => 'KEY', + '001c' => 'AAAA', + '0026' => 'A6', + '00fb' => 'IXFR', + '00fc' => 'AXFR', + '00ff' => 'ANY', +); + +my %sum = ( + (map {$_ => 0} values %querytypes), +); + +sub process_line($) +{ + my $line = shift; + if ($line =~ /^(@[a-f0-9]{24}) ([a-f0-9]{8}):[a-f0-9]{4}:[a-f0-9]{4} ([\+\-IC\/]) ([a-f0-9]{4}) (.+)$/) + { + #my $time = tai2unix($1); + my $ip = join(".", unpack("C*", pack("H8", $2))); + my $rtype = $3; + my $qtype = $querytypes{$4}; + #my $qstring = $5; # currently unused + + if ($rtype eq '+') + { + if ($qtype eq 'A'){$A++;}; + if ($qtype eq 'NS'){$NS++;}; + if ($qtype eq 'CNAME'){$CNAME++;}; + if ($qtype eq 'SOA'){$SOA++;}; + if ($qtype eq 'PTR'){$PTR++;}; + if ($qtype eq 'HINFO'){$HINFO++;}; + if ($qtype eq 'MX'){$MX++;}; + if ($qtype eq 'TXT'){$TXT++;}; + if ($qtype eq 'RP'){$RP++;}; + if ($qtype eq 'SIG'){$SIG++;}; + if ($qtype eq 'KEY'){$KEY++;}; + if ($qtype eq 'AAAA'){$AAAA++;}; + if ($qtype eq 'A6'){$A6++;}; + if ($qtype eq 'IXFR'){$IXFR++;}; + if ($qtype eq 'AXFR'){$AXFR++;}; + if ($qtype eq 'ANY'){$ANY++;}; + } + } +} + +open(LOG, "<$logfile") or die "Error opening $logfile: $!"; + +while () +{ + process_line($_); +} + +print "a.value $A\n"; +print "ns.value $NS\n"; +print "cname.value $CNAME\n"; +print "soa.value $SOA\n"; +print "ptr.value $PTR\n"; +print "mx.value $MX\n"; +print "aaaa.value $AAAA\n"; +print "any.value $ANY\n"; +print "hinfo.value $HINFO\n"; +print "txt.value $TXT\n"; +print "rp.value $RP\n"; +print "sig.value $SIG\n"; +print "key.value $KEY\n"; +print "a6.value $A6\n"; +print "ixfr.value $IXFR\n"; +print "axfr.value $AXFR\n"; + -- cgit v1.2.3 From bad976aee83677afeccdd9750fe791e7665fbfbd Mon Sep 17 00:00:00 2001 From: am Date: Fri, 1 Feb 2008 11:46:02 +0000 Subject: =?UTF-8?q?neuer=20versuch=20mit=20munin=20f=C3=BCr=20immer1-5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn/ipuppet/trunk/modules/munin@662 d66ca3ae-40d7-4aa7-90d4-87d79ca94279 --- files/plugins/pg__connections | 142 ++++++++++++++++++++++++++++++++++++++++++ files/plugins/pg__locks | 119 +++++++++++++++++++++++++++++++++++ files/plugins/pg_conn | 51 +++++++++++++++ 3 files changed, 312 insertions(+) create mode 100755 files/plugins/pg__connections create mode 100755 files/plugins/pg__locks create mode 100755 files/plugins/pg_conn (limited to 'files') diff --git a/files/plugins/pg__connections b/files/plugins/pg__connections new file mode 100755 index 0000000..ca95f56 --- /dev/null +++ b/files/plugins/pg__connections @@ -0,0 +1,142 @@ +#!/usr/bin/perl -w +# Plugin for monitor postgres connections. +# +# Licenced under GPL v2. +# +# Usage: +# +# Symlink into /etc/munin/plugins/ and add the monitored +# database to the filename. e.g.: +# +# ln -s /usr/share/munin/plugins/pg__connections \ +# /etc/munin/plugins/pg__connections +# This should, however, be given through autoconf and suggest. +# +# If required, give username, password and/or Postgresql server +# host through environment variables. +# +# You must also activate Postgresql statistics. See +# http://www.postgresql.org/docs/7.4/interactive/monitoring-stats.html +# for how to enable this. Specifically, the following lines must +# exist in your postgresql.conf: +# +# stats_start_collector = true +# stats_block_level = true +# +# +# Parameters: +# +# config (required) +# +# Config variables: +# +# dbhost - Which database server to use. Defaults to +# 'localhost'. +# dbname - Which database to use. Defaults to template1 +# dbuser - A Postgresql user account with read permission to +# the given database. Defaults to +# 'postgres'. Anyway, Munin must be told which user +# this plugin should be run as. +# dbpass - The corresponding password, if +# applicable. Default to undef. Remember that +# pg_hba.conf must be configured accordingly. +# +# Magic markers +#%# family=auto +#%# capabilities=autoconf + +use strict; +use DBI; + +my $dbhost = $ENV{'dbhost'} || '127.0.0.1'; +my $dbname = $ENV{'dbname'} || 'template1'; +my $dbuser = $ENV{'dbuser'} || 'postgres'; +my $dbuserx = $ENV{'dbuserx'} || ''; +my $dbport = $ENV{'dbport'} || '5432'; +my $dbpass = $ENV{'dbpass'} || ''; + +# Check for DBD::Pg +if (! eval "require DBD::Pg;") { + print "requires DBD::Pg\n"; + exit 1; +} + +my $dsn = "DBI:Pg:dbname=$dbname;host=$dbhost;port=$dbport"; +#print "$dsn\n"; +my $dbh = DBI->connect ($dsn, $dbuser, + $dbpass, + {RaiseError =>1}) || die ""; + + + +if (exists $ARGV[0]) { + if ($ARGV[0] eq 'autoconf') { + # Check for DBD::Pg + if (! eval "require DBD::Pg;") { + print "no (DBD::Pg not found)"; + exit 1; + } + if ($dbh) { + print "yes\n"; + exit 0; + } else { + print "no Unable to access Database $dbname on host $dbhost as user $dbuser.\nError returned was: ". $DBI::errstr; + exit 1; + } + } + + if ($ARGV[0] eq "config") { + my $sql_max = "SHOW max_connections;"; + my $sth_max = $dbh->prepare($sql_max); + $sth_max->execute(); + my ($max_connections) = $sth_max->fetchrow(); + my $warning = int ($max_connections * 0.7); + my $critical = int ($max_connections * 0.8); + print "graph_title PostgresSQL active connections\n"; + print "graph_args -l 0 --base 1000\n"; + print "graph_vlabel Connections\n"; + print "graph_category Postgresql\n"; + print "graph_info Shows active Postgresql connections from $dbname\n"; + + + my $sql = "select datname, count(*) from pg_stat_activity group by datname"; + my $sth = $dbh->prepare($sql); + $sth->execute(); + my $setarea = "yes"; + while ( my ($datname,$curr_conn) = $sth->fetchrow_array ) { + print "$datname.label $datname active connections\n"; + print "$datname.info $datname active connections\n"; + print "$datname.type GAUGE\n"; + if ($setarea eq "yes") { + print "$datname.draw AREA\n"; + $setarea=""; + } else { + print "$datname.draw STACK\n"; + } + } + + print "max_connections.label Max. connections\n"; + print "max_connections.info Max. connections\n"; + print "max_connections.type GAUGE\n"; + + print "warning $warning\n"; + print "critical $critical\n"; + exit 0; + } +} + + +# select datname, count(*) from pg_stat_activity group by datname +my $sql_max = "SHOW max_connections;"; +my $sth_max = $dbh->prepare($sql_max); +$sth_max->execute(); +my ($max_connections) = $sth_max->fetchrow(); + +#my $sql = "SELECT COUNT (*) FROM pg_stat_activity;"; +my $sql = "select datname, count(*) from pg_stat_activity group by datname"; +my $sth = $dbh->prepare($sql); +$sth->execute(); +while ( my ($datname,$curr_conn) = $sth->fetchrow_array ) { + print "$datname.value $curr_conn\n"; +} +print "max_connections.value $max_connections\n"; diff --git a/files/plugins/pg__locks b/files/plugins/pg__locks new file mode 100755 index 0000000..33a9a8a --- /dev/null +++ b/files/plugins/pg__locks @@ -0,0 +1,119 @@ +#!/usr/bin/perl -w +# Plugin for monitor postgres connections. +# +# Licenced under GPL v2. +# +# Usage: +# +# Symlink into /etc/munin/plugins/ and add the monitored +# database to the filename. e.g.: +# +# ln -s /usr/share/munin/plugins/pg__locks \ +# /etc/munin/plugins/pg__locks +# This should, however, be given through autoconf and suggest. +# +# If required, give username, password and/or Postgresql server +# host through environment variables. +# +# You must also activate Postgresql statistics. See +# http://www.postgresql.org/docs/8.1/interactive/monitoring-locks.html +# for how to enable this. Specifically, the following lines must +# exist in your postgresql.conf: +# +# stats_start_collector = true +# stats_block_level = true +# +# +# Parameters: +# +# config (required) +# +# Config variables: +# +# dbhost - Which database server to use. Defaults to +# 'localhost'. +# dbname - Which database to use. Defaults to template1 +# dbuser - A Postgresql user account with read permission to +# the given database. Defaults to +# 'postgres'. Anyway, Munin must be told which user +# this plugin should be run as. +# dbpass - The corresponding password, if +# applicable. Default to undef. Remember that +# pg_hba.conf must be configured accordingly. +# +# Magic markers +#%# family=auto +#%# capabilities=autoconf + +use strict; +use DBI; + +my $dbhost = $ENV{'dbhost'} || '127.0.0.1'; +my $dbname = $ENV{'dbname'} || 'template1'; +my $dbuser = $ENV{'dbuser'} || 'postgres'; +my $dbport = $ENV{'dbport'} || '5432'; +my $dbpass = $ENV{'dbpass'} || ''; + +# Check for DBD::Pg +if (! eval "require DBD::Pg;") { + exit 1; +} + +my $dsn = "DBI:Pg:dbname=$dbname;host=$dbhost;port=$dbport"; +#print "$dsn\n"; +my $dbh = DBI->connect ($dsn, $dbuser, + $dbpass, + {RaiseError =>1}) || die ""; + + + +if (exists $ARGV[0]) { + if ($ARGV[0] eq 'autoconf') { + # Check for DBD::Pg + if (! eval "require DBD::Pg;") { + print "no (DBD::Pg not found)"; + exit 1; + } + if ($dbh) { + print "yes\n"; + exit 0; + } else { + print "no Unable to access Database $dbname on host $dbhost as user $dbuser.\nError returned was: ". $DBI::errstr; + exit 1; + } + } + + if ($ARGV[0] eq "config") { + print "graph_title PostgresSQL locks\n"; + print "graph_args --base 1000\n"; + print "graph_vlabel Locks\n"; + print "graph_category Postgresql\n"; + print "graph_info Shows Postgresql locks\n"; + print "locks.label Locks\n"; + print "locks.info Locks (more info here, please... :)\n"; + print "locks.type GAUGE\n"; + print "locks.warning 5\n"; + print "locks.critical 10\n"; + print "exlocks.label Exclusive locks\n"; + print "exlocks.info Exclusive locks (here too, please... :)\n"; + print "exlocks.type GAUGE\n"; + print "exlocks.warning 5\n"; + print "exlocks.critical 10\n"; + exit 0; + } +} + +my $sql="SELECT mode,COUNT(mode) FROM pg_locks GROUP BY mode ORDER BY mode;"; +my $sth = $dbh->prepare ($sql); +$sth->execute (); +my $locks = 0; +my $exlocks = 0; +while (my ($mode, $count) = $sth->fetchrow ()) { + if ($mode =~ /exclusive/i) { + $exlocks = $exlocks + $count; + } + $locks = $locks+$count; +} +print "locks.value $locks\n"; +print "exlocks.value $exlocks\n"; + diff --git a/files/plugins/pg_conn b/files/plugins/pg_conn new file mode 100755 index 0000000..aa2ebb7 --- /dev/null +++ b/files/plugins/pg_conn @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Plugin to monitor PostgreSQL connections. +# +# Parameters: +# +# config (required) +# autoconf (optional - only used by munin-config) +# Based on netstat plugin +# $Log$ +# eric@ohmforce.com +# +# +# Magic markers (optional - used by munin-config and some installation +# scripts): +#%# family=auto +#%# capabilities=autoconf + + + +if [ "$1" = "autoconf" ]; then + if ( netstat -s 2>/dev/null >/dev/null ); then + echo yes + exit 0 + else + if [ $? -eq 127 ] + then + echo "no (netstat program not found)" + exit 1 + else + echo no + exit 1 + fi + fi +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title PostgreSQL' + echo 'graph_args -l 0 ' + echo 'graph_vlabel Number of PostgreSQL connections' + echo 'graph_category postgresql' + echo 'graph_period second' + echo 'graph_info This graph shows the number of opened connections on PostgreSQL.' + echo 'established.label established' + echo 'established.type GAUGE' + echo 'established.max 500' + echo 'established.info The number of currently open connections.' + exit 0 +fi +netstat -a | awk '{ print $4 }'| grep postgres | wc -l | xargs echo established.value -- cgit v1.2.3 From ef97c202ad675255deb20bdfce59fe03ad757a63 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 29 Mar 2008 14:27:08 +0000 Subject: fixed header git-svn-id: https://svn/ipuppet/trunk/modules/munin@1142 d66ca3ae-40d7-4aa7-90d4-87d79ca94279 --- files/plugins/selinuxenforced | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'files') diff --git a/files/plugins/selinuxenforced b/files/plugins/selinuxenforced index 2f88b9b..16a3f66 100755 --- a/files/plugins/selinuxenforced +++ b/files/plugins/selinuxenforced @@ -1,14 +1,9 @@ #!/bin/sh # -*- sh -*- # -# Plugin to count the daily amount of Virii (qmailscan) +# Plugin to monitor the status of selinux # -# Contributed by David Obando (david@cryptix.de) - 03.12.2005 -# - -# define the logfiles. when you rotate them at any other time than 00:00 you have to define two logfiles: -#LOG0=/var/spool/qmailscan/quarantine.log -#LOG1=/var/spool/qmailscan/quarantine.log.1 +# Contributed by admin(at)immerda.ch if [ "$1" = "autoconf" ]; then echo yes -- cgit v1.2.3 From bb8699288512aa2d1de7ad12b0420146f8daabfd Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 30 Mar 2008 17:34:40 +0000 Subject: added default apache modules git-svn-id: https://svn/ipuppet/trunk/modules/munin@1152 d66ca3ae-40d7-4aa7-90d4-87d79ca94279 --- files/plugins/apache_activity | 99 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 files/plugins/apache_activity (limited to 'files') diff --git a/files/plugins/apache_activity b/files/plugins/apache_activity new file mode 100755 index 0000000..65fc072 --- /dev/null +++ b/files/plugins/apache_activity @@ -0,0 +1,99 @@ +#!/usr/bin/perl +# +# Parameters supported: +# +# config +# autoconf +# +# Configurable variables +# +# url - Override default status-url +# +# Magic markers: +#%# family=auto +#%# capabilities=autoconf + +my $ret = undef; +if (!eval "require LWP::UserAgent;") { + $ret = "LWP::UserAgent not found"; +} + +my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto"; +my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80); +my %chars = ( + # '\_' => 'Waiting', + # 'S' => 'Starting up', + 'R' => 'Reading request', + 'W' => 'Sending reply', + 'K' => 'Keepalive', + 'D' => 'DNS lookup', + 'C' => 'Closing', + # 'L' => 'Logging', + # 'G' => 'Gracefully finishing', + # 'I' => 'Idle cleanup', + # '\.' => 'Open slot', + ); + +# "_" Waiting for Connection, "S" Starting up, "R" Reading Request, +# "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, +# "C" Closing connection, "L" Logging, "G" Gracefully finishing, +# "I" Idle cleanup of worker, "." Open slot with no current process + +if (exists $ARGV[0] and $ARGV[0] eq "autoconf") { + if ($ret) { + print "no ($ret)\n"; + exit 1; + } + my $ua = LWP::UserAgent->new(timeout => 30); + my @badports; + + foreach my $port (@PORTS) { + my $url = sprintf $URL, $port; + my $response = $ua->request(HTTP::Request->new('GET',$url)); + push @badports, $port unless $response->is_success and $response->content =~ /Scoreboard/im; + } + + if (@badports) { + print "no (no apache server-status on ports @badports)\n"; + exit 1; + } else { + print "yes\n"; + exit 0; + } +} + +if (exists $ARGV[0] and $ARGV[0] eq "config") { + print "graph_title Apache activity\n"; + print "graph_args --base 1000 -l 0\n"; + print "graph_category apache\n"; + print "graph_vlabel processes\n"; + foreach my $port (@PORTS) { + while (my ($char, $val) = each (%chars)) { + $char =~ s/\\\./dot/; + $char =~ s/\\\_/underline/; + print "activity_${port}_${char}.label "; + print $val, "\n"; + print "activity_${port}_${char}.type GAUGE\n"; + } + } + exit 0; +} + +foreach my $port (@PORTS) { + my $ua = LWP::UserAgent->new (timeout => 30); + my $url = sprintf $URL, $port; + my $response = $ua->request (HTTP::Request->new('GET',$url)); + if ($response->content =~ /^Scoreboard\:\s?(.*)$/sm) { + my $string = $1; + chomp $string; + my @act = split (//, $string); + foreach my $char (keys (%chars)) { + my $num = scalar (grep (/$char/, @act)); + $char =~ s/\\\./dot/; + $char =~ s/\\\_/underline/; + print "activity_${port}_${char}.value $num\n"; + } + } +} + + -- cgit v1.2.3