1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 14:16:00 +00:00

Merge pull request #539 from ssm/fix/syntax-errors

Add syntax checking, and fix all syntax errors
This commit is contained in:
Stig Sandbeck Mathisen 2014-10-05 21:15:30 +02:00
commit 155a8dbd8c
66 changed files with 1895 additions and 1606 deletions

58
.travis.yml Normal file
View file

@ -0,0 +1,58 @@
---
language: perl
install:
- sudo apt-get update
- sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk ksh pylint
- sudo apt-get --no-install-recommends install pkg-config libdb-dev libvirt-dev libexpat-dev
# - Munin/Plugin.pm is in "munin-node" on precise
- sudo apt-get --no-install-recommends install munin-node
# Modules used by test script
- cpanm --notest Capture::Tiny
- cpanm --notest File::Find
- cpanm --notest Test::More
#
# Modules used by plugins
- cpanm --notest Asterisk::AMI
- cpanm --notest BerkeleyDB
- cpanm --notest Cache::Memcached
- cpanm --notest DBD::Pg
- cpanm --notest Data::Dump
- cpanm --notest Date::Manip
- cpanm --notest Date::Parse
- cpanm --notest DateTime::Format::ISO8601
- cpanm --notest Device::SerialPort
- cpanm --notest FCGI::Client
- cpanm --notest File::ReadBackwards
- cpanm --notest File::Tail::Multi
- cpanm --notest Graphics::ColorObject
- cpanm --notest IPC::Run3
- cpanm --notest IPC::ShareLite
- cpanm --notest JSON::Any
- cpanm --notest Mail::Sendmail
- cpanm --notest Modern::Perl
- cpanm --notest MooseX::POE
- cpanm --notest Net::DNS
- cpanm --notest Net::OpenSSH
- cpanm --notest Net::SNMP
- cpanm --notest Net::Telnet
- cpanm --notest Net::Telnet::Cisco
- cpanm --notest POE
- cpanm --notest POE::Component::IRC
- cpanm --notest POE::Quickie
- cpanm --notest Proc::ProcessTable
- cpanm --notest Redis
- cpanm --notest WWW::Mechanize::TreeBuilder
- cpanm --notest Text::Iconv
- cpanm --notest XML::LibXML
- cpanm --notest XML::Simple
- cpanm --notest XML::Smart
- cpanm --notest XML::Twig
- cpanm --notest nvidia::ml
# - Sys::Virt version matching the test system's libvirt-dev
- cpanm --notest DANBERR/Sys-Virt-0.9.8.tar.gz
# Modules used by plugins, but missing on cpan
# - Sun::Solaris::Kstat
# - VMware::VIRuntime
# - MythTV
script: "PERL5LIB=$PERL5LIB:/usr/share/perl5 prove"

View file

@ -63,7 +63,7 @@ if(defined($ARGV[0])) {
print "graph_total Total\n"; print "graph_total Total\n";
print "graph_vlabel Bits\n"; print "graph_vlabel Bits\n";
print "graph_category $server\n"; print "graph_category $server\n";
print "graph_info This graph show $server total bandwidth used by various "\ print "graph_info This graph show $server total bandwidth used by various " .
"projects.\n"; "projects.\n";
while ((my $project, my @files) = each(%logs)) { while ((my $project, my @files) = each(%logs)) {
print $project.".label $project\n"; print $project.".label $project\n";

View file

@ -60,7 +60,7 @@ if(defined($ARGV[0])) {
print "graph_args --base 1000\n"; print "graph_args --base 1000\n";
print "graph_vlabel bits per \${graph_period} in (-) / out (+)\n"; print "graph_vlabel bits per \${graph_period} in (-) / out (+)\n";
print "graph_category $server\n"; print "graph_category $server\n";
print "graph_info This graph show $server in/out bandwidth used by various"\ print "graph_info This graph show $server in/out bandwidth used by various" .
" projects.\n"; " projects.\n";
while ((my $project, my @files) = each(%logs)) { while ((my $project, my @files) = each(%logs)) {
print "i".$project.".label $project\n"; print "i".$project.".label $project\n";

View file

@ -19,7 +19,7 @@ room=${0##*tinychat_users_}
## ##
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
# Check that curl is installed # Check that curl is installed
if hash curl &>/dev/null; then if hash curl >/dev/null 2>&1; then
echo "yes" echo "yes"
else else
echo "no (no curl installed)" echo "no (no curl installed)"

View file

@ -69,7 +69,7 @@ GPLv2
CONFIGDIR=$(awk -F : '/^configdirectory:/ { gsub(/ /, "", $2); print $2 }' /etc/imapd.conf 2> /dev/null) CONFIGDIR=$(awk -F : '/^configdirectory:/ { gsub(/ /, "", $2); print $2 }' /etc/imapd.conf 2> /dev/null)
PROCDIR="${CONFIGDIR}/proc" PROCDIR="${CONFIGDIR}/proc"
if [ "$1" == "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ "x${CONFIGDIR}x" != "xx" ] && [ -d ${PROCDIR} ]; then if [ "x${CONFIGDIR}x" != "xx" ] && [ -d ${PROCDIR} ]; then
echo yes echo yes
else else
@ -79,14 +79,14 @@ if [ "$1" == "autoconf" ]; then
fi fi
# Check if we actually got some sensible data # Check if we actually got some sensible data
if [ "x${CONFIGDIR}x" == "xx" ]; then if [ "x${CONFIGDIR}x" = "xx" ]; then
exit 1 exit 1
fi fi
# If run with the "config"-parameter, give out information on how the # If run with the "config"-parameter, give out information on how the
# graphs should look. # graphs should look.
if [ "$1" == "config" ]; then if [ "$1" = "config" ]; then
echo 'graph_title Cyrus IMAPd Load' echo 'graph_title Cyrus IMAPd Load'
echo 'graph_args --base 1000 -l 0' echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel connections' echo 'graph_vlabel connections'

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# -*- sh -*- # -*- sh -*-
# vim: ft=sh # vim: ft=sh

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Plugin to monitor hylafax queue # Plugin to monitor hylafax queue
# #

View file

@ -4,14 +4,14 @@
# env.LOGFILE /var/log/proftpd/proftpd.log # env.LOGFILE /var/log/proftpd/proftpd.log
if [ "$1" = 'config' ]; then if [ "$1" = 'config' ]; then
echo "graph_args --base 1000 -l 0" echo "graph_args --base 1000 -l 0"
echo "graph_title Serveur FTP" echo "graph_title Serveur FTP"
echo "graph_category Ftp" echo "graph_category Ftp"
echo "graph_vlabel Stats Proftpd" echo "graph_vlabel Stats Proftpd"
echo "succes.label Login succes" echo "succes.label Login succes"
echo "succes.draw AREA" echo "succes.draw AREA"
echo "failed.label Login failed" echo "failed.label Login failed"
echo "failed.draw AREA" echo "failed.draw AREA"
fi fi
LOGFILE=${LOGFILE:-"/var/log/proftpd/proftpd.log"} LOGFILE=${LOGFILE:-"/var/log/proftpd/proftpd.log"}

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# #
# Script to show pureftp counts. # Script to show pureftp counts.
@ -30,10 +30,10 @@ if [ "$1" = "config" ]; then
echo 'graph_title FTP Server' echo 'graph_title FTP Server'
echo 'graph_args --base 1000 -l 0' echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel Daily FTP Operations' echo 'graph_vlabel Daily FTP Operations'
echo 'graph_category FTP' echo 'graph_category FTP'
echo 'graph_period second' echo 'graph_period second'
echo 'ftp_put.type GAUGE' echo 'ftp_put.type GAUGE'
echo 'ftp_get.type GAUGE' echo 'ftp_get.type GAUGE'
echo 'ftp_put.label Files PUT' echo 'ftp_put.label Files PUT'
echo 'ftp_get.label Files GET' echo 'ftp_get.label Files GET'
exit 0 exit 0
@ -44,4 +44,3 @@ echo $(grep "`date '+%Y-%m-%d'`" /var/log/pure-ftpd/transfer.log | grep [[:spac
echo -n echo -n
echo -en "ftp_get.value " echo -en "ftp_get.value "
echo $(grep "`date '+%Y-%m-%d'`" /var/log/pure-ftpd/transfer.log | grep [[:space:]]\\[\\]sent[[:space:]] | wc -l) echo $(grep "`date '+%Y-%m-%d'`" /var/log/pure-ftpd/transfer.log | grep [[:space:]]\\[\\]sent[[:space:]] | wc -l)

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
########################## ##########################
# googlecode_ # googlecode_
########################## ##########################

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# -*- sh -*- # -*- sh -*-
: << =cut : << =cut

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Plugin to graph response times of the specified websites/URLs. # Plugin to graph response times of the specified websites/URLs.
# #

View file

@ -1,4 +1,4 @@
#! @@PERL@@ -w #!/usr/bin/perl
# -*- perl -*- # -*- perl -*-
=pod =pod

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
do_config() { do_config() {
graph=( 2 # number of graphs. graph=( 2 # number of graphs.

View file

@ -1,4 +1,4 @@
#! @@PERL@@ -w #!/usr/bin/perl
# -*- perl -*- # -*- perl -*-
=head1 NAME =head1 NAME

View file

@ -92,7 +92,7 @@ graph_vlabel ${vlabel}
graph_category ${category} graph_category ${category}
graph_info ${info} graph_info ${info}
EOH1 EOH1
[[ -n "${period}" ]] && echo "graph_period ${period}" [ -n "${period}" ] && echo "graph_period ${period}"
I=1 I=1
for name in ${names}; do for name in ${names}; do
eval iquery='${query_'${name}'}' eval iquery='${query_'${name}'}'

View file

@ -71,7 +71,8 @@
#%# family=auto #%# family=auto
#%# capabilities=autoconf #%# capabilities=autoconf
use DBI; use DBI;
use MythTV; eval 'use MythTV; 1;'
or die 'Please install MythTV';
use strict; use strict;
use warnings; use warnings;
use Munin::Plugin; use Munin::Plugin;

View file

@ -1,4 +1,4 @@
#!/usr/bin/ruby -rauto_gem #!/usr/bin/ruby
# #
# Munin plugin for the D-link DIR-655 router # Munin plugin for the D-link DIR-655 router
# #

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# #
# Munin plugin to show changing the ip address by ddclient. # Munin plugin to show changing the ip address by ddclient.

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Wildcard-plugin to monitor IP addresses through iptables. To monitor an # Wildcard-plugin to monitor IP addresses through iptables. To monitor an
# IP, link fwbuilder_<ipaddress> to this file. E.g. # IP, link fwbuilder_<ipaddress> to this file. E.g.

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Munin plugin for HFSC Traffic Shaping Statistics # Munin plugin for HFSC Traffic Shaping Statistics
# #

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Munin plugin for HFSC Traffic Shaping Statistics UP/DOWN # Munin plugin for HFSC Traffic Shaping Statistics UP/DOWN
# #

View file

@ -84,7 +84,7 @@ IFACES=`$iptables -L munin_node -nvx | awk '$6 ~ /(eth|ppp)[0-9]/ { if (done[$6]
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then
# echo "graph_order out in" # echo "graph_order out in"
if [ "$TYPE" == "pkts" ]; then if [ "$TYPE" = "pkts" ]; then
echo "graph_title pkts" echo "graph_title pkts"
echo 'graph_vlabel pkts per ${graph_period}' echo 'graph_vlabel pkts per ${graph_period}'
else else
@ -107,7 +107,7 @@ if [ "$1" = "config" ]; then
exit 0 exit 0
fi; fi;
if [ "$TYPE" == "pkts" ]; then if [ "$TYPE" = "pkts" ]; then
$iptables -L munin_node -nvx | egrep "eth|ppp" | awk "{ print \$6 \".value \" \$1 }" $iptables -L munin_node -nvx | egrep "eth|ppp" | awk "{ print \$6 \".value \" \$1 }"
else else
$iptables -L munin_node -nvx | egrep "eth|ppp" | awk "{ print \$6 \".value \" \$2 }" $iptables -L munin_node -nvx | egrep "eth|ppp" | awk "{ print \$6 \".value \" \$2 }"

View file

@ -55,6 +55,7 @@ NETSTAT=${netstat:-`which netstat`}
NETSTAT=${NETSTAT:-/usr/bin/netstat} NETSTAT=${NETSTAT:-/usr/bin/netstat}
PORTS=${ports:-389 636} PORTS=${ports:-389 636}
TEMP_FILE=$(mktemp /tmp/munin_ldap.XXXXXX) TEMP_FILE=$(mktemp /tmp/munin_ldap.XXXXXX)
trap "rm -f ${TEMP_FILE}" EXIT
PATH=/bin:/usr/bin:/usr/local/bin PATH=/bin:/usr/bin:/usr/local/bin
SOCKET=${socket:-/var/run/openldap/ldapi} SOCKET=${socket:-/var/run/openldap/ldapi}
@ -96,7 +97,7 @@ if [ "$1" = "autoconf" ]; then
for port in $PORTS; do for port in $PORTS; do
ONE_LISTENING=${ONE_LISTENING}$(find_ips_bound $port) ONE_LISTENING=${ONE_LISTENING}$(find_ips_bound $port)
done done
rm -f $TEMP_FILE
if [ -n "$ONE_LISTENING" ]; then if [ -n "$ONE_LISTENING" ]; then
echo yes echo yes
exit 0 exit 0
@ -121,17 +122,26 @@ if [ "$1" = "config" ]; then
echo "socket.label ldapi" echo "socket.label ldapi"
fi fi
fi fi
rm -f $TEMP_FILE
exit 0 exit 0
fi fi
for port in $LISTENING_PORTS; do for port in $LISTENING_PORTS; do
for ip in $(find_ips_bound $port); do for ip in $(find_ips_bound $port); do
echo "$(echo $ip | sed 's/\./_/g')_${port}.value $(grep "^tcp[46]\{0,1\}\([[:space:]]\{1,\}[[:digit:]]\{1,\}\)\{2\}[[:space:]]\{1,\}$ip[\.:]$port[[:space:]].*ESTABLISHED$" $TEMP_FILE | wc -l | sed 's/[[:space:]]*//g')"
label=$(printf "%s_%d" "$(echo $ip | tr ':.' '_')" "$port")
connections=$(
awk -v ip_port="${ip}:${port}" \
'BEGIN { counter=0 }
$1 ~ /tcp[46]?/ && $4 == ip_port && $6 == "ESTABLISHED" { counter++ }
END { print counter }' \
$TEMP_FILE
)
printf "%s.value %d\n" "$label" "$connections"
done done
done done
if [ -e "$SOCKET" ]; then if [ -e "$SOCKET" ]; then
echo "socket.value $($NETSTAT -an ${FAMILYMARK}unix | grep $SOCKET | wc -l | sed 's/[[:space:]]*//g')" echo "socket.value $($NETSTAT -an ${FAMILYMARK}unix | grep $SOCKET | wc -l | sed 's/[[:space:]]*//g')"
fi fi
rm -f $TEMP_FILE

View file

@ -72,7 +72,14 @@ USA.
use strict; use strict;
use warnings; use warnings;
use threads;
# This evil "eval" is to make Travis CI able to test the plugin syntax
# without having a perl built with threads.
#
# Also: The use of interpreter-based threads in perl is officially
# discouraged.
eval 'use threads; 1;' or die 'Could not use threads';
use Net::Ping; use Net::Ping;
my (%defaults, @hosts, $cmd_arg); my (%defaults, @hosts, $cmd_arg);

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# #
# Munin plugin to show the up- / download stream of the actual # Munin plugin to show the up- / download stream of the actual

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# A Munin Plugin to show umts signal strength using gcom # A Munin Plugin to show umts signal strength using gcom
# Created by Derik Vercueil <jfvercueil@yahoo.co.uk> # Created by Derik Vercueil <jfvercueil@yahoo.co.uk>

View file

@ -64,7 +64,7 @@ if(defined($ARGV[0])) {
print "graph_total Total\n"; print "graph_total Total\n";
print "graph_vlabel Bits\n"; print "graph_vlabel Bits\n";
print "graph_category $server\n"; print "graph_category $server\n";
print "graph_info This graph show $server total bandwidth used by various "\ print "graph_info This graph show $server total bandwidth used by various " .
"projects.\n"; "projects.\n";
while ((my $project, my @files) = each(%logs)) { while ((my $project, my @files) = each(%logs)) {
print $project.".label $project\n"; print $project.".label $project\n";

View file

@ -61,7 +61,7 @@ if(defined($ARGV[0])) {
print "graph_args --base 1000\n"; print "graph_args --base 1000\n";
print "graph_vlabel bits per \${graph_period} in (-) / out (+)\n"; print "graph_vlabel bits per \${graph_period} in (-) / out (+)\n";
print "graph_category $server\n"; print "graph_category $server\n";
print "graph_info This graph show $server in/out bandwidth used by various"\ print "graph_info This graph show $server in/out bandwidth used by various" .
" projects.\n"; " projects.\n";
while ((my $project, my @files) = each(%logs)) { while ((my $project, my @files) = each(%logs)) {
print "i".$project.".label $project\n"; print "i".$project.".label $project\n";

View file

@ -72,7 +72,7 @@ for i in $LIST1; do
done done
# If TOTU is 0, change to 1 for avoid problem in the division # If TOTU is 0, change to 1 for avoid problem in the division
if [[ $TOTU -eq 0 ]]; then if [ "$TOTU" = "0" ]; then
TOTU=1 TOTU=1
fi fi

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# #
# Script to show adsl router stats for routers with Conexant based chips and the standard Conexant web admin gui like the eTec EpicRouter... # Script to show adsl router stats for routers with Conexant based chips and the standard Conexant web admin gui like the eTec EpicRouter...

View file

@ -29,7 +29,7 @@ usage() {
echo 'For testing the script, run qstatcod4and5_ cods IP PORT' echo 'For testing the script, run qstatcod4and5_ cods IP PORT'
echo ' - GameType : cods ... run qstat for seeing available gametype' echo ' - GameType : cods ... run qstat for seeing available gametype'
echo 'For munin you must ln -s /usr/share/munin/plugins/qstatcod4and5_ /etc/munin/plugins/cod4_cods_IP_PORT' echo 'For munin you must ln -s /usr/share/munin/plugins/qstatcod4and5_ /etc/munin/plugins/cod4_cods_IP_PORT'
echo 'Example you will test this COD4 Server: 123.456.789.123:28960 echo 'Example you will test this COD4 Server: 123.456.789.123:28960'
echo 'your symlink looks like this: ln -s /usr/share/munin/plugins/cod4server /etc/munin/plugins/cod4_cods_123.456.789.123_28960' echo 'your symlink looks like this: ln -s /usr/share/munin/plugins/cod4server /etc/munin/plugins/cod4_cods_123.456.789.123_28960'
echo 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe}; echo 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe};
echo 'Have Fun' echo 'Have Fun'

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
####################################################################################################################### #######################################################################################################################
# #
# = PowerMTA Munin multi-monitor = # = PowerMTA Munin multi-monitor =

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
vmta="208-97-205-153" vmta="208-97-205-153"
# Lets run the command to pull the vmta's in # Lets run the command to pull the vmta's in

View file

@ -1,4 +1,4 @@
#!/sbin/sh #!/bin/sh
# See /usr/include/sys/dk.h ! # See /usr/include/sys/dk.h !
PATH=/usr/bin:/usr/sbin:/sbin PATH=/usr/bin:/usr/sbin:/sbin

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Plugin to monitor CPU share, for a selected set of processes. Tested on Linux. # Plugin to monitor CPU share, for a selected set of processes. Tested on Linux.
# #

View file

@ -1,37 +1,63 @@
#!/bin/sh #!/bin/sh
#
# Plugin to monitor the number of connections to RabbitMQ
#
# Usage: Link or copy into /etc/munin/node.d/
#
# Parameters
# env.conn_warn <warning connections>
# env.conn_crit <critical connections>
#
# Magic markers (optional - only used by munin-config and some
# installation scripts):
#
#%# family=auto
#%# capabilities=autoconf
# If run with the "autoconf"-parameter, give our opinion on wether we : << =cut
# should be run on this system or not. This is optinal, and only used by
# munin-config. In the case of this plugin, we should most probably
# always be included.
if [ "$1" = "autoconf" ]; then =head1 NAME
echo yes
exit 0
fi
HOME=/tmp/ rabbitmq_connections - monitor the number of connections to RabbitMQ
=head1 CONFIGURATION
You will need to add configuration to
/etc/munin/plugin-conf.d/rabbitmq_connection.conf for this plugin to
work.
=over 2
=item C<user>
Required. Valid choices are C<rabbitmq> and C<root>. This is required
by C<rabbitmqctl>.
=item C<env.conn_warn>
Optional, default value is 500
=item C<env.conn_crit>
Optional, default value is 1000
=back
=head2 EXAMPLE CONFIGURATION
[rabbitmq_connections]
user rabbitmq
env.conn_warn 512
env.conn_crit 1024
=head1 MAGIC MARKERS
#%# family=contrib
=cut
case $(whoami) in
rabbitmq|root)
;;
*)
echo 'Error: Plugin requires "user" to be set in plugin configuration.' >&2
echo 'See "munindoc rabbitmq_connections" for more information' >&2
exit 1
;;
esac
# If run with the "config"-parameter, give out information on how the # If run with the "config"-parameter, give out information on how the
# graphs should look. # graphs should look.
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then
CONN_WARN=${queue_warn:-500} CONN_WARN=${conn_warn:-500}
CONN_CRIT=${queue_crit:-1000} CONN_CRIT=${conn_crit:-1000}
# The host name this plugin is for. (Can be overridden to have # The host name this plugin is for. (Can be overridden to have
# one machine answer for several) # one machine answer for several)
@ -63,4 +89,11 @@ fi
# real work - i.e. display the data. Almost always this will be # real work - i.e. display the data. Almost always this will be
# "value" subfield for every data field. # "value" subfield for every data field.
echo "connections.value $(HOME=$HOME rabbitmqctl list_connections | grep -v "^Listing" | grep -v "done.$" | wc -l)" if hash rabbitmqctl >/dev/null 2>&1; then
connections=$(HOME=/tmp rabbitmqctl list_connections state | grep -c running)
else
echo "$0: Could not run rabbitmqctl" >&2
connections=U
fi
printf "connections.value %s\n" "$connections"

View file

@ -32,7 +32,7 @@ reddit_user=${0##*reddit_karma_}
## ##
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
# Check that curl is installed # Check that curl is installed
if hash curl &>/dev/null; then if hash curl >/dev/null 2>&1; then
echo "yes" echo "yes"
else else
echo "no (no curl installed)" echo "no (no curl installed)"

View file

@ -269,7 +269,7 @@ if 'MUNIN_CAP_MULTIGRAPH' not in os.environ:
# Parse host_name and counter type from arg0 # Parse host_name and counter type from arg0
called_as = os.path.basename(sys.argv[0]) called_as = os.path.basename(sys.argv[0])
regex_str = '^snmp_'(.+)'_brocade_ifs' regex_str = r'^snmp_(.+)_brocade_ifs'
match = re.match(regex_str, called_as) match = re.match(regex_str, called_as)
if match: if match:
host_name = match.group(1) host_name = match.group(1)

View file

@ -133,12 +133,6 @@ if (!defined ($session))
die "Croaking: could not establish SNMP object"; die "Croaking: could not establish SNMP object";
} }
if (!defined ($session))
{
die "Croaking: $error";
}
if ($ARGV[0] and $ARGV[0] eq "config") if ($ARGV[0] and $ARGV[0] eq "config")
{ {
print "host_name $host\n"; print "host_name $host\n";

View file

@ -40,11 +40,11 @@ if [ "$1" = "suggest" ]; then
if [ ! "$RC" != "0" ] ; then if [ ! "$RC" != "0" ] ; then
FILE=`basename $0` FILE=`basename $0`
DIR=`dirname $0` DIR=`dirname $0`
HOSTNAME=`host $IP | sed s/.*pointer//\ ` HOST_NAME=`host $IP | sed s/.*pointer//\ `
HOSTNAME=`echo $HOSTNAME | sed -e 's/\.$//'` HOST_NAME=`echo $HOST_NAME | sed -e 's/\.$//'`
LINKDIR="/etc/munin/plugins/" LINKDIR="/etc/munin/plugins/"
LINKFILE=`echo $FILE | sed s/__/_$HOSTNAME_/` LINKFILE=`echo $FILE | sed s/__/_$HOST_NAME_/`
echo file $FILE dir $DIR hostname $HOSTNAME linkdir $LINKDIR linkfile $LINKFILE echo file $FILE dir $DIR hostname $HOST_NAME linkdir $LINKDIR linkfile $LINKFILE
#echo "ln -s $DIR/$FILE $LINKNAME" #echo "ln -s $DIR/$FILE $LINKNAME"
fi fi

View file

@ -1,4 +1,5 @@
#!/usr/bin/ruby #!/usr/bin/ruby
# encoding: utf-8
# Plugin to monitor Room Alert 11E environmental units. # Plugin to monitor Room Alert 11E environmental units.
# Requires ruby and the ruby SNMP library. # Requires ruby and the ruby SNMP library.

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# A Munin Plugin to show auth stuff # A Munin Plugin to show auth stuff
# Created by Dominik Schulz <lkml@ds.gauner.org> # Created by Dominik Schulz <lkml@ds.gauner.org>

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Script to monitor iostat cpu|tps. # Script to monitor iostat cpu|tps.
# #

View file

@ -73,7 +73,8 @@ else
sub value # get value for variables sub value # get value for variables
{ {
my %h_ramvalues; my %h_ramvalues;
use Sun::Solaris::Kstat; eval 'use Sun::Solaris::Kstat; 1;'
or die 'Please install Sun::Solaros::Kstat';
my $Kstat = Sun::Solaris::Kstat->new(); my $Kstat = Sun::Solaris::Kstat->new();
# --- Fetch Hardware info --- # --- Fetch Hardware info ---

View file

@ -71,7 +71,8 @@ else
sub value sub value
{ {
my %h_swapvalue; my %h_swapvalue;
use Sun::Solaris::Kstat; eval 'use Sun::Solaris::Kstat; 1;'
or die 'Please install Sun::Solaris::Kstat';
my $Kstat = Sun::Solaris::Kstat->new(); my $Kstat = Sun::Solaris::Kstat->new();
# --- Fetch Hardware info --- # --- Fetch Hardware info ---

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/php
<?php <?php
# plugin made by Dju # plugin made by Dju

View file

@ -1,4 +1,4 @@
#!@@PERL@@ #!/usr/bin/perl
# -*- perl -*- # -*- perl -*-
# #
# varnish4_ - Munin plugin to for Varnish 4.x # varnish4_ - Munin plugin to for Varnish 4.x

View file

@ -115,9 +115,14 @@ use strict;
use sort 'stable'; # guarantee stability use sort 'stable'; # guarantee stability
no warnings; # don't want warnings in output no warnings; # don't want warnings in output
use VMware::VIRuntime; # need to install VIM SDK (vSphere CLI/SDK 4.1 or newer) # need to install VIM SDK (vSphere CLI/SDK 4.1 or newer)
use VMware::VILib; eval 'use VMware::VIRuntime; 1;'
use VMware::VIExt; or die 'Please install vSphere SDK for VMware::* modules';
eval 'use VMware::VILib; 1;'
or die 'Please install vSphere SDK for VMware::* modules';
eval 'use VMware::VIExt; 1;'
or die 'Please install vsphere SDK for VMware::* modules';
use Data::Dumper; use Data::Dumper;
use DateTime::Format::ISO8601; # may need to install "libdatetime-format-iso8601-perl" on Debian-based systems use DateTime::Format::ISO8601; # may need to install "libdatetime-format-iso8601-perl" on Debian-based systems
use List::Util qw(sum max); use List::Util qw(sum max);

View file

@ -51,7 +51,7 @@ fi
DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)") DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)")
for dom in $DOMAINS; do for dom in $DOMAINS; do
dev=$( xm list $dom --long | awk '/vifname / { print $2 }' | sed 's/)//' ) dev=$( xm list $dom --long | awk '/vifname / { print $2 }' | sed 's/)//' )
if [ "$dev" == "" ]; then if [ "$dev" = "" ]; then
dev=$( xm network-list $dom |\ dev=$( xm network-list $dom |\
egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@') egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@')
fi fi

View file

@ -64,7 +64,11 @@
#%# capabilities=autoconf suggest #%# capabilities=autoconf suggest
use strict; use strict;
use Munin::Plugin;
# Need to use eval EXPR here. "-T" is used on the command line, and
# munin is not installable in a reasonable way for automated testing.
eval 'use Munin::Plugin; 1;' or die 'Please install Munin::Plugin';
use File::Basename; use File::Basename;
use IO::Socket::UNIX qw(SOCK_STREAM); use IO::Socket::UNIX qw(SOCK_STREAM);

175
t/test.t Normal file
View file

@ -0,0 +1,175 @@
# -*- perl -*-
use strict;
use warnings;
use Test::More;
use File::Find ();
use Capture::Tiny ':all';
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;
my $num_plugins = 0;
sub wanted {
my ( $dev, $ino, $mode, $nlink, $uid, $gid, $interpreter, $arguments );
( ( $dev, $ino, $mode, $nlink, $uid, $gid ) = lstat($_) )
&& -f _
&& ( ( $interpreter, $arguments ) = hashbang("$_") )
&& ($interpreter)
&& ++$num_plugins
&& process_file( $_, $name, $interpreter, $arguments );
}
File::Find::find( { wanted => \&wanted }, 'plugins' );
sub hashbang {
my ($filename) = @_;
open my $file, '<', $filename;
my $firstline = <$file>;
close $file;
$firstline =~ m{ ^\#! # hashbang
\s* # optional space
(?:/usr/bin/env\s+)? # optional /usr/bin/env
(?<interpreter>\S+) # interpreter
(?:\s+
(?<arguments>[^\n]*) # optional interpreter arguments
)?
}xms;
return ( $+{interpreter}, $+{arguments} );
}
sub process_file {
my ( $file, $filename, $interpreter, $arguments ) = @_;
use v5.10.1;
if ( $interpreter =~ m{/bin/sh} ) {
subtest $filename => sub {
plan tests => 2;
run_check(
{ command => [ 'sh', '-n', $file ],
description => 'sh syntax check'
}
);
run_check(
{ command => [ 'checkbashisms', $file ],
description => 'checkbashisms'
}
);
};
}
elsif ( $interpreter =~ m{/bin/ksh} ) {
run_check(
{ command => [ 'ksh', '-n', $file ],
description => 'ksh syntax check',
filename => $filename
}
);
}
elsif ( $interpreter =~ m{bash} ) {
run_check(
{ command => [ 'bash', '-n', $file ],
description => 'bash syntax check',
filename => $filename
}
);
}
elsif ( $interpreter =~ m{perl} ) {
my $command;
if ( $arguments =~ m{-.*T}mx ) {
$command = [ 'perl', '-cwT', $file ];
}
else {
$command = [ 'perl', '-cw', $file ];
}
run_check(
{ command => $command,
description => 'perl syntax check',
filename => $filename
}
);
}
elsif ( $interpreter =~ m{python} ) {
run_check(
{ command => [ 'python', '-m', 'py_compile', $file ],
description => 'python compile',
filename => $filename
}
);
}
elsif ( $interpreter =~ m{php} ) {
run_check(
{ command => [ 'php', '-l', $file ],
description => 'php syntax check',
filename => $filename
}
);
}
elsif ( $interpreter =~ m{j?ruby} ) {
run_check(
{ command => [ 'ruby', '-cw', $file ],
description => 'ruby syntax check',
filename => $filename
}
);
}
elsif ( $interpreter =~ m{gawk} ) {
run_check(
{ command => [
'gawk', '--source', 'BEGIN { exit(0) } END { exit(0) }',
'--file', $file
],
description => 'gawk syntax check',
filename => $filename
}
);
}
elsif ( $interpreter =~ m{expect} ) {
SKIP: {
skip 'no idea how to check expect scripts', 1;
pass("No pretending everything is ok");
}
}
else {
fail( $filename . " unknown interpreter " . $interpreter );
}
}
sub run_check {
my ($args) = @_;
my $check_command = $args->{command};
my $description = $args->{description};
my $filename = $args->{filename};
my $message;
if ($filename) {
$message = sprintf( '%s: %s', $filename, $description );
}
else {
$message = $description;
}
my ( $stdout, $stderr, $exit ) = capture {
system( @{$check_command} );
};
ok( ( $exit == 0 ), $message );
if ($exit) {
diag(
sprintf(
"\nCommand: %s\n\nSTDOUT:\n\n%s\n\nSTDERR:\n\n%s\n\n",
join( " ", @{$check_command} ),
$stdout, $stderr
)
);
}
}
done_testing($num_plugins);