Ruby plugins: apply style changes as suggested by "rubocop --fix-layout"

This commit is contained in:
Lars Kruse 2020-08-25 16:52:39 +02:00
parent 26c29daa2b
commit b0b39b018e
30 changed files with 1447 additions and 1384 deletions

View File

@ -1,21 +1,26 @@
#!/usr/bin/env ruby
# netstat_bsd_m revision 1 (Feb 2012)
#
# This plugin shows various statistics from 'netstat -m'
#
# Required privileges: none
#
# OS:
# Supposed: BSD
# Tested: FreeBSD 8.2
#
# Author: Artem Sheremet <dot.doom@gmail.com>
#
=begin
netstat_bsd_m revision 1 (Feb 2012)
This plugin shows various statistics from 'netstat -m'
Required privileges: none
OS:
Supposed: BSD
Tested: FreeBSD 8.2
Author: Artem Sheremet <dot.doom@gmail.com>
#%# family=auto
#%# capabilities=autoconf suggest
=end
# original filename
PLUGIN_NAME = 'netstat_bsd_m_'
@ -61,7 +66,7 @@ when 'config'
desc, values = data.first
stack = values.size > 1
first = true
puts <<CONFIG
puts <<~CONFIG
graph_title Netstat: #{desc}
graph_category network
graph_vlabel current

View File

@ -125,6 +125,7 @@ end
new_data.split("\n=").each { |report|
next if report.empty?
report =~ /\A(\w+) REPORT==== (.*) ===\n(.*)\z/m
type, time, text = $1, $2, $3
next unless type and time and text
@ -141,7 +142,7 @@ log_info[:start] += new_data.size
File.open(CACHE_FILE, 'w') { |f| f.write log_info.to_yaml } unless $debug_mode
if ARGV.first == 'config'
puts <<CONFIG
puts <<~CONFIG
graph_title Ejabberd Log
graph_vlabel total
graph_category chat

View File

@ -1,37 +1,42 @@
#!/usr/bin/env ruby
# mongrel_memory - A munin plugin for OpenSolaris to monitor memory size of
# each individual mongrel process
# Copyright (C) 2009 Matthias Marschall - mm@agileweboperations.com
#
# Based on:
# mongrel_process_memory - A munin plugin to monitor memory size of
# each individual mongrel process
# Copyright (C) 2007 Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Author: Ben VandenBos
# Contributors: Adam Jacob (<adam@hjksolutions.com>)
# Ryan Woodrum
# Matthias Marschall (mm@agileweboperations.com)
#
=begin
mongrel_memory - A munin plugin for OpenSolaris to monitor memory size of
each individual mongrel process
Copyright (C) 2009 Matthias Marschall - mm@agileweboperations.com
Based on:
mongrel_process_memory - A munin plugin to monitor memory size of
each individual mongrel process
Copyright (C) 2007 Ben VandenBos and Avvo, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Author: Ben VandenBos
Contributors: Adam Jacob (<adam@hjksolutions.com>)
Ryan Woodrum
Matthias Marschall (mm@agileweboperations.com)
#%# family=auto
#%# capabilities=autoconf
=end
module Munin
class MongrelProcessMemory
def run
pid_port_map = get_pids()
port_list = Hash.new
@ -57,7 +62,6 @@ module Munin
def autoconf
get_pids().length > 0
end
end
end

View File

@ -1,32 +1,36 @@
#!/usr/bin/env ruby
#
# mongrel_process_memory - A munin plugin to monitor memory size of
# each individual mongrel process
# Copyright (C) 2007 Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Author: Ben VandenBos
# Contributors: Adam Jacob (<adam@hjksolutions.com>)
# Ryan Woodrum
#
=begin
mongrel_process_memory - A munin plugin to monitor memory size of
each individual mongrel process
Copyright (C) 2007 Ben VandenBos and Avvo, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Author: Ben VandenBos
Contributors: Adam Jacob (<adam@hjksolutions.com>)
Ryan Woodrum
#%# family=auto
#%# capabilities=autoconf
=end
module Munin
class MongrelProcessMemory
def run
h = get_pids()
ps_output = ""
@ -68,7 +72,6 @@ module Munin
def autoconf
pids.length > 0
end
end
end

View File

@ -1,25 +1,30 @@
#!/usr/bin/env ruby
#
# Plugin to monitor the number of connections blocked by moblock.
#
# Requirements:
#
# Moblock up and running with generated log files going to /var/log/moblock
#
# Parameters supported:
#
# config
# autoconf
#
# Configurable variables
#
# logfile - Override default moblock logfile
#
# Magic markers
#
=begin
Plugin to monitor the number of connections blocked by moblock.
Requirements:
Moblock up and running with generated log files going to /var/log/moblock
Parameters supported:
config
autoconf
Configurable variables
logfile - Override default moblock logfile
Magic markers
#%# family=auto
#%# capabilities=autoconf
=end
#
# Initialize vars
#

View File

@ -1,49 +1,54 @@
#!/usr/bin/env ruby
#
# Munin Plugin for MSSQL - transaction monitoring
#
# Author: Wilfred Chau <openapp.developer@gmail.com>
# Date: 2011-05-18
# Version: 1.0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
# Prerequistes:
# 1) /etc/odbc.ini and /etc/freetds.conf
# 2) rubygems
# 3) ruby-dbi
#
# Usage:
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
# 2) chmod to allow executable to others
# 3) create symbolic link in /etc/munin/plugins
# ln -s /usr/share/munin/plugins/mssql_transaction.rb /etc/munin/plugins/mssql_transaction.rb
#
# Parameters:
# autoconf
# config (required)
#
# Config variables:
# sqluser : mssql user who has view server state privilege
# sqlpass : password for the mssql user
# dsn : datasource name as defined in /etc/odbc.ini
# instance: instance to monitor
#
=begin
Munin Plugin for MSSQL - transaction monitoring
Author: Wilfred Chau <openapp.developer@gmail.com>
Date: 2011-05-18
Version: 1.0
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Prerequistes:
1) /etc/odbc.ini and /etc/freetds.conf
2) rubygems
3) ruby-dbi
Usage:
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
2) chmod to allow executable to others
3) create symbolic link in /etc/munin/plugins
ln -s /usr/share/munin/plugins/mssql_transaction.rb /etc/munin/plugins/mssql_transaction.rb
Parameters:
autoconf
config (required)
Config variables:
sqluser : mssql user who has view server state privilege
sqlpass : password for the mssql user
dsn : datasource name as defined in /etc/odbc.ini
instance: instance to monitor
#%# family=auto
#%# capabilities=autoconf
=end
require 'rubygems'
require 'dbi'

View File

@ -1,48 +1,53 @@
#!/usr/bin/env ruby
#
# Munin Plugin for MSSQL - Buffer cache hit ratio monitoring
#
# Author: Wilfred Chau <openapp.developer@gmail.com>
# Date: 2011-05-19
# Version: 1.0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
# Prerequistes:
# 1) /etc/odbc.ini and /etc/freetds.conf
# 2) rubygems
# 3) ruby-dbi
#
# Usage:
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
# 2) chmod to allow executable to others
# 3) create symbolic link in /etc/munin/plugins
# ln -s /usr/share/munin/plugins/mssql_buffercachehitratio.rb /etc/munin/plugins/mssql_buffercachehitratio.rb
#
# Parameters:
# autoconf
# config (required)
#
# Config variables:
# sqluser : mssql user who has view server state privilege
# sqlpass : password for the mssql user
# dsn : datasource name as defined in /etc/odbc.ini
#
=begin
Munin Plugin for MSSQL - Buffer cache hit ratio monitoring
Author: Wilfred Chau <openapp.developer@gmail.com>
Date: 2011-05-19
Version: 1.0
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Prerequistes:
1) /etc/odbc.ini and /etc/freetds.conf
2) rubygems
3) ruby-dbi
Usage:
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
2) chmod to allow executable to others
3) create symbolic link in /etc/munin/plugins
ln -s /usr/share/munin/plugins/mssql_buffercachehitratio.rb /etc/munin/plugins/mssql_buffercachehitratio.rb
Parameters:
autoconf
config (required)
Config variables:
sqluser : mssql user who has view server state privilege
sqlpass : password for the mssql user
dsn : datasource name as defined in /etc/odbc.ini
#%# family=auto
#%# capabilities=autoconf
=end
require 'rubygems'
require 'dbi'

View File

@ -1,49 +1,54 @@
#!/usr/bin/env ruby
#
# Munin Plugin for MSSQL - Data file size monitoring
#
# Author: Wilfred Chau <openapp.developer@gmail.com>
# Date: 2011-05-19
# Version: 1.0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
# Prerequistes:
# 1) /etc/odbc.ini and /etc/freetds.conf
# 2) rubygems
# 3) ruby-dbi
#
# Usage:
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
# 2) chmod to allow executable to others
# 3) create symbolic link in /etc/munin/plugins
# ln -s /usr/share/munin/plugins/mssql_datafilesizes.rb /etc/munin/plugins/mssql_datafilesizes.rb
#
# Parameters:
# autoconf
# config (required)
#
# Config variables:
# sqluser : mssql user who has view server state privilege
# sqlpass : password for the mssql user
# dsn : datasource name as defined in /etc/odbc.ini
# instance: instance to monitor
#
=begin
Munin Plugin for MSSQL - Data file size monitoring
Author: Wilfred Chau <openapp.developer@gmail.com>
Date: 2011-05-19
Version: 1.0
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Prerequistes:
1) /etc/odbc.ini and /etc/freetds.conf
2) rubygems
3) ruby-dbi
Usage:
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
2) chmod to allow executable to others
3) create symbolic link in /etc/munin/plugins
ln -s /usr/share/munin/plugins/mssql_datafilesizes.rb /etc/munin/plugins/mssql_datafilesizes.rb
Parameters:
autoconf
config (required)
Config variables:
sqluser : mssql user who has view server state privilege
sqlpass : password for the mssql user
dsn : datasource name as defined in /etc/odbc.ini
instance: instance to monitor
#%# family=auto
#%# capabilities=autoconf
=end
require 'rubygems'
require 'dbi'

View File

@ -1,49 +1,54 @@
#!/usr/bin/env ruby
#
# Munin Plugin for MSSQL - log files monitoring
#
# Author: Wilfred Chau <openapp.developer@gmail.com>
# Date: 2011-05-19
# Version: 1.0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
# Prerequistes:
# 1) /etc/odbc.ini and /etc/freetds.conf
# 2) rubygems
# 3) ruby-dbi
#
# Usage:
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
# 2) chmod to allow executable to others
# 3) create symbolic link in /etc/munin/plugins
# ln -s /usr/share/munin/plugins/mssql_logfilesizes.rb /etc/munin/plugins/mssql_logfilesizes.rb
#
# Parameters:
# autoconf
# config (required)
#
# Config variables:
# sqluser : mssql user who has view server state privilege
# sqlpass : password for the mssql user
# dsn : datasource name as defined in /etc/odbc.ini
# instance: instance to monitor
#
=begin
Munin Plugin for MSSQL - log files monitoring
Author: Wilfred Chau <openapp.developer@gmail.com>
Date: 2011-05-19
Version: 1.0
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Prerequistes:
1) /etc/odbc.ini and /etc/freetds.conf
2) rubygems
3) ruby-dbi
Usage:
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
2) chmod to allow executable to others
3) create symbolic link in /etc/munin/plugins
ln -s /usr/share/munin/plugins/mssql_logfilesizes.rb /etc/munin/plugins/mssql_logfilesizes.rb
Parameters:
autoconf
config (required)
Config variables:
sqluser : mssql user who has view server state privilege
sqlpass : password for the mssql user
dsn : datasource name as defined in /etc/odbc.ini
instance: instance to monitor
#%# family=auto
#%# capabilities=autoconf
=end
require 'rubygems'
require 'dbi'

View File

@ -1,22 +1,26 @@
#!/usr/bin/env ruby
# netstat_s revision 6 (Nov 2013)
#
# This plugin shows various statistics from 'netstat -s'
#
# Required privileges: none
#
# OS:
# Supposed: BSD, Linux (only a few items, see netstat_multi for more)
# Tested: FreeBSD: 8.2, 8.3, 9.1
# Linux : Debian 6 (kernel 2.6.32), Arch (kernel 3.11.6), CentOS 6
#
# Author: Artem Sheremet <dot.doom@gmail.com>
#
=begin
netstat_s revision 6 (Nov 2013)
This plugin shows various statistics from 'netstat -s'
Required privileges: none
OS:
Supposed: BSD, Linux (only a few items, see netstat_multi for more)
Tested: FreeBSD: 8.2, 8.3, 9.1
Linux : Debian 6 (kernel 2.6.32), Arch (kernel 3.11.6), CentOS 6
Author: Artem Sheremet <dot.doom@gmail.com>
#%# family=auto
#%# capabilities=autoconf suggest
=end
# original filename
PLUGIN_NAME = 'netstat_s_'
@ -54,6 +58,7 @@ class Graph
multigraphs = {}
@parse_expr.each { |expr, descr|
next unless descr # no label - skip this entry
descr.each { |entry|
labels_array = (multigraphs[entry[0]] ||= [])
labels_array.push [entry[1], entry[2]]
@ -125,6 +130,7 @@ class Graph
multigraphs = {}
@parse_expr.each { |expr, descr|
next unless descr # no label - skip this entry
index = data.index { |line| line =~ expr }
if index
data.delete_at index
@ -291,8 +297,7 @@ def graphs_for(protocol)
])
]
when 'udp'
$os == :linux ? [
] : [
$os == :linux ? [] : [
Graph.new('received', protocol, [
[/(\d+) datagrams received$/, [[:packets, 'total']]],
[/(\d+) with incomplete header$/, [[:packets, 'incomplete header']]],
@ -312,8 +317,7 @@ def graphs_for(protocol)
])
]
when 'ip'
$os == :linux ? [
] : [
$os == :linux ? [] : [
Graph.new('received', protocol, [
[/(\d+) total packets received$/, [[:packets, 'total']]],
[/(\d+) bad header checksums$/, [[:packets, 'bad header checksum']]],

View File

@ -1,54 +1,59 @@
#!/usr/bin/env ruby
#
# Munin Plugin for PGA memory components monitoring
#
# Author: Wilfred Chau <openapp.developer@gmail.com>
# Date: 2011-05-13
# Version: 1.0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
# Prerequistes:
# 1) env.ORACLE_HOME set in munin-node
# 2) rubygems
# 3) oci8 - DBI gem for connecting to Oracle
# * instruction of installing oci8 is available here:
# http://ruby-oci8.rubyforge.org/en/InstallBinaryPackage.html
#
# Usage:
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
# 2) chmod to allow executable to others
# 3) create symbolic link in /etc/munin/plugins
# ln -s /usr/share/munin/plugins/oracle_<sid>_pga.rb /etc/munin/plugins/oracle_<sid>_pga.rb
# ** replace <sid> with your oralce sid
#
# Parameters:
# autoconf
# config (required)
#
# Configurable variables:
# orauser : oracle user who has select privilege to query v$pgastat view
# orapass : password for the oracle user
# dbport : port used by the monitored instance (notice: numeric value)
# dbname : database to be monitored
# dbhost : host or ip address of db instance
#
#
=begin
Munin Plugin for PGA memory components monitoring
Author: Wilfred Chau <openapp.developer@gmail.com>
Date: 2011-05-13
Version: 1.0
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Prerequistes:
1) env.ORACLE_HOME set in munin-node
2) rubygems
3) oci8 - DBI gem for connecting to Oracle
* instruction of installing oci8 is available here:
http://ruby-oci8.rubyforge.org/en/InstallBinaryPackage.html
Usage:
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
2) chmod to allow executable to others
3) create symbolic link in /etc/munin/plugins
ln -s /usr/share/munin/plugins/oracle_<sid>_pga.rb /etc/munin/plugins/oracle_<sid>_pga.rb
** replace <sid> with your oralce sid
Parameters:
autoconf
config (required)
Configurable variables:
orauser : oracle user who has select privilege to query v$pgastat view
orapass : password for the oracle user
dbport : port used by the monitored instance (notice: numeric value)
dbname : database to be monitored
dbhost : host or ip address of db instance
#%# family=auto
#%# capabilities=autoconf
=end
require 'rubygems'
require 'oci8'
@ -68,7 +73,6 @@ def runQuery (name,query)
rows.close
end
#
# Queries
#
@ -79,8 +83,7 @@ pga_query = "SELECT TO_CHAR(ROUND(decode(unit,'bytes',(value)/(1024*1024),value)
from V$PGASTAT where name = 'total PGA inuse'"
pga_components = { "pga_target" => pga_target_query,
"pga_in_use" => pga_query
}
"pga_in_use" => pga_query }
#
# autoconf

View File

@ -1,53 +1,58 @@
#!/usr/bin/env ruby
#
# Munin Plugin for SGA memory components monitoring
#
# Author: Wilfred Chau <openapp.developer@gmail.com>
# Date: 2011-05-12
# Version: 1.0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
# Prerequistes:
# 1) env.ORACLE_HOME set in munin-node
# 2) rubygems
# 3) oci8 - DBI gem for connecting to Oracle
# * instruction of installing oci8 is available here:
# http://ruby-oci8.rubyforge.org/en/InstallBinaryPackage.html
#
# Usage:
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
# 2) chmod to allow executable to others
# 3) create symbolic link in /etc/munin/plugins
# ln -s /usr/share/munin/plugins/oracle_orcl_sga.rb /etc/munin/plugins/oracle_orcl_sga.rb
#
# Parameters:
# autoconf
# config (required)
#
# Configurable variables:
# orauser : oracle user who has select privilege to query v$sgastat view
# orapass : password for the oracle user
# dbport : port used by the monitored instance (notice: numeric value)
# dbname : database to be monitored
# dbhost : host or ip address of db instance
#
#
=begin
Munin Plugin for SGA memory components monitoring
Author: Wilfred Chau <openapp.developer@gmail.com>
Date: 2011-05-12
Version: 1.0
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Prerequistes:
1) env.ORACLE_HOME set in munin-node
2) rubygems
3) oci8 - DBI gem for connecting to Oracle
* instruction of installing oci8 is available here:
http://ruby-oci8.rubyforge.org/en/InstallBinaryPackage.html
Usage:
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins)
2) chmod to allow executable to others
3) create symbolic link in /etc/munin/plugins
ln -s /usr/share/munin/plugins/oracle_orcl_sga.rb /etc/munin/plugins/oracle_orcl_sga.rb
Parameters:
autoconf
config (required)
Configurable variables:
orauser : oracle user who has select privilege to query v$sgastat view
orapass : password for the oracle user
dbport : port used by the monitored instance (notice: numeric value)
dbname : database to be monitored
dbhost : host or ip address of db instance
#%# family=auto
#%# capabilities=autoconf
=end
require 'rubygems'
require 'oci8'
@ -67,7 +72,6 @@ def runQuery (name,query)
rows.close
end
#
# Queries
#
@ -98,14 +102,12 @@ log_buffer_query = "SELECT TO_CHAR(ROUND(SUM(decode(pool, NULL,
decode(name, 'log_buffer', (bytes)/(1024*1024),0),0)),2)) sga_lbuffer
from V$SGASTAT"
memory_components = { "fixed_area" => fixed_area_query,
"buffer_cache" => buffer_cache_query,
"java_pool" => java_pool_query,
"large_pool" => large_pool_query,
"log_buffer" => log_buffer_query,
"shared_pool" => shared_pool_query
}
"shared_pool" => shared_pool_query }
#
# autoconf

View File

@ -14,13 +14,12 @@ require 'mysql'
require 'yaml'
class Grapher
def initialize(db_conf)
@db_conf = db_conf
end
def config
puts <<-END_CONFIG
puts <<~END_CONFIG
graph_title Delayed_Jobs Queue Size
graph_args -l 0
graph_vlabel jobs to be run
@ -39,7 +38,6 @@ jobs.type GAUGE
value = result.fetch_hash.values.first
puts "jobs.value #{value}"
end
end
if __FILE__ == $0

View File

@ -20,7 +20,6 @@ SERVICE_F = '/etc/services'
PORT = /^[\d]+(\.[\d]+){0,1}$/ === SERVICE ? SERVICE : %x[grep #{SERVICE} #{SERVICE_F}].split("\t\t")[1].split('/')[0]
class PortMonit < Munin::Plugin
graph_attributes "#{SERVICE} port usage, known as #{PORT}",
:category => 'network',
:info => 'This graph shows connection split by the state of the socket.',
@ -55,10 +54,8 @@ class PortMonit < Munin::Plugin
:type => :GAUGE, :min => 0
def retrieve_values
@_netstat = %x[netstat -n -P tcp | egrep "\.#{PORT} "].split("\n")
{ :ESTABLISHED => count(@_netstat, 'ESTABLISHED'),
:CLOSE_WAIT => count(@_netstat, 'CLOSE_WAIT'),
:CLOSING => count(@_netstat, 'CLOSING'),
@ -69,6 +66,7 @@ class PortMonit < Munin::Plugin
end
private
def count(source, regex)
@_result = 0

View File

@ -24,10 +24,10 @@ passenger_rss = nil
`#{memory_stats_command}`.each_line do |line|
next unless /### Total private dirty RSS: (\d+\.\d+) MB/.match(line)
passenger_rss = $~[1] unless apache_rss.nil?
apache_rss ||= $~[1]
end
puts "apache_rss.value #{apache_rss}"
puts "passenger_rss.value #{passenger_rss}"

View File

@ -39,4 +39,3 @@ puts "max.value #{max}"
puts "count.value #{count}"
puts "active.value #{active}"
puts "queued.value #{queued.to_i}"

View File

@ -1,7 +1,7 @@
#!/usr/bin/env ruby
def output_config
puts <<-END
puts <<~END
graph_category webserver
graph_title status
graph_vlabel count

View File

@ -98,7 +98,5 @@ open(url, :http_basic_authentication=>[user, pwd]) do |f|
key = line.gsub!(/(<[^>]*>)|\n|\t| /s, "")
one_liners = one_liners + 1
end
end
end

View File

@ -1,36 +1,41 @@
#!/usr/bin/env ruby
# munin plugin to retrieve connection statistics from the web admin interface
# on a Linksys AG241v2 ADSL modem
# Makes use of the http://modemaddress/ADSLCStatus.htm page
#This plugin has only been tested on a Debian testing system
=begin
# This modem also has some basic SNMP support so you can configure it
# as per the instructions on the munin wiki
# http://munin.projects.linpro.no/wiki/Using_SNMP_plugins
# By default the SNMP server is disabled, you can enable it in the web admin
# You will need to set up the "virtual node" configuration as detailed
# for snmp plugins
munin plugin to retrieve connection statistics from the web admin interface
on a Linksys AG241v2 ADSL modem
Makes use of the http://modemaddress/ADSLCStatus.htm page
# Plugin will require some configuration in /etc/munin/plugin-conf.d/ag241_MODEMADDRESS
# e.g.
# [ag241_vocume.stargate_*]
# env.user admin
# env.pass password
# #env.port 80
This plugin has only been tested on a Debian testing system
# Once you have the above config set you will need to symlink the plugin to
# /etc/munin/plugins/ag241_MODEMADDRESS_syncrate
# /etc/munin/plugins/ag241_MODEMADDRESS_attenutation
# /etc/munin/plugins/ag241_MODEMADDRESS_noise
# now restart munin-node.
# hopefully in 20-30mins you will have some nice graphs
This modem also has some basic SNMP support so you can configure it
as per the instructions on the munin wiki
http://munin.projects.linpro.no/wiki/Using_SNMP_plugins
By default the SNMP server is disabled, you can enable it in the web admin
You will need to set up the "virtual node" configuration as detailed
for snmp plugins
Plugin will require some configuration in /etc/munin/plugin-conf.d/ag241_MODEMADDRESS
e.g.
[ag241_vocume.stargate_*]
env.user admin
env.pass password
#env.port 80
#Some magical munin foo...
Once you have the above config set you will need to symlink the plugin to
/etc/munin/plugins/ag241_MODEMADDRESS_syncrate
/etc/munin/plugins/ag241_MODEMADDRESS_attenutation
/etc/munin/plugins/ag241_MODEMADDRESS_noise
now restart munin-node.
hopefully in 20-30mins you will have some nice graphs
Some magical munin foo...
#%# family=manual
#%# capabilities=
=end
# Require this module, it is part of the standard ruby lib AFAIK
require 'net/http'

View File

@ -31,7 +31,6 @@ require 'mechanize'
require 'digest/md5'
require 'nokogiri'
def output
nics = Hash.new
nics["LAN"] = Hash.new
@ -135,7 +134,6 @@ def output
end
end
def config
# build the configuration for graphs
puts "multigraph if_packets"
@ -244,7 +242,6 @@ def config
end
end
# main
if ARGV.length == 1 and ARGV[0] == 'config'
config()

View File

@ -89,6 +89,7 @@ when "config"
if not is_vb_valid(vb, subchannel)
next
end
puts "#{field_name(unit, vb, letter)}.label #{label(unit, vb)}"
end
end
@ -96,7 +97,6 @@ when "config"
exit 0
end
units.each do |unit|
SNMP::Manager.open(:Host => unit,
:Community => community,
@ -105,6 +105,7 @@ units.each do |unit|
if not is_vb_valid(vb, subchannel)
next
end
puts "#{field_name(unit, vb, letter)}.value #{vb.value.to_f / 100}"
end
end

View File

@ -1,32 +1,38 @@
#!/usr/bin/env ruby
# Plugin to monitor the number of invalid access to sshd per country
#
# Require read permissions for SYSLOG
# ref) ls -l /var/log/secure
# Require geoip rubygem
# ref) http://geoip.rubyforge.org/
# Require GeoIP-database for searching ip or host for the country
# ref) http://www.maxmind.com/app/geoip_country
#
# Parameters:
# config (required)
# autoconf (optional - used by munin-config)
#
# $Log$
# Revision 1.0 2010/12/25 11:56:12 hirata yoshiyuki
# released.
#
# Magick markers (optional):
=begin
Plugin to monitor the number of invalid access to sshd per country
Require read permissions for SYSLOG
ref) ls -l /var/log/secure
Require geoip rubygem
ref) http://geoip.rubyforge.org/
Require GeoIP-database for searching ip or host for the country
ref) http://www.maxmind.com/app/geoip_country
Parameters:
config (required)
autoconf (optional - used by munin-config)
$Log$
Revision 1.0 2010/12/25 11:56:12 hirata yoshiyuki
released.
Magick markers (optional):
#%# family=auto
#%# capabilities=autoconf
#
# config example for /etc/munin/plugin-conf.d/munin-node
#[sshd_invalid_countries_ruby]
#user root
#group root
#env.logfile /var/log/secure
#env.geoip /home/you/GeoIP.dat
#env.loadpath /usr/local/lib/ruby/gems/1.9.1/gems/geoip-0.8.8/lib/
config example for /etc/munin/plugin-conf.d/munin-node
[sshd_invalid_countries_ruby]
user root
group root
env.logfile /var/log/secure
env.geoip /home/you/GeoIP.dat
env.loadpath /usr/local/lib/ruby/gems/1.9.1/gems/geoip-0.8.8/lib/
=end
require (ENV['loadpath'] || '') + 'geoip'

View File

@ -1,44 +1,49 @@
#!/usr/bin/env ruby
# thin_memory - A munin plugin for Linux to monitor memory size of each individual thin process
#
# For Linux ONLY !
# DOES NOT WORK on OSX, Solaris or BSD.
# only linux, because this script relies on proc filesystem
#
# Original author:
# Frederico de Souza Araujo - fred.the.master@gmail.com
# http://www.frederico-araujo.com
#
# Usurper:
# Adam Michel - elfurbe@furbism.com
# http://www.furbism.com
#
# Originally based on:
# thin_process_memory -
# A munin plugin to monitor memory size of
# each individual thin process
# by Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
=begin
thin_memory - A munin plugin for Linux to monitor memory size of each individual thin process
For Linux ONLY !
DOES NOT WORK on OSX, Solaris or BSD.
only linux, because this script relies on proc filesystem
Original author:
Frederico de Souza Araujo - fred.the.master@gmail.com
http://www.frederico-araujo.com
Usurper:
Adam Michel - elfurbe@furbism.com
http://www.furbism.com
Originally based on:
thin_process_memory -
A munin plugin to monitor memory size of
each individual thin process
by Ben VandenBos and Avvo, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#%# family=auto
#%# capabilities=autoconf
=end
module Munin
class ThinProcessMemory
# run main method
def run
instances = get_pids()
@ -67,7 +72,6 @@ module Munin
def autoconf
get_pids().length > 0
end
end
end

View File

@ -1,45 +1,50 @@
#!/usr/bin/env ruby
# thin_threads -
# A munin plugin for Linux to monitor how many threads per thin process
#
# For Linux ONLY !
# DOES NOT WORK on OSX, Solaris or BSD.
# only linux, because this script relies on proc filesystem
#
# Original author:
# Frederico de Souza Araujo - fred.the.master@gmail.com
# http://www.frederico-araujo.com
#
# Usurper:
# Adam Michel - elfurbe@furbism.com
# http://www.furbism.com
#
# Originally based on:
# thin_process_memory -
# A munin plugin to monitor memory size of
# each individual thin process
# by Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
=begin
thin_threads -
A munin plugin for Linux to monitor how many threads per thin process
For Linux ONLY !
DOES NOT WORK on OSX, Solaris or BSD.
only linux, because this script relies on proc filesystem
Original author:
Frederico de Souza Araujo - fred.the.master@gmail.com
http://www.frederico-araujo.com
Usurper:
Adam Michel - elfurbe@furbism.com
http://www.furbism.com
Originally based on:
thin_process_memory -
A munin plugin to monitor memory size of
each individual thin process
by Ben VandenBos and Avvo, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#%# family=auto
#%# capabilities=autoconf
=end
module Munin
class ThinThreads
def run
instances = get_pids()
instances.each do |instance|
@ -71,7 +76,6 @@ module Munin
def autoconf
get_pids().length > 0
end
end
end

View File

@ -1,42 +1,47 @@
#!/usr/bin/env ruby
# thin_peak_memory -
# A munin plugin for Linux to monitor the maximum memory size
# that an each individual thin process has reached
#
# For Linux ONLY !
# DOES NOT WORK on OSX, Solaris or BSD.
# only linux, because this script relies on proc filesystem
#
# Author:
# Frederico de Souza Araujo - fred.the.master@gmail.com
# http://www.frederico-araujo.com
#
# Based on:
# thin_process_memory -
# A munin plugin to monitor memory size of
# each individual thin process
# by Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
=begin
thin_peak_memory -
A munin plugin for Linux to monitor the maximum memory size
that an each individual thin process has reached
For Linux ONLY !
DOES NOT WORK on OSX, Solaris or BSD.
only linux, because this script relies on proc filesystem
Author:
Frederico de Souza Araujo - fred.the.master@gmail.com
http://www.frederico-araujo.com
Based on:
thin_process_memory -
A munin plugin to monitor memory size of
each individual thin process
by Ben VandenBos and Avvo, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#%# family=auto
#%# capabilities=autoconf
=end
module Munin
class ThinPeakMemory
def run
instances = get_pids()
instances.each do |instance|
@ -69,7 +74,6 @@ module Munin
def autoconf
get_pids().length > 0
end
end
end

View File

@ -32,6 +32,7 @@ module Munin
chunks = line.strip.split(/\s+/, 5)
pid, pcmd = chunks[0], chunks[4]
next if pid !~ /\A\d+\z/ or pcmd !~ /worker/
result << pid.to_i
end
result

View File

@ -32,6 +32,7 @@ module Munin
chunks = line.strip.split(/\s+/, 5)
pid, pcmd = chunks[0], chunks[4]
next if pid !~ /\A\d+\z/ or pcmd !~ /worker/
result << pid.to_i
end
result