From 80cb37418a4c757b40354ddc57d8ef82736b46ff Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 15:38:36 +0200 Subject: [PATCH 01/96] Add automated tests --- .travis.yml | 15 ++++++++ t/test.t | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .travis.yml create mode 100644 t/test.t diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..45098892 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +--- +language: perl +install: + - sudo apt-get install devscripts python ruby php5-cli gawk + # + # Modules used by test script + - cpanm --notest Test::More File::Find Capture::Tiny + # + # Modules used by plugins + - cpanm --notest Asterisk::AMI Cache::Memcached BerkeleyDB DBD::Pg Data::Dump Device::SerialPort FCGI::Client File::ReadBackwards File::Tail::Multi Graphics::ColorNames IPC::Run3 IPC::ShareLite Modern::Perl MooseX::POE Net::Telnet Net::Telnet::Cisco POE Proc::ProcessTable Redis Sys::Virt WWW::Mechanize::TreeBuilder nvidia::ml + # Modules used by plugins, but missing on cpan + # - Sun::Solaris::Kstat + # - VMware::VIRuntime + # - MythTV +script: "prove" diff --git a/t/test.t b/t/test.t new file mode 100644 index 00000000..2d02b413 --- /dev/null +++ b/t/test.t @@ -0,0 +1,107 @@ +# -*- 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 ); + + ( ( $dev, $ino, $mode, $nlink, $uid, $gid ) = lstat($_) ) + && -f _ + && ( $interpreter = hashbang("$_") ) + && ++$num_plugins + && process_file( $_, $name, $interpreter ); +} + +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 + (?\S+) # interpreter + }xm; + + return $+{interpreter}; +} + +sub process_file { + my ( $file, $filename, $interpreter ) = @_; + use v5.10.1; + + if ( $interpreter =~ m{/bin/sh} ) { + subtest $filename => sub { + plan tests => 2; + ok( check_file_with( [ 'sh', '-n', $file ] ), "sh syntax check" ); + ok( check_file_with( [ 'checkbashisms', $file ] ), + "checkbashisms" ); + }; + } + elsif ( $interpreter =~ m{/bin/bash} ) { + ok( check_file_with( [ 'bash', '-n', $file ] ), + $filename . " bash syntax check" ); + } + elsif ( $interpreter =~ m{perl} ) { + ok( check_file_with( [ 'perl', '-cw', $file ] ), + $filename . " perl syntax check" ); + } + elsif ( $interpreter =~ m{python} ) { + ok( check_file_with( + [ 'pylint', '--errors-only', '--report=no', $file ] + ), + $filename . " python syntax check" + ); + } + elsif ( $interpreter =~ m{php} ) { + ok( check_file_with( [ 'php', '-l', $file ] ), + $filename . " php syntax check" ); + } + elsif ( $interpreter =~ m{j?ruby} ) { + ok( check_file_with( [ 'ruby', '-cw', $file ] ), + $filename . " ruby syntax check" ); + } + elsif ( $interpreter =~ m{gawk} ) { + ok( check_file_with( + [ 'gawk', '--source', "'BEGIN { exit(0) } END { exit(0) }'", + '--file', $file + ] + ), + $filename . " gawk syntax check" + ); + } + else { + fail( $filename . " unknown interpreter " . $interpreter ); + } +} + +sub check_file_with { + my ($check_command) = @_; + my ( $stdout, $stderr, $exit ) = capture { + system( @{$check_command} ); + }; + if ( $exit == 0 ) { + return 1; + } + else { + diag($stdout); + diag($stderr); + return; + } +} + +done_testing($num_plugins); From bb4550ffc8c8ff1c9ee8dfc0d8a4391f8cd65163 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 15:47:48 +0200 Subject: [PATCH 02/96] run "apt-get update", and keep install minimal --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 45098892..32be832b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ --- language: perl install: - - sudo apt-get install devscripts python ruby php5-cli gawk + - sudo apt-get update + - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk # # Modules used by test script - cpanm --notest Test::More File::Find Capture::Tiny From 67f74fbda23ac66075657da1c1dd920245e2fe95 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 15:54:02 +0200 Subject: [PATCH 03/96] Add libvirt and berkeleydb development libraries --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 32be832b..efa42737 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: perl install: - sudo apt-get update - - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk + - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk libdb5.3-dev libvirt-dev # # Modules used by test script - cpanm --notest Test::More File::Find Capture::Tiny From bfbae319503c6b92d993fa0bb52e8a2cd8b93195 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 15:57:15 +0200 Subject: [PATCH 04/96] use a non-versioned package --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index efa42737..57731096 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: perl install: - sudo apt-get update - - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk libdb5.3-dev libvirt-dev + - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk libdb-dev libvirt-dev # # Modules used by test script - cpanm --notest Test::More File::Find Capture::Tiny From a9118ccda79834185fa871da470186052d5aa8b3 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 16:14:38 +0200 Subject: [PATCH 05/96] Use a specific version of Sys::Virt - to match operatingsystem - also get build deps --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 57731096..28a1aa96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,15 @@ language: perl install: - sudo apt-get update - - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk libdb-dev libvirt-dev + - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk + - sudo apt-get install libdb-dev libvirt-dev libexpat-dev # # Modules used by test script - cpanm --notest Test::More File::Find Capture::Tiny # # Modules used by plugins - - cpanm --notest Asterisk::AMI Cache::Memcached BerkeleyDB DBD::Pg Data::Dump Device::SerialPort FCGI::Client File::ReadBackwards File::Tail::Multi Graphics::ColorNames IPC::Run3 IPC::ShareLite Modern::Perl MooseX::POE Net::Telnet Net::Telnet::Cisco POE Proc::ProcessTable Redis Sys::Virt WWW::Mechanize::TreeBuilder nvidia::ml + - cpanm --notest Asterisk::AMI Cache::Memcached BerkeleyDB DBD::Pg Data::Dump Device::SerialPort FCGI::Client File::ReadBackwards File::Tail::Multi Graphics::ColorNames IPC::Run3 IPC::ShareLite Modern::Perl MooseX::POE Net::Telnet Net::Telnet::Cisco POE Proc::ProcessTable Redis WWW::Mechanize::TreeBuilder nvidia::ml + - cpanm --notest DANBERR/Sys-Virt-1.2.2.tar.gz # Modules used by plugins, but missing on cpan # - Sun::Solaris::Kstat # - VMware::VIRuntime From e78f2c7a44b6cd8f62758f315461dc898dd412b2 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 16:29:05 +0200 Subject: [PATCH 06/96] adjust build dependencies for Sys::Virt --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28a1aa96..f977488e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,14 +3,15 @@ language: perl install: - sudo apt-get update - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk - - sudo apt-get install libdb-dev libvirt-dev libexpat-dev - # + - sudo apt-get --no-install-recommends install pkg-config libdb-dev libvirt-dev libexpat-dev + # Modules used by test script - cpanm --notest Test::More File::Find Capture::Tiny # # Modules used by plugins - cpanm --notest Asterisk::AMI Cache::Memcached BerkeleyDB DBD::Pg Data::Dump Device::SerialPort FCGI::Client File::ReadBackwards File::Tail::Multi Graphics::ColorNames IPC::Run3 IPC::ShareLite Modern::Perl MooseX::POE Net::Telnet Net::Telnet::Cisco POE Proc::ProcessTable Redis WWW::Mechanize::TreeBuilder nvidia::ml - - cpanm --notest DANBERR/Sys-Virt-1.2.2.tar.gz + # - 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 From a2024d95a2d73525a4dfb1878e90cda9736b4d62 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 16:33:02 +0200 Subject: [PATCH 07/96] Add "pylint" for syntax checks --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f977488e..cfc5c005 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: perl install: - sudo apt-get update - - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk + - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk pylint - sudo apt-get --no-install-recommends install pkg-config libdb-dev libvirt-dev libexpat-dev # Modules used by test script From 22bbd906a3d9e11354e7638a442c1c27d78a242c Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 16:42:48 +0200 Subject: [PATCH 08/96] split install lines, to keep sane --- .travis.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cfc5c005..d85ef88d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,32 @@ install: - sudo apt-get --no-install-recommends install pkg-config libdb-dev libvirt-dev libexpat-dev # Modules used by test script - - cpanm --notest Test::More File::Find Capture::Tiny + - cpanm --notest Capture::Tiny + - cpanm --notest File::Find + - cpanm --notest Test::More # # Modules used by plugins - - cpanm --notest Asterisk::AMI Cache::Memcached BerkeleyDB DBD::Pg Data::Dump Device::SerialPort FCGI::Client File::ReadBackwards File::Tail::Multi Graphics::ColorNames IPC::Run3 IPC::ShareLite Modern::Perl MooseX::POE Net::Telnet Net::Telnet::Cisco POE Proc::ProcessTable Redis WWW::Mechanize::TreeBuilder nvidia::ml + - cpanm --notest Asterisk::AMI + - cpanm --notest BerkeleyDB + - cpanm --notest Cache::Memcached + - cpanm --notest DBD::Pg + - cpanm --notest Data::Dump + - cpanm --notest Device::SerialPort + - cpanm --notest FCGI::Client + - cpanm --notest File::ReadBackwards + - cpanm --notest File::Tail::Multi + - cpanm --notest Graphics::ColorNames + - cpanm --notest IPC::Run3 + - cpanm --notest IPC::ShareLite + - cpanm --notest Modern::Perl + - cpanm --notest MooseX::POE + - cpanm --notest Net::Telnet + - cpanm --notest Net::Telnet::Cisco + - cpanm --notest POE + - cpanm --notest Proc::ProcessTable + - cpanm --notest Redis + - cpanm --notest WWW::Mechanize::TreeBuilder + - 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 From f043e1555ce4985984a872d327364f62341ffaca Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 16:43:37 +0200 Subject: [PATCH 09/96] Add more test dependencies --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index d85ef88d..b8a1b713 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ install: - cpanm --notest Cache::Memcached - cpanm --notest DBD::Pg - cpanm --notest Data::Dump + - cpanm --notest Date::Parse - cpanm --notest Device::SerialPort - cpanm --notest FCGI::Client - cpanm --notest File::ReadBackwards @@ -23,14 +24,19 @@ install: - cpanm --notest Graphics::ColorNames - cpanm --notest IPC::Run3 - cpanm --notest IPC::ShareLite + - cpanm --notest JSON::Any - cpanm --notest Modern::Perl - cpanm --notest MooseX::POE + - cpanm --notest Net::SNMP - cpanm --notest Net::Telnet - cpanm --notest Net::Telnet::Cisco - cpanm --notest POE - cpanm --notest Proc::ProcessTable - cpanm --notest Redis - cpanm --notest WWW::Mechanize::TreeBuilder + - cpanm --notest Text::Iconv + - cpanm --notest XML::Simple + - 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 From 528bec5859ede576168511666ee085ff91b5e421 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 16:53:17 +0200 Subject: [PATCH 10/96] Add "XML::LibXML" to test dependencies --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b8a1b713..4abad145 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,7 @@ install: - cpanm --notest Redis - cpanm --notest WWW::Mechanize::TreeBuilder - cpanm --notest Text::Iconv + - cpanm --notest XML::LibXML - cpanm --notest XML::Simple - cpanm --notest XML::Twig - cpanm --notest nvidia::ml From 2b6d5c5ac61dae002cb3d323b9ca65c8d33c2b55 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 16:55:41 +0200 Subject: [PATCH 11/96] Add some POE libs to test dependencies --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4abad145..add8100a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,8 @@ install: - 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 From 2ac1f7b84aa920b05a6538c05cb98b399c597738 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 16:58:35 +0200 Subject: [PATCH 12/96] More test dependencies --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index add8100a..93b32908 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,17 +16,21 @@ install: - cpanm --notest Cache::Memcached - cpanm --notest DBD::Pg - cpanm --notest Data::Dump + - cpanm --notest Date::Manip - cpanm --notest Date::Parse - cpanm --notest Device::SerialPort - cpanm --notest FCGI::Client - cpanm --notest File::ReadBackwards - cpanm --notest File::Tail::Multi - - cpanm --notest Graphics::ColorNames + - 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 From b8ef86efd6efc3e9a3c7e8f8fc9d30e5fbb87805 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 17:08:04 +0200 Subject: [PATCH 13/96] Install "munin-node" so we have access to Munin/Plugin.pm --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 93b32908..ecfcded4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ install: - sudo apt-get update - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk 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 From 8bda292b6459ac1f48016365fda47db67101f320 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 17:26:05 +0200 Subject: [PATCH 14/96] use Munin::Plugin (and whatever else) from system perl library --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ecfcded4..602e8ffa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,4 +53,4 @@ install: # - Sun::Solaris::Kstat # - VMware::VIRuntime # - MythTV -script: "prove" +script: "PERL5LIB=$PERL5LIB:/usr/share/perl5 prove" From 2333696650bd0973fa2508d6b0afe5e9c1334545 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:32:33 +0200 Subject: [PATCH 15/96] Syntax check ksh --- .travis.yml | 2 +- t/test.t | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 602e8ffa..fba41a51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: perl install: - sudo apt-get update - - sudo apt-get --no-install-recommends install devscripts python ruby php5-cli gawk pylint + - 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 diff --git a/t/test.t b/t/test.t index 2d02b413..8b507715 100644 --- a/t/test.t +++ b/t/test.t @@ -52,6 +52,10 @@ sub process_file { "checkbashisms" ); }; } + elsif ( $interpreter =~ m{/bin/ksh} ) { + ok( check_file_with( [ 'ksh', '-n', $file ] ), + $filename . " ksh syntax check" ); + } elsif ( $interpreter =~ m{/bin/bash} ) { ok( check_file_with( [ 'bash', '-n', $file ] ), $filename . " bash syntax check" ); @@ -62,7 +66,7 @@ sub process_file { } elsif ( $interpreter =~ m{python} ) { ok( check_file_with( - [ 'pylint', '--errors-only', '--report=no', $file ] + [ 'pylint', '--rcfile=/dev/null', '--errors-only', '--report=no', $file ] ), $filename . " python syntax check" ); @@ -98,8 +102,7 @@ sub check_file_with { return 1; } else { - diag($stdout); - diag($stderr); + diag(sprintf("\nCommand: %s\n\nSTDOUT:\n\n%s\n\nSTDERR:\n\n%s\n\n", join(" ", @{$check_command}), $stdout, $stderr)); return; } } From 92e7aaf801d1bf4b357a406027bf0729cf0f9035 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:43:08 +0200 Subject: [PATCH 16/96] relax bash regexp a bit, to allow for /usr/bin/env bash --- t/test.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/test.t b/t/test.t index 8b507715..0c4f6730 100644 --- a/t/test.t +++ b/t/test.t @@ -56,7 +56,7 @@ sub process_file { ok( check_file_with( [ 'ksh', '-n', $file ] ), $filename . " ksh syntax check" ); } - elsif ( $interpreter =~ m{/bin/bash} ) { + elsif ( $interpreter =~ m{bash} ) { ok( check_file_with( [ 'bash', '-n', $file ] ), $filename . " bash syntax check" ); } From 4ca527841485c970d4775687fd59cc98f95263d5 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 18:49:58 +0200 Subject: [PATCH 17/96] Set interpreter to "/usr/bin/perl" - No need for @@PERL@@ as interpreter in contrib --- plugins/jchkmail_counters_/jchkmail_counters_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/jchkmail_counters_/jchkmail_counters_ b/plugins/jchkmail_counters_/jchkmail_counters_ index 63c5f3e8..3302bed4 100644 --- a/plugins/jchkmail_counters_/jchkmail_counters_ +++ b/plugins/jchkmail_counters_/jchkmail_counters_ @@ -1,4 +1,4 @@ -#! @@PERL@@ -w +#!/usr/bin/perl # -*- perl -*- =pod From 098e1dde1ca8df0be3eaa99200ed4be6ded6a177 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 18:53:55 +0200 Subject: [PATCH 18/96] Set interpreter for to /bin/bash - Plugin uses several bash features, like arrays, and bare '((' --- plugins/logins/logins | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/logins/logins b/plugins/logins/logins index a50ca568..db7278b4 100755 --- a/plugins/logins/logins +++ b/plugins/logins/logins @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash do_config() { graph=( 2 # number of graphs. From ac2e2fda07b2056c365f75a58c2b0ff8bc0de32e Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 18:58:23 +0200 Subject: [PATCH 19/96] Use UNIX line breaks - Using DOS line breaks introduced syntax errors --- plugins/unicorn/unicorn_ | 138 +++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/plugins/unicorn/unicorn_ b/plugins/unicorn/unicorn_ index f54cfb3e..07682d87 100644 --- a/plugins/unicorn/unicorn_ +++ b/plugins/unicorn/unicorn_ @@ -1,69 +1,69 @@ -#!/bin/bash -# Copyright (c) 2013 Gareth Davies (shaolintiger@gmail.com www.shaolintiger.com) -# License GPLv2 -# This plugin monitors number of workers, total memory used and average memory per process for Unicorn. -# Here are the symlinks to enable it -# -# ln -s /usr/share/munin/plugins/unicorn_ /etc/munin/plugins/unicorn_average -# ln -s /usr/share/munin/plugins/unicorn_ /etc/munin/plugins/unicorn_memory -# ln -s /usr/share/munin/plugins/unicorn_ /etc/munin/plugins/unicorn_processes - -mode=`echo $0 | cut -d _ -f 2` - -if [ "$1" = "suggest" ]; then - echo "memory" - echo "processes" - echo "average" - exit 0 -fi - -if [ "$mode" = "memory" ]; then - if [ "$1" = "config" ]; then - echo "graph_title Total Unicorn Memory" - echo "graph_vlabel Total RAM" - echo "graph_category Unicorn" - echo "graph_args --base 1024" - echo "ram.label Total RAM" - exit 0 - else - - memory_array=(`ps auwx | grep "unicorn worker" | grep -v grep | awk '{print $6 }'`) - - for i in "${memory_array[@]}" - do - sum=$(( $sum + ( $i * 1024) )) - done - echo -n "ram.value " - echo $sum - - fi - -elif [ "$mode" = "processes" ]; then - if [ "$1" = "config" ]; then - echo "graph_title Unicorn Processes" - echo "graph_vlabel Processes" - echo "graph_category Unicorn" - echo "processes.label active processes" - else - echo -n "processes.value " - ps awwwux | grep 'unicorn worker' | grep -v grep | wc -l - exit 0 - fi - -elif [ "$mode" = "average" ]; then - if [ "$1" = "config" ]; then - echo 'graph_title Unicorn Average Process Size' - echo 'graph_args --base 1024 -l 0 ' - echo 'graph_vlabel Average Process Size' - echo 'graph_category Unicorn' - echo 'unicorn_average.label Average Process Size' - echo 'unicorn_average.draw LINE2' - echo 'unicorn_average.info The average process size for Unicorn' - else - echo -n "unicorn_average.value " - ps awwwux | grep 'unicorn worker' | grep -v grep | grep -v master | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}' - exit 0 - fi - -fi -exit 0 +#!/bin/bash +# Copyright (c) 2013 Gareth Davies (shaolintiger@gmail.com www.shaolintiger.com) +# License GPLv2 +# This plugin monitors number of workers, total memory used and average memory per process for Unicorn. +# Here are the symlinks to enable it +# +# ln -s /usr/share/munin/plugins/unicorn_ /etc/munin/plugins/unicorn_average +# ln -s /usr/share/munin/plugins/unicorn_ /etc/munin/plugins/unicorn_memory +# ln -s /usr/share/munin/plugins/unicorn_ /etc/munin/plugins/unicorn_processes + +mode=`echo $0 | cut -d _ -f 2` + +if [ "$1" = "suggest" ]; then + echo "memory" + echo "processes" + echo "average" + exit 0 +fi + +if [ "$mode" = "memory" ]; then + if [ "$1" = "config" ]; then + echo "graph_title Total Unicorn Memory" + echo "graph_vlabel Total RAM" + echo "graph_category Unicorn" + echo "graph_args --base 1024" + echo "ram.label Total RAM" + exit 0 + else + + memory_array=(`ps auwx | grep "unicorn worker" | grep -v grep | awk '{print $6 }'`) + + for i in "${memory_array[@]}" + do + sum=$(( $sum + ( $i * 1024) )) + done + echo -n "ram.value " + echo $sum + + fi + +elif [ "$mode" = "processes" ]; then + if [ "$1" = "config" ]; then + echo "graph_title Unicorn Processes" + echo "graph_vlabel Processes" + echo "graph_category Unicorn" + echo "processes.label active processes" + else + echo -n "processes.value " + ps awwwux | grep 'unicorn worker' | grep -v grep | wc -l + exit 0 + fi + +elif [ "$mode" = "average" ]; then + if [ "$1" = "config" ]; then + echo 'graph_title Unicorn Average Process Size' + echo 'graph_args --base 1024 -l 0 ' + echo 'graph_vlabel Average Process Size' + echo 'graph_category Unicorn' + echo 'unicorn_average.label Average Process Size' + echo 'unicorn_average.draw LINE2' + echo 'unicorn_average.info The average process size for Unicorn' + else + echo -n "unicorn_average.value " + ps awwwux | grep 'unicorn worker' | grep -v grep | grep -v master | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}' + exit 0 + fi + +fi +exit 0 From db1228b35d8de6c9d6a9666c341585637308ff1d Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:05:06 +0200 Subject: [PATCH 20/96] Use UNIX line breaks - using DOS line breaks introduced syntax errors --- plugins/samba/samba_locked | 80 +++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/plugins/samba/samba_locked b/plugins/samba/samba_locked index c9958c3b..787de0c6 100755 --- a/plugins/samba/samba_locked +++ b/plugins/samba/samba_locked @@ -1,40 +1,40 @@ -#!/bin/sh -# -# Plugin to monitor the number of Samba locked files on the machine. -# -# Parameters: -# -# config (required) -# autoconf (optional - used by munin-config) -# -# $Log$ -# Revision 1.0 2007/04/16 Jon Higgs -# Initial Release - Adapated from jimmyo's processses plugin. -# -# Magick markers (optional - used by munin-config and som installation -# scripts): -#%# family=auto -#%# capabilities=autoconf - -if [ "$1" = "autoconf" ]; then - echo yes - exit 0 -fi - -if [ "$1" = "config" ]; then - - echo 'graph_title Samba Locked Files' - echo 'graph_args --base 1000 -l 0 ' - echo 'graph_vlabel number of locked files' - echo 'graph_category Samba' - echo 'graph_info This graph shows the number locked Samba Files.' - echo 'samba_locked.label Locked Files' - echo 'samba_locked.draw LINE2' - echo 'samba_locked.info The current number of locked files.' - exit 0 -fi - -echo "samba_locked.value $(smbstatus -L 2> /dev/null | grep -c DENY_)" - -# If here, always return OK -exit 0 +#!/bin/sh +# +# Plugin to monitor the number of Samba locked files on the machine. +# +# Parameters: +# +# config (required) +# autoconf (optional - used by munin-config) +# +# $Log$ +# Revision 1.0 2007/04/16 Jon Higgs +# Initial Release - Adapated from jimmyo's processses plugin. +# +# Magick markers (optional - used by munin-config and som installation +# scripts): +#%# family=auto +#%# capabilities=autoconf + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title Samba Locked Files' + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel number of locked files' + echo 'graph_category Samba' + echo 'graph_info This graph shows the number locked Samba Files.' + echo 'samba_locked.label Locked Files' + echo 'samba_locked.draw LINE2' + echo 'samba_locked.info The current number of locked files.' + exit 0 +fi + +echo "samba_locked.value $(smbstatus -L 2> /dev/null | grep -c DENY_)" + +# If here, always return OK +exit 0 From 4658dd392c1089feb2a1f8b3629a0c68a66f4aa9 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:06:34 +0200 Subject: [PATCH 21/96] Use UNIX line breaks --- plugins/dxtv/hadoop-under_replicated-blocks | 38 ++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/plugins/dxtv/hadoop-under_replicated-blocks b/plugins/dxtv/hadoop-under_replicated-blocks index 2e313423..5fc49783 100755 --- a/plugins/dxtv/hadoop-under_replicated-blocks +++ b/plugins/dxtv/hadoop-under_replicated-blocks @@ -1,19 +1,19 @@ -#!/bin/sh - -#Author Juned Memon www.tipsNtrapS.com (juned.memon@tipsntraps.com) - -#To Check how stable the Hadoop filesystem is, we generally check number of under-replicated nodes in hadoop. This plugin graphs the under-replicated nodes in hadoop. - -case $1 in - config) - cat <<'EOM' -graph_title Under Replicated Blocks Hadoop -graph_category hadoop -graph_vlabel block -block.label block -EOM - exit 0;; -esac - -echo -n "block.value " -hadoop dfsadmin -report | grep "Under replicated blocks" | awk '{print $4}' +#!/bin/sh + +#Author Juned Memon www.tipsNtrapS.com (juned.memon@tipsntraps.com) + +#To Check how stable the Hadoop filesystem is, we generally check number of under-replicated nodes in hadoop. This plugin graphs the under-replicated nodes in hadoop. + +case $1 in + config) + cat <<'EOM' +graph_title Under Replicated Blocks Hadoop +graph_category hadoop +graph_vlabel block +block.label block +EOM + exit 0;; +esac + +echo -n "block.value " +hadoop dfsadmin -report | grep "Under replicated blocks" | awk '{print $4}' From f477c6748ee15c926f192bf1f7747653326a4c3f Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:40:59 +0200 Subject: [PATCH 22/96] Change interpreter to /bin/bash, since it uses bash features --- plugins/processes/process_cpushare | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/processes/process_cpushare b/plugins/processes/process_cpushare index 46ca5a97..d6ee3dc2 100755 --- a/plugins/processes/process_cpushare +++ b/plugins/processes/process_cpushare @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Plugin to monitor CPU share, for a selected set of processes. Tested on Linux. # From a0cb4d4344285999f42b22fbd3cf5931f15b3a7f Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:41:16 +0200 Subject: [PATCH 23/96] Use "/bin/sh" instead of "/sbin/sh" as interpreter --- plugins/processes/cpuutil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/processes/cpuutil b/plugins/processes/cpuutil index f8dd0021..57421392 100755 --- a/plugins/processes/cpuutil +++ b/plugins/processes/cpuutil @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh # See /usr/include/sys/dk.h ! PATH=/usr/bin:/usr/sbin:/sbin From de4ba4b5ac6706a7e9b8e41d3fc4c863e8c39e7b Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:45:24 +0200 Subject: [PATCH 24/96] Fix syntax error --- plugins/nginx/nginx_byprojects/byprojects_inout_bandwidth | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nginx/nginx_byprojects/byprojects_inout_bandwidth b/plugins/nginx/nginx_byprojects/byprojects_inout_bandwidth index d96ef0f3..6f62bc53 100644 --- a/plugins/nginx/nginx_byprojects/byprojects_inout_bandwidth +++ b/plugins/nginx/nginx_byprojects/byprojects_inout_bandwidth @@ -61,7 +61,7 @@ if(defined($ARGV[0])) { print "graph_args --base 1000\n"; print "graph_vlabel bits per \${graph_period} in (-) / out (+)\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"; while ((my $project, my @files) = each(%logs)) { print "i".$project.".label $project\n"; From 7afe6bfbf371a2951b4eade7004773e4458f7024 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:48:14 +0200 Subject: [PATCH 25/96] Fix syntax error --- plugins/nginx/nginx_byprojects/byprojects_bandwidth | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nginx/nginx_byprojects/byprojects_bandwidth b/plugins/nginx/nginx_byprojects/byprojects_bandwidth index 65842633..62126994 100644 --- a/plugins/nginx/nginx_byprojects/byprojects_bandwidth +++ b/plugins/nginx/nginx_byprojects/byprojects_bandwidth @@ -64,7 +64,7 @@ if(defined($ARGV[0])) { print "graph_total Total\n"; print "graph_vlabel Bits\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"; while ((my $project, my @files) = each(%logs)) { print $project.".label $project\n"; From 23c3f26abf80722c9c1f96400884086d30d75919 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:51:32 +0200 Subject: [PATCH 26/96] Set interpreter "/bin/bash" for bash scripts --- plugins/powermta/pmta_ | 2 +- plugins/powermta/powermta_vmta_recpients | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/powermta/pmta_ b/plugins/powermta/pmta_ index cf066e1c..4c6d0f24 100755 --- a/plugins/powermta/pmta_ +++ b/plugins/powermta/pmta_ @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ####################################################################################################################### # # = PowerMTA Munin multi-monitor = diff --git a/plugins/powermta/powermta_vmta_recpients b/plugins/powermta/powermta_vmta_recpients index 18e90e17..46b53a3d 100755 --- a/plugins/powermta/powermta_vmta_recpients +++ b/plugins/powermta/powermta_vmta_recpients @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash vmta="208-97-205-153" # Lets run the command to pull the vmta's in From c04671c43ac6f51605490594472a1dc3feea65da Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:52:22 +0200 Subject: [PATCH 27/96] Set /bin/bash as interpreter for bash script --- plugins/disk/du_pattern | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/disk/du_pattern b/plugins/disk/du_pattern index 221cda77..55f82618 100755 --- a/plugins/disk/du_pattern +++ b/plugins/disk/du_pattern @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # -*- sh -*- # vim: ft=sh From b531bd5797cc7251cbc648f8565fa5cc39ed7a3e Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:53:20 +0200 Subject: [PATCH 28/96] Convert to UNIX line breaks --- plugins/disk/du_multidirs | 66 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/plugins/disk/du_multidirs b/plugins/disk/du_multidirs index 61c40ac2..223bbb59 100755 --- a/plugins/disk/du_multidirs +++ b/plugins/disk/du_multidirs @@ -1,33 +1,33 @@ -#!/bin/sh -# -# (c)2009, Christian Kujau modified by dano229 -# Based on the 'homedirs' plugin, initially written in Perl by Philipp Gruber -# -# We still need a cronjob to update CACHEFILE once in a while, e.g.: -# 0 * * * * root [ -O /tmp/munin-du_multidirs.cache ] && du -sk /dir /dir2 dir3/* > /tmp/munin-du_multidirs.cache -# -CACHEFILE=/tmp/munin-du_multidirs.cache - -if [ "$1" = "autoconf" ]; then - echo yes - exit 0 -fi - -if [ "$1" = "config" ]; then - echo 'graph_title Directory usage' - echo 'graph_args --base 1024 -l 1' - echo 'graph_vlabel Bytes' - echo 'graph_category disk' - echo 'graph_info This graph shows the size of several directories' - - awk '!/lost\+found/ {print $2 }' $CACHEFILE | sort | while read label; do - field=`echo "$label" | sed 's/^[^A-Za-z_]/_/' | sed 's/[^A-Za-z0-9_]/_/g'` - echo "$field".label "$label" - echo "$field".draw LINE1 -# echo "$field".warning 0 -# echo "$field".critical 0 - done - exit 0 -fi - -awk '!/lost\+found/ { sub(/[^a-zA-Z_]/,"_",$2); gsub(/[^a-zA-Z0-9_]/,"_",$2); print $2".value "$1 * 1024 }' $CACHEFILE | sort -r -n -k2 \ No newline at end of file +#!/bin/sh +# +# (c)2009, Christian Kujau modified by dano229 +# Based on the 'homedirs' plugin, initially written in Perl by Philipp Gruber +# +# We still need a cronjob to update CACHEFILE once in a while, e.g.: +# 0 * * * * root [ -O /tmp/munin-du_multidirs.cache ] && du -sk /dir /dir2 dir3/* > /tmp/munin-du_multidirs.cache +# +CACHEFILE=/tmp/munin-du_multidirs.cache + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + echo 'graph_title Directory usage' + echo 'graph_args --base 1024 -l 1' + echo 'graph_vlabel Bytes' + echo 'graph_category disk' + echo 'graph_info This graph shows the size of several directories' + + awk '!/lost\+found/ {print $2 }' $CACHEFILE | sort | while read label; do + field=`echo "$label" | sed 's/^[^A-Za-z_]/_/' | sed 's/[^A-Za-z0-9_]/_/g'` + echo "$field".label "$label" + echo "$field".draw LINE1 +# echo "$field".warning 0 +# echo "$field".critical 0 + done + exit 0 +fi + +awk '!/lost\+found/ { sub(/[^a-zA-Z_]/,"_",$2); gsub(/[^a-zA-Z0-9_]/,"_",$2); print $2".value "$1 * 1024 }' $CACHEFILE | sort -r -n -k2 From 614b043a325e29f555c1ca989ab7ff25b817d149 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:54:23 +0200 Subject: [PATCH 29/96] Set /bin/bash as interpreter on bash script --- plugins/network/ddclient | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/network/ddclient b/plugins/network/ddclient index 2d5ad862..cebf6db7 100644 --- a/plugins/network/ddclient +++ b/plugins/network/ddclient @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # # Munin plugin to show changing the ip address by ddclient. From b8d75e80e860d7f989b8924bd019d2d988d29d98 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:56:19 +0200 Subject: [PATCH 30/96] Use UNIX line breaks --- plugins/network/sockstat | 84 ++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/plugins/network/sockstat b/plugins/network/sockstat index ad78669b..250e2ec6 100755 --- a/plugins/network/sockstat +++ b/plugins/network/sockstat @@ -1,42 +1,42 @@ -#!/bin/sh -# - -PATH=/bin:/usr/bin - -if [ "$1" = "autoconf" ]; then - echo yes - exit 0 -fi - -DAEMONS=`sockstat | awk '{print substr($0, 1, 8)}' | sort | uniq` - -if [ "$1" = "config" ]; then - echo 'graph_title Connections' - echo 'graph_vlabel Connections' - echo 'graph_noscale true' - echo 'graph_category network' - echo 'graph_info This graph shows connections load.' - - for D in $DAEMONS - do - echo "_$D.label $D" - done - - echo "_TOTAL.label TOTAL" - - exit 0 -fi - -VALUES=`sockstat | awk '{print substr($0, 1, 8)}' | sort | uniq -c` -NUM=1 - -for D in $DAEMONS -do - echo -n "_$D.value " - VAL=`echo $VALUES | cut -d ' ' -f $NUM` - echo $VAL -NUM=$(($NUM + 2)) -done - -echo -n "_TOTAL.value " -sockstat | wc -l +#!/bin/sh +# + +PATH=/bin:/usr/bin + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +DAEMONS=`sockstat | awk '{print substr($0, 1, 8)}' | sort | uniq` + +if [ "$1" = "config" ]; then + echo 'graph_title Connections' + echo 'graph_vlabel Connections' + echo 'graph_noscale true' + echo 'graph_category network' + echo 'graph_info This graph shows connections load.' + + for D in $DAEMONS + do + echo "_$D.label $D" + done + + echo "_TOTAL.label TOTAL" + + exit 0 +fi + +VALUES=`sockstat | awk '{print substr($0, 1, 8)}' | sort | uniq -c` +NUM=1 + +for D in $DAEMONS +do + echo -n "_$D.value " + VAL=`echo $VALUES | cut -d ' ' -f $NUM` + echo $VAL +NUM=$(($NUM + 2)) +done + +echo -n "_TOTAL.value " +sockstat | wc -l From 685a58d863929489e0bf0e9882a6eb4f322d03a7 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:57:39 +0200 Subject: [PATCH 31/96] Use /bin/bash on bash script --- plugins/network/speedport_300 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/network/speedport_300 b/plugins/network/speedport_300 index 66de83ef..c7e5d95c 100755 --- a/plugins/network/speedport_300 +++ b/plugins/network/speedport_300 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # # Munin plugin to show the up- / download stream of the actual From 41fedbb267424cac7ea5ab39d1da64a334bd978b Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 19:59:02 +0200 Subject: [PATCH 32/96] Use /bin/bash for bash script, and save with UNIX line breaks --- plugins/network/hfsc_sep | 378 +++++++++++++++++++-------------------- 1 file changed, 189 insertions(+), 189 deletions(-) diff --git a/plugins/network/hfsc_sep b/plugins/network/hfsc_sep index 40e3a413..114458d6 100755 --- a/plugins/network/hfsc_sep +++ b/plugins/network/hfsc_sep @@ -1,189 +1,189 @@ -#!/bin/sh -# -# Munin plugin for HFSC Traffic Shaping Statistics UP/DOWN -# -# It shows the download and upload statistic graph of a used net bandwidth per a user. -# -# This plugin was tailored to the HFSC solution -# presented at http://www.elessar.one.pl/article_kernel2.6.php -# -# You can find the plugin description and the installation notes here: -# http://www.elessar.one.pl/article_munin.php -# -### -# Written by Rafal Rajs -# Date: 2007/06/19 -# Email: elessar1@poczta.wp.pl -# WWW: http://www.elessar.one.pl -### - -# path to the file with global defs -. /etc/scripts/globals - -# imported from HFSC script -# set class numbers - -N_CLASS_D_1=70 -N_CLASS_D_2=100 -N_CLASS_U_1=130 -N_CLASS_U_2=160 -SH_TMP="/etc/scripts/tmp1.txt" - -if [ "$1" = "config" ]; then - - echo "graph_title HFSC Traffic Shaping Stats - UP/DOWN" - echo 'graph_vlabel bytes DOWN(-)/UP(+) per ${graph_period}' - echo 'graph_width 450' - echo 'graph_category network' - - j=1 - - while [ $j -le $L_USERS ] - do - echo "${USERNAMES[${j}]}_down.label ${USERNAMES[${j}]}" - echo "${USERNAMES[${j}]}_down.type COUNTER" - echo "${USERNAMES[${j}]}_down.graph no" - - if [ $j == 1 ]; then - echo "${USERNAMES[${j}]}_down.draw AREA" - else - echo "${USERNAMES[${j}]}_down.draw STACK" - fi; - - echo "${USERNAMES[${j}]}_down.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}" - echo "${USERNAMES[${j}]}_down.min 0" - echo "${USERNAMES[${j}]}_down.max 130000" - - echo "${USERNAMES[${j}]}_up.label ${USERNAMES[${j}]}" - echo "${USERNAMES[${j}]}_up.type COUNTER" - echo "${USERNAMES[${j}]}_up.negative ${USERNAMES[${j}]}_down" - - if [ $j == 1 ]; then - echo "${USERNAMES[${j}]}_up.draw AREA" - else - echo "${USERNAMES[${j}]}_up.draw STACK" - fi; - - echo "${USERNAMES[${j}]}_up.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}" - echo "${USERNAMES[${j}]}_up.min 0" - echo "${USERNAMES[${j}]}_up.max 30000" - - - j=$[$j+1] - - done; - -#customized colours - echo 'Serwer_down.colour 000000' - echo 'Serwer_up.colour 000000' - - exit 0 - -fi; - -#### DOWNLOAD - -temp1=`/sbin/tc -s class show dev imq0 > $SH_TMP` - -while read line -do - test_hfsc=`echo $line | grep "hfsc"` - - j=1 - - while [ $j -le $L_USERS ] - do - case $test_hfsc in - - *hfsc[\ ]1:$[$N_CLASS_D_1+$j]*) - # check N_CLASS_D_1 stats for every user - read line - temp1=`echo $line | awk '{ print $2; }'` - STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] -# echo "N_CLASS_D_1="$temp1 -# echo "N_CLASS_D_1_SUM "$j" ="${STAT_USER[$j]} - ;; - *hfsc[\ ]1:$[$N_CLASS_D_2+$j]*) - # check N_CLASS_D_2 stats for every user - read line - temp1=`echo $line | awk '{ print $2; }'` - STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] -# echo "N_CLASS_D_2="$temp1 -# echo "N_CLASS_D_2_SUM "$j" ="${STAT_USER[$j]} - ;; - esac - - j=$[$j+1] - - done; - -done < $SH_TMP - - -#### - -j=1 -while [ $j -le $L_USERS ] -do - echo ${USERNAMES[${j}]}"_down.value "${STAT_USER[$j]} - j=$[$j+1] -done; - -#reset values - -j=1 -while [ $j -le $L_USERS ] -do - STAT_USER[$j]=0 - j=$[$j+1] -done; - -#### UPLOAD - -temp1=`/sbin/tc -s class show dev imq1 > $SH_TMP` - -while read line -do - test_hfsc=`echo $line | grep "hfsc"` - - j=1 - - while [ $j -le $L_USERS ] - do - case $test_hfsc in - - *hfsc[\ ]1:$[$N_CLASS_U_1+$j]*) - # check N_CLASS_U_1 stats for every user - read line - temp1=`echo $line | awk '{ print $2; }'` - STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] -# echo "N_CLASS_U_1="$temp1 -# echo "N_CLASS_U_1_SUM "$j" ="${STAT_USER[$j]} - ;; - *hfsc[\ ]1:$[$N_CLASS_U_2+$j]*) - # check N_CLASS_U_2 stats for every user - read line - temp1=`echo $line | awk '{ print $2; }'` - STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] -# echo "N_CLASS_U_2="$temp1 -# echo "N_CLASS_U_2_SUM "$j" ="${STAT_USER[$j]} - ;; - esac - - j=$[$j+1] - - done; - -done < $SH_TMP - -j=1 -while [ $j -le $L_USERS ] -do - echo ${USERNAMES[${j}]}"_up.value "${STAT_USER[$j]} - j=$[$j+1] -done; - - -## clean temp file -temp1=`echo "" > $SH_TMP` - +#!/bin/bash +# +# Munin plugin for HFSC Traffic Shaping Statistics UP/DOWN +# +# It shows the download and upload statistic graph of a used net bandwidth per a user. +# +# This plugin was tailored to the HFSC solution +# presented at http://www.elessar.one.pl/article_kernel2.6.php +# +# You can find the plugin description and the installation notes here: +# http://www.elessar.one.pl/article_munin.php +# +### +# Written by Rafal Rajs +# Date: 2007/06/19 +# Email: elessar1@poczta.wp.pl +# WWW: http://www.elessar.one.pl +### + +# path to the file with global defs +. /etc/scripts/globals + +# imported from HFSC script +# set class numbers + +N_CLASS_D_1=70 +N_CLASS_D_2=100 +N_CLASS_U_1=130 +N_CLASS_U_2=160 +SH_TMP="/etc/scripts/tmp1.txt" + +if [ "$1" = "config" ]; then + + echo "graph_title HFSC Traffic Shaping Stats - UP/DOWN" + echo 'graph_vlabel bytes DOWN(-)/UP(+) per ${graph_period}' + echo 'graph_width 450' + echo 'graph_category network' + + j=1 + + while [ $j -le $L_USERS ] + do + echo "${USERNAMES[${j}]}_down.label ${USERNAMES[${j}]}" + echo "${USERNAMES[${j}]}_down.type COUNTER" + echo "${USERNAMES[${j}]}_down.graph no" + + if [ $j == 1 ]; then + echo "${USERNAMES[${j}]}_down.draw AREA" + else + echo "${USERNAMES[${j}]}_down.draw STACK" + fi; + + echo "${USERNAMES[${j}]}_down.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}" + echo "${USERNAMES[${j}]}_down.min 0" + echo "${USERNAMES[${j}]}_down.max 130000" + + echo "${USERNAMES[${j}]}_up.label ${USERNAMES[${j}]}" + echo "${USERNAMES[${j}]}_up.type COUNTER" + echo "${USERNAMES[${j}]}_up.negative ${USERNAMES[${j}]}_down" + + if [ $j == 1 ]; then + echo "${USERNAMES[${j}]}_up.draw AREA" + else + echo "${USERNAMES[${j}]}_up.draw STACK" + fi; + + echo "${USERNAMES[${j}]}_up.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}" + echo "${USERNAMES[${j}]}_up.min 0" + echo "${USERNAMES[${j}]}_up.max 30000" + + + j=$[$j+1] + + done; + +#customized colours + echo 'Serwer_down.colour 000000' + echo 'Serwer_up.colour 000000' + + exit 0 + +fi; + +#### DOWNLOAD + +temp1=`/sbin/tc -s class show dev imq0 > $SH_TMP` + +while read line +do + test_hfsc=`echo $line | grep "hfsc"` + + j=1 + + while [ $j -le $L_USERS ] + do + case $test_hfsc in + + *hfsc[\ ]1:$[$N_CLASS_D_1+$j]*) + # check N_CLASS_D_1 stats for every user + read line + temp1=`echo $line | awk '{ print $2; }'` + STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] +# echo "N_CLASS_D_1="$temp1 +# echo "N_CLASS_D_1_SUM "$j" ="${STAT_USER[$j]} + ;; + *hfsc[\ ]1:$[$N_CLASS_D_2+$j]*) + # check N_CLASS_D_2 stats for every user + read line + temp1=`echo $line | awk '{ print $2; }'` + STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] +# echo "N_CLASS_D_2="$temp1 +# echo "N_CLASS_D_2_SUM "$j" ="${STAT_USER[$j]} + ;; + esac + + j=$[$j+1] + + done; + +done < $SH_TMP + + +#### + +j=1 +while [ $j -le $L_USERS ] +do + echo ${USERNAMES[${j}]}"_down.value "${STAT_USER[$j]} + j=$[$j+1] +done; + +#reset values + +j=1 +while [ $j -le $L_USERS ] +do + STAT_USER[$j]=0 + j=$[$j+1] +done; + +#### UPLOAD + +temp1=`/sbin/tc -s class show dev imq1 > $SH_TMP` + +while read line +do + test_hfsc=`echo $line | grep "hfsc"` + + j=1 + + while [ $j -le $L_USERS ] + do + case $test_hfsc in + + *hfsc[\ ]1:$[$N_CLASS_U_1+$j]*) + # check N_CLASS_U_1 stats for every user + read line + temp1=`echo $line | awk '{ print $2; }'` + STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] +# echo "N_CLASS_U_1="$temp1 +# echo "N_CLASS_U_1_SUM "$j" ="${STAT_USER[$j]} + ;; + *hfsc[\ ]1:$[$N_CLASS_U_2+$j]*) + # check N_CLASS_U_2 stats for every user + read line + temp1=`echo $line | awk '{ print $2; }'` + STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] +# echo "N_CLASS_U_2="$temp1 +# echo "N_CLASS_U_2_SUM "$j" ="${STAT_USER[$j]} + ;; + esac + + j=$[$j+1] + + done; + +done < $SH_TMP + +j=1 +while [ $j -le $L_USERS ] +do + echo ${USERNAMES[${j}]}"_up.value "${STAT_USER[$j]} + j=$[$j+1] +done; + + +## clean temp file +temp1=`echo "" > $SH_TMP` + From ae84b39f3b13b487f501334f5bbc26ab3f475b2c Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 20:01:25 +0200 Subject: [PATCH 33/96] Use /bin/bash for bash script ("echo -en" is a bash feature) --- plugins/network/umts_sig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/network/umts_sig b/plugins/network/umts_sig index fd0bfc5b..b66a9b55 100755 --- a/plugins/network/umts_sig +++ b/plugins/network/umts_sig @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # A Munin Plugin to show umts signal strength using gcom # Created by Derik Vercueil From 047358a0bc9876bff06197df03df2789c27bdca2 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 20:02:19 +0200 Subject: [PATCH 34/96] Use sh "=" comparison, instead of bash "==" --- plugins/network/ipt_basic_ | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/network/ipt_basic_ b/plugins/network/ipt_basic_ index 03d427e2..6f05638c 100755 --- a/plugins/network/ipt_basic_ +++ b/plugins/network/ipt_basic_ @@ -84,7 +84,7 @@ IFACES=`$iptables -L munin_node -nvx | awk '$6 ~ /(eth|ppp)[0-9]/ { if (done[$6] if [ "$1" = "config" ]; then # echo "graph_order out in" - if [ "$TYPE" == "pkts" ]; then + if [ "$TYPE" = "pkts" ]; then echo "graph_title pkts" echo 'graph_vlabel pkts per ${graph_period}' else @@ -107,7 +107,7 @@ if [ "$1" = "config" ]; then exit 0 fi; -if [ "$TYPE" == "pkts" ]; then +if [ "$TYPE" = "pkts" ]; then $iptables -L munin_node -nvx | egrep "eth|ppp" | awk "{ print \$6 \".value \" \$1 }" else $iptables -L munin_node -nvx | egrep "eth|ppp" | awk "{ print \$6 \".value \" \$2 }" From 0463ac1060eceb24b71d84cbbd52c1abcac3930a Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 20:03:03 +0200 Subject: [PATCH 35/96] Set /bin/bash as interpreter for bash script --- plugins/network/fwbuilder_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/network/fwbuilder_ b/plugins/network/fwbuilder_ index b2a99a55..d955eea6 100755 --- a/plugins/network/fwbuilder_ +++ b/plugins/network/fwbuilder_ @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Wildcard-plugin to monitor IP addresses through iptables. To monitor an # IP, link fwbuilder_ to this file. E.g. From c4ed6e7737b88ceb3a683040b05941a2de67b0da Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 20:16:59 +0200 Subject: [PATCH 36/96] remove shell quoting, it is not needed --- t/test.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/test.t b/t/test.t index 0c4f6730..0f7085f9 100644 --- a/t/test.t +++ b/t/test.t @@ -81,7 +81,7 @@ sub process_file { } elsif ( $interpreter =~ m{gawk} ) { ok( check_file_with( - [ 'gawk', '--source', "'BEGIN { exit(0) } END { exit(0) }'", + [ 'gawk', '--source', 'BEGIN { exit(0) } END { exit(0) }', '--file', $file ] ), From 6b5e75a04cd31f4b3f2c3ecc6189648ff2bd2ca0 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 20:17:52 +0200 Subject: [PATCH 37/96] Tidy with perltidy --- t/test.t | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/t/test.t b/t/test.t index 0f7085f9..17c2b031 100644 --- a/t/test.t +++ b/t/test.t @@ -66,7 +66,10 @@ sub process_file { } elsif ( $interpreter =~ m{python} ) { ok( check_file_with( - [ 'pylint', '--rcfile=/dev/null', '--errors-only', '--report=no', $file ] + [ 'pylint', '--rcfile=/dev/null', + '--errors-only', '--report=no', + $file + ] ), $filename . " python syntax check" ); @@ -102,7 +105,13 @@ sub check_file_with { return 1; } else { - diag(sprintf("\nCommand: %s\n\nSTDOUT:\n\n%s\n\nSTDERR:\n\n%s\n\n", join(" ", @{$check_command}), $stdout, $stderr)); + diag( + sprintf( + "\nCommand: %s\n\nSTDOUT:\n\n%s\n\nSTDERR:\n\n%s\n\n", + join( " ", @{$check_command} ), + $stdout, $stderr + ) + ); return; } } From a2bedd79e76e85c1ee19f3158c149fdaa85e5e92 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 20:30:29 +0200 Subject: [PATCH 38/96] Fix syntax error in string concatenation --- plugins/apache/apache_byprojects/byprojects_bandwidth | 2 +- plugins/apache/apache_byprojects/byprojects_inout_bandwidth | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/apache/apache_byprojects/byprojects_bandwidth b/plugins/apache/apache_byprojects/byprojects_bandwidth index d5f6e841..8370cf79 100644 --- a/plugins/apache/apache_byprojects/byprojects_bandwidth +++ b/plugins/apache/apache_byprojects/byprojects_bandwidth @@ -63,7 +63,7 @@ if(defined($ARGV[0])) { print "graph_total Total\n"; print "graph_vlabel Bits\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"; while ((my $project, my @files) = each(%logs)) { print $project.".label $project\n"; diff --git a/plugins/apache/apache_byprojects/byprojects_inout_bandwidth b/plugins/apache/apache_byprojects/byprojects_inout_bandwidth index e92800cb..29dbecf9 100644 --- a/plugins/apache/apache_byprojects/byprojects_inout_bandwidth +++ b/plugins/apache/apache_byprojects/byprojects_inout_bandwidth @@ -60,7 +60,7 @@ if(defined($ARGV[0])) { print "graph_args --base 1000\n"; print "graph_vlabel bits per \${graph_period} in (-) / out (+)\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"; while ((my $project, my @files) = each(%logs)) { print "i".$project.".label $project\n"; From 2ebcc8dcdcd9f67020e9eb8f1edc8d1f3052e36d Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 20:33:52 +0200 Subject: [PATCH 39/96] Fix tiny bashism, keeping the plugin as /bin/sh --- plugins/chat/tinychat_users_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chat/tinychat_users_ b/plugins/chat/tinychat_users_ index 1a487e5a..39a40679 100755 --- a/plugins/chat/tinychat_users_ +++ b/plugins/chat/tinychat_users_ @@ -19,7 +19,7 @@ room=${0##*tinychat_users_} ## if [ "$1" = "autoconf" ]; then # Check that curl is installed - if hash curl &>/dev/null; then + if hash curl >/dev/null 2>&1; then echo "yes" else echo "no (no curl installed)" From 2eef2d55b55262cad0de15a2113dfab6f3574dc4 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:01:55 +0200 Subject: [PATCH 40/96] Use /bin/sh "=" comparison, instead of "==" --- plugins/virtualization/xen_traffic_all | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/virtualization/xen_traffic_all b/plugins/virtualization/xen_traffic_all index c090ee09..b1368739 100755 --- a/plugins/virtualization/xen_traffic_all +++ b/plugins/virtualization/xen_traffic_all @@ -51,7 +51,7 @@ fi DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)") for dom in $DOMAINS; do dev=$( xm list $dom --long | awk '/vifname / { print $2 }' | sed 's/)//' ) - if [ "$dev" == "" ]; then + if [ "$dev" = "" ]; then dev=$( xm network-list $dom |\ egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@') fi From bebd78f74ba41f0355c60d34dab36a1c747de5cd Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:03:22 +0200 Subject: [PATCH 41/96] Use /bin/bash as interpreter, and switch to UNIX line breaks --- plugins/system/iostat-cputps-average | 158 +++++++++++++-------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/plugins/system/iostat-cputps-average b/plugins/system/iostat-cputps-average index ccc846d1..bcbde46e 100755 --- a/plugins/system/iostat-cputps-average +++ b/plugins/system/iostat-cputps-average @@ -1,79 +1,79 @@ -#!/bin/sh -# -# Script to monitor iostat cpu|tps. -# -# Parameters understood: -# -# config (required) -# autoconf (optional - used by munin-config) - -judge=`basename $0 | sed 's/^iostat_//g'` -current=`date +%H":"%M":"%S`; -tenMago=`date --date "10 minutes ago" +%H":"%M":"%S` -export LANG=en_US.UTF-8 - -# autoconf - -if [ "$1" == "autoconf" ]; then - if ( sar 1 1 >/dev/null 2>&1 ); then - echo yes - exit 0 - else - if [ $? -eq 127 ]; then - echo "no (could not run \"sar\")" - exit 1 - else - echo no - exit 1 - fi - fi -fi - -ARRAY=( `sar -p -d -s ${tenMago} -e ${current} | grep -v nodev | grep "Average" | awk '{ print $2 , $3 , $10 }'` ) - -# config - -if [ "$1" == "config" ]; then - if [ "$judge" == cpu_average ]; then - echo 'graph_title iostat util' - echo 'graph_args --upper-limit 100 -l 0' - echo 'graph_vlabel %' - echo 'graph_category System' - for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do - echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}" - i=`expr $i + 2` - done - exit 0 - fi - - if [ "$judge" == tps_average ]; then - echo 'graph_title iostat tps' - echo 'graph_args -l 0' - echo 'graph_vlabel tps' - echo 'graph_category System' - for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do - echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}" - i=`expr $i + 2` - done - exit 0 - fi -fi - -# other - -if [ "$judge" == cpu_average ]; then -for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do - echo -n "_dev_${ARRAY[i]}.value " - i=`expr $i + 2` - echo "${ARRAY[i]}" -done -fi - -if [ "$judge" == tps_average ]; then -for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do - echo -n "_dev_${ARRAY[i]}.value " - i=`expr $i + 1` - echo "${ARRAY[i]}" - i=`expr $i + 1` -done -fi +#!/bin/bash +# +# Script to monitor iostat cpu|tps. +# +# Parameters understood: +# +# config (required) +# autoconf (optional - used by munin-config) + +judge=`basename $0 | sed 's/^iostat_//g'` +current=`date +%H":"%M":"%S`; +tenMago=`date --date "10 minutes ago" +%H":"%M":"%S` +export LANG=en_US.UTF-8 + +# autoconf + +if [ "$1" == "autoconf" ]; then + if ( sar 1 1 >/dev/null 2>&1 ); then + echo yes + exit 0 + else + if [ $? -eq 127 ]; then + echo "no (could not run \"sar\")" + exit 1 + else + echo no + exit 1 + fi + fi +fi + +ARRAY=( `sar -p -d -s ${tenMago} -e ${current} | grep -v nodev | grep "Average" | awk '{ print $2 , $3 , $10 }'` ) + +# config + +if [ "$1" == "config" ]; then + if [ "$judge" == cpu_average ]; then + echo 'graph_title iostat util' + echo 'graph_args --upper-limit 100 -l 0' + echo 'graph_vlabel %' + echo 'graph_category System' + for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do + echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}" + i=`expr $i + 2` + done + exit 0 + fi + + if [ "$judge" == tps_average ]; then + echo 'graph_title iostat tps' + echo 'graph_args -l 0' + echo 'graph_vlabel tps' + echo 'graph_category System' + for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do + echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}" + i=`expr $i + 2` + done + exit 0 + fi +fi + +# other + +if [ "$judge" == cpu_average ]; then +for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do + echo -n "_dev_${ARRAY[i]}.value " + i=`expr $i + 2` + echo "${ARRAY[i]}" +done +fi + +if [ "$judge" == tps_average ]; then +for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do + echo -n "_dev_${ARRAY[i]}.value " + i=`expr $i + 1` + echo "${ARRAY[i]}" + i=`expr $i + 1` +done +fi From 8348cd2805ccc5134dd69b2041a01388973447cb Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:04:24 +0200 Subject: [PATCH 42/96] Use /bin/bash as interpreter for bash script - uses "echo -en" several places --- plugins/system/auth | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system/auth b/plugins/system/auth index 8602b428..c089a731 100755 --- a/plugins/system/auth +++ b/plugins/system/auth @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # A Munin Plugin to show auth stuff # Created by Dominik Schulz From 73239efaefc1221b8a70357fb0084bb76c26fdf2 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:13:45 +0200 Subject: [PATCH 43/96] Set /bin/bash as interpreter for bash script --- plugins/fax/faxstat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fax/faxstat b/plugins/fax/faxstat index d44b25bb..7c0deefb 100755 --- a/plugins/fax/faxstat +++ b/plugins/fax/faxstat @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Plugin to monitor hylafax queue # From 6a28f5a215a79115c5557dbbe41f13250d8d0094 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:16:42 +0200 Subject: [PATCH 44/96] Save with UNIX line breaks - also remove lots of trailing whitespace on last line --- plugins/ftp/proftpd | 50 ++++++++++---------- plugins/ftp/pureftpd_count | 93 +++++++++++++++++++------------------- 2 files changed, 71 insertions(+), 72 deletions(-) diff --git a/plugins/ftp/proftpd b/plugins/ftp/proftpd index 835a2553..aacae81b 100755 --- a/plugins/ftp/proftpd +++ b/plugins/ftp/proftpd @@ -1,25 +1,25 @@ -#! /bin/sh -# configuration : -# -# env.LOGFILE /var/log/proftpd/proftpd.log - -if [ "$1" = 'config' ]; then - echo "graph_args --base 1000 -l 0" - echo "graph_title Serveur FTP" - echo "graph_category Ftp" - echo "graph_vlabel Stats Proftpd" - echo "succes.label Login succes" - echo "succes.draw AREA" - echo "failed.label Login failed" - echo "failed.draw AREA" -fi - -LOGFILE=${LOGFILE:-"/var/log/proftpd/proftpd.log"} - -succes=$(grep -c "successful" "$LOGFILE" ) -failed=$(grep -c "Login failed" "$LOGFILE" ) - -echo "succes.value $succes" -echo "failed.value $failed" - -exit 0 +#! /bin/sh +# configuration : +# +# env.LOGFILE /var/log/proftpd/proftpd.log + +if [ "$1" = 'config' ]; then + echo "graph_args --base 1000 -l 0" + echo "graph_title Serveur FTP" + echo "graph_category Ftp" + echo "graph_vlabel Stats Proftpd" + echo "succes.label Login succes" + echo "succes.draw AREA" + echo "failed.label Login failed" + echo "failed.draw AREA" +fi + +LOGFILE=${LOGFILE:-"/var/log/proftpd/proftpd.log"} + +succes=$(grep -c "successful" "$LOGFILE" ) +failed=$(grep -c "Login failed" "$LOGFILE" ) + +echo "succes.value $succes" +echo "failed.value $failed" + +exit 0 diff --git a/plugins/ftp/pureftpd_count b/plugins/ftp/pureftpd_count index 19a5a222..ab7bc247 100755 --- a/plugins/ftp/pureftpd_count +++ b/plugins/ftp/pureftpd_count @@ -1,47 +1,46 @@ -#!/bin/sh -# -# -# Script to show pureftp counts. -# Logs are searched in /var/log/pure-ftpd/transfer.log by default. -# Logs must be in w3c format: -# pure-ftpd --altlog w3c:/var/log/pure-ftpd/transfer.log -# -# Parameters understood: -# -# config (required) -# autoconf (optional - used by munin-config) -# -# -# Magic markers (optional - used by munin-config and installation -# scripts): -# -#%# family=auto -#%# capabilities=autoconf - -MAXLABEL=20 - -if [ "$1" = "autoconf" ]; then - echo yes - exit 0 -fi - -if [ "$1" = "config" ]; then - - echo 'graph_title FTP Server' - echo 'graph_args --base 1000 -l 0' - echo 'graph_vlabel Daily FTP Operations' - echo 'graph_category FTP' - echo 'graph_period second' - echo 'ftp_put.type GAUGE' - echo 'ftp_get.type GAUGE' - echo 'ftp_put.label Files PUT' - echo 'ftp_get.label Files GET' - exit 0 -fi - -echo -en "ftp_put.value " -echo $(grep "`date '+%Y-%m-%d'`" /var/log/pure-ftpd/transfer.log | grep [[:space:]]\\[\\]created[[:space:]] | wc -l) -echo -n -echo -en "ftp_get.value " -echo $(grep "`date '+%Y-%m-%d'`" /var/log/pure-ftpd/transfer.log | grep [[:space:]]\\[\\]sent[[:space:]] | wc -l) - +#!/bin/sh +# +# +# Script to show pureftp counts. +# Logs are searched in /var/log/pure-ftpd/transfer.log by default. +# Logs must be in w3c format: +# pure-ftpd --altlog w3c:/var/log/pure-ftpd/transfer.log +# +# Parameters understood: +# +# config (required) +# autoconf (optional - used by munin-config) +# +# +# Magic markers (optional - used by munin-config and installation +# scripts): +# +#%# family=auto +#%# capabilities=autoconf + +MAXLABEL=20 + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title FTP Server' + echo 'graph_args --base 1000 -l 0' + echo 'graph_vlabel Daily FTP Operations' + echo 'graph_category FTP' + echo 'graph_period second' + echo 'ftp_put.type GAUGE' + echo 'ftp_get.type GAUGE' + echo 'ftp_put.label Files PUT' + echo 'ftp_get.label Files GET' + exit 0 +fi + +echo -en "ftp_put.value " +echo $(grep "`date '+%Y-%m-%d'`" /var/log/pure-ftpd/transfer.log | grep [[:space:]]\\[\\]created[[:space:]] | wc -l) +echo -n +echo -en "ftp_get.value " +echo $(grep "`date '+%Y-%m-%d'`" /var/log/pure-ftpd/transfer.log | grep [[:space:]]\\[\\]sent[[:space:]] | wc -l) From 7684702713261637fe0897c195f411163592d414 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:19:32 +0200 Subject: [PATCH 45/96] Use /bin/bash as interpreter for bash script --- plugins/google/googlecode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/google/googlecode b/plugins/google/googlecode index 1bcbfc59..d0eaf3f4 100755 --- a/plugins/google/googlecode +++ b/plugins/google/googlecode @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ########################## # googlecode_ ########################## From aaeaa2e64ad90a6a31803bcd4ce8e44d78b48b99 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:21:32 +0200 Subject: [PATCH 46/96] USe /bin/bash as interpreter for bash script --- plugins/gpu/nvidia_gpu_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gpu/nvidia_gpu_ b/plugins/gpu/nvidia_gpu_ index d96de12c..56741504 100755 --- a/plugins/gpu/nvidia_gpu_ +++ b/plugins/gpu/nvidia_gpu_ @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # -*- sh -*- : << =cut From fc37652294864eb2d5ecfe519a09180e07dce77f Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:22:23 +0200 Subject: [PATCH 47/96] Save with UNIX line breaks --- plugins/healthcheck/healthcheck_log | 322 ++++++++++++++-------------- plugins/mail/postfix-policyd | 106 ++++----- 2 files changed, 214 insertions(+), 214 deletions(-) diff --git a/plugins/healthcheck/healthcheck_log b/plugins/healthcheck/healthcheck_log index 1cd79779..9e86dbe9 100755 --- a/plugins/healthcheck/healthcheck_log +++ b/plugins/healthcheck/healthcheck_log @@ -1,161 +1,161 @@ -#!/bin/bash -# -#healthcheck on munin -#egrep system log and alert. -# -#programed by rti (hiroyuki fujie) super.rti@gmail.com @super_rti -#LICENSE: NYSL (public domain) -# -# -#config file -# /etc/munin/plugin-conf.d/munin-node -# -#example minimum config -#--------------------------------------------------- -#[healthcheck_log] -#user root -#env.log_1 /var/log/messages -#--------------------------------------------------- -# -#check two log -#--------------------------------------------------- -#[healthcheck_log] -#user root -#env.log_1 /var/log/messages -#env.log_2 /var/log/syslog -#--------------------------------------------------- -# -#check two three -#--------------------------------------------------- -#[healthcheck_log] -#user root -#env.log_1 /var/log/messages -#env.log_2 /var/log/syslog -#env.log_3 /var/log/dmesg -#--------------------------------------------------- -# -#set name -#--------------------------------------------------- -#[healthcheck_log] -#user root -#env.log_1 /var/log/messages -#env.name_1 my_server_messages -#--------------------------------------------------- -# -#set egrep string -#--------------------------------------------------- -#[healthcheck_log] -#user root -#env.log_1 /var/log/messages -#env.grep_1 alert|warning -#--------------------------------------------------- -# -#set egrep string -#--------------------------------------------------- -#[healthcheck_log] -#user root -#env.log_1 /var/log/messages -#env.grep_1 alert|warning -#--------------------------------------------------- -# -#full option -#/etc/munin/plugin-conf.d/munin-node -#--------------------------------------------------- -#[healthcheck_log] -#user root #log file is read only root user. -#env.log_1 /var/log/messages #target log filename -#env.grep_1 critical|error #egrep string. - #defualt by critical|error|warning|crash|fatal|kernel -#--------------------------------------------------- -# - - -#edakari speed up. -CHECKMAX=`env | grep log_ | wc -l` -let CHECKMAX="$CHECKMAX + 1" -MINUTE_BY_GREP_RANGE=10 - -if [ "$1" = "autoconf" ]; then - if [ $CHECKMAX -le 1 ]; then - echo no - exit 1 - fi - echo yes - exit 0 -fi - -if [ "$1" = "config" ]; then - echo 'graph_title log grep (match count)' - echo "graph_args --base 1000 -l 0 --vertical-label match_count" - echo 'graph_scale no' - echo 'graph_vlabel match_count' - echo 'graph_category healthcheck' - echo 'graph_info This graph shows the bad event count on log' - - for(( I = 1; I < $CHECKMAX; ++I )) - do - eval log=\$log_${I} - eval name=\$name_${I} - eval grep=\$grep_${I} - if [ "x${log}" = "x" ]; then - continue - fi - if [ "x${name}" = "x" ]; then - name=`echo $log | sed 's#[/|\.]#_#g'` - fi - if [ "x${name}" = "x" ]; then - grep="critical|error|crash|fatal|kernel" - fi - - echo "$name.label $name" - echo "$name.info egrep $grep $log | wc -l" - echo "$name.draw LINE2" - echo "$name.min 0" - echo "$name.max 20" - echo "$name.critical 0:0" - done - - exit 0 -fi - -NOWTIME=`date --date "$MINUTE_BY_GREP_RANGE minute ago" +%s` - -for(( I = 1; I < $CHECKMAX; ++I )) -do - eval log=\$log_${I} - eval name=\$name_${I} - eval grep=\$grep_${I} - if [ "x${log}" = "x" ]; then - continue - fi - if [ "x${name}" = "x" ]; then - name=`echo $log | sed 's#[/|\.]#_#g'` - fi - if [ "x${grep}" = "x" ]; then - grep="critical|error|crash|fatal|kernel" - fi - - COUNT=0 - MESSAGE= - IFS=$'\n' - MATCHLINES=(`egrep -i "$grep" "$log"`) - for(( N = ${#MATCHLINES[@]} - 1; N >= 0 ; --N )) - do - LINE=${MATCHLINES[$N]} - DATESTRING=`echo $LINE | awk '{ printf("%s %s %s",$1,$2,$3)}'` - LOGTIME=`date --date "$DATESTRING" +%s` - if [ $LOGTIME -lt $NOWTIME ]; then - break - fi - let COUNT="$COUNT + 1" - MESSAGE="$MESSAGE$LINE //@LINE@// " - done - - - if [ $COUNT -eq 0 ]; then - echo "${name}.value 0" - else - echo "${name}.value ${COUNT}" - echo "${name}.extinfo ${MESSAGE}" - fi -done +#!/bin/bash +# +#healthcheck on munin +#egrep system log and alert. +# +#programed by rti (hiroyuki fujie) super.rti@gmail.com @super_rti +#LICENSE: NYSL (public domain) +# +# +#config file +# /etc/munin/plugin-conf.d/munin-node +# +#example minimum config +#--------------------------------------------------- +#[healthcheck_log] +#user root +#env.log_1 /var/log/messages +#--------------------------------------------------- +# +#check two log +#--------------------------------------------------- +#[healthcheck_log] +#user root +#env.log_1 /var/log/messages +#env.log_2 /var/log/syslog +#--------------------------------------------------- +# +#check two three +#--------------------------------------------------- +#[healthcheck_log] +#user root +#env.log_1 /var/log/messages +#env.log_2 /var/log/syslog +#env.log_3 /var/log/dmesg +#--------------------------------------------------- +# +#set name +#--------------------------------------------------- +#[healthcheck_log] +#user root +#env.log_1 /var/log/messages +#env.name_1 my_server_messages +#--------------------------------------------------- +# +#set egrep string +#--------------------------------------------------- +#[healthcheck_log] +#user root +#env.log_1 /var/log/messages +#env.grep_1 alert|warning +#--------------------------------------------------- +# +#set egrep string +#--------------------------------------------------- +#[healthcheck_log] +#user root +#env.log_1 /var/log/messages +#env.grep_1 alert|warning +#--------------------------------------------------- +# +#full option +#/etc/munin/plugin-conf.d/munin-node +#--------------------------------------------------- +#[healthcheck_log] +#user root #log file is read only root user. +#env.log_1 /var/log/messages #target log filename +#env.grep_1 critical|error #egrep string. + #defualt by critical|error|warning|crash|fatal|kernel +#--------------------------------------------------- +# + + +#edakari speed up. +CHECKMAX=`env | grep log_ | wc -l` +let CHECKMAX="$CHECKMAX + 1" +MINUTE_BY_GREP_RANGE=10 + +if [ "$1" = "autoconf" ]; then + if [ $CHECKMAX -le 1 ]; then + echo no + exit 1 + fi + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + echo 'graph_title log grep (match count)' + echo "graph_args --base 1000 -l 0 --vertical-label match_count" + echo 'graph_scale no' + echo 'graph_vlabel match_count' + echo 'graph_category healthcheck' + echo 'graph_info This graph shows the bad event count on log' + + for(( I = 1; I < $CHECKMAX; ++I )) + do + eval log=\$log_${I} + eval name=\$name_${I} + eval grep=\$grep_${I} + if [ "x${log}" = "x" ]; then + continue + fi + if [ "x${name}" = "x" ]; then + name=`echo $log | sed 's#[/|\.]#_#g'` + fi + if [ "x${name}" = "x" ]; then + grep="critical|error|crash|fatal|kernel" + fi + + echo "$name.label $name" + echo "$name.info egrep $grep $log | wc -l" + echo "$name.draw LINE2" + echo "$name.min 0" + echo "$name.max 20" + echo "$name.critical 0:0" + done + + exit 0 +fi + +NOWTIME=`date --date "$MINUTE_BY_GREP_RANGE minute ago" +%s` + +for(( I = 1; I < $CHECKMAX; ++I )) +do + eval log=\$log_${I} + eval name=\$name_${I} + eval grep=\$grep_${I} + if [ "x${log}" = "x" ]; then + continue + fi + if [ "x${name}" = "x" ]; then + name=`echo $log | sed 's#[/|\.]#_#g'` + fi + if [ "x${grep}" = "x" ]; then + grep="critical|error|crash|fatal|kernel" + fi + + COUNT=0 + MESSAGE= + IFS=$'\n' + MATCHLINES=(`egrep -i "$grep" "$log"`) + for(( N = ${#MATCHLINES[@]} - 1; N >= 0 ; --N )) + do + LINE=${MATCHLINES[$N]} + DATESTRING=`echo $LINE | awk '{ printf("%s %s %s",$1,$2,$3)}'` + LOGTIME=`date --date "$DATESTRING" +%s` + if [ $LOGTIME -lt $NOWTIME ]; then + break + fi + let COUNT="$COUNT + 1" + MESSAGE="$MESSAGE$LINE //@LINE@// " + done + + + if [ $COUNT -eq 0 ]; then + echo "${name}.value 0" + else + echo "${name}.value ${COUNT}" + echo "${name}.extinfo ${MESSAGE}" + fi +done diff --git a/plugins/mail/postfix-policyd b/plugins/mail/postfix-policyd index fee80923..fb094740 100755 --- a/plugins/mail/postfix-policyd +++ b/plugins/mail/postfix-policyd @@ -1,53 +1,53 @@ -#!/bin/bash -# -# Plugin to monitor incoming mails greylisted by postfix-policyd -# -# Parameters understood: -# -# config (required) -# autoconf (optional) -# - -MYSQL_USER="postfix-policyd" -MYSQL_PASS="" -MYSQL_DB="postfixpolicyd" - -if [ "$1" = "autoconf" ]; then - if [ -n "${MYSQL_PASS}" ] ; then - echo yes - exit 0 - else - echo "no (set mysql pass)" - exit 1 - fi -fi - -if [ "$1" = "config" ]; then - echo 'graph_title Postfix-Policyd daily filtering' - echo 'graph_order delayed passed whitelisted' - echo 'graph_category mail' - echo 'graph_vlabel Count' - echo 'graph_scale no' - -## echo 'graph_args --base 1000 -l 0' - echo 'delayed.label delayed' - echo 'delayed.type GAUGE' - echo 'passed.label passed' - echo 'passed.type GAUGE' - echo 'whitelisted.label whitelisted' - echo 'whitelisted.type GAUGE' - echo 'blacklisted.label blacklisted' - echo 'blacklisted.type GAUGE' - - exit 0 -fi - -DELAYED="`echo "SELECT COUNT(*) FROM triplet WHERE _count = 0" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`" -PASSED="`echo "SELECT COUNT(*) FROM triplet WHERE _count != 0" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`" -WHITELISTED="`echo "SELECT COUNT(*) FROM whitelist" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`" -BLACKLISTED="`echo "SELECT COUNT(*) FROM blacklist" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`" - -echo "delayed.value ${DELAYED}" -echo "passed.value ${PASSED}" -echo "whitelisted.value ${WHITELISTED}" -echo "blacklisted.value ${BLACKLISTED}" \ No newline at end of file +#!/bin/bash +# +# Plugin to monitor incoming mails greylisted by postfix-policyd +# +# Parameters understood: +# +# config (required) +# autoconf (optional) +# + +MYSQL_USER="postfix-policyd" +MYSQL_PASS="" +MYSQL_DB="postfixpolicyd" + +if [ "$1" = "autoconf" ]; then + if [ -n "${MYSQL_PASS}" ] ; then + echo yes + exit 0 + else + echo "no (set mysql pass)" + exit 1 + fi +fi + +if [ "$1" = "config" ]; then + echo 'graph_title Postfix-Policyd daily filtering' + echo 'graph_order delayed passed whitelisted' + echo 'graph_category mail' + echo 'graph_vlabel Count' + echo 'graph_scale no' + +## echo 'graph_args --base 1000 -l 0' + echo 'delayed.label delayed' + echo 'delayed.type GAUGE' + echo 'passed.label passed' + echo 'passed.type GAUGE' + echo 'whitelisted.label whitelisted' + echo 'whitelisted.type GAUGE' + echo 'blacklisted.label blacklisted' + echo 'blacklisted.type GAUGE' + + exit 0 +fi + +DELAYED="`echo "SELECT COUNT(*) FROM triplet WHERE _count = 0" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`" +PASSED="`echo "SELECT COUNT(*) FROM triplet WHERE _count != 0" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`" +WHITELISTED="`echo "SELECT COUNT(*) FROM whitelist" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`" +BLACKLISTED="`echo "SELECT COUNT(*) FROM blacklist" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`" + +echo "delayed.value ${DELAYED}" +echo "passed.value ${PASSED}" +echo "whitelisted.value ${WHITELISTED}" +echo "blacklisted.value ${BLACKLISTED}" From 016752f36dc3965ec2a10634b803d76d0da6c3eb Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:38:21 +0200 Subject: [PATCH 48/96] Use /usr/bin/php for php plugin (was "/bin/bash" !) --- plugins/ubuntu/ubuntu-mirrors | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ubuntu/ubuntu-mirrors b/plugins/ubuntu/ubuntu-mirrors index d9214c76..53f51de4 100755 --- a/plugins/ubuntu/ubuntu-mirrors +++ b/plugins/ubuntu/ubuntu-mirrors @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/php Date: Sat, 4 Oct 2014 21:39:22 +0200 Subject: [PATCH 49/96] Also install XML::Smart for syntax checks --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fba41a51..b5d8e8c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,6 +45,7 @@ install: - 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 From 977d987f35e77c816209b4bd753669b94124b54e Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:44:29 +0200 Subject: [PATCH 50/96] Use /bin/bash as interpreter, and store with UNIX line breaks --- plugins/network/hfsc | 308 +++++++++++++++++++++---------------------- 1 file changed, 154 insertions(+), 154 deletions(-) diff --git a/plugins/network/hfsc b/plugins/network/hfsc index 3e7412ea..14314069 100755 --- a/plugins/network/hfsc +++ b/plugins/network/hfsc @@ -1,154 +1,154 @@ -#!/bin/sh -# -# Munin plugin for HFSC Traffic Shaping Statistics -# -# It shows the general statistic graph of a used net bandwidth per a user. -# -# This plugin was tailored to the HFSC solution -# presented at http://www.elessar.one.pl/article_kernel2.6.php -# -# You can find the plugin description and the installation notes here: -# http://www.elessar.one.pl/article_munin.php -# -### -# Written by Rafal Rajs -# Date: 2007/06/19 -# Email: elessar1@poczta.wp.pl -# WWW: http://www.elessar.one.pl -### - -#path to the file with global defs -. /etc/scripts/globals - - -# imported from HFSC script -# set class numbers - -N_CLASS_D_1=70 -N_CLASS_D_2=100 -N_CLASS_U_1=130 -N_CLASS_U_2=160 -SH_TMP="/etc/scripts/tmp.txt" - -if [ "$1" = "config" ]; then - - echo "graph_title HFSC Traffic Shaping Stats" - echo 'graph_vlabel bytes per ${graph_period}' - echo 'graph_category network' - - j=1 - - while [ $j -le $L_USERS ] - do - echo "${USERNAMES[${j}]}.label ${USERNAMES[${j}]}" - echo "${USERNAMES[${j}]}.type COUNTER" - - if [ $j == 1 ]; then - echo "${USERNAMES[${j}]}.draw AREA" - else - echo "${USERNAMES[${j}]}.draw STACK" - fi; - - echo "${USERNAMES[${j}]}.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}" - echo "${USERNAMES[${j}]}.min 0" - echo "${USERNAMES[${j}]}.max 130000" - - j=$[$j+1] - - done; - -#customized colours - echo 'Serwer.colour 000000' - - exit 0 - -fi; - -#### DOWNLOAD - -temp1=`/sbin/tc -s class show dev imq0 > $SH_TMP` - - -while read line -do - test_hfsc=`echo $line | grep "hfsc"` - - j=1 - - while [ $j -le $L_USERS ] - do - case $test_hfsc in - - *hfsc[\ ]1:$[$N_CLASS_D_1+$j]*) - # check N_CLASS_D_1 stats for every user - read line - temp1=`echo $line | awk '{ print $2; }'` - STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] -# echo "N_CLASS_D_1="$temp1 -# echo "N_CLASS_D_1_SUM "$j" ="${STAT_USER[$j]} - ;; - *hfsc[\ ]1:$[$N_CLASS_D_2+$j]*) - # check N_CLASS_D_2 stats for every user - read line - temp1=`echo $line | awk '{ print $2; }'` - STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] -# echo "N_CLASS_D_2="$temp1 -# echo "N_CLASS_D_2_SUM "$j" ="${STAT_USER[$j]} - ;; - esac - - j=$[$j+1] - - done; - -done < $SH_TMP - -#### UPLOAD - -temp1=`/sbin/tc -s class show dev imq1 > $SH_TMP` - - -while read line -do - test_hfsc=`echo $line | grep "hfsc"` - - j=1 - - while [ $j -le $L_USERS ] - do - case $test_hfsc in - - *hfsc[\ ]1:$[$N_CLASS_U_1+$j]*) - # check N_CLASS_U_1 stats for every user - read line - temp1=`echo $line | awk '{ print $2; }'` - STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] -# echo "N_CLASS_U_1="$temp1 -# echo "N_CLASS_U_1_SUM "$j" ="${STAT_USER[$j]} - ;; - *hfsc[\ ]1:$[$N_CLASS_U_2+$j]*) - # check N_CLASS_U_2 stats for every user - read line - temp1=`echo $line | awk '{ print $2; }'` - STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] -# echo "N_CLASS_U_2="$temp1 -# echo "N_CLASS_U_2_SUM "$j" ="${STAT_USER[$j]} - ;; - esac - - j=$[$j+1] - - done; - -done < $SH_TMP - -j=1 -while [ $j -le $L_USERS ] -do - echo ${USERNAMES[${j}]}".value "${STAT_USER[$j]} - j=$[$j+1] -done; - - -## clean temp file -temp1=`echo "" > $SH_TMP` +#!/bin/bash +# +# Munin plugin for HFSC Traffic Shaping Statistics +# +# It shows the general statistic graph of a used net bandwidth per a user. +# +# This plugin was tailored to the HFSC solution +# presented at http://www.elessar.one.pl/article_kernel2.6.php +# +# You can find the plugin description and the installation notes here: +# http://www.elessar.one.pl/article_munin.php +# +### +# Written by Rafal Rajs +# Date: 2007/06/19 +# Email: elessar1@poczta.wp.pl +# WWW: http://www.elessar.one.pl +### + +#path to the file with global defs +. /etc/scripts/globals + + +# imported from HFSC script +# set class numbers + +N_CLASS_D_1=70 +N_CLASS_D_2=100 +N_CLASS_U_1=130 +N_CLASS_U_2=160 +SH_TMP="/etc/scripts/tmp.txt" + +if [ "$1" = "config" ]; then + + echo "graph_title HFSC Traffic Shaping Stats" + echo 'graph_vlabel bytes per ${graph_period}' + echo 'graph_category network' + + j=1 + + while [ $j -le $L_USERS ] + do + echo "${USERNAMES[${j}]}.label ${USERNAMES[${j}]}" + echo "${USERNAMES[${j}]}.type COUNTER" + + if [ $j == 1 ]; then + echo "${USERNAMES[${j}]}.draw AREA" + else + echo "${USERNAMES[${j}]}.draw STACK" + fi; + + echo "${USERNAMES[${j}]}.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}" + echo "${USERNAMES[${j}]}.min 0" + echo "${USERNAMES[${j}]}.max 130000" + + j=$[$j+1] + + done; + +#customized colours + echo 'Serwer.colour 000000' + + exit 0 + +fi; + +#### DOWNLOAD + +temp1=`/sbin/tc -s class show dev imq0 > $SH_TMP` + + +while read line +do + test_hfsc=`echo $line | grep "hfsc"` + + j=1 + + while [ $j -le $L_USERS ] + do + case $test_hfsc in + + *hfsc[\ ]1:$[$N_CLASS_D_1+$j]*) + # check N_CLASS_D_1 stats for every user + read line + temp1=`echo $line | awk '{ print $2; }'` + STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] +# echo "N_CLASS_D_1="$temp1 +# echo "N_CLASS_D_1_SUM "$j" ="${STAT_USER[$j]} + ;; + *hfsc[\ ]1:$[$N_CLASS_D_2+$j]*) + # check N_CLASS_D_2 stats for every user + read line + temp1=`echo $line | awk '{ print $2; }'` + STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] +# echo "N_CLASS_D_2="$temp1 +# echo "N_CLASS_D_2_SUM "$j" ="${STAT_USER[$j]} + ;; + esac + + j=$[$j+1] + + done; + +done < $SH_TMP + +#### UPLOAD + +temp1=`/sbin/tc -s class show dev imq1 > $SH_TMP` + + +while read line +do + test_hfsc=`echo $line | grep "hfsc"` + + j=1 + + while [ $j -le $L_USERS ] + do + case $test_hfsc in + + *hfsc[\ ]1:$[$N_CLASS_U_1+$j]*) + # check N_CLASS_U_1 stats for every user + read line + temp1=`echo $line | awk '{ print $2; }'` + STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] +# echo "N_CLASS_U_1="$temp1 +# echo "N_CLASS_U_1_SUM "$j" ="${STAT_USER[$j]} + ;; + *hfsc[\ ]1:$[$N_CLASS_U_2+$j]*) + # check N_CLASS_U_2 stats for every user + read line + temp1=`echo $line | awk '{ print $2; }'` + STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1] +# echo "N_CLASS_U_2="$temp1 +# echo "N_CLASS_U_2_SUM "$j" ="${STAT_USER[$j]} + ;; + esac + + j=$[$j+1] + + done; + +done < $SH_TMP + +j=1 +while [ $j -le $L_USERS ] +do + echo ${USERNAMES[${j}]}".value "${STAT_USER[$j]} + j=$[$j+1] +done; + + +## clean temp file +temp1=`echo "" > $SH_TMP` From abe9f3b6ee0c6648ddf2dd5e23c6d570ceb7de50 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:45:45 +0200 Subject: [PATCH 51/96] Use UNIX line breaks --- plugins/network/packetloss | 120 ++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/plugins/network/packetloss b/plugins/network/packetloss index 7a6091da..f2c19d4a 100755 --- a/plugins/network/packetloss +++ b/plugins/network/packetloss @@ -1,60 +1,60 @@ -#!/bin/sh -# -# Copyright (c) 2009 Sven-Hendrik Haase -# Copyright (C) 2004 Jimmy Olsen -# -# 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; version 2 dated June, -# 1991. -# -# 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. -# -# -# Plugin to monitor packet loss -# -# Please note that sometimes it can take quite long for the plugin to return -# a value on a network with lots of packet loss. -# You therefore need to account for it by appending the following to your -# plugin-conf.d/munin-node. Remember to restart munin-node afterwards. -# Append the next 3 lines to plugin-conf.d/munin-node: -# [packetloss_*] -# timeout 60 -# user root -# -# Parameters: -# -# ping_args - Arguments to ping (default "-c 2") -# ping_args2 - Arguments after the host name (required for Solaris) -# ping - Ping program to use -# host - Host to ping -# -# Arguments for Solaris: -# ping_args -s -# ping_args2 56 2 -# -#%# family=manual - -file_host=`basename $0 | sed 's/^packetloss_//g'` -host=${host:-${file_host:-www.google.com}} - -if [ "$1" = "config" ]; then - echo "graph_title Packet loss to $host (in %)" - echo 'graph_args --upper-limit 100 -l 0' - echo 'graph_vlabel %' - echo 'graph_category network' - echo 'graph_info This graph shows packet loss statistics.' - echo "packetloss.label $host" - echo "packetloss.info Packet loss statistics for $host." - echo 'packetloss.draw LINE2' - exit 0 -fi - -${ping:-ping} ${ping_args:-'-c 10'} ${host} ${ping_args2} | perl -n -e 'print "packetloss.value $1\n" if /(\d+)% packet loss/;' \ No newline at end of file +#!/bin/sh +# +# Copyright (c) 2009 Sven-Hendrik Haase +# Copyright (C) 2004 Jimmy Olsen +# +# 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; version 2 dated June, +# 1991. +# +# 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. +# +# +# Plugin to monitor packet loss +# +# Please note that sometimes it can take quite long for the plugin to return +# a value on a network with lots of packet loss. +# You therefore need to account for it by appending the following to your +# plugin-conf.d/munin-node. Remember to restart munin-node afterwards. +# Append the next 3 lines to plugin-conf.d/munin-node: +# [packetloss_*] +# timeout 60 +# user root +# +# Parameters: +# +# ping_args - Arguments to ping (default "-c 2") +# ping_args2 - Arguments after the host name (required for Solaris) +# ping - Ping program to use +# host - Host to ping +# +# Arguments for Solaris: +# ping_args -s +# ping_args2 56 2 +# +#%# family=manual + +file_host=`basename $0 | sed 's/^packetloss_//g'` +host=${host:-${file_host:-www.google.com}} + +if [ "$1" = "config" ]; then + echo "graph_title Packet loss to $host (in %)" + echo 'graph_args --upper-limit 100 -l 0' + echo 'graph_vlabel %' + echo 'graph_category network' + echo 'graph_info This graph shows packet loss statistics.' + echo "packetloss.label $host" + echo "packetloss.info Packet loss statistics for $host." + echo 'packetloss.draw LINE2' + exit 0 +fi + +${ping:-ping} ${ping_args:-'-c 10'} ${host} ${ping_args2} | perl -n -e 'print "packetloss.value $1\n" if /(\d+)% packet loss/;' From 5d0b617cd2dfe0bdf07d98b09a0edbc83dbe468a Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:46:21 +0200 Subject: [PATCH 52/96] Use /bin/bash as interpreter for bash script --- plugins/ftp/pureftpd_count | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ftp/pureftpd_count b/plugins/ftp/pureftpd_count index ab7bc247..93adb923 100755 --- a/plugins/ftp/pureftpd_count +++ b/plugins/ftp/pureftpd_count @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # # Script to show pureftp counts. From 673303f12796bab13aefb41022908e5a82aba199 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:49:45 +0200 Subject: [PATCH 53/96] "handle" expect scripts by pretending syntax is ok --- t/test.t | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/t/test.t b/t/test.t index 17c2b031..e2743488 100644 --- a/t/test.t +++ b/t/test.t @@ -91,6 +91,11 @@ sub process_file { $filename . " gawk syntax check" ); } + elsif ( $interpreter =~ m{expect} ) { + pass( + "No idea how to check expect scripts, pretending everything is ok" + ); + } else { fail( $filename . " unknown interpreter " . $interpreter ); } From da59e03cf2433110434ec9bb7bda39434045b74e Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 21:52:28 +0200 Subject: [PATCH 54/96] Save with UNIX line endings --- plugins/healthcheck/healthcheck_process | 184 ++++++++++++------------ plugins/trafic_ro/trafic_ro_24h | 34 ++--- 2 files changed, 109 insertions(+), 109 deletions(-) diff --git a/plugins/healthcheck/healthcheck_process b/plugins/healthcheck/healthcheck_process index 1d8863bd..7e5edc3d 100755 --- a/plugins/healthcheck/healthcheck_process +++ b/plugins/healthcheck/healthcheck_process @@ -1,92 +1,92 @@ -#!/bin/bash -# -#healthcheck on munin -#check process and alert. -# -#programed by rti (hiroyuki fujie) super.rti@gmail.com @super_rti -#LICENSE: NYSL (public domain) -# -#config file -# /etc/munin/plugin-conf.d/munin-node -# -#example minimum config -#--------------------------------------------------- -#[healthcheck_process] -#env.process_1 httpd -#--------------------------------------------------- -# -#chcek two process -#--------------------------------------------------- -#[healthcheck_process] -#env.process_1 httpd -#env.process_2 samba -#--------------------------------------------------- -# -#chcek three process -#--------------------------------------------------- -#[healthcheck_process] -#env.process_1 httpd -#env.process_2 samba -#env.process_3 mysqld -#--------------------------------------------------- -# -# -# - -#edakari speed up. -CHECKMAX=`env | grep process_ | wc -l` -let CHECKMAX="$CHECKMAX + 1" - -if [ "$1" = "autoconf" ]; then - if [ $CHECKMAX -le 1 ]; then - echo no - exit 1 - fi - echo yes - exit 0 -fi - -if [ "$1" = "config" ]; then - - echo 'graph_title process memory Usage(MB)' - echo "graph_args --base 1000 -l 0 --vertical-label MB" - echo 'graph_scale no' - echo 'graph_vlabel process memory' - echo 'graph_category healthcheck' - echo 'graph_info This graph shows the Memory used by process' - - for(( I = 1; I < $CHECKMAX; ++I )) - do - eval process=\$process_${I} - eval alertmemory=\$alertmemory_${I} - if [ "x${process}" = "x" ]; then - continue - fi - - echo "$process.label $process" - echo "$process.info Memory used by $process" - echo "$process.draw LINE2" - echo "$process.min -10" - echo "$process.critical 0:" - done - - exit 0 -fi - -for(( I = 1; I < $CHECKMAX; ++I )) -do - eval process=\$process_${I} - if [ "x${process}" = "x" ]; then - continue - fi - - vrets=(`ps u --no-headers -C $process | awk 'BEGIN { count = 0 ; sum = 0; } { count ++ ; sum += $6/1024 ; } END { printf("%d %d\n",count,sum); }'`) - count=${vrets[0]} - value=${vrets[1]} - if [ $count -le 0 ]; then - echo "$process.value -10" - echo "$process.extinfo process down" - else - echo "$process.value $value" - fi -done +#!/bin/bash +# +#healthcheck on munin +#check process and alert. +# +#programed by rti (hiroyuki fujie) super.rti@gmail.com @super_rti +#LICENSE: NYSL (public domain) +# +#config file +# /etc/munin/plugin-conf.d/munin-node +# +#example minimum config +#--------------------------------------------------- +#[healthcheck_process] +#env.process_1 httpd +#--------------------------------------------------- +# +#chcek two process +#--------------------------------------------------- +#[healthcheck_process] +#env.process_1 httpd +#env.process_2 samba +#--------------------------------------------------- +# +#chcek three process +#--------------------------------------------------- +#[healthcheck_process] +#env.process_1 httpd +#env.process_2 samba +#env.process_3 mysqld +#--------------------------------------------------- +# +# +# + +#edakari speed up. +CHECKMAX=`env | grep process_ | wc -l` +let CHECKMAX="$CHECKMAX + 1" + +if [ "$1" = "autoconf" ]; then + if [ $CHECKMAX -le 1 ]; then + echo no + exit 1 + fi + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title process memory Usage(MB)' + echo "graph_args --base 1000 -l 0 --vertical-label MB" + echo 'graph_scale no' + echo 'graph_vlabel process memory' + echo 'graph_category healthcheck' + echo 'graph_info This graph shows the Memory used by process' + + for(( I = 1; I < $CHECKMAX; ++I )) + do + eval process=\$process_${I} + eval alertmemory=\$alertmemory_${I} + if [ "x${process}" = "x" ]; then + continue + fi + + echo "$process.label $process" + echo "$process.info Memory used by $process" + echo "$process.draw LINE2" + echo "$process.min -10" + echo "$process.critical 0:" + done + + exit 0 +fi + +for(( I = 1; I < $CHECKMAX; ++I )) +do + eval process=\$process_${I} + if [ "x${process}" = "x" ]; then + continue + fi + + vrets=(`ps u --no-headers -C $process | awk 'BEGIN { count = 0 ; sum = 0; } { count ++ ; sum += $6/1024 ; } END { printf("%d %d\n",count,sum); }'`) + count=${vrets[0]} + value=${vrets[1]} + if [ $count -le 0 ]; then + echo "$process.value -10" + echo "$process.extinfo process down" + else + echo "$process.value $value" + fi +done diff --git a/plugins/trafic_ro/trafic_ro_24h b/plugins/trafic_ro/trafic_ro_24h index 0e4ab979..9200fc5f 100755 --- a/plugins/trafic_ro/trafic_ro_24h +++ b/plugins/trafic_ro/trafic_ro_24h @@ -1,17 +1,17 @@ -#!/bin/sh -RID=${0##*trafic_ro_} - -if [ "$1" = "config" ]; then - echo graph_title $V 24h visitors for $RID - echo 'graph_args --base 1000' - echo 'graph_vlabel vizitatori_ultimele_24_ore' - echo 'graph_category Trafic_ro' - echo 'graph_info 24h visitors.' - echo "24h_visitors.label $RID" - echo "24h_visitors.info 24H visitors for $RID" - echo '24h_visitors.draw LINE2' - exit 0 -fi - -VISITORS="$(echo 'munin' | curl curl --silent -X POST -H 'Content-type: text/xml' -d @- http://api.trafic.ro/rest/0.01/sumar-site/$RID | xmlstarlet sel -t -m "/sumar-site/vizitatori_ultimele_24_ore" -v ".")" -echo "24h_visitors.value" $VISITORS; +#!/bin/sh +RID=${0##*trafic_ro_} + +if [ "$1" = "config" ]; then + echo graph_title $V 24h visitors for $RID + echo 'graph_args --base 1000' + echo 'graph_vlabel vizitatori_ultimele_24_ore' + echo 'graph_category Trafic_ro' + echo 'graph_info 24h visitors.' + echo "24h_visitors.label $RID" + echo "24h_visitors.info 24H visitors for $RID" + echo '24h_visitors.draw LINE2' + exit 0 +fi + +VISITORS="$(echo 'munin' | curl curl --silent -X POST -H 'Content-type: text/xml' -d @- http://api.trafic.ro/rest/0.01/sumar-site/$RID | xmlstarlet sel -t -m "/sumar-site/vizitatori_ultimele_24_ore" -v ".")" +echo "24h_visitors.value" $VISITORS; From 010011efe8e415486c2e54807168bc09c71dc2fd Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:03:52 +0200 Subject: [PATCH 55/96] Use "=" for comparison with /bin/sh --- plugins/cyrus/cyrus-imapd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/cyrus/cyrus-imapd b/plugins/cyrus/cyrus-imapd index d765af6e..faaba8cc 100755 --- a/plugins/cyrus/cyrus-imapd +++ b/plugins/cyrus/cyrus-imapd @@ -69,7 +69,7 @@ GPLv2 CONFIGDIR=$(awk -F : '/^configdirectory:/ { gsub(/ /, "", $2); print $2 }' /etc/imapd.conf 2> /dev/null) PROCDIR="${CONFIGDIR}/proc" -if [ "$1" == "autoconf" ]; then +if [ "$1" = "autoconf" ]; then if [ "x${CONFIGDIR}x" != "xx" ] && [ -d ${PROCDIR} ]; then echo yes else @@ -79,14 +79,14 @@ if [ "$1" == "autoconf" ]; then fi # Check if we actually got some sensible data -if [ "x${CONFIGDIR}x" == "xx" ]; then +if [ "x${CONFIGDIR}x" = "xx" ]; then exit 1 fi # If run with the "config"-parameter, give out information on how the # graphs should look. -if [ "$1" == "config" ]; then +if [ "$1" = "config" ]; then echo 'graph_title Cyrus IMAPd Load' echo 'graph_args --base 1000 -l 0' echo 'graph_vlabel connections' From 78e3f780715364a81cdbbc67a9799802a1155870 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:05:54 +0200 Subject: [PATCH 56/96] Use UNIX line breaks --- plugins/ups/apc_status | 66 +++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/plugins/ups/apc_status b/plugins/ups/apc_status index 586803ac..fee73ff5 100755 --- a/plugins/ups/apc_status +++ b/plugins/ups/apc_status @@ -1,33 +1,33 @@ -#!/bin/sh -# -# (c) Andreas Kreisl -# -# Link name will be used as title: apc_{$title} -# -# env.keys LOADPCT BCHARGE LINEV BATTV TIMELEFT -# env.unit % or Volt or Minutes -# - - -if [ -z "$keys" ]; then - keys="TIMELEFT" -fi - -if [ "$1" = "config" ]; then - title=`basename $0 | sed 's/^apc_//g' | awk '{ sub(/^./,toupper(substr($0,1,1))); print; }'` - echo "graph_title APC Status - $title" - echo 'graph_args --base 1000 -l 0 ' - echo "graph_vlabel $unit" - echo 'graph_category sensors' - title=`/sbin/apcaccess | egrep "^MODEL" | awk '{print $3" "$4" "$5" "$6" "$7" "$8" "$9;}'` - echo "graph_info $title" - for key in $keys; do - echo "$key.label $key" - echo "$key.info Value of $key." - echo "$key.draw LINE2" - done - exit 0 -fi - -searchkey=`echo "$keys" | tr " " "\|"` -/sbin/apcaccess | egrep "$searchkey" | awk '{print $1".value "$3;}' +#!/bin/sh +# +# (c) Andreas Kreisl +# +# Link name will be used as title: apc_{$title} +# +# env.keys LOADPCT BCHARGE LINEV BATTV TIMELEFT +# env.unit % or Volt or Minutes +# + + +if [ -z "$keys" ]; then + keys="TIMELEFT" +fi + +if [ "$1" = "config" ]; then + title=`basename $0 | sed 's/^apc_//g' | awk '{ sub(/^./,toupper(substr($0,1,1))); print; }'` + echo "graph_title APC Status - $title" + echo 'graph_args --base 1000 -l 0 ' + echo "graph_vlabel $unit" + echo 'graph_category sensors' + title=`/sbin/apcaccess | egrep "^MODEL" | awk '{print $3" "$4" "$5" "$6" "$7" "$8" "$9;}'` + echo "graph_info $title" + for key in $keys; do + echo "$key.label $key" + echo "$key.info Value of $key." + echo "$key.draw LINE2" + done + exit 0 +fi + +searchkey=`echo "$keys" | tr " " "\|"` +/sbin/apcaccess | egrep "$searchkey" | awk '{print $1".value "$3;}' From e7125ea079de4b33505150f5db68a1c402678ece Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:09:30 +0200 Subject: [PATCH 57/96] Tell ruby that this script contains UTF-8 characters --- plugins/snmp/snmp_room_alert_ | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/snmp/snmp_room_alert_ b/plugins/snmp/snmp_room_alert_ index e895f143..249c6c12 100755 --- a/plugins/snmp/snmp_room_alert_ +++ b/plugins/snmp/snmp_room_alert_ @@ -1,4 +1,5 @@ #!/usr/bin/ruby +# encoding: utf-8 # Plugin to monitor Room Alert 11E environmental units. # Requires ruby and the ruby SNMP library. From a55f4e4a4d52e604fe09878f5362c0f4376829f8 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:14:17 +0200 Subject: [PATCH 58/96] remove dead code block using an unknown variable - same "if" test in the block above, so this would never be reached --- plugins/snmp/snmp__cpu_usage | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/snmp/snmp__cpu_usage b/plugins/snmp/snmp__cpu_usage index d3c3c0a5..0d02bf63 100755 --- a/plugins/snmp/snmp__cpu_usage +++ b/plugins/snmp/snmp__cpu_usage @@ -133,12 +133,6 @@ if (!defined ($session)) die "Croaking: could not establish SNMP object"; } - -if (!defined ($session)) -{ - die "Croaking: $error"; -} - if ($ARGV[0] and $ARGV[0] eq "config") { print "host_name $host\n"; From ea4a0c6244db23588c28ee60150205fa5133276a Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:15:24 +0200 Subject: [PATCH 59/96] Change "&>" bashism to "> ... 2>&1", keeping the script as /bin/sh --- plugins/reddit_karma/reddit_karma_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/reddit_karma/reddit_karma_ b/plugins/reddit_karma/reddit_karma_ index 5e195f1d..855cd478 100755 --- a/plugins/reddit_karma/reddit_karma_ +++ b/plugins/reddit_karma/reddit_karma_ @@ -32,7 +32,7 @@ reddit_user=${0##*reddit_karma_} ## if [ "$1" = "autoconf" ]; then # Check that curl is installed - if hash curl &>/dev/null; then + if hash curl >/dev/null 2>&1; then echo "yes" else echo "no (no curl installed)" From 1c67e3d6485437f4e0e3c143d9075c335c984559 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:19:38 +0200 Subject: [PATCH 60/96] Save with UNIX line breaks --- plugins/powermta/powermta_vmta_recpients | 84 ++++++++++++------------ 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/plugins/powermta/powermta_vmta_recpients b/plugins/powermta/powermta_vmta_recpients index 46b53a3d..f873dc99 100755 --- a/plugins/powermta/powermta_vmta_recpients +++ b/plugins/powermta/powermta_vmta_recpients @@ -1,42 +1,42 @@ -#!/bin/bash - -vmta="208-97-205-153" -# Lets run the command to pull the vmta's in -queues=(`pmta show queue */$vmta | awk -F" " '{print $1}'`) # Pull in top queues - -# Now we need to do some further cleanup for blank or erroneous array items -unset queues[0] -unset queues[${#queues[@]}] - - - -case $1 in - config) - -echo "graph_title RGMTA2 PMTA VMTA $vmta Recipents" -echo "graph_vlabel recipents" -echo "graph_scale no" -echo "graph_category PowerMTA" -for i in ${queues[@]};do -queue=(`pmta show queue $i`) -unset queue[0] -unset queue[${#queue[@]}] - -domain=`echo "${queue[7]}" | awk -F" " '{print $1}' | cut -d/ -f1 | sed -e 's/[\.]/_/g'` -domain2=`echo "${queue[7]}" | awk -F" " '{print $1}' | cut -d/ -f1` -echo $domain'.label '$domain2 -echo $domain'.draw STACK' -done -exit 0;; -esac - -for i in ${queues[@]};do -queue=(`pmta show queue $i`) -unset queue[0] -unset queue[${#queue[@]}] - -domain=`echo "${queue[7]}" | awk -F" " '{print $1}' | cut -d/ -f1 | sed -e 's/[\.]/_/g'` -recpts=${queue[8]} -conns=${queue[10]} -echo $domain'.value '$recpts -done +#!/bin/bash + +vmta="208-97-205-153" +# Lets run the command to pull the vmta's in +queues=(`pmta show queue */$vmta | awk -F" " '{print $1}'`) # Pull in top queues + +# Now we need to do some further cleanup for blank or erroneous array items +unset queues[0] +unset queues[${#queues[@]}] + + + +case $1 in + config) + +echo "graph_title RGMTA2 PMTA VMTA $vmta Recipents" +echo "graph_vlabel recipents" +echo "graph_scale no" +echo "graph_category PowerMTA" +for i in ${queues[@]};do +queue=(`pmta show queue $i`) +unset queue[0] +unset queue[${#queue[@]}] + +domain=`echo "${queue[7]}" | awk -F" " '{print $1}' | cut -d/ -f1 | sed -e 's/[\.]/_/g'` +domain2=`echo "${queue[7]}" | awk -F" " '{print $1}' | cut -d/ -f1` +echo $domain'.label '$domain2 +echo $domain'.draw STACK' +done +exit 0;; +esac + +for i in ${queues[@]};do +queue=(`pmta show queue $i`) +unset queue[0] +unset queue[${#queue[@]}] + +domain=`echo "${queue[7]}" | awk -F" " '{print $1}' | cut -d/ -f1 | sed -e 's/[\.]/_/g'` +recpts=${queue[8]} +conns=${queue[10]} +echo $domain'.value '$recpts +done From 6c9ad881ae9db71ff282b8a28703b83b353656cd Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:20:32 +0200 Subject: [PATCH 61/96] fix unterminated string --- plugins/other/qstatcod4and5_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/other/qstatcod4and5_ b/plugins/other/qstatcod4and5_ index 86363491..e60d9156 100755 --- a/plugins/other/qstatcod4and5_ +++ b/plugins/other/qstatcod4and5_ @@ -29,7 +29,7 @@ usage() { echo 'For testing the script, run qstatcod4and5_ cods IP PORT' 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 '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 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe}; echo 'Have Fun' From 73e23cb7ba188d9c89461e8b89bd6387c810bb9d Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:21:02 +0200 Subject: [PATCH 62/96] use /bin/bash as interpreter for bash script --- plugins/other/conexant_adsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/other/conexant_adsl b/plugins/other/conexant_adsl index d2fe3914..fa774d81 100755 --- a/plugins/other/conexant_adsl +++ b/plugins/other/conexant_adsl @@ -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... From 81fd4c97c3822f03354d39f14065a7c9559e1082 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:21:35 +0200 Subject: [PATCH 63/96] Save with UNIX line breaks --- plugins/oracle/oracle_connections | 306 +++++++++++++++--------------- 1 file changed, 153 insertions(+), 153 deletions(-) diff --git a/plugins/oracle/oracle_connections b/plugins/oracle/oracle_connections index 17d26344..c039da4d 100755 --- a/plugins/oracle/oracle_connections +++ b/plugins/oracle/oracle_connections @@ -1,153 +1,153 @@ -#!/bin/bash -# -# Munin plugin to monitor oracle connections w/o DBD::Oracle, or perl for that -# matter ;-) -# -# Author: Kevin Kunkel (kunkel.kevin@gmail.com) on December 11, 2007 -# (Based off the perl munin plugin by Joan Carles Soler) -# -# Licenced under GPL v2. -# -# Usage: -# -# If required, give username, password and/or oracle server -# host through environment variables. -# -# Parameters: -# autoconf -# config (required) -# -# Config variables: -# -# ORACLE_SID - Which database to use. Defaults to orcl -# oracle_user - A oracle user account with read permission to -# the v$session view. Defaults to -# 'oracle'. Anyway, Munin must be told which user -# this plugin should be run as. -# oracle_pass - The corresponding password, if -# applicable. Default to undef. -# -# SHOW_ORACLE_USERS - If set to 1 show usernames and num. of connections. -# Default is not show users (0). -# Magic markers -#%# family=auto -#%# capabilities=autoconf - - -# Hard-code environment variables here - -#oracle_user= -#oracle_pass= -#ORACLE_SID= -#ORACLE_HOME= -#SHOW_ORACLE_USERS= - -# End variable hard-code - - - -if [ -z "$ORACLE_HOME" ] ; then - # Adjust to your oratab locations - for oratab in /var/opt/oracle/oratab /etc/oratab - do - [ ! -f $oratab ] && continue - IFS=: - while read SID HOME STARTUP; - do - if [ "$SID" = "*" ] - then - ORACLE_HOME=$HOME - break - fi - done < $oratab - [ -n "$ORACLE_HOME" ] && break - break - done -fi - -if [ -z "$ORACLE_SID" ] -then - ORACLE_SID="orcl" -fi - -if [ -z "$oracle_user" ] -then - oracle_user="oracle" -fi - -if [ -z "$SHOW_ORACLE_USERS" ] -then - SHOW_ORACLE_USERS=0 -else - if [ $SHOW_ORACLE_USERS -ne 1 ] - then - SHOW_ORACLE_USERS=0 - fi -fi - -PATH=$PATH:$ORACLE_HOME/bin -export ORACLE_HOME PATH ORACLE_SID - -if [ "$1" = "autoconf" ] -then - echo yes - exit 0 -fi -if [ "$1" = "config" ] -then - WARN_CRIT=`sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | \ - grep -v '^$' | awk '{print $1 * 0.7 " " $1 * 0.8 }' -set pagesize 0 -select value from v\\$parameter where name = 'sessions'; -EOF` - echo "graph_title Oracle active connections to $ORACLE_SID" - echo "graph_args -l 0 --base 1000" - echo "graph_vlabel Connections" - echo "graph_category Oracle" - echo "graph_info Shows active oracle connections to $ORACLE_SID" - echo "graph_scale no" - if [ $SHOW_ORACLE_USERS -eq 1 ] - then - sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | \ - grep -v '^$' | awk '{ print $1 ".label " $1 " active connections" - print $1 ".info " $1 " active connections" - print $1 ".type GAUGE" }; END { - print "total.label active connections" - print "total.info active connections" - print "total.type GAUGE" - }' -set pagesize 0 -select username, count(username) from v\$session where username is not null group by username; -EOF - echo $WARN_CRIT| awk '{ print "total.warning " $1 "\ntotal.critical " $2 }' - else - echo "connections.label active connections" - echo "connections.info active connections" - echo "connections.type GAUGE" - echo $WARN_CRIT| awk '{ print "connections.warning " $1 "\nconnections.critical " $2 }' - fi -fi - - -if [ $SHOW_ORACLE_USERS -eq 1 ] -then - sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | \ - grep -v '^$'|awk 'BEGIN { total=0 } { - print $1 ".value " $2 - total=total+$2 } END { print "total.value " total }' -set pagesize 0 -select username, count(username) from v\$session where username is not null group by username; -EOF -else - sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | grep -v '^$'|\ - awk '{ print "connections.value " $1 }' -set pagesize 0 -select count(username) from v\$session where username is not null; -EOF -fi - -echo "max_connections.value" "`sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | \ - grep -v '^$' | awk '{print $1 }' -set pagesize 0 -select value from v\\$parameter where name = 'sessions'; -EOF`" +#!/bin/bash +# +# Munin plugin to monitor oracle connections w/o DBD::Oracle, or perl for that +# matter ;-) +# +# Author: Kevin Kunkel (kunkel.kevin@gmail.com) on December 11, 2007 +# (Based off the perl munin plugin by Joan Carles Soler) +# +# Licenced under GPL v2. +# +# Usage: +# +# If required, give username, password and/or oracle server +# host through environment variables. +# +# Parameters: +# autoconf +# config (required) +# +# Config variables: +# +# ORACLE_SID - Which database to use. Defaults to orcl +# oracle_user - A oracle user account with read permission to +# the v$session view. Defaults to +# 'oracle'. Anyway, Munin must be told which user +# this plugin should be run as. +# oracle_pass - The corresponding password, if +# applicable. Default to undef. +# +# SHOW_ORACLE_USERS - If set to 1 show usernames and num. of connections. +# Default is not show users (0). +# Magic markers +#%# family=auto +#%# capabilities=autoconf + + +# Hard-code environment variables here + +#oracle_user= +#oracle_pass= +#ORACLE_SID= +#ORACLE_HOME= +#SHOW_ORACLE_USERS= + +# End variable hard-code + + + +if [ -z "$ORACLE_HOME" ] ; then + # Adjust to your oratab locations + for oratab in /var/opt/oracle/oratab /etc/oratab + do + [ ! -f $oratab ] && continue + IFS=: + while read SID HOME STARTUP; + do + if [ "$SID" = "*" ] + then + ORACLE_HOME=$HOME + break + fi + done < $oratab + [ -n "$ORACLE_HOME" ] && break + break + done +fi + +if [ -z "$ORACLE_SID" ] +then + ORACLE_SID="orcl" +fi + +if [ -z "$oracle_user" ] +then + oracle_user="oracle" +fi + +if [ -z "$SHOW_ORACLE_USERS" ] +then + SHOW_ORACLE_USERS=0 +else + if [ $SHOW_ORACLE_USERS -ne 1 ] + then + SHOW_ORACLE_USERS=0 + fi +fi + +PATH=$PATH:$ORACLE_HOME/bin +export ORACLE_HOME PATH ORACLE_SID + +if [ "$1" = "autoconf" ] +then + echo yes + exit 0 +fi +if [ "$1" = "config" ] +then + WARN_CRIT=`sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | \ + grep -v '^$' | awk '{print $1 * 0.7 " " $1 * 0.8 }' +set pagesize 0 +select value from v\\$parameter where name = 'sessions'; +EOF` + echo "graph_title Oracle active connections to $ORACLE_SID" + echo "graph_args -l 0 --base 1000" + echo "graph_vlabel Connections" + echo "graph_category Oracle" + echo "graph_info Shows active oracle connections to $ORACLE_SID" + echo "graph_scale no" + if [ $SHOW_ORACLE_USERS -eq 1 ] + then + sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | \ + grep -v '^$' | awk '{ print $1 ".label " $1 " active connections" + print $1 ".info " $1 " active connections" + print $1 ".type GAUGE" }; END { + print "total.label active connections" + print "total.info active connections" + print "total.type GAUGE" + }' +set pagesize 0 +select username, count(username) from v\$session where username is not null group by username; +EOF + echo $WARN_CRIT| awk '{ print "total.warning " $1 "\ntotal.critical " $2 }' + else + echo "connections.label active connections" + echo "connections.info active connections" + echo "connections.type GAUGE" + echo $WARN_CRIT| awk '{ print "connections.warning " $1 "\nconnections.critical " $2 }' + fi +fi + + +if [ $SHOW_ORACLE_USERS -eq 1 ] +then + sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | \ + grep -v '^$'|awk 'BEGIN { total=0 } { + print $1 ".value " $2 + total=total+$2 } END { print "total.value " total }' +set pagesize 0 +select username, count(username) from v\$session where username is not null group by username; +EOF +else + sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | grep -v '^$'|\ + awk '{ print "connections.value " $1 }' +set pagesize 0 +select count(username) from v\$session where username is not null; +EOF +fi + +echo "max_connections.value" "`sqlplus -s ${oracle_user}/${oracle_pass}@$ORACLE_SID << EOF | \ + grep -v '^$' | awk '{print $1 }' +set pagesize 0 +select value from v\\$parameter where name = 'sessions'; +EOF`" From 5fe31e0c3832d3e760521cf7aeb70c1c27e2283e Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:23:52 +0200 Subject: [PATCH 64/96] Fix comparison to be /bin/sh compliant --- plugins/openvpn/openvpn_as_mtime | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/openvpn/openvpn_as_mtime b/plugins/openvpn/openvpn_as_mtime index c92720f6..c260a598 100755 --- a/plugins/openvpn/openvpn_as_mtime +++ b/plugins/openvpn/openvpn_as_mtime @@ -72,7 +72,7 @@ for i in $LIST1; do done # If TOTU is 0, change to 1 for avoid problem in the division -if [[ $TOTU -eq 0 ]]; then +if [ "$TOTU" = "0" ]; then TOTU=1 fi From 96f2bc003a85f1881d91bc73c037c17a53bee089 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:27:32 +0200 Subject: [PATCH 65/96] Use single bracket for test, keeping /bin/sh as interpreter --- plugins/mysql/mysql_report | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mysql/mysql_report b/plugins/mysql/mysql_report index 798021e8..8ae0e02c 100755 --- a/plugins/mysql/mysql_report +++ b/plugins/mysql/mysql_report @@ -92,7 +92,7 @@ graph_vlabel ${vlabel} graph_category ${category} graph_info ${info} EOH1 - [[ -n "${period}" ]] && echo "graph_period ${period}" + [ -n "${period}" ] && echo "graph_period ${period}" I=1 for name in ${names}; do eval iquery='${query_'${name}'}' From b407ae17caff249deaa3c34d8db7aa639e3a28f7 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 22:29:27 +0200 Subject: [PATCH 66/96] Save with UNIX line breaks --- plugins/glassfish/glassfish_counters_ | 192 +++++++++++++------------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/plugins/glassfish/glassfish_counters_ b/plugins/glassfish/glassfish_counters_ index a24320e4..d2189ae0 100644 --- a/plugins/glassfish/glassfish_counters_ +++ b/plugins/glassfish/glassfish_counters_ @@ -1,96 +1,96 @@ -#!/bin/bash -# -*- sh -*- - -: << =cut - -=head1 NAME - -glassfish_counters_ - Wildcard-plugin to monitor counters in GlassFish - -=head1 CONFIGURATION - -This plugin does need the full path to the asadmin script: - [glassfish_counters_*] - env.ASADMIN /usr/local/glassfish/bin/asadmin - -This is a wildcard plugin. To monitor an subtree, link -glassfish_counters_ to this file. E.g. - - ln -s /usr/share/munin/plugins/glassfish_counters_ \ - /etc/munin/plugins/glassfish_counters_server.web.request - -...will monitor server.web.request.* - -To ignore certain counters, just add more "IGNORE" lines on top of -the awk script. (XXX: Fixme for env.) - -=head1 AUTHOR -Philipp Buehler - -=head1 LICENSE - -BSD 2-clause - -=head1 VERSION - - $Id: glassfish_counters_.in$ - 0.0.1 - -=cut -[ -z $ASADMIN ] && { - echo "ASADMIN not set in node configuration" - exit 1 - } || MUN_AS_ADMIN=${ASADMIN} - -check_link () { - scriptname=${0##*/} - myself=${scriptname##*_} - if [ "x$myself" = "x" ] ; then - echo "plugin must be symlinked, e.g. to glassfish_counters_server.web.request" - exit 1 - fi -} - -SUBTREE=${0##*glassfish_counters_} - -case $1 in - suggest) - echo "not implemented" - exit 0 - ;; - config) - check_link - $MUN_AS_ADMIN get -t --monitor=true "${SUBTREE}.*" | \ - awk 'BEGIN{ FS="[ = ]"} - /requestcount/ { next; } # IGNORE - /dotted-name/ { myself = $NF - print "graph_title GlassFish", myself - print "graph_vlabel count" - print "graph_category glassfish" - print "graph_info this shows available counters from", myself - next - } - /-name / { nwhat = split($1, what, ".") - gsub(/-name/, "", what[nwhat]) - print what[nwhat] ".label " $NF - print what[nwhat] ".type GAUGE" - } - /-description / { nwhat = split($1, what, ".") - gsub(/-description/, "", what[nwhat]) - $1 = ""; line = $0 - gsub(/^ /,"", line) - print what[nwhat] ".info " line - } - ' - exit 0 - ;; -esac - -check_link -$MUN_AS_ADMIN get -t --monitor=true "${SUBTREE}.*" | \ -awk 'BEGIN{ FS="[ = ]" } - /requestcount/ { next;} # IGNORE - /-count / { nwhat = split($1, what, ".") - gsub(/-count/, "", what[nwhat]) - print what[nwhat] ".value " $NF} -' +#!/bin/bash +# -*- sh -*- + +: << =cut + +=head1 NAME + +glassfish_counters_ - Wildcard-plugin to monitor counters in GlassFish + +=head1 CONFIGURATION + +This plugin does need the full path to the asadmin script: + [glassfish_counters_*] + env.ASADMIN /usr/local/glassfish/bin/asadmin + +This is a wildcard plugin. To monitor an subtree, link +glassfish_counters_ to this file. E.g. + + ln -s /usr/share/munin/plugins/glassfish_counters_ \ + /etc/munin/plugins/glassfish_counters_server.web.request + +...will monitor server.web.request.* + +To ignore certain counters, just add more "IGNORE" lines on top of +the awk script. (XXX: Fixme for env.) + +=head1 AUTHOR +Philipp Buehler + +=head1 LICENSE + +BSD 2-clause + +=head1 VERSION + + $Id: glassfish_counters_.in$ + 0.0.1 + +=cut +[ -z $ASADMIN ] && { + echo "ASADMIN not set in node configuration" + exit 1 + } || MUN_AS_ADMIN=${ASADMIN} + +check_link () { + scriptname=${0##*/} + myself=${scriptname##*_} + if [ "x$myself" = "x" ] ; then + echo "plugin must be symlinked, e.g. to glassfish_counters_server.web.request" + exit 1 + fi +} + +SUBTREE=${0##*glassfish_counters_} + +case $1 in + suggest) + echo "not implemented" + exit 0 + ;; + config) + check_link + $MUN_AS_ADMIN get -t --monitor=true "${SUBTREE}.*" | \ + awk 'BEGIN{ FS="[ = ]"} + /requestcount/ { next; } # IGNORE + /dotted-name/ { myself = $NF + print "graph_title GlassFish", myself + print "graph_vlabel count" + print "graph_category glassfish" + print "graph_info this shows available counters from", myself + next + } + /-name / { nwhat = split($1, what, ".") + gsub(/-name/, "", what[nwhat]) + print what[nwhat] ".label " $NF + print what[nwhat] ".type GAUGE" + } + /-description / { nwhat = split($1, what, ".") + gsub(/-description/, "", what[nwhat]) + $1 = ""; line = $0 + gsub(/^ /,"", line) + print what[nwhat] ".info " line + } + ' + exit 0 + ;; +esac + +check_link +$MUN_AS_ADMIN get -t --monitor=true "${SUBTREE}.*" | \ +awk 'BEGIN{ FS="[ = ]" } + /requestcount/ { next;} # IGNORE + /-count / { nwhat = split($1, what, ".") + gsub(/-count/, "", what[nwhat]) + print what[nwhat] ".value " $NF} +' From 9b01da77bad45d6040613954a33cdcad4afa886b Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sat, 4 Oct 2014 23:52:40 +0200 Subject: [PATCH 67/96] improve output and disable python checks for now --- t/test.t | 129 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 88 insertions(+), 41 deletions(-) diff --git a/t/test.t b/t/test.t index e2743488..50010787 100644 --- a/t/test.t +++ b/t/test.t @@ -47,69 +47,117 @@ sub process_file { if ( $interpreter =~ m{/bin/sh} ) { subtest $filename => sub { plan tests => 2; - ok( check_file_with( [ 'sh', '-n', $file ] ), "sh syntax check" ); - ok( check_file_with( [ 'checkbashisms', $file ] ), - "checkbashisms" ); + run_check( + { command => [ 'sh', '-n', $file ], + description => 'sh syntax check' + } + ); + run_check( + { command => [ 'checkbashisms', $file ], + description => 'checkbashisms' + } + ); }; } elsif ( $interpreter =~ m{/bin/ksh} ) { - ok( check_file_with( [ 'ksh', '-n', $file ] ), - $filename . " ksh syntax check" ); - } - elsif ( $interpreter =~ m{bash} ) { - ok( check_file_with( [ 'bash', '-n', $file ] ), - $filename . " bash syntax check" ); - } - elsif ( $interpreter =~ m{perl} ) { - ok( check_file_with( [ 'perl', '-cw', $file ] ), - $filename . " perl syntax check" ); - } - elsif ( $interpreter =~ m{python} ) { - ok( check_file_with( - [ 'pylint', '--rcfile=/dev/null', - '--errors-only', '--report=no', - $file - ] - ), - $filename . " python syntax check" + 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} ) { + run_check( + { command => [ 'perl', '-cw', $file ], + description => 'perl syntax check', + filename => $filename + } + ); + } + elsif ( $interpreter =~ m{python} ) { + SKIP: { + skip 'need better syntax check for python', 1; + run_check( + { command => [ + 'pylint', '--rcfile=/dev/null', + '--errors-only', '--report=no', + $file + ], + description => 'python syntax check', + filename => $filename + } + ); + } + } elsif ( $interpreter =~ m{php} ) { - ok( check_file_with( [ 'php', '-l', $file ] ), - $filename . " php syntax check" ); + run_check( + { command => [ 'php', '-l', $file ], + description => 'php syntax check', + filename => $filename + } + ); } elsif ( $interpreter =~ m{j?ruby} ) { - ok( check_file_with( [ 'ruby', '-cw', $file ] ), - $filename . " ruby syntax check" ); + run_check( + { command => [ 'ruby', '-cw', $file ], + description => 'ruby syntax check', + filename => $filename + } + ); } elsif ( $interpreter =~ m{gawk} ) { - ok( check_file_with( - [ 'gawk', '--source', 'BEGIN { exit(0) } END { exit(0) }', + run_check( + { command => [ + 'gawk', '--source', 'BEGIN { exit(0) } END { exit(0) }', '--file', $file - ] - ), - $filename . " gawk syntax check" + ], + description => 'gawk syntax check', + filename => $filename + } ); } elsif ( $interpreter =~ m{expect} ) { - pass( - "No idea how to check expect scripts, pretending everything is ok" - ); + SKIP: { + skip 'no idea how to check expect scripts', 1; + pass("No pretending everything is ok"); + } } else { fail( $filename . " unknown interpreter " . $interpreter ); } } -sub check_file_with { - my ($check_command) = @_; +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} ); }; - if ( $exit == 0 ) { - return 1; - } - else { + + ok( ( $exit == 0 ), $message ); + + if ($exit) { diag( sprintf( "\nCommand: %s\n\nSTDOUT:\n\n%s\n\nSTDERR:\n\n%s\n\n", @@ -117,7 +165,6 @@ sub check_file_with { $stdout, $stderr ) ); - return; } } From beca89999e82732430a8632228be3b5c363d39e0 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 00:17:23 +0200 Subject: [PATCH 68/96] Handle perl -T checks --- t/test.t | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/t/test.t b/t/test.t index 50010787..80316e95 100644 --- a/t/test.t +++ b/t/test.t @@ -14,13 +14,14 @@ use vars qw/*name *dir *prune/; my $num_plugins = 0; sub wanted { - my ( $dev, $ino, $mode, $nlink, $uid, $gid, $interpreter ); + my ( $dev, $ino, $mode, $nlink, $uid, $gid, $interpreter, $arguments ); ( ( $dev, $ino, $mode, $nlink, $uid, $gid ) = lstat($_) ) && -f _ - && ( $interpreter = hashbang("$_") ) + && ( ( $interpreter, $arguments ) = hashbang("$_") ) + && ($interpreter) && ++$num_plugins - && process_file( $_, $name, $interpreter ); + && process_file( $_, $name, $interpreter, $arguments ); } File::Find::find( { wanted => \&wanted }, 'plugins' ); @@ -31,17 +32,20 @@ sub hashbang { my $firstline = <$file>; close $file; - $firstline =~ m{ ^\#! # hashbang - \s* # optional space - (?:/usr/bin/env\s+)? # optional /usr/bin/env - (?\S+) # interpreter - }xm; + $firstline =~ m{ ^\#! # hashbang + \s* # optional space + (?:/usr/bin/env\s+)? # optional /usr/bin/env + (?\S+) # interpreter + (?:\s+ + (?[^\n]*) # optional interpreter arguments + )? + }xms; - return $+{interpreter}; + return ($+{interpreter}, $+{arguments}); } sub process_file { - my ( $file, $filename, $interpreter ) = @_; + my ( $file, $filename, $interpreter, $arguments ) = @_; use v5.10.1; if ( $interpreter =~ m{/bin/sh} ) { @@ -76,8 +80,15 @@ sub process_file { ); } elsif ( $interpreter =~ m{perl} ) { + my $command; + if ($arguments =~ m{-.*T}mx) { + $command = [ 'perl', '-cwT', $file ]; + } + else { + $command = [ 'perl', '-cw', $file ]; + } run_check( - { command => [ 'perl', '-cw', $file ], + { command => $command, description => 'perl syntax check', filename => $filename } From 2882ff54d646789c0d9dd926d27a6bf98eb7ed57 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 00:17:33 +0200 Subject: [PATCH 69/96] Be verbose --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b5d8e8c1..79957420 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,4 +54,4 @@ install: # - Sun::Solaris::Kstat # - VMware::VIRuntime # - MythTV -script: "PERL5LIB=$PERL5LIB:/usr/share/perl5 prove" +script: "PERL5LIB=$PERL5LIB:/usr/share/perl5 prove -v" From c4c0a9872c7d667f35373be0b21b63755cae3544 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 00:18:43 +0200 Subject: [PATCH 70/96] Use /usr/bin/perl, not @@PERL@@ as interpreter --- plugins/varnish4/varnish4_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/varnish4/varnish4_ b/plugins/varnish4/varnish4_ index f05eb51a..5ba23dad 100644 --- a/plugins/varnish4/varnish4_ +++ b/plugins/varnish4/varnish4_ @@ -1,4 +1,4 @@ -#!@@PERL@@ +#!/usr/bin/perl # -*- perl -*- # # varnish4_ - Munin plugin to for Varnish 4.x From 31361e95a55b48da7bd4beaaa46721f3ab906aa9 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 00:27:25 +0200 Subject: [PATCH 71/96] Use /bin/bash as interpreter - uses "echo -en" --- plugins/http/wget_page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/http/wget_page b/plugins/http/wget_page index c157609c..467b46f2 100755 --- a/plugins/http/wget_page +++ b/plugins/http/wget_page @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Plugin to graph response times of the specified websites/URLs. # From fa0c04bb4a4b89c750e7215a1e90276cb28514d0 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 00:28:05 +0200 Subject: [PATCH 72/96] Use /usr/bin/perl, not @@PERL@@, as interpreter --- plugins/mail/sendmail_mailq | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mail/sendmail_mailq b/plugins/mail/sendmail_mailq index bb33a87c..64139226 100644 --- a/plugins/mail/sendmail_mailq +++ b/plugins/mail/sendmail_mailq @@ -1,4 +1,4 @@ -#! @@PERL@@ -w +#!/usr/bin/perl # -*- perl -*- =head1 NAME From a9d8c625416c25bfba8ebfe1660c88277bcd25ba Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 00:53:39 +0200 Subject: [PATCH 73/96] add todo list for tests --- t/todo.org | 274 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 t/todo.org diff --git a/t/todo.org b/t/todo.org new file mode 100644 index 00000000..ccf11d92 --- /dev/null +++ b/t/todo.org @@ -0,0 +1,274 @@ +* [0/12] tests + + 11/1006 ok + + (less 110 skipped, 883 okay) + +** TODO ok 1 # skip need better syntax check for python + + Not really OK, we need a useful syntax check for python. + + 109 of these. + +** TODO not ok 18 - plugins/zeo/zeo_monitor_: perl syntax check + + Looks like perl -T also sanitizes PERL5LIB, since this is set to + include /usr/share/perl5, where Munin::Plugin is. + +#+BEGIN_EXAMPLE +# Failed test 'plugins/zeo/zeo_monitor_: perl syntax check' +# at t/test.t line 169. +# +# Command: perl -cwT zeo_monitor_ +# +# STDOUT: +# +# +# +# STDERR: +# +# Can't locate Munin/Plugin.pm in @INC (@INC contains: /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4) at zeo_monitor_ line 67. +# BEGIN failed--compilation aborted at zeo_monitor_ line 67. +#+END_EXAMPLE + +** TODO not ok 64 - plugins/virtualization/vmware/esx_: perl syntax check + + Missing perl module. VMware::VIRuntime. Not on CPAN. + +#+BEGIN_EXAMPLE +# Failed test 'plugins/virtualization/vmware/esx_: perl syntax check' +# at t/test.t line 169. +# +# Command: perl -cw esx_ +# +# STDOUT: +# +# +# +# STDERR: +# +# Can't locate VMware/VIRuntime.pm in @INC (@INC contains: /usr/share/perl5 /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4 .) at esx_ line 118. +# BEGIN failed--compilation aborted at esx_ line 118. +# +#+END_EXAMPLE +** TODO not ok 109 - plugins/system/swapspace-info: perl syntax check + + Missing Sun::Solaris::Kstat. Not on CPAN + +#+BEGIN_EXAMPLE + +# Failed test 'plugins/system/swapspace-info: perl syntax check' +# at t/test.t line 169. +# +# Command: perl -cw swapspace-info +# +# STDOUT: +# +# +# +# STDERR: +# +# Can't locate Sun/Solaris/Kstat.pm in @INC (@INC contains: /usr/share/perl5 /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4 .) at swapspace-info line 74. +# BEGIN failed--compilation aborted at swapspace-info line 74. +# + +#+END_EXAMPLE + +** TODO not ok 110 - plugins/system/solaris-memstat: ksh syntax check + + Can't see what's wrong here. False positive? + +#+BEGIN_EXAMPLE +# Failed test 'plugins/system/solaris-memstat: ksh syntax check' +# at t/test.t line 169. +# +# Command: ksh -n solaris-memstat +# +# STDOUT: +# +# +# +# STDERR: +# +# solaris-memstat: syntax error at line 119: `if' unmatched +# +# +#+END_EXAMPLE + +** TODO not ok 112 - plugins/system/raminfo: perl syntax check + + Missing Sun::Solaris::Kstat. Not on CPAN + +#+BEGIN_EXAMPLE +# Failed test 'plugins/system/raminfo: perl syntax check' +# at t/test.t line 169. +# +# Command: perl -cw raminfo +# +# STDOUT: +# +# +# +# STDERR: +# +# Can't locate Sun/Solaris/Kstat.pm in @INC (@INC contains: /usr/share/perl5 /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4 .) at raminfo line 76. +# BEGIN failed--compilation aborted at raminfo line 76. +# +# +#+END_EXAMPLE + +** TODO not ok 191 - plugins/snmp/snmp__webthermometer + + False positive in "checkbashisms". It looks for $HOSTNAME, which is + set implicitly by bash, but explicitly by the plugin. + +#+BEGIN_EXAMPLE +# Subtest: plugins/snmp/snmp__webthermometer +1..2 +ok 1 - sh syntax check +not ok 2 - checkbashisms +# Failed test 'checkbashisms' +# at t/test.t line 169. +# +# Command: checkbashisms snmp__webthermometer +# +# STDOUT: +# +# +# +# STDERR: +# +# possible bashism in snmp__webthermometer line 44 ($HOST(TYPE|NAME)): +# HOSTNAME=`echo $HOSTNAME | sed -e 's/\.$//'` +# possible bashism in snmp__webthermometer line 47 ($HOST(TYPE|NAME)): +# echo file $FILE dir $DIR hostname $HOSTNAME linkdir $LINKDIR linkfile $LINKFILE +# +# +# Looks like you failed 1 test of 2. +#+END_EXAMPLE + +** TODO not ok 319 - plugins/rabbitmq/rabbitmq_connections + + False positive in "checkbashisms". + +#+BEGIN_EXAMPLE +# Subtest: plugins/rabbitmq/rabbitmq_connections +1..2 +ok 1 - sh syntax check +not ok 2 - checkbashisms +# Failed test 'checkbashisms' +# at t/test.t line 169. +# +# Command: checkbashisms rabbitmq_connections +# +# STDOUT: +# +# +# +# STDERR: +# +# possible bashism in rabbitmq_connections line 66 ($"foo" should be eval_gettext "foo"): +# echo "connections.value $(HOME=$HOME rabbitmqctl list_connections | grep -v "^Listing" | grep -v "done.$" | wc -l)" +# +# +# Looks like you failed 1 test of 2. +not ok 319 - plugins/rabbitmq/rabbitmq_connections +# Failed test 'plugins/rabbitmq/rabbitmq_connections' +# at t/test.t line 64. +#+END_EXAMPLE + +** TODO not ok 536 - plugins/network/multi_tcp_ping: perl syntax check + + threads… + +#+BEGIN_EXAMPLE +# Failed test 'plugins/network/multi_tcp_ping: perl syntax check' +# at t/test.t line 169. +# +# Command: perl -cw multi_tcp_ping +# +# STDOUT: +# +# +# +# STDERR: +# +# This Perl not built to support threads +# Compilation failed in require at multi_tcp_ping line 75. +# BEGIN failed--compilation aborted at multi_tcp_ping line 75. +# +# +#+END_EXAMPLE + +** TODO not ok 538 - plugins/network/ldap_connections + + False positive at 'ESTABLISHED$"'. + + Still, quite horrible shell code. + +#+BEGIN_EXAMPLE +# Subtest: plugins/network/ldap_connections +1..2 +ok 1 - sh syntax check +not ok 2 - checkbashisms +# Failed test 'checkbashisms' +# at t/test.t line 169. +# +# Command: checkbashisms ldap_connections +# +# STDOUT: +# +# +# +# STDERR: +# +# possible bashism in ldap_connections line 130 ($"foo" should be eval_gettext "foo"): +# 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')" +# +# +# Looks like you failed 1 test of 2. +#+END_EXAMPLE + +** TODO not ok 572 - plugins/network/d-link-dir-655-router-statistics-plugin: ruby syntax check + + No idea + +#+BEGIN_EXAMPLE +# Failed test 'plugins/network/d-link-dir-655-router-statistics-plugin: ruby syntax check' +# at t/test.t line 169. +# +# Command: ruby -cw d-link-dir-655-router-statistics-plugin +# +# STDOUT: +# +# +# +# STDERR: +# +# /home/travis/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- auto_gem (LoadError) +# from /home/travis/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require' +# +# +#+END_EXAMPLE + +** TODO not ok 627 - plugins/mythtv/mythtv_status_: perl syntax check + + Missing perl module MythTV, not on CPAN. + +#+BEGIN_EXAMPLE +# Failed test 'plugins/mythtv/mythtv_status_: perl syntax check' +# at t/test.t line 169. +# +# Command: perl -cw mythtv_status_ +# +# STDOUT: +# +# +# +# STDERR: +# +# Can't locate MythTV.pm in @INC (@INC contains: /usr/share/perl5 /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4 .) at mythtv_status_ line 74. +# BEGIN failed--compilation aborted at mythtv_status_ line 74. +# +# +#+END_EXAMPLE From 67470547f0aeac3b77b23e9ae5829379d2e98036 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 01:28:29 +0200 Subject: [PATCH 74/96] Use eval around hard-to-find perl modules --- plugins/mythtv/mythtv_status_ | 3 ++- plugins/system/raminfo | 3 ++- plugins/system/swapspace-info | 3 ++- plugins/virtualization/vmware/esx_ | 11 ++++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/mythtv/mythtv_status_ b/plugins/mythtv/mythtv_status_ index 91f464f8..ca2f1774 100755 --- a/plugins/mythtv/mythtv_status_ +++ b/plugins/mythtv/mythtv_status_ @@ -71,7 +71,8 @@ #%# family=auto #%# capabilities=autoconf use DBI; -use MythTV; +eval 'use MythTV; 1;' + or die 'Please install MythTV'; use strict; use warnings; use Munin::Plugin; diff --git a/plugins/system/raminfo b/plugins/system/raminfo index 64838178..9b4360a8 100755 --- a/plugins/system/raminfo +++ b/plugins/system/raminfo @@ -73,7 +73,8 @@ else sub value # get value for variables { 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(); # --- Fetch Hardware info --- diff --git a/plugins/system/swapspace-info b/plugins/system/swapspace-info index 91cc3a28..afa6e6cd 100755 --- a/plugins/system/swapspace-info +++ b/plugins/system/swapspace-info @@ -71,7 +71,8 @@ else sub value { 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(); # --- Fetch Hardware info --- diff --git a/plugins/virtualization/vmware/esx_ b/plugins/virtualization/vmware/esx_ index 003eac27..01577285 100755 --- a/plugins/virtualization/vmware/esx_ +++ b/plugins/virtualization/vmware/esx_ @@ -115,9 +115,14 @@ use strict; use sort 'stable'; # guarantee stability no warnings; # don't want warnings in output -use VMware::VIRuntime; # need to install VIM SDK (vSphere CLI/SDK 4.1 or newer) -use VMware::VILib; -use VMware::VIExt; +# need to install VIM SDK (vSphere CLI/SDK 4.1 or newer) +eval 'use VMware::VIRuntime; 1;' + 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 DateTime::Format::ISO8601; # may need to install "libdatetime-format-iso8601-perl" on Debian-based systems use List::Util qw(sum max); From 76e4b0332cb3cfcaeb07168c4a08020f2ce06c9e Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 01:45:57 +0200 Subject: [PATCH 75/96] Add DateTime::Format::ISO8601, needed for tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 79957420..cb3fc612 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ install: - 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 From ac8db54cb1e1f2179bc4485292eab85c6d1140ef Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 01:48:53 +0200 Subject: [PATCH 76/96] Use eval EXPR to load Munin::Plugin, for automated tests --- plugins/zeo/zeo_monitor_ | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/zeo/zeo_monitor_ b/plugins/zeo/zeo_monitor_ index 60691989..4af76406 100755 --- a/plugins/zeo/zeo_monitor_ +++ b/plugins/zeo/zeo_monitor_ @@ -64,7 +64,11 @@ #%# capabilities=autoconf suggest 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 IO::Socket::UNIX qw(SOCK_STREAM); From 1123a5f9710b3dbc63a7ac685b12f1b900fdaba6 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 02:00:11 +0200 Subject: [PATCH 77/96] Remove OK tests from todo list [ci skip] --- t/todo.org | 114 ++--------------------------------------------------- 1 file changed, 4 insertions(+), 110 deletions(-) diff --git a/t/todo.org b/t/todo.org index ccf11d92..a9b3c8cf 100644 --- a/t/todo.org +++ b/t/todo.org @@ -1,8 +1,9 @@ -* [0/12] tests +* [0/7] tests - 11/1006 ok + Summary: - (less 110 skipped, 883 okay) + Failed 6/1006 subtests + (less 110 skipped subtests: 890 okay) ** TODO ok 1 # skip need better syntax check for python @@ -10,70 +11,6 @@ 109 of these. -** TODO not ok 18 - plugins/zeo/zeo_monitor_: perl syntax check - - Looks like perl -T also sanitizes PERL5LIB, since this is set to - include /usr/share/perl5, where Munin::Plugin is. - -#+BEGIN_EXAMPLE -# Failed test 'plugins/zeo/zeo_monitor_: perl syntax check' -# at t/test.t line 169. -# -# Command: perl -cwT zeo_monitor_ -# -# STDOUT: -# -# -# -# STDERR: -# -# Can't locate Munin/Plugin.pm in @INC (@INC contains: /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4) at zeo_monitor_ line 67. -# BEGIN failed--compilation aborted at zeo_monitor_ line 67. -#+END_EXAMPLE - -** TODO not ok 64 - plugins/virtualization/vmware/esx_: perl syntax check - - Missing perl module. VMware::VIRuntime. Not on CPAN. - -#+BEGIN_EXAMPLE -# Failed test 'plugins/virtualization/vmware/esx_: perl syntax check' -# at t/test.t line 169. -# -# Command: perl -cw esx_ -# -# STDOUT: -# -# -# -# STDERR: -# -# Can't locate VMware/VIRuntime.pm in @INC (@INC contains: /usr/share/perl5 /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4 .) at esx_ line 118. -# BEGIN failed--compilation aborted at esx_ line 118. -# -#+END_EXAMPLE -** TODO not ok 109 - plugins/system/swapspace-info: perl syntax check - - Missing Sun::Solaris::Kstat. Not on CPAN - -#+BEGIN_EXAMPLE - -# Failed test 'plugins/system/swapspace-info: perl syntax check' -# at t/test.t line 169. -# -# Command: perl -cw swapspace-info -# -# STDOUT: -# -# -# -# STDERR: -# -# Can't locate Sun/Solaris/Kstat.pm in @INC (@INC contains: /usr/share/perl5 /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4 .) at swapspace-info line 74. -# BEGIN failed--compilation aborted at swapspace-info line 74. -# - -#+END_EXAMPLE - ** TODO not ok 110 - plugins/system/solaris-memstat: ksh syntax check Can't see what's wrong here. False positive? @@ -95,28 +32,6 @@ # #+END_EXAMPLE -** TODO not ok 112 - plugins/system/raminfo: perl syntax check - - Missing Sun::Solaris::Kstat. Not on CPAN - -#+BEGIN_EXAMPLE -# Failed test 'plugins/system/raminfo: perl syntax check' -# at t/test.t line 169. -# -# Command: perl -cw raminfo -# -# STDOUT: -# -# -# -# STDERR: -# -# Can't locate Sun/Solaris/Kstat.pm in @INC (@INC contains: /usr/share/perl5 /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4 .) at raminfo line 76. -# BEGIN failed--compilation aborted at raminfo line 76. -# -# -#+END_EXAMPLE - ** TODO not ok 191 - plugins/snmp/snmp__webthermometer False positive in "checkbashisms". It looks for $HOSTNAME, which is @@ -251,24 +166,3 @@ not ok 2 - checkbashisms # #+END_EXAMPLE -** TODO not ok 627 - plugins/mythtv/mythtv_status_: perl syntax check - - Missing perl module MythTV, not on CPAN. - -#+BEGIN_EXAMPLE -# Failed test 'plugins/mythtv/mythtv_status_: perl syntax check' -# at t/test.t line 169. -# -# Command: perl -cw mythtv_status_ -# -# STDOUT: -# -# -# -# STDERR: -# -# Can't locate MythTV.pm in @INC (@INC contains: /usr/share/perl5 /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/site_perl/5.14.4 /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4/x86_64-linux /home/travis/perl5/perlbrew/perls/5.14/lib/5.14.4 .) at mythtv_status_ line 74. -# BEGIN failed--compilation aborted at mythtv_status_ line 74. -# -# -#+END_EXAMPLE From 08f196eb102e1946719689e447bbecfe79994d7b Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 11:23:53 +0200 Subject: [PATCH 78/96] perltidy a bit --- t/test.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/test.t b/t/test.t index 80316e95..72f71137 100644 --- a/t/test.t +++ b/t/test.t @@ -41,7 +41,7 @@ sub hashbang { )? }xms; - return ($+{interpreter}, $+{arguments}); + return ( $+{interpreter}, $+{arguments} ); } sub process_file { @@ -81,7 +81,7 @@ sub process_file { } elsif ( $interpreter =~ m{perl} ) { my $command; - if ($arguments =~ m{-.*T}mx) { + if ( $arguments =~ m{-.*T}mx ) { $command = [ 'perl', '-cwT', $file ]; } else { From f007901b64a8f900964e3e61e1f24f4898824f81 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 11:24:14 +0200 Subject: [PATCH 79/96] Check python scirpts with "py_compile" - leaves a mess behind, but works --- t/test.t | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/t/test.t b/t/test.t index 72f71137..a12151fb 100644 --- a/t/test.t +++ b/t/test.t @@ -95,19 +95,12 @@ sub process_file { ); } elsif ( $interpreter =~ m{python} ) { - SKIP: { - skip 'need better syntax check for python', 1; - run_check( - { command => [ - 'pylint', '--rcfile=/dev/null', - '--errors-only', '--report=no', - $file - ], - description => 'python syntax check', - filename => $filename - } - ); - } + run_check( + { command => [ 'python', '-m', 'py_compile', $file ], + description => 'python compile', + filename => $filename + } + ); } elsif ( $interpreter =~ m{php} ) { run_check( From e33c35ffc3dda6e57df8d536de5b6cf042c2ea37 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 11:52:56 +0200 Subject: [PATCH 80/96] Update TODO list [ci skip] --- t/todo.org | 85 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/t/todo.org b/t/todo.org index a9b3c8cf..6b58f16b 100644 --- a/t/todo.org +++ b/t/todo.org @@ -1,17 +1,39 @@ -* [0/7] tests +* munin contrib - plugin tests Summary: - Failed 6/1006 subtests - (less 110 skipped subtests: 890 okay) + Failed 7/1006 subtests -** TODO ok 1 # skip need better syntax check for python + (less 1 skipped subtest: 998 okay) - Not really OK, we need a useful syntax check for python. - 109 of these. +** [0/1] Need to investigate -** TODO not ok 110 - plugins/system/solaris-memstat: ksh syntax check +*** TODO not ok 572 - plugins/network/d-link-dir-655-router-statistics-plugin: ruby syntax check + + Need to investigate. + +#+BEGIN_EXAMPLE +# Failed test 'plugins/network/d-link-dir-655-router-statistics-plugin: ruby syntax check' +# at t/test.t line 169. +# +# Command: ruby -cw d-link-dir-655-router-statistics-plugin +# +# STDOUT: +# +# +# +# STDERR: +# +# /home/travis/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- auto_gem (LoadError) +# from /home/travis/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require' +# +# +#+END_EXAMPLE + +** [0/4] False positives + +*** TODO not ok 110 - plugins/system/solaris-memstat: ksh syntax check Can't see what's wrong here. False positive? @@ -32,7 +54,7 @@ # #+END_EXAMPLE -** TODO not ok 191 - plugins/snmp/snmp__webthermometer +*** TODO not ok 191 - plugins/snmp/snmp__webthermometer False positive in "checkbashisms". It looks for $HOSTNAME, which is set implicitly by bash, but explicitly by the plugin. @@ -62,7 +84,7 @@ not ok 2 - checkbashisms # Looks like you failed 1 test of 2. #+END_EXAMPLE -** TODO not ok 319 - plugins/rabbitmq/rabbitmq_connections +*** TODO not ok 319 - plugins/rabbitmq/rabbitmq_connections False positive in "checkbashisms". @@ -92,32 +114,9 @@ not ok 319 - plugins/rabbitmq/rabbitmq_connections # at t/test.t line 64. #+END_EXAMPLE -** TODO not ok 536 - plugins/network/multi_tcp_ping: perl syntax check +*** TODO not ok 538 - plugins/network/ldap_connections - threads… - -#+BEGIN_EXAMPLE -# Failed test 'plugins/network/multi_tcp_ping: perl syntax check' -# at t/test.t line 169. -# -# Command: perl -cw multi_tcp_ping -# -# STDOUT: -# -# -# -# STDERR: -# -# This Perl not built to support threads -# Compilation failed in require at multi_tcp_ping line 75. -# BEGIN failed--compilation aborted at multi_tcp_ping line 75. -# -# -#+END_EXAMPLE - -** TODO not ok 538 - plugins/network/ldap_connections - - False positive at 'ESTABLISHED$"'. + False positive in checkbashisms at 'ESTABLISHED$"'. Still, quite horrible shell code. @@ -144,15 +143,18 @@ not ok 2 - checkbashisms # Looks like you failed 1 test of 2. #+END_EXAMPLE -** TODO not ok 572 - plugins/network/d-link-dir-655-router-statistics-plugin: ruby syntax check - - No idea + +** [0/1] Blame the CI provider + +*** TODO not ok 536 - plugins/network/multi_tcp_ping: perl syntax check + + Perl on travis-ci not built to support threads #+BEGIN_EXAMPLE -# Failed test 'plugins/network/d-link-dir-655-router-statistics-plugin: ruby syntax check' +# Failed test 'plugins/network/multi_tcp_ping: perl syntax check' # at t/test.t line 169. # -# Command: ruby -cw d-link-dir-655-router-statistics-plugin +# Command: perl -cw multi_tcp_ping # # STDOUT: # @@ -160,8 +162,9 @@ not ok 2 - checkbashisms # # STDERR: # -# /home/travis/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- auto_gem (LoadError) -# from /home/travis/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require' +# This Perl not built to support threads +# Compilation failed in require at multi_tcp_ping line 75. +# BEGIN failed--compilation aborted at multi_tcp_ping line 75. # # #+END_EXAMPLE From e586cd5cb451c0eaeae1c3a55ec5ef1b8be4e13d Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 12:56:45 +0200 Subject: [PATCH 81/96] remove "-rauto_gem" from hashbang --- plugins/network/d-link-dir-655-router-statistics-plugin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/network/d-link-dir-655-router-statistics-plugin b/plugins/network/d-link-dir-655-router-statistics-plugin index d98f002a..8c7923de 100755 --- a/plugins/network/d-link-dir-655-router-statistics-plugin +++ b/plugins/network/d-link-dir-655-router-statistics-plugin @@ -1,4 +1,4 @@ -#!/usr/bin/ruby -rauto_gem +#!/usr/bin/ruby # # Munin plugin for the D-link DIR-655 router # From 6281364b6703d8ac71fa46c3f25636a893f96260 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 14:40:19 +0200 Subject: [PATCH 82/96] use "trap" to remove temporary file --- plugins/network/ldap_connections | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/network/ldap_connections b/plugins/network/ldap_connections index 8d77d359..485cfdd4 100755 --- a/plugins/network/ldap_connections +++ b/plugins/network/ldap_connections @@ -55,6 +55,7 @@ NETSTAT=${netstat:-`which netstat`} NETSTAT=${NETSTAT:-/usr/bin/netstat} PORTS=${ports:-389 636} TEMP_FILE=$(mktemp /tmp/munin_ldap.XXXXXX) +trap "rm -f ${TEMP_FILE}" EXIT PATH=/bin:/usr/bin:/usr/local/bin SOCKET=${socket:-/var/run/openldap/ldapi} @@ -96,7 +97,7 @@ if [ "$1" = "autoconf" ]; then for port in $PORTS; do ONE_LISTENING=${ONE_LISTENING}$(find_ips_bound $port) done - rm -f $TEMP_FILE + if [ -n "$ONE_LISTENING" ]; then echo yes exit 0 @@ -121,7 +122,7 @@ if [ "$1" = "config" ]; then echo "socket.label ldapi" fi fi - rm -f $TEMP_FILE + exit 0 fi @@ -134,4 +135,3 @@ if [ -e "$SOCKET" ]; then echo "socket.value $($NETSTAT -an ${FAMILYMARK}unix | grep $SOCKET | wc -l | sed 's/[[:space:]]*//g')" fi -rm -f $TEMP_FILE From cd6dafa84232b1111b7fc273382d05ed6baaf513 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 14:41:16 +0200 Subject: [PATCH 83/96] Rewrite hard-to-read shell oneliner --- plugins/network/ldap_connections | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/network/ldap_connections b/plugins/network/ldap_connections index 485cfdd4..fc24b18b 100755 --- a/plugins/network/ldap_connections +++ b/plugins/network/ldap_connections @@ -128,7 +128,17 @@ fi for port in $LISTENING_PORTS; 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 if [ -e "$SOCKET" ]; then From ab5dfc2bba26e64e0eb86688c4846caf20cdd6bc Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 14:57:45 +0200 Subject: [PATCH 84/96] No need to test verbosely anymore --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cb3fc612..7c5a84e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,4 +55,4 @@ install: # - Sun::Solaris::Kstat # - VMware::VIRuntime # - MythTV -script: "PERL5LIB=$PERL5LIB:/usr/share/perl5 prove -v" +script: "PERL5LIB=$PERL5LIB:/usr/share/perl5 prove" From ad9a1aac23b9b41e75484d7afee9e8687908d495 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 15:32:35 +0200 Subject: [PATCH 85/96] Update todo list [ci skip] --- t/todo.org | 51 +++++++++------------------------------------------ 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/t/todo.org b/t/todo.org index 6b58f16b..b2ace3e7 100644 --- a/t/todo.org +++ b/t/todo.org @@ -2,22 +2,19 @@ Summary: - Failed 7/1006 subtests + Failed 5/1006 subtests - (less 1 skipped subtest: 998 okay) + (less 1 skipped subtest: 1000 okay) +** [0/1] Failing test +*** TODO Failed test 'plugins/snmp/snmp__brocade_ifs: python compile' -** [0/1] Need to investigate - -*** TODO not ok 572 - plugins/network/d-link-dir-655-router-statistics-plugin: ruby syntax check - - Need to investigate. + python plugin with error in regular expression string. #+BEGIN_EXAMPLE -# Failed test 'plugins/network/d-link-dir-655-router-statistics-plugin: ruby syntax check' -# at t/test.t line 169. +# at t/test.t line 162. # -# Command: ruby -cw d-link-dir-655-router-statistics-plugin +# Command: python -m py_compile snmp__brocade_ifs # # STDOUT: # @@ -25,12 +22,12 @@ # # STDERR: # -# /home/travis/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- auto_gem (LoadError) -# from /home/travis/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require' +# SyntaxError: ('invalid syntax', ('snmp__brocade_ifs', 272, 22, "regex_str = '^snmp_'(.+)'_brocade_ifs'\n")) # # #+END_EXAMPLE + ** [0/4] False positives *** TODO not ok 110 - plugins/system/solaris-memstat: ksh syntax check @@ -114,35 +111,6 @@ not ok 319 - plugins/rabbitmq/rabbitmq_connections # at t/test.t line 64. #+END_EXAMPLE -*** TODO not ok 538 - plugins/network/ldap_connections - - False positive in checkbashisms at 'ESTABLISHED$"'. - - Still, quite horrible shell code. - -#+BEGIN_EXAMPLE -# Subtest: plugins/network/ldap_connections -1..2 -ok 1 - sh syntax check -not ok 2 - checkbashisms -# Failed test 'checkbashisms' -# at t/test.t line 169. -# -# Command: checkbashisms ldap_connections -# -# STDOUT: -# -# -# -# STDERR: -# -# possible bashism in ldap_connections line 130 ($"foo" should be eval_gettext "foo"): -# 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')" -# -# -# Looks like you failed 1 test of 2. -#+END_EXAMPLE - ** [0/1] Blame the CI provider @@ -168,4 +136,3 @@ not ok 2 - checkbashisms # # #+END_EXAMPLE - From 149c09ddc8a00e6f6dc29e006dd841ca82578cf2 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 15:47:22 +0200 Subject: [PATCH 86/96] Fix syntax error in regular expression string --- plugins/snmp/snmp__brocade_ifs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/snmp/snmp__brocade_ifs b/plugins/snmp/snmp__brocade_ifs index 2b04de29..c0578e3e 100755 --- a/plugins/snmp/snmp__brocade_ifs +++ b/plugins/snmp/snmp__brocade_ifs @@ -269,7 +269,7 @@ if 'MUNIN_CAP_MULTIGRAPH' not in os.environ: # Parse host_name and counter type from arg0 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) if match: host_name = match.group(1) From fefcad986e268d265ca5923f9104658f8aaa3449 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 15:49:54 +0200 Subject: [PATCH 87/96] Work around false positive in checkbashisms - Nothing wrong with the plugin, but checkbashisms triggers on the presence of a variable called $HOSTNAME - Changing the variable name in the plugin is the "easy way out". --- plugins/snmp/snmp__webthermometer | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/snmp/snmp__webthermometer b/plugins/snmp/snmp__webthermometer index fb6fd0ad..c81ac19f 100755 --- a/plugins/snmp/snmp__webthermometer +++ b/plugins/snmp/snmp__webthermometer @@ -40,11 +40,11 @@ if [ "$1" = "suggest" ]; then if [ ! "$RC" != "0" ] ; then FILE=`basename $0` DIR=`dirname $0` - HOSTNAME=`host $IP | sed s/.*pointer//\ ` - HOSTNAME=`echo $HOSTNAME | sed -e 's/\.$//'` + HOST_NAME=`host $IP | sed s/.*pointer//\ ` + HOST_NAME=`echo $HOST_NAME | sed -e 's/\.$//'` LINKDIR="/etc/munin/plugins/" - LINKFILE=`echo $FILE | sed s/__/_$HOSTNAME_/` - echo file $FILE dir $DIR hostname $HOSTNAME linkdir $LINKDIR linkfile $LINKFILE + LINKFILE=`echo $FILE | sed s/__/_$HOST_NAME_/` + echo file $FILE dir $DIR hostname $HOST_NAME linkdir $LINKDIR linkfile $LINKFILE #echo "ln -s $DIR/$FILE $LINKNAME" fi From 8974c45c9615061fa15017c41f877aa231468f62 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 20:11:42 +0200 Subject: [PATCH 88/96] Remove unimplemented but advertised "autoconf" --- plugins/rabbitmq/rabbitmq_connections | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/plugins/rabbitmq/rabbitmq_connections b/plugins/rabbitmq/rabbitmq_connections index fb254604..2e6970b9 100755 --- a/plugins/rabbitmq/rabbitmq_connections +++ b/plugins/rabbitmq/rabbitmq_connections @@ -12,17 +12,6 @@ # installation scripts): # #%# family=auto -#%# capabilities=autoconf - -# If run with the "autoconf"-parameter, give our opinion on wether we -# 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 - echo yes - exit 0 -fi HOME=/tmp/ From 2583b9fb70783ce03fda765fc02036396480916f Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 20:12:15 +0200 Subject: [PATCH 89/96] Update documentation --- plugins/rabbitmq/rabbitmq_connections | 55 ++++++++++++++++++++------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/plugins/rabbitmq/rabbitmq_connections b/plugins/rabbitmq/rabbitmq_connections index 2e6970b9..9b943b93 100755 --- a/plugins/rabbitmq/rabbitmq_connections +++ b/plugins/rabbitmq/rabbitmq_connections @@ -1,19 +1,46 @@ #!/bin/sh -# -# Plugin to monitor the number of connections to RabbitMQ -# -# Usage: Link or copy into /etc/munin/node.d/ -# -# Parameters -# env.conn_warn -# env.conn_crit -# -# Magic markers (optional - only used by munin-config and some -# installation scripts): -# -#%# family=auto -HOME=/tmp/ +: << =cut + +=head1 NAME + +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 + +Required. Valid choices are C and C. This is required +by C. + +=item C + +Optional, default value is 500 + +=item C + +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 # If run with the "config"-parameter, give out information on how the # graphs should look. From 679a3ce7beec5476eb7ac45fd814e5f790b0dbfb Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 20:12:44 +0200 Subject: [PATCH 90/96] Check if we are running as a user required by rabbitmqctl --- plugins/rabbitmq/rabbitmq_connections | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/rabbitmq/rabbitmq_connections b/plugins/rabbitmq/rabbitmq_connections index 9b943b93..89a6a4f7 100755 --- a/plugins/rabbitmq/rabbitmq_connections +++ b/plugins/rabbitmq/rabbitmq_connections @@ -42,6 +42,16 @@ Optional, default value is 1000 =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 # graphs should look. From bb206faee657f57d3fe882aad46d65f0ad07e96e Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 20:13:20 +0200 Subject: [PATCH 91/96] Fix mis-spelled variable names --- plugins/rabbitmq/rabbitmq_connections | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/rabbitmq/rabbitmq_connections b/plugins/rabbitmq/rabbitmq_connections index 89a6a4f7..98f283ac 100755 --- a/plugins/rabbitmq/rabbitmq_connections +++ b/plugins/rabbitmq/rabbitmq_connections @@ -56,8 +56,8 @@ esac # graphs should look. if [ "$1" = "config" ]; then - CONN_WARN=${queue_warn:-500} - CONN_CRIT=${queue_crit:-1000} + CONN_WARN=${conn_warn:-500} + CONN_CRIT=${conn_crit:-1000} # The host name this plugin is for. (Can be overridden to have # one machine answer for several) From 8dda09085a5646647f7678aa02662faa247cd70d Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 20:14:14 +0200 Subject: [PATCH 92/96] Handle missing rabbitmqctl --- plugins/rabbitmq/rabbitmq_connections | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/rabbitmq/rabbitmq_connections b/plugins/rabbitmq/rabbitmq_connections index 98f283ac..b9eee25a 100755 --- a/plugins/rabbitmq/rabbitmq_connections +++ b/plugins/rabbitmq/rabbitmq_connections @@ -89,4 +89,11 @@ fi # real work - i.e. display the data. Almost always this will be # "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" From 2a638429c5dc21196572128ca5ef275647468d97 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 20:27:19 +0200 Subject: [PATCH 93/96] Update t/todo.org with new numbahs [ci skip] --- t/todo.org | 90 +++--------------------------------------------------- 1 file changed, 4 insertions(+), 86 deletions(-) diff --git a/t/todo.org b/t/todo.org index b2ace3e7..c5cda727 100644 --- a/t/todo.org +++ b/t/todo.org @@ -2,37 +2,15 @@ Summary: - Failed 5/1006 subtests + Failed 2/1006 subtests - (less 1 skipped subtest: 1000 okay) + (less 1 skipped subtest: 1003 okay) -** [0/1] Failing test -*** TODO Failed test 'plugins/snmp/snmp__brocade_ifs: python compile' - - python plugin with error in regular expression string. - -#+BEGIN_EXAMPLE -# at t/test.t line 162. -# -# Command: python -m py_compile snmp__brocade_ifs -# -# STDOUT: -# -# -# -# STDERR: -# -# SyntaxError: ('invalid syntax', ('snmp__brocade_ifs', 272, 22, "regex_str = '^snmp_'(.+)'_brocade_ifs'\n")) -# -# -#+END_EXAMPLE - - -** [0/4] False positives +** [0/1] False positives *** TODO not ok 110 - plugins/system/solaris-memstat: ksh syntax check - Can't see what's wrong here. False positive? + Can't see what's wrong here. False positive from "ksh -n"? #+BEGIN_EXAMPLE # Failed test 'plugins/system/solaris-memstat: ksh syntax check' @@ -51,66 +29,6 @@ # #+END_EXAMPLE -*** TODO not ok 191 - plugins/snmp/snmp__webthermometer - - False positive in "checkbashisms". It looks for $HOSTNAME, which is - set implicitly by bash, but explicitly by the plugin. - -#+BEGIN_EXAMPLE -# Subtest: plugins/snmp/snmp__webthermometer -1..2 -ok 1 - sh syntax check -not ok 2 - checkbashisms -# Failed test 'checkbashisms' -# at t/test.t line 169. -# -# Command: checkbashisms snmp__webthermometer -# -# STDOUT: -# -# -# -# STDERR: -# -# possible bashism in snmp__webthermometer line 44 ($HOST(TYPE|NAME)): -# HOSTNAME=`echo $HOSTNAME | sed -e 's/\.$//'` -# possible bashism in snmp__webthermometer line 47 ($HOST(TYPE|NAME)): -# echo file $FILE dir $DIR hostname $HOSTNAME linkdir $LINKDIR linkfile $LINKFILE -# -# -# Looks like you failed 1 test of 2. -#+END_EXAMPLE - -*** TODO not ok 319 - plugins/rabbitmq/rabbitmq_connections - - False positive in "checkbashisms". - -#+BEGIN_EXAMPLE -# Subtest: plugins/rabbitmq/rabbitmq_connections -1..2 -ok 1 - sh syntax check -not ok 2 - checkbashisms -# Failed test 'checkbashisms' -# at t/test.t line 169. -# -# Command: checkbashisms rabbitmq_connections -# -# STDOUT: -# -# -# -# STDERR: -# -# possible bashism in rabbitmq_connections line 66 ($"foo" should be eval_gettext "foo"): -# echo "connections.value $(HOME=$HOME rabbitmqctl list_connections | grep -v "^Listing" | grep -v "done.$" | wc -l)" -# -# -# Looks like you failed 1 test of 2. -not ok 319 - plugins/rabbitmq/rabbitmq_connections -# Failed test 'plugins/rabbitmq/rabbitmq_connections' -# at t/test.t line 64. -#+END_EXAMPLE - ** [0/1] Blame the CI provider From 632c24d0a9b1bd385b6291a3fdf5c2521a2dd435 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 20:30:52 +0200 Subject: [PATCH 94/96] Save with UNIX line breaks --- plugins/system/solaris-memstat | 236 ++++++++++++++++----------------- 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/plugins/system/solaris-memstat b/plugins/system/solaris-memstat index 55495a50..ba818ec9 100755 --- a/plugins/system/solaris-memstat +++ b/plugins/system/solaris-memstat @@ -1,118 +1,118 @@ -#! /bin/ksh -# Copyright (c) 2010, Wikimedia Deutschland -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of Wikimedia Deutschland nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY WIKIMEDIA DEUTSCHLAND ''AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL WIKIMEDIA DEUTSCHLAND BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# NOTE: This software is not released as a product. It was written primarily for -# Wikimedia Deutschland's own use, and is made public as is, in the hope it may -# be useful. Wikimedia Deutschland may at any time discontinue developing or -# supporting this software. There is no guarantee any new versions or even fixes -# for security issues will be released. -### -# Munin plugin to report Solaris memory usage via mdb's memstat. -# Must be run as root. -# -# river@tamara.tcx.org.uk 2010-08-28 - -#%# family=auto -#%# capabilities=autoconf - -if [ "$1" = "autoconf" ]; then - if [ -e /usr/bin/mdb ]; then - echo yes - exit 0 - else - echo /usr/bin/mdb not found - exit 1 - fi -fi - -if [ "$1" = "config" ]; then - echo ' -graph_args --base 1024 -l 0 --vertical-label Bytes -graph_title Memory usage -graph_category system -graph_info This graph shows system memory use. -graph_order kernel anon exec cacheused zfs cachefree free - -kernel.label kernel -kernel.draw AREA -kernel.info Memory used by kernel - -anon.label anon -anon.draw STACK -anon.info Memory used by programs - -exec.label exec_and_libs -exec.draw STACK -exec.info Memory used by executable files and libraries - -cacheused.label cacheused -cacheused.draw STACK -cacheused.info Memory used by page cache - -zfs.label zfs -zfs.draw STACK -zfs.info Memory used for ZFS file cache - -cachefree.label cachefree -cachefree.draw STACK -cachefree.info Free memory in cache list - -free.label free -free.draw STACK -free.info Free memory -' - exit 0 -fi - -echo "::memstat" | mdb -k | nawk ' -BEGIN { - pagesize='$(getconf PAGESIZE)' - kernel=0 - zfs=0 - anon=0 - exec=0 - cache=0 - phys=0 -} - -/^Kernel/ { kernel=$2 } -/^ZFS File Data/ { zfs=$4 } -/^Anon/ { anon=$2 } -/^Exec and libs/ { exec=$4 } -/^Page cache/ { cacheused=$3 } -/^Free \(cachelist\)/ { cachefree=$3 } -/^Free \(freelist\)/ { free=$3 } - -END { - print "kernel.value " (kernel * pagesize) - print "zfs.value " (zfs * pagesize) - print "anon.value " (anon * pagesize) - print "exec.value " (exec * pagesize) - print "cacheused.value " (cacheused * pagesize) - print "cachefree.value " (cachefree * pagesize) - print "free.value " (free * pagesize) -} -' +#! /bin/ksh +# Copyright (c) 2010, Wikimedia Deutschland +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Wikimedia Deutschland nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY WIKIMEDIA DEUTSCHLAND ''AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL WIKIMEDIA DEUTSCHLAND BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: This software is not released as a product. It was written primarily for +# Wikimedia Deutschland's own use, and is made public as is, in the hope it may +# be useful. Wikimedia Deutschland may at any time discontinue developing or +# supporting this software. There is no guarantee any new versions or even fixes +# for security issues will be released. +### +# Munin plugin to report Solaris memory usage via mdb's memstat. +# Must be run as root. +# +# river@tamara.tcx.org.uk 2010-08-28 + +#%# family=auto +#%# capabilities=autoconf + +if [ "$1" = "autoconf" ]; then + if [ -e /usr/bin/mdb ]; then + echo yes + exit 0 + else + echo /usr/bin/mdb not found + exit 1 + fi +fi + +if [ "$1" = "config" ]; then + echo ' +graph_args --base 1024 -l 0 --vertical-label Bytes +graph_title Memory usage +graph_category system +graph_info This graph shows system memory use. +graph_order kernel anon exec cacheused zfs cachefree free + +kernel.label kernel +kernel.draw AREA +kernel.info Memory used by kernel + +anon.label anon +anon.draw STACK +anon.info Memory used by programs + +exec.label exec_and_libs +exec.draw STACK +exec.info Memory used by executable files and libraries + +cacheused.label cacheused +cacheused.draw STACK +cacheused.info Memory used by page cache + +zfs.label zfs +zfs.draw STACK +zfs.info Memory used for ZFS file cache + +cachefree.label cachefree +cachefree.draw STACK +cachefree.info Free memory in cache list + +free.label free +free.draw STACK +free.info Free memory +' + exit 0 +fi + +echo "::memstat" | mdb -k | nawk ' +BEGIN { + pagesize='$(getconf PAGESIZE)' + kernel=0 + zfs=0 + anon=0 + exec=0 + cache=0 + phys=0 +} + +/^Kernel/ { kernel=$2 } +/^ZFS File Data/ { zfs=$4 } +/^Anon/ { anon=$2 } +/^Exec and libs/ { exec=$4 } +/^Page cache/ { cacheused=$3 } +/^Free \(cachelist\)/ { cachefree=$3 } +/^Free \(freelist\)/ { free=$3 } + +END { + print "kernel.value " (kernel * pagesize) + print "zfs.value " (zfs * pagesize) + print "anon.value " (anon * pagesize) + print "exec.value " (exec * pagesize) + print "cacheused.value " (cacheused * pagesize) + print "cachefree.value " (cachefree * pagesize) + print "free.value " (free * pagesize) +} +' From ff4c91acb8c6a22cf7dd86fd14a0a2bb40ee8e35 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 20:38:16 +0200 Subject: [PATCH 95/96] Place "use threads" within "eval" to make it pass syntax checks on travis-ci --- plugins/network/multi_tcp_ping | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/network/multi_tcp_ping b/plugins/network/multi_tcp_ping index a3e93732..1ab779a4 100755 --- a/plugins/network/multi_tcp_ping +++ b/plugins/network/multi_tcp_ping @@ -72,7 +72,14 @@ USA. use strict; 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; my (%defaults, @hosts, $cmd_arg); From 3bb0f8a3420312558decefaa65f048e0e5224c1c Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 20:47:12 +0200 Subject: [PATCH 96/96] Remove todo list, all tests pass [ci skip] --- t/todo.org | 56 ------------------------------------------------------ 1 file changed, 56 deletions(-) delete mode 100644 t/todo.org diff --git a/t/todo.org b/t/todo.org deleted file mode 100644 index c5cda727..00000000 --- a/t/todo.org +++ /dev/null @@ -1,56 +0,0 @@ -* munin contrib - plugin tests - - Summary: - - Failed 2/1006 subtests - - (less 1 skipped subtest: 1003 okay) - -** [0/1] False positives - -*** TODO not ok 110 - plugins/system/solaris-memstat: ksh syntax check - - Can't see what's wrong here. False positive from "ksh -n"? - -#+BEGIN_EXAMPLE -# Failed test 'plugins/system/solaris-memstat: ksh syntax check' -# at t/test.t line 169. -# -# Command: ksh -n solaris-memstat -# -# STDOUT: -# -# -# -# STDERR: -# -# solaris-memstat: syntax error at line 119: `if' unmatched -# -# -#+END_EXAMPLE - - -** [0/1] Blame the CI provider - -*** TODO not ok 536 - plugins/network/multi_tcp_ping: perl syntax check - - Perl on travis-ci not built to support threads - -#+BEGIN_EXAMPLE -# Failed test 'plugins/network/multi_tcp_ping: perl syntax check' -# at t/test.t line 169. -# -# Command: perl -cw multi_tcp_ping -# -# STDOUT: -# -# -# -# STDERR: -# -# This Perl not built to support threads -# Compilation failed in require at multi_tcp_ping line 75. -# BEGIN failed--compilation aborted at multi_tcp_ping line 75. -# -# -#+END_EXAMPLE