mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Ruby plugins: apply style changes as suggested by "rubocop --fix-layout"
This commit is contained in:
parent
26c29daa2b
commit
b0b39b018e
30 changed files with 1447 additions and 1384 deletions
|
@ -14,18 +14,17 @@ require 'mysql'
|
|||
require 'yaml'
|
||||
|
||||
class Grapher
|
||||
|
||||
def initialize(db_conf)
|
||||
@db_conf = db_conf
|
||||
end
|
||||
|
||||
def config
|
||||
puts <<-END_CONFIG
|
||||
graph_title Delayed_Jobs Queue Size
|
||||
graph_args -l 0
|
||||
graph_vlabel jobs to be run
|
||||
jobs.label jobs
|
||||
jobs.type GAUGE
|
||||
puts <<~END_CONFIG
|
||||
graph_title Delayed_Jobs Queue Size
|
||||
graph_args -l 0
|
||||
graph_vlabel jobs to be run
|
||||
jobs.label jobs
|
||||
jobs.type GAUGE
|
||||
END_CONFIG
|
||||
end
|
||||
|
||||
|
@ -39,7 +38,6 @@ jobs.type GAUGE
|
|||
value = result.fetch_hash.values.first
|
||||
puts "jobs.value #{value}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
|
|
|
@ -15,64 +15,62 @@
|
|||
require 'rubygems'
|
||||
require 'munin'
|
||||
|
||||
SERVICE = $0.split( '_' ).last
|
||||
SERVICE = $0.split('_').last
|
||||
SERVICE_F = '/etc/services'
|
||||
PORT = /^[\d]+(\.[\d]+){0,1}$/ === SERVICE ? SERVICE : %x[grep #{SERVICE} #{SERVICE_F}].split( "\t\t" )[1].split( '/' )[0]
|
||||
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.',
|
||||
:vlabel => 'Current connections'
|
||||
:category => 'network',
|
||||
:info => 'This graph shows connection split by the state of the socket.',
|
||||
:vlabel => 'Current connections'
|
||||
|
||||
declare_field :ESTABLISHED,
|
||||
:label => 'Established', :draw => :AREA,
|
||||
:type => :GAUGE, :min => 0
|
||||
declare_field :ESTABLISHED,
|
||||
:label => 'Established', :draw => :AREA,
|
||||
:type => :GAUGE, :min => 0
|
||||
|
||||
declare_field :CLOSE_WAIT,
|
||||
:label => 'Waiting close', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
declare_field :CLOSE_WAIT,
|
||||
:label => 'Waiting close', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
|
||||
declare_field :TIME_WAIT,
|
||||
:label => 'Waiting after close', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
declare_field :TIME_WAIT,
|
||||
:label => 'Waiting after close', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
|
||||
declare_field :CLOSING,
|
||||
:label => 'Closing', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
declare_field :CLOSING,
|
||||
:label => 'Closing', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
|
||||
declare_field :LAST_ACK,
|
||||
:label => 'Waiting for acknowledgement', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
declare_field :LAST_ACK,
|
||||
:label => 'Waiting for acknowledgement', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
|
||||
declare_field :FIN_WAIT_1,
|
||||
:label => 'Socket closed, connection shutting down', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
declare_field :FIN_WAIT_1,
|
||||
:label => 'Socket closed, connection shutting down', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
|
||||
declare_field :FIN_WAIT_2,
|
||||
:label => 'Connection closed, Socket still waiting', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
declare_field :FIN_WAIT_2,
|
||||
:label => 'Connection closed, Socket still waiting', :draw => :STACK,
|
||||
:type => :GAUGE, :min => 0
|
||||
|
||||
def retrieve_values
|
||||
@_netstat = %x[netstat -n -P tcp | egrep "\.#{PORT} "].split("\n")
|
||||
|
||||
@_netstat = %x[netstat -n -P tcp | egrep "\.#{PORT} "].split( "\n" )
|
||||
|
||||
|
||||
{ :ESTABLISHED => count( @_netstat, 'ESTABLISHED' ),
|
||||
:CLOSE_WAIT => count( @_netstat, 'CLOSE_WAIT' ),
|
||||
:CLOSING => count( @_netstat, 'CLOSING' ),
|
||||
:LAST_ACK => count( @_netstat, 'LAST_ACK' ),
|
||||
:FIN_WAIT_1 => count( @_netstat, 'FIN_WAIT_1' ),
|
||||
:FIN_WAIT_2 => count( @_netstat, 'FIN_WAIT_2' ),
|
||||
:TIME_WAIT => count( @_netstat, 'TIME_WAIT' ) }
|
||||
{ :ESTABLISHED => count(@_netstat, 'ESTABLISHED'),
|
||||
:CLOSE_WAIT => count(@_netstat, 'CLOSE_WAIT'),
|
||||
:CLOSING => count(@_netstat, 'CLOSING'),
|
||||
:LAST_ACK => count(@_netstat, 'LAST_ACK'),
|
||||
:FIN_WAIT_1 => count(@_netstat, 'FIN_WAIT_1'),
|
||||
:FIN_WAIT_2 => count(@_netstat, 'FIN_WAIT_2'),
|
||||
:TIME_WAIT => count(@_netstat, 'TIME_WAIT') }
|
||||
end
|
||||
|
||||
private
|
||||
def count( source, regex )
|
||||
|
||||
def count(source, regex)
|
||||
@_result = 0
|
||||
|
||||
source.each { |obj| @_result += 1 if obj.match( regex ) }
|
||||
source.each { |obj| @_result += 1 if obj.match(regex) }
|
||||
|
||||
return @_result
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue