Révision b0b39b01
Ruby plugins: apply style changes as suggested by "rubocop --fix-layout"
| plugins/bsd/netstat_bsd_m_ | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 | 2 |
|
| 3 |
# netstat_bsd_m revision 1 (Feb 2012) |
|
| 4 |
# |
|
| 5 |
# This plugin shows various statistics from 'netstat -m' |
|
| 6 |
# |
|
| 7 |
# Required privileges: none |
|
| 8 |
# |
|
| 9 |
# OS: |
|
| 10 |
# Supposed: BSD |
|
| 11 |
# Tested: FreeBSD 8.2 |
|
| 12 |
# |
|
| 13 |
# Author: Artem Sheremet <dot.doom@gmail.com> |
|
| 14 |
# |
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
netstat_bsd_m revision 1 (Feb 2012) |
|
| 6 |
|
|
| 7 |
This plugin shows various statistics from 'netstat -m' |
|
| 8 |
|
|
| 9 |
Required privileges: none |
|
| 10 |
|
|
| 11 |
OS: |
|
| 12 |
Supposed: BSD |
|
| 13 |
Tested: FreeBSD 8.2 |
|
| 14 |
|
|
| 15 |
Author: Artem Sheremet <dot.doom@gmail.com> |
|
| 16 |
|
|
| 15 | 17 |
|
| 16 | 18 |
#%# family=auto |
| 17 | 19 |
#%# capabilities=autoconf suggest |
| 18 | 20 |
|
| 21 |
=end |
|
| 22 |
|
|
| 23 |
|
|
| 19 | 24 |
# original filename |
| 20 | 25 |
PLUGIN_NAME = 'netstat_bsd_m_' |
| 21 | 26 |
|
| 22 | 27 |
class String |
| 23 |
def escape
|
|
| 24 |
self.gsub /[^\w]/, '_'
|
|
| 25 |
end
|
|
| 26 |
|
|
| 27 |
unless method_defined? :start_with?
|
|
| 28 |
def start_with?(str)
|
|
| 29 |
self[0...str.size] == str
|
|
| 30 |
end
|
|
| 31 |
end
|
|
| 28 |
def escape
|
|
| 29 |
self.gsub /[^\w]/, '_'
|
|
| 30 |
end
|
|
| 31 |
|
|
| 32 |
unless method_defined? :start_with?
|
|
| 33 |
def start_with?(str)
|
|
| 34 |
self[0...str.size] == str
|
|
| 35 |
end
|
|
| 36 |
end
|
|
| 32 | 37 |
end |
| 33 | 38 |
|
| 34 | 39 |
def netstat_m(filter = nil) |
| 35 |
Hash[`netstat -m`.split($/).map { |line|
|
|
| 36 |
if line =~ /^([\d\/K]+) (.*) \(([\w\/+]+)\)$/
|
|
| 37 |
# 7891K/22385K/30276K bytes allocated to network (current/cache/total)
|
|
| 38 |
values, desc, names = $1, $2, $3
|
|
| 39 |
[desc, names.split('/').zip(values.split '/')] if filter.nil? or desc.escape == filter
|
|
| 40 |
elsif line =~ /^(\d+) (.*)$/
|
|
| 41 |
# 12327 requests for I/O initiated by sendfile
|
|
| 42 |
value, desc = $1, $2
|
|
| 43 |
[desc, [[ :value, value ]]] if filter.nil? or desc.escape == filter
|
|
| 44 |
end
|
|
| 45 |
}.compact]
|
|
| 40 |
Hash[`netstat -m`.split($/).map { |line|
|
|
| 41 |
if line =~ /^([\d\/K]+) (.*) \(([\w\/+]+)\)$/
|
|
| 42 |
# 7891K/22385K/30276K bytes allocated to network (current/cache/total)
|
|
| 43 |
values, desc, names = $1, $2, $3
|
|
| 44 |
[desc, names.split('/').zip(values.split '/')] if filter.nil? or desc.escape == filter
|
|
| 45 |
elsif line =~ /^(\d+) (.*)$/
|
|
| 46 |
# 12327 requests for I/O initiated by sendfile
|
|
| 47 |
value, desc = $1, $2
|
|
| 48 |
[desc, [[:value, value]]] if filter.nil? or desc.escape == filter
|
|
| 49 |
end
|
|
| 50 |
}.compact]
|
|
| 46 | 51 |
end |
| 47 | 52 |
|
| 48 | 53 |
stat_name = File.basename($0, '.*').escape |
| ... | ... | |
| 50 | 55 |
|
| 51 | 56 |
case ARGV.first |
| 52 | 57 |
when 'autoconf' |
| 53 |
puts `uname -s`.include?('FreeBSD') ? 'yes' : 'no'
|
|
| 58 |
puts `uname -s`.include?('FreeBSD') ? 'yes' : 'no'
|
|
| 54 | 59 |
when 'suggest' |
| 55 |
puts netstat_m.keys.map(&:escape).join $/
|
|
| 60 |
puts netstat_m.keys.map(&:escape).join $/
|
|
| 56 | 61 |
when 'config' |
| 57 |
data = netstat_m(stat_name)
|
|
| 58 |
if data.empty?
|
|
| 59 |
warn "no data for <#{stat_name}>. Try running with 'suggest'"
|
|
| 60 |
else
|
|
| 61 |
desc, values = data.first
|
|
| 62 |
stack = values.size > 1
|
|
| 63 |
first = true
|
|
| 64 |
puts <<CONFIG
|
|
| 65 |
graph_title Netstat: #{desc}
|
|
| 66 |
graph_category network |
|
| 67 |
graph_vlabel current |
|
| 68 |
graph_order #{values.map { |name, _| name.to_s.escape }.join ' '}
|
|
| 69 |
CONFIG |
|
| 70 |
puts values.map { |name, _|
|
|
| 71 |
esc_name = name.to_s.escape
|
|
| 72 |
"#{esc_name}.draw " + if %w(total max).include? name
|
|
| 73 |
'LINE'
|
|
| 74 |
elsif stack
|
|
| 75 |
if first
|
|
| 76 |
first = false
|
|
| 77 |
'AREA'
|
|
| 78 |
else
|
|
| 79 |
'STACK'
|
|
| 80 |
end
|
|
| 81 |
else
|
|
| 82 |
'LINE2'
|
|
| 83 |
end + "\n#{esc_name}.label #{name}"
|
|
| 84 |
}.join $/
|
|
| 85 |
end
|
|
| 62 |
data = netstat_m(stat_name)
|
|
| 63 |
if data.empty?
|
|
| 64 |
warn "no data for <#{stat_name}>. Try running with 'suggest'"
|
|
| 65 |
else
|
|
| 66 |
desc, values = data.first
|
|
| 67 |
stack = values.size > 1
|
|
| 68 |
first = true
|
|
| 69 |
puts <<~CONFIG
|
|
| 70 |
graph_title Netstat: #{desc}
|
|
| 71 |
graph_category network
|
|
| 72 |
graph_vlabel current
|
|
| 73 |
graph_order #{values.map { |name, _| name.to_s.escape }.join ' '}
|
|
| 74 |
CONFIG
|
|
| 75 |
puts values.map { |name, _|
|
|
| 76 |
esc_name = name.to_s.escape
|
|
| 77 |
"#{esc_name}.draw " + if %w(total max).include? name
|
|
| 78 |
'LINE'
|
|
| 79 |
elsif stack
|
|
| 80 |
if first
|
|
| 81 |
first = false
|
|
| 82 |
'AREA'
|
|
| 83 |
else
|
|
| 84 |
'STACK'
|
|
| 85 |
end
|
|
| 86 |
else
|
|
| 87 |
'LINE2'
|
|
| 88 |
end + "\n#{esc_name}.label #{name}"
|
|
| 89 |
}.join $/
|
|
| 90 |
end
|
|
| 86 | 91 |
when nil # fetch |
| 87 |
data = netstat_m(stat_name)
|
|
| 88 |
unless data.empty?
|
|
| 89 |
puts data.first.last.map { |name, value|
|
|
| 90 |
value = value.to_i * 1024 if value.end_with? 'K'
|
|
| 91 |
"#{name.to_s.escape}.value #{value}"
|
|
| 92 |
}.join $/
|
|
| 93 |
end
|
|
| 92 |
data = netstat_m(stat_name)
|
|
| 93 |
unless data.empty?
|
|
| 94 |
puts data.first.last.map { |name, value|
|
|
| 95 |
value = value.to_i * 1024 if value.end_with? 'K'
|
|
| 96 |
"#{name.to_s.escape}.value #{value}"
|
|
| 97 |
}.join $/
|
|
| 98 |
end
|
|
| 94 | 99 |
else |
| 95 |
warn "unrecognized argument <#{ARGV.first}>"
|
|
| 100 |
warn "unrecognized argument <#{ARGV.first}>"
|
|
| 96 | 101 |
end |
| plugins/ejabberd/ejabberd_scanlog | ||
|---|---|---|
| 28 | 28 |
$debug_mode = ARGV.first == 'debug' |
| 29 | 29 |
|
| 30 | 30 |
if $debug_mode |
| 31 |
log_info = DEFAULT_CACHE
|
|
| 31 |
log_info = DEFAULT_CACHE
|
|
| 32 | 32 |
else |
| 33 |
begin
|
|
| 34 |
log_info = YAML.load IO.read(CACHE_FILE)
|
|
| 35 |
rescue
|
|
| 36 |
log_info = DEFAULT_CACHE
|
|
| 37 |
end
|
|
| 38 |
|
|
| 39 |
if File.size(LOG_FILE) < log_info[:start]
|
|
| 40 |
# logrotate?
|
|
| 41 |
log_info = DEFAULT_CACHE
|
|
| 42 |
end
|
|
| 33 |
begin
|
|
| 34 |
log_info = YAML.load IO.read(CACHE_FILE)
|
|
| 35 |
rescue
|
|
| 36 |
log_info = DEFAULT_CACHE
|
|
| 37 |
end
|
|
| 38 |
|
|
| 39 |
if File.size(LOG_FILE) < log_info[:start]
|
|
| 40 |
# logrotate?
|
|
| 41 |
log_info = DEFAULT_CACHE
|
|
| 42 |
end
|
|
| 43 | 43 |
end |
| 44 | 44 |
|
| 45 | 45 |
if ARGV.first == 'reset' |
| 46 |
log_info = { :start => File.size(LOG_FILE)-1 }
|
|
| 47 |
puts 'Log reset'
|
|
| 46 |
log_info = { :start => File.size(LOG_FILE) - 1 }
|
|
| 47 |
puts 'Log reset'
|
|
| 48 | 48 |
end |
| 49 | 49 |
|
| 50 | 50 |
new_data = '' |
| 51 | 51 |
File.open(LOG_FILE, 'rb') do |flog| |
| 52 |
flog.seek(log_info[:start])
|
|
| 53 |
new_data = flog.read
|
|
| 52 |
flog.seek(log_info[:start])
|
|
| 53 |
new_data = flog.read
|
|
| 54 | 54 |
end |
| 55 | 55 |
|
| 56 | 56 |
KNOWN_LOG_TYPES = [ |
| 57 |
# each element is an instance of Array. 1st item: error description, others: text to search log for
|
|
| 58 |
['EJAB-1482 Crash when waiting for item',
|
|
| 59 |
['wait_for_']],
|
|
| 60 |
['EJAB-1483 ODBC sup failure (wrong PID?)',
|
|
| 61 |
['ejabberd_odbc_sup']],
|
|
| 62 |
['EJAB-1483 ODBC sup wrong PID failure echo',
|
|
| 63 |
["mod_pubsub_odbc,'-unsubscribe"]],
|
|
| 64 |
['DNS failure',
|
|
| 65 |
['You should check your DNS configuration']],
|
|
| 66 |
['Database unavailable/too slow',
|
|
| 67 |
['Database was not available or too slow']],
|
|
| 68 |
['State machine terminated: timeout',
|
|
| 69 |
['State machine',
|
|
| 70 |
'terminating',
|
|
| 71 |
'Reason for',
|
|
| 72 |
'timeout']],
|
|
| 73 |
['The auth module returned an error',
|
|
| 74 |
['The authentication module',
|
|
| 75 |
'returned an error']],
|
|
| 76 |
['MySQL disconnected',
|
|
| 77 |
['mysql',
|
|
| 78 |
'Received unknown signal, exiting']],
|
|
| 79 |
['Connecting to MySQL: failed',
|
|
| 80 |
['mysql',
|
|
| 81 |
'Failed connecting to']],
|
|
| 82 |
['Timeout while running a hook',
|
|
| 83 |
['ejabberd_hooks',
|
|
| 84 |
'timeout']],
|
|
| 85 |
['SQL transaction restarts exceeded',
|
|
| 86 |
['SQL transaction restarts exceeded']],
|
|
| 87 |
['Unexpected info',
|
|
| 88 |
['nexpected info']],
|
|
| 89 |
['Other sql_cmd timeout',
|
|
| 90 |
['sql_cmd']],
|
|
| 91 |
['System limit hit: ports', # check with length(erlang:ports())., set in ejabberdctl config file
|
|
| 92 |
['system_limit',
|
|
| 93 |
'open_port']],
|
|
| 94 |
['Other system limit hit', # processes? check with erlang:system_info(process_count)., erlang:system_info(process_limit)., set in ejabberdctl cfg
|
|
| 95 |
['system_limit']],
|
|
| 96 |
['Generic server terminating',
|
|
| 97 |
['Generic server',
|
|
| 98 |
'terminating']],
|
|
| 99 |
['Mnesia table shrinked',
|
|
| 100 |
['shrinking table']],
|
|
| 101 |
['Admin access failed',
|
|
| 102 |
['Access of',
|
|
| 103 |
'failed with error']],
|
|
| 104 |
['MySQL sock timedout',
|
|
| 105 |
['mysql_',
|
|
| 106 |
': Socket',
|
|
| 107 |
'timedout']],
|
|
| 108 |
['Configuration error',
|
|
| 109 |
['{badrecord,config}']],
|
|
| 110 |
['Strange vCard error (vhost)',
|
|
| 111 |
['error found when trying to get the vCard']],
|
|
| 112 |
['Mnesia is overloaded',
|
|
| 113 |
['Mnesia is overloaded']],
|
|
| 114 |
['MySQL: init failed recv data',
|
|
| 115 |
['mysql_conn: init failed receiving data']],
|
|
| 116 |
['TCP Error',
|
|
| 117 |
['Failed TCP']]
|
|
| 57 |
# each element is an instance of Array. 1st item: error description, others: text to search log for
|
|
| 58 |
['EJAB-1482 Crash when waiting for item',
|
|
| 59 |
['wait_for_']],
|
|
| 60 |
['EJAB-1483 ODBC sup failure (wrong PID?)',
|
|
| 61 |
['ejabberd_odbc_sup']],
|
|
| 62 |
['EJAB-1483 ODBC sup wrong PID failure echo',
|
|
| 63 |
["mod_pubsub_odbc,'-unsubscribe"]],
|
|
| 64 |
['DNS failure',
|
|
| 65 |
['You should check your DNS configuration']],
|
|
| 66 |
['Database unavailable/too slow',
|
|
| 67 |
['Database was not available or too slow']],
|
|
| 68 |
['State machine terminated: timeout',
|
|
| 69 |
['State machine',
|
|
| 70 |
'terminating',
|
|
| 71 |
'Reason for',
|
|
| 72 |
'timeout']],
|
|
| 73 |
['The auth module returned an error',
|
|
| 74 |
['The authentication module',
|
|
| 75 |
'returned an error']],
|
|
| 76 |
['MySQL disconnected',
|
|
| 77 |
['mysql',
|
|
| 78 |
'Received unknown signal, exiting']],
|
|
| 79 |
['Connecting to MySQL: failed',
|
|
| 80 |
['mysql',
|
|
| 81 |
'Failed connecting to']],
|
|
| 82 |
['Timeout while running a hook',
|
|
| 83 |
['ejabberd_hooks',
|
|
| 84 |
'timeout']],
|
|
| 85 |
['SQL transaction restarts exceeded',
|
|
| 86 |
['SQL transaction restarts exceeded']],
|
|
| 87 |
['Unexpected info',
|
|
| 88 |
['nexpected info']],
|
|
| 89 |
['Other sql_cmd timeout',
|
|
| 90 |
['sql_cmd']],
|
|
| 91 |
['System limit hit: ports', # check with length(erlang:ports())., set in ejabberdctl config file
|
|
| 92 |
['system_limit',
|
|
| 93 |
'open_port']],
|
|
| 94 |
['Other system limit hit', # processes? check with erlang:system_info(process_count)., erlang:system_info(process_limit)., set in ejabberdctl cfg
|
|
| 95 |
['system_limit']],
|
|
| 96 |
['Generic server terminating',
|
|
| 97 |
['Generic server',
|
|
| 98 |
'terminating']],
|
|
| 99 |
['Mnesia table shrinked',
|
|
| 100 |
['shrinking table']],
|
|
| 101 |
['Admin access failed',
|
|
| 102 |
['Access of',
|
|
| 103 |
'failed with error']],
|
|
| 104 |
['MySQL sock timedout',
|
|
| 105 |
['mysql_',
|
|
| 106 |
': Socket',
|
|
| 107 |
'timedout']],
|
|
| 108 |
['Configuration error',
|
|
| 109 |
['{badrecord,config}']],
|
|
| 110 |
['Strange vCard error (vhost)',
|
|
| 111 |
['error found when trying to get the vCard']],
|
|
| 112 |
['Mnesia is overloaded',
|
|
| 113 |
['Mnesia is overloaded']],
|
|
| 114 |
['MySQL: init failed recv data',
|
|
| 115 |
['mysql_conn: init failed receiving data']],
|
|
| 116 |
['TCP Error',
|
|
| 117 |
['Failed TCP']]
|
|
| 118 | 118 |
] |
| 119 | 119 |
|
| 120 | 120 |
def log_type(text) |
| 121 |
KNOWN_LOG_TYPES.find_index { |entry|
|
|
| 122 |
entry[1].all? { |substr| text.include? substr }
|
|
| 123 |
}
|
|
| 121 |
KNOWN_LOG_TYPES.find_index { |entry|
|
|
| 122 |
entry[1].all? { |substr| text.include? substr }
|
|
| 123 |
}
|
|
| 124 | 124 |
end |
| 125 | 125 |
|
| 126 | 126 |
new_data.split("\n=").each { |report|
|
| 127 |
next if report.empty? |
|
| 128 |
report =~ /\A(\w+) REPORT==== (.*) ===\n(.*)\z/m |
|
| 129 |
type, time, text = $1, $2, $3 |
|
| 130 |
next unless type and time and text |
|
| 131 |
|
|
| 132 |
log_info[type] = (log_info[type] || 0) + 1 |
|
| 133 |
if sub_type = log_type(text) |
|
| 134 |
log_info[sub_type] = (log_info[sub_type] || 0) + 1 |
|
| 135 |
elsif $debug_mode |
|
| 136 |
warn "Unparsed log entry #{type}: #{text} at #{time}"
|
|
| 137 |
end |
|
| 127 |
next if report.empty? |
|
| 128 |
|
|
| 129 |
report =~ /\A(\w+) REPORT==== (.*) ===\n(.*)\z/m |
|
| 130 |
type, time, text = $1, $2, $3 |
|
| 131 |
next unless type and time and text |
|
| 132 |
|
|
| 133 |
log_info[type] = (log_info[type] || 0) + 1 |
|
| 134 |
if sub_type = log_type(text) |
|
| 135 |
log_info[sub_type] = (log_info[sub_type] || 0) + 1 |
|
| 136 |
elsif $debug_mode |
|
| 137 |
warn "Unparsed log entry #{type}: #{text} at #{time}"
|
|
| 138 |
end |
|
| 138 | 139 |
} |
| 139 | 140 |
|
| 140 | 141 |
log_info[:start] += new_data.size |
| 141 | 142 |
File.open(CACHE_FILE, 'w') { |f| f.write log_info.to_yaml } unless $debug_mode
|
| 142 | 143 |
|
| 143 | 144 |
if ARGV.first == 'config' |
| 144 |
puts <<CONFIG
|
|
| 145 |
graph_title Ejabberd Log |
|
| 146 |
graph_vlabel total |
|
| 147 |
graph_category chat |
|
| 148 |
graph_args -l 0 |
|
| 149 |
CONFIG |
|
| 145 |
puts <<~CONFIG
|
|
| 146 |
graph_title Ejabberd Log
|
|
| 147 |
graph_vlabel total
|
|
| 148 |
graph_category chat
|
|
| 149 |
graph_args -l 0
|
|
| 150 |
CONFIG
|
|
| 150 | 151 |
end |
| 151 | 152 |
|
| 152 | 153 |
(KNOWN_LOG_TYPES + %w(ERROR WARNING INFO DEBUG)).each.with_index { |log_type, index|
|
| 153 |
label, index = if log_type.is_a? Array
|
|
| 154 |
[log_type.first, index]
|
|
| 155 |
else
|
|
| 156 |
[log_type, log_type]
|
|
| 157 |
end
|
|
| 158 |
if ARGV.first == 'config'
|
|
| 159 |
puts "T#{index}.label #{label}"
|
|
| 160 |
puts "T#{index}.draw LINE"
|
|
| 161 |
else
|
|
| 162 |
puts "T#{index}.value #{log_info[index] or 0}"
|
|
| 163 |
end
|
|
| 154 |
label, index = if log_type.is_a? Array
|
|
| 155 |
[log_type.first, index]
|
|
| 156 |
else
|
|
| 157 |
[log_type, log_type]
|
|
| 158 |
end
|
|
| 159 |
if ARGV.first == 'config'
|
|
| 160 |
puts "T#{index}.label #{label}"
|
|
| 161 |
puts "T#{index}.draw LINE"
|
|
| 162 |
else
|
|
| 163 |
puts "T#{index}.value #{log_info[index] or 0}"
|
|
| 164 |
end
|
|
| 164 | 165 |
} |
| plugins/http/mongrel_memory | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# mongrel_memory - A munin plugin for OpenSolaris to monitor memory size of |
|
| 3 |
# each individual mongrel process |
|
| 4 |
# Copyright (C) 2009 Matthias Marschall - mm@agileweboperations.com |
|
| 5 |
# |
|
| 6 |
# Based on: |
|
| 7 |
# mongrel_process_memory - A munin plugin to monitor memory size of |
|
| 8 |
# each individual mongrel process |
|
| 9 |
# Copyright (C) 2007 Ben VandenBos and Avvo, Inc. |
|
| 10 |
# |
|
| 11 |
# This program is free software; you can redistribute it and/or modify |
|
| 12 |
# it under the terms of the GNU General Public License version 2 |
|
| 13 |
# as published by the Free Software Foundation. |
|
| 14 |
# |
|
| 15 |
# This program is distributed in the hope that it will be useful, |
|
| 16 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
# GNU General Public License for more details. |
|
| 19 |
# |
|
| 20 |
# You should have received a copy of the GNU General Public License along |
|
| 21 |
# with this program; if not, write to the Free Software Foundation, Inc., |
|
| 22 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 23 |
# |
|
| 24 |
# Author: Ben VandenBos |
|
| 25 |
# Contributors: Adam Jacob (<adam@hjksolutions.com>) |
|
| 26 |
# Ryan Woodrum |
|
| 27 |
# Matthias Marschall (mm@agileweboperations.com) |
|
| 28 |
# |
|
| 2 |
|
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
mongrel_memory - A munin plugin for OpenSolaris to monitor memory size of |
|
| 6 |
each individual mongrel process |
|
| 7 |
Copyright (C) 2009 Matthias Marschall - mm@agileweboperations.com |
|
| 8 |
|
|
| 9 |
Based on: |
|
| 10 |
mongrel_process_memory - A munin plugin to monitor memory size of |
|
| 11 |
each individual mongrel process |
|
| 12 |
Copyright (C) 2007 Ben VandenBos and Avvo, Inc. |
|
| 13 |
|
|
| 14 |
This program is free software; you can redistribute it and/or modify |
|
| 15 |
it under the terms of the GNU General Public License version 2 |
|
| 16 |
as published by the Free Software Foundation. |
|
| 17 |
|
|
| 18 |
This program is distributed in the hope that it will be useful, |
|
| 19 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 20 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 21 |
GNU General Public License for more details. |
|
| 22 |
|
|
| 23 |
You should have received a copy of the GNU General Public License along |
|
| 24 |
with this program; if not, write to the Free Software Foundation, Inc., |
|
| 25 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 26 |
|
|
| 27 |
Author: Ben VandenBos |
|
| 28 |
Contributors: Adam Jacob (<adam@hjksolutions.com>) |
|
| 29 |
Ryan Woodrum |
|
| 30 |
Matthias Marschall (mm@agileweboperations.com) |
|
| 31 |
|
|
| 29 | 32 |
#%# family=auto |
| 30 | 33 |
#%# capabilities=autoconf |
| 31 | 34 |
|
| 35 |
=end |
|
| 36 |
|
|
| 37 |
|
|
| 32 | 38 |
module Munin |
| 33 | 39 |
class MongrelProcessMemory |
| 34 |
|
|
| 35 | 40 |
def run |
| 36 | 41 |
pid_port_map = get_pids() |
| 37 | 42 |
port_list = Hash.new |
| ... | ... | |
| 48 | 53 |
pids += `pgrep ruby`.split("\n")
|
| 49 | 54 |
pids.each { |pid|
|
| 50 | 55 |
l = `pargs -l #{pid}`
|
| 51 |
l =~ /-p (\d+)/
|
|
| 52 |
h[pid] = $1 if $1
|
|
| 56 |
l =~ /-p (\d+)/
|
|
| 57 |
h[pid] = $1 if $1
|
|
| 53 | 58 |
} |
| 54 | 59 |
h |
| 55 | 60 |
end |
| ... | ... | |
| 57 | 62 |
def autoconf |
| 58 | 63 |
get_pids().length > 0 |
| 59 | 64 |
end |
| 60 |
|
|
| 61 | 65 |
end |
| 62 | 66 |
end |
| 63 | 67 |
|
| plugins/http/mongrel_process_memory | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# |
|
| 3 |
# mongrel_process_memory - A munin plugin to monitor memory size of |
|
| 4 |
# each individual mongrel process |
|
| 5 |
# Copyright (C) 2007 Ben VandenBos and Avvo, Inc. |
|
| 6 |
# |
|
| 7 |
# This program is free software; you can redistribute it and/or modify |
|
| 8 |
# it under the terms of the GNU General Public License version 2 |
|
| 9 |
# as published by the Free Software Foundation. |
|
| 10 |
# |
|
| 11 |
# This program is distributed in the hope that it will be useful, |
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 |
# GNU General Public License for more details. |
|
| 15 |
# |
|
| 16 |
# You should have received a copy of the GNU General Public License along |
|
| 17 |
# with this program; if not, write to the Free Software Foundation, Inc., |
|
| 18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 19 |
# |
|
| 20 |
# Author: Ben VandenBos |
|
| 21 |
# Contributors: Adam Jacob (<adam@hjksolutions.com>) |
|
| 22 |
# Ryan Woodrum |
|
| 23 |
# |
|
| 2 |
|
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
mongrel_process_memory - A munin plugin to monitor memory size of |
|
| 6 |
each individual mongrel process |
|
| 7 |
Copyright (C) 2007 Ben VandenBos and Avvo, Inc. |
|
| 8 |
|
|
| 9 |
This program is free software; you can redistribute it and/or modify |
|
| 10 |
it under the terms of the GNU General Public License version 2 |
|
| 11 |
as published by the Free Software Foundation. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License along |
|
| 19 |
with this program; if not, write to the Free Software Foundation, Inc., |
|
| 20 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 21 |
|
|
| 22 |
Author: Ben VandenBos |
|
| 23 |
Contributors: Adam Jacob (<adam@hjksolutions.com>) |
|
| 24 |
Ryan Woodrum |
|
| 25 |
|
|
| 24 | 26 |
#%# family=auto |
| 25 | 27 |
#%# capabilities=autoconf |
| 26 | 28 |
|
| 29 |
=end |
|
| 30 |
|
|
| 31 |
|
|
| 27 | 32 |
module Munin |
| 28 | 33 |
class MongrelProcessMemory |
| 29 |
|
|
| 30 | 34 |
def run |
| 31 | 35 |
h = get_pids() |
| 32 | 36 |
ps_output = "" |
| 33 |
#I have no doubt that this is a terrible way of doing this. |
|
| 37 |
# I have no doubt that this is a terrible way of doing this.
|
|
| 34 | 38 |
h.each do |k, v| |
| 35 | 39 |
ps_output = ps_output + `ps --no-heading l #{k}`
|
| 36 | 40 |
end |
| ... | ... | |
| 59 | 63 |
pids = `pgrep mongrel_rails` |
| 60 | 64 |
pids.each { |p|
|
| 61 | 65 |
l = `ps #{p}`
|
| 62 |
l =~ /-p (\d+)/
|
|
| 63 |
h[p] = $1
|
|
| 66 |
l =~ /-p (\d+)/
|
|
| 67 |
h[p] = $1
|
|
| 64 | 68 |
} |
| 65 | 69 |
h |
| 66 | 70 |
end |
| ... | ... | |
| 68 | 72 |
def autoconf |
| 69 | 73 |
pids.length > 0 |
| 70 | 74 |
end |
| 71 |
|
|
| 72 | 75 |
end |
| 73 | 76 |
end |
| 74 | 77 |
|
| plugins/icecast/icecast2_simple | ||
|---|---|---|
| 18 | 18 |
|
| 19 | 19 |
def get_conf |
| 20 | 20 |
# Default values |
| 21 |
conf = {:host => '127.0.0.1', :port => 8000,
|
|
| 22 |
:username => 'admin', :password => 'hackme' } |
|
| 21 |
conf = { :host => '127.0.0.1', :port => 8000,
|
|
| 22 |
:username => 'admin', :password => 'hackme' }
|
|
| 23 | 23 |
conf.keys.each do |key| |
| 24 | 24 |
env_key = sprintf('icecast_%s', key)
|
| 25 | 25 |
conf[key] = ENV[env_key] if ENV.has_key?(env_key) |
| ... | ... | |
| 31 | 31 |
begin |
| 32 | 32 |
data = Hpricot(open(sprintf('http://%s:%s/admin/stats',
|
| 33 | 33 |
conf[:host], conf[:port]), |
| 34 |
:http_basic_authentication=>[conf[:username],
|
|
| 35 |
conf[:password]])) |
|
| 34 |
:http_basic_authentication => [conf[:username],
|
|
| 35 |
conf[:password]]))
|
|
| 36 | 36 |
rescue OpenURI::HTTPError |
| 37 | 37 |
puts "Cannot connect: HTTP connection error" |
| 38 | 38 |
exit 1 |
| ... | ... | |
| 43 | 43 |
def get_values(data) |
| 44 | 44 |
vals = {}
|
| 45 | 45 |
[:sources, :clients].each do |key| |
| 46 |
elem = data/key
|
|
| 46 |
elem = data / key
|
|
| 47 | 47 |
if elem.nil? |
| 48 | 48 |
vals[key] = 0 |
| 49 | 49 |
else |
| plugins/minecraft/minecraft-users | ||
|---|---|---|
| 8 | 8 |
require 'socket' |
| 9 | 9 |
|
| 10 | 10 |
if ARGV[0] == 'config' |
| 11 |
puts "graph_title Connected players"
|
|
| 12 |
puts "graph_vlabel players"
|
|
| 13 |
puts "players.label players"
|
|
| 14 |
puts "graph_info Number of players connected to Minecraft"
|
|
| 15 |
puts "graph_category games"
|
|
| 16 |
exit
|
|
| 11 |
puts "graph_title Connected players" |
|
| 12 |
puts "graph_vlabel players" |
|
| 13 |
puts "players.label players" |
|
| 14 |
puts "graph_info Number of players connected to Minecraft" |
|
| 15 |
puts "graph_category games" |
|
| 16 |
exit |
|
| 17 | 17 |
end |
| 18 | 18 |
|
| 19 | 19 |
host = ENV['host'] |
| plugins/moblock/moblock_connections | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# |
|
| 3 |
# Plugin to monitor the number of connections blocked by moblock. |
|
| 4 |
# |
|
| 5 |
# Requirements: |
|
| 6 |
# |
|
| 7 |
# Moblock up and running with generated log files going to /var/log/moblock |
|
| 8 |
# |
|
| 9 |
# Parameters supported: |
|
| 10 |
# |
|
| 11 |
# config |
|
| 12 |
# autoconf |
|
| 13 |
# |
|
| 14 |
# Configurable variables |
|
| 15 |
# |
|
| 16 |
# logfile - Override default moblock logfile |
|
| 17 |
# |
|
| 18 |
# Magic markers |
|
| 19 |
# |
|
| 2 |
|
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
Plugin to monitor the number of connections blocked by moblock. |
|
| 6 |
|
|
| 7 |
Requirements: |
|
| 8 |
|
|
| 9 |
Moblock up and running with generated log files going to /var/log/moblock |
|
| 10 |
|
|
| 11 |
Parameters supported: |
|
| 12 |
|
|
| 13 |
config |
|
| 14 |
autoconf |
|
| 15 |
|
|
| 16 |
Configurable variables |
|
| 17 |
|
|
| 18 |
logfile - Override default moblock logfile |
|
| 19 |
|
|
| 20 |
Magic markers |
|
| 21 |
|
|
| 20 | 22 |
#%# family=auto |
| 21 | 23 |
#%# capabilities=autoconf |
| 22 | 24 |
|
| 25 |
=end |
|
| 26 |
|
|
| 27 |
|
|
| 23 | 28 |
# |
| 24 | 29 |
# Initialize vars |
| 25 | 30 |
# |
| ... | ... | |
| 54 | 59 |
# |
| 55 | 60 |
# Grep moblock logs for stats |
| 56 | 61 |
# |
| 57 |
def fetch(debug=false)
|
|
| 62 |
def fetch(debug = false)
|
|
| 58 | 63 |
num_in = %x{cat #{$logfile} | grep --extended-regexp 'IN: ' | wc -l}
|
| 59 | 64 |
num_out = %x{cat #{$logfile} | grep --extended-regexp 'OUT: ' | wc -l}
|
| 60 | 65 |
num_total = num_in.to_i + num_out.to_i |
| ... | ... | |
| 80 | 85 |
# Handle command line args |
| 81 | 86 |
# |
| 82 | 87 |
case ARGV.first |
| 83 |
when 'config'
|
|
| 84 |
config
|
|
| 85 |
when 'debug'
|
|
| 86 |
fetch true
|
|
| 87 |
when 'autoconf'
|
|
| 88 |
autoconf
|
|
| 89 |
else
|
|
| 90 |
fetch
|
|
| 88 |
when 'config' |
|
| 89 |
config |
|
| 90 |
when 'debug' |
|
| 91 |
fetch true |
|
| 92 |
when 'autoconf' |
|
| 93 |
autoconf |
|
| 94 |
else |
|
| 95 |
fetch |
|
| 91 | 96 |
end |
| plugins/mssql/microsoft-sql | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# |
|
| 3 |
# Munin Plugin for MSSQL - transaction monitoring |
|
| 4 |
# |
|
| 5 |
# Author: Wilfred Chau <openapp.developer@gmail.com> |
|
| 6 |
# Date: 2011-05-18 |
|
| 7 |
# Version: 1.0 |
|
| 8 |
# |
|
| 9 |
# This program is free software; you can redistribute it and/or modify |
|
| 10 |
# it under the terms of the GNU General Public License version 2 |
|
| 11 |
# as published by the Free Software Foundation. |
|
| 12 |
# |
|
| 13 |
# This program is distributed in the hope that it will be useful, |
|
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
# GNU General Public License for more details. |
|
| 17 |
# |
|
| 18 |
# You should have received a copy of the GNU General Public License along |
|
| 19 |
# with this program; if not, write to the Free Software Foundation, Inc., |
|
| 20 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 21 |
# |
|
| 22 |
# |
|
| 23 |
# Prerequistes: |
|
| 24 |
# 1) /etc/odbc.ini and /etc/freetds.conf |
|
| 25 |
# 2) rubygems |
|
| 26 |
# 3) ruby-dbi |
|
| 27 |
# |
|
| 28 |
# Usage: |
|
| 29 |
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins) |
|
| 30 |
# 2) chmod to allow executable to others |
|
| 31 |
# 3) create symbolic link in /etc/munin/plugins |
|
| 32 |
# ln -s /usr/share/munin/plugins/mssql_transaction.rb /etc/munin/plugins/mssql_transaction.rb |
|
| 33 |
# |
|
| 34 |
# Parameters: |
|
| 35 |
# autoconf |
|
| 36 |
# config (required) |
|
| 37 |
# |
|
| 38 |
# Config variables: |
|
| 39 |
# sqluser : mssql user who has view server state privilege |
|
| 40 |
# sqlpass : password for the mssql user |
|
| 41 |
# dsn : datasource name as defined in /etc/odbc.ini |
|
| 42 |
# instance: instance to monitor |
|
| 43 |
# |
|
| 2 |
|
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
Munin Plugin for MSSQL - transaction monitoring |
|
| 6 |
|
|
| 7 |
Author: Wilfred Chau <openapp.developer@gmail.com> |
|
| 8 |
Date: 2011-05-18 |
|
| 9 |
Version: 1.0 |
|
| 10 |
|
|
| 11 |
This program is free software; you can redistribute it and/or modify |
|
| 12 |
it under the terms of the GNU General Public License version 2 |
|
| 13 |
as published by the Free Software Foundation. |
|
| 14 |
|
|
| 15 |
This program is distributed in the hope that it will be useful, |
|
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
GNU General Public License for more details. |
|
| 19 |
|
|
| 20 |
You should have received a copy of the GNU General Public License along |
|
| 21 |
with this program; if not, write to the Free Software Foundation, Inc., |
|
| 22 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 23 |
|
|
| 24 |
|
|
| 25 |
Prerequistes: |
|
| 26 |
1) /etc/odbc.ini and /etc/freetds.conf |
|
| 27 |
2) rubygems |
|
| 28 |
3) ruby-dbi |
|
| 29 |
|
|
| 30 |
Usage: |
|
| 31 |
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins) |
|
| 32 |
2) chmod to allow executable to others |
|
| 33 |
3) create symbolic link in /etc/munin/plugins |
|
| 34 |
ln -s /usr/share/munin/plugins/mssql_transaction.rb /etc/munin/plugins/mssql_transaction.rb |
|
| 35 |
|
|
| 36 |
Parameters: |
|
| 37 |
autoconf |
|
| 38 |
config (required) |
|
| 39 |
|
|
| 40 |
Config variables: |
|
| 41 |
sqluser : mssql user who has view server state privilege |
|
| 42 |
sqlpass : password for the mssql user |
|
| 43 |
dsn : datasource name as defined in /etc/odbc.ini |
|
| 44 |
instance: instance to monitor |
|
| 45 |
|
|
| 44 | 46 |
#%# family=auto |
| 45 | 47 |
#%# capabilities=autoconf |
| 46 | 48 |
|
| 49 |
=end |
|
| 50 |
|
|
| 51 |
|
|
| 47 | 52 |
require 'rubygems' |
| 48 | 53 |
require 'dbi' |
| 49 | 54 |
|
| ... | ... | |
| 56 | 61 |
# Queries |
| 57 | 62 |
# |
| 58 | 63 |
# |
| 59 |
dbh = DBI.connect("DBI:ODBC:#{dsn}",sqluser,sqlpass)
|
|
| 64 |
dbh = DBI.connect("DBI:ODBC:#{dsn}", sqluser, sqlpass)
|
|
| 60 | 65 |
|
| 61 | 66 |
instance_name_query = "SELECT distinct instance_name |
| 62 | 67 |
FROM sys.dm_os_performance_counters |
| ... | ... | |
| 69 | 74 |
and object_name = 'SQLServer:Databases' |
| 70 | 75 |
and instance_name = ?" |
| 71 | 76 |
|
| 72 |
all_instance_names = Array.new
|
|
| 77 |
all_instance_names = Array.new |
|
| 73 | 78 |
sth = dbh.execute(instance_name_query) |
| 74 | 79 |
sth.fetch do |row| |
| 75 |
all_instance_names.push(row[0].strip)
|
|
| 80 |
all_instance_names.push(row[0].strip)
|
|
| 76 | 81 |
end |
| 77 | 82 |
sth.finish |
| 78 | 83 |
|
| ... | ... | |
| 80 | 85 |
# autoconf |
| 81 | 86 |
# |
| 82 | 87 |
if ARGV[0] == "autoconf" |
| 83 |
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
|
| 84 |
puts "yes"
|
|
| 85 |
else
|
|
| 86 |
puts "no"
|
|
| 87 |
puts "Usage: #{__FILE__} autoconf|conf"
|
|
| 88 |
end
|
|
| 89 |
exit 0
|
|
| 88 |
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
|
| 89 |
puts "yes"
|
|
| 90 |
else
|
|
| 91 |
puts "no"
|
|
| 92 |
puts "Usage: #{__FILE__} autoconf|conf"
|
|
| 93 |
end
|
|
| 94 |
exit 0
|
|
| 90 | 95 |
# |
| 91 | 96 |
# config definition |
| 92 | 97 |
# |
| 93 | 98 |
elsif ARGV[0] == "config" |
| 94 |
puts "graph_args --base 1000 -r --lower-limit 0"
|
|
| 95 |
puts "graph_title MSSQL Transactions/s"
|
|
| 96 |
puts "graph_category db"
|
|
| 97 |
puts "graph_info This graph shows transactions/s"
|
|
| 98 |
puts "graph_vlabel transactions/s"
|
|
| 99 |
puts "graph_scale no"
|
|
| 100 |
puts "graph_period second"
|
|
| 101 |
|
|
| 102 |
all_instance_names.sort.each do |s|
|
|
| 103 |
puts "#{s}.label #{s}"
|
|
| 104 |
puts "#{s}.info INSTANCE: #{s}"
|
|
| 105 |
puts "#{s}.type DERIVE"
|
|
| 106 |
puts "#{s}.draw LINE1"
|
|
| 107 |
end
|
|
| 108 |
|
|
| 109 |
exit 0
|
|
| 99 |
puts "graph_args --base 1000 -r --lower-limit 0"
|
|
| 100 |
puts "graph_title MSSQL Transactions/s"
|
|
| 101 |
puts "graph_category db"
|
|
| 102 |
puts "graph_info This graph shows transactions/s"
|
|
| 103 |
puts "graph_vlabel transactions/s"
|
|
| 104 |
puts "graph_scale no"
|
|
| 105 |
puts "graph_period second"
|
|
| 106 |
|
|
| 107 |
all_instance_names.sort.each do |s|
|
|
| 108 |
puts "#{s}.label #{s}"
|
|
| 109 |
puts "#{s}.info INSTANCE: #{s}"
|
|
| 110 |
puts "#{s}.type DERIVE"
|
|
| 111 |
puts "#{s}.draw LINE1"
|
|
| 112 |
end
|
|
| 113 |
|
|
| 114 |
exit 0
|
|
| 110 | 115 |
end |
| 111 | 116 |
|
| 112 | 117 |
# |
| ... | ... | |
| 114 | 119 |
# |
| 115 | 120 |
sth = dbh.prepare(transaction_query) |
| 116 | 121 |
all_instance_names.sort.each do |k| |
| 117 |
sth.execute(k)
|
|
| 118 |
sth.fetch do |row|
|
|
| 119 |
# since type is DERIVE, need to convert value to integer then to string
|
|
| 120 |
puts "#{k.to_s}.value #{row[0].to_i.to_s}"
|
|
| 121 |
end
|
|
| 122 |
sth.execute(k)
|
|
| 123 |
sth.fetch do |row|
|
|
| 124 |
# since type is DERIVE, need to convert value to integer then to string
|
|
| 125 |
puts "#{k.to_s}.value #{row[0].to_i.to_s}"
|
|
| 126 |
end
|
|
| 122 | 127 |
end |
| 123 | 128 |
sth.finish |
| 124 | 129 |
dbh.disconnect |
| plugins/mssql/microsoft-sql-buffer-cache-hit-ratio | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# |
|
| 3 |
# Munin Plugin for MSSQL - Buffer cache hit ratio monitoring |
|
| 4 |
# |
|
| 5 |
# Author: Wilfred Chau <openapp.developer@gmail.com> |
|
| 6 |
# Date: 2011-05-19 |
|
| 7 |
# Version: 1.0 |
|
| 8 |
# |
|
| 9 |
# This program is free software; you can redistribute it and/or modify |
|
| 10 |
# it under the terms of the GNU General Public License version 2 |
|
| 11 |
# as published by the Free Software Foundation. |
|
| 12 |
# |
|
| 13 |
# This program is distributed in the hope that it will be useful, |
|
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
# GNU General Public License for more details. |
|
| 17 |
# |
|
| 18 |
# You should have received a copy of the GNU General Public License along |
|
| 19 |
# with this program; if not, write to the Free Software Foundation, Inc., |
|
| 20 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 21 |
# |
|
| 22 |
# |
|
| 23 |
# Prerequistes: |
|
| 24 |
# 1) /etc/odbc.ini and /etc/freetds.conf |
|
| 25 |
# 2) rubygems |
|
| 26 |
# 3) ruby-dbi |
|
| 27 |
# |
|
| 28 |
# Usage: |
|
| 29 |
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins) |
|
| 30 |
# 2) chmod to allow executable to others |
|
| 31 |
# 3) create symbolic link in /etc/munin/plugins |
|
| 32 |
# ln -s /usr/share/munin/plugins/mssql_buffercachehitratio.rb /etc/munin/plugins/mssql_buffercachehitratio.rb |
|
| 33 |
# |
|
| 34 |
# Parameters: |
|
| 35 |
# autoconf |
|
| 36 |
# config (required) |
|
| 37 |
# |
|
| 38 |
# Config variables: |
|
| 39 |
# sqluser : mssql user who has view server state privilege |
|
| 40 |
# sqlpass : password for the mssql user |
|
| 41 |
# dsn : datasource name as defined in /etc/odbc.ini |
|
| 42 |
# |
|
| 2 |
|
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
Munin Plugin for MSSQL - Buffer cache hit ratio monitoring |
|
| 6 |
|
|
| 7 |
Author: Wilfred Chau <openapp.developer@gmail.com> |
|
| 8 |
Date: 2011-05-19 |
|
| 9 |
Version: 1.0 |
|
| 10 |
|
|
| 11 |
This program is free software; you can redistribute it and/or modify |
|
| 12 |
it under the terms of the GNU General Public License version 2 |
|
| 13 |
as published by the Free Software Foundation. |
|
| 14 |
|
|
| 15 |
This program is distributed in the hope that it will be useful, |
|
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
GNU General Public License for more details. |
|
| 19 |
|
|
| 20 |
You should have received a copy of the GNU General Public License along |
|
| 21 |
with this program; if not, write to the Free Software Foundation, Inc., |
|
| 22 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 23 |
|
|
| 24 |
|
|
| 25 |
Prerequistes: |
|
| 26 |
1) /etc/odbc.ini and /etc/freetds.conf |
|
| 27 |
2) rubygems |
|
| 28 |
3) ruby-dbi |
|
| 29 |
|
|
| 30 |
Usage: |
|
| 31 |
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins) |
|
| 32 |
2) chmod to allow executable to others |
|
| 33 |
3) create symbolic link in /etc/munin/plugins |
|
| 34 |
ln -s /usr/share/munin/plugins/mssql_buffercachehitratio.rb /etc/munin/plugins/mssql_buffercachehitratio.rb |
|
| 35 |
|
|
| 36 |
Parameters: |
|
| 37 |
autoconf |
|
| 38 |
config (required) |
|
| 39 |
|
|
| 40 |
Config variables: |
|
| 41 |
sqluser : mssql user who has view server state privilege |
|
| 42 |
sqlpass : password for the mssql user |
|
| 43 |
dsn : datasource name as defined in /etc/odbc.ini |
|
| 44 |
|
|
| 43 | 45 |
#%# family=auto |
| 44 | 46 |
#%# capabilities=autoconf |
| 45 | 47 |
|
| 48 |
=end |
|
| 49 |
|
|
| 50 |
|
|
| 46 | 51 |
require 'rubygems' |
| 47 | 52 |
require 'dbi' |
| 48 | 53 |
|
| ... | ... | |
| 54 | 59 |
# Queries |
| 55 | 60 |
# |
| 56 | 61 |
# |
| 57 |
dbh = DBI.connect("DBI:ODBC:#{dsn}",sqluser,sqlpass)
|
|
| 62 |
dbh = DBI.connect("DBI:ODBC:#{dsn}", sqluser, sqlpass)
|
|
| 58 | 63 |
|
| 59 | 64 |
buffercachehitratio_query = "select (a.cntr_value * 1.0 / b.cntr_value) * 100.0 |
| 60 | 65 |
from sys.dm_os_performance_counters a |
| ... | ... | |
| 70 | 75 |
# autoconf |
| 71 | 76 |
# |
| 72 | 77 |
if ARGV[0] == "autoconf" |
| 73 |
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
|
| 74 |
puts "yes"
|
|
| 75 |
else
|
|
| 76 |
puts "no"
|
|
| 77 |
puts "Usage: #{__FILE__} autoconf|conf"
|
|
| 78 |
end
|
|
| 79 |
exit 0
|
|
| 78 |
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
|
| 79 |
puts "yes"
|
|
| 80 |
else
|
|
| 81 |
puts "no"
|
|
| 82 |
puts "Usage: #{__FILE__} autoconf|conf"
|
|
| 83 |
end
|
|
| 84 |
exit 0
|
|
| 80 | 85 |
# |
| 81 | 86 |
# config definition |
| 82 | 87 |
# |
| 83 | 88 |
elsif ARGV[0] == "config" |
| 84 |
puts "graph_args --base 1000 -r --lower-limit 0"
|
|
| 85 |
puts "graph_title MSSQL Buffer Cache Hit Ratio "
|
|
| 86 |
puts "graph_category db"
|
|
| 87 |
puts "graph_info This graph shows Buffer Cache Hit Ratio"
|
|
| 88 |
puts "graph_vlabel %"
|
|
| 89 |
puts "graph_scale no"
|
|
| 90 |
puts "graph_period second"
|
|
| 91 |
|
|
| 92 |
puts "bc_hitratio.label BufferCacheHitRatio"
|
|
| 93 |
puts "bc_hitratio.info BufferCacheHitRatio"
|
|
| 94 |
puts "bc_hitratio.type GAUGE"
|
|
| 95 |
puts "bc_hitratio.draw LINE1"
|
|
| 96 |
|
|
| 97 |
exit 0
|
|
| 89 |
puts "graph_args --base 1000 -r --lower-limit 0"
|
|
| 90 |
puts "graph_title MSSQL Buffer Cache Hit Ratio "
|
|
| 91 |
puts "graph_category db"
|
|
| 92 |
puts "graph_info This graph shows Buffer Cache Hit Ratio"
|
|
| 93 |
puts "graph_vlabel %"
|
|
| 94 |
puts "graph_scale no"
|
|
| 95 |
puts "graph_period second"
|
|
| 96 |
|
|
| 97 |
puts "bc_hitratio.label BufferCacheHitRatio"
|
|
| 98 |
puts "bc_hitratio.info BufferCacheHitRatio"
|
|
| 99 |
puts "bc_hitratio.type GAUGE"
|
|
| 100 |
puts "bc_hitratio.draw LINE1"
|
|
| 101 |
|
|
| 102 |
exit 0
|
|
| 98 | 103 |
end |
| 99 | 104 |
|
| 100 | 105 |
sth = dbh.execute(buffercachehitratio_query) |
| 101 | 106 |
sth.fetch do |row| |
| 102 |
puts "bc_hitratio.value #{row[0].strip.to_s}"
|
|
| 107 |
puts "bc_hitratio.value #{row[0].strip.to_s}"
|
|
| 103 | 108 |
end |
| 104 | 109 |
sth.finish |
| 105 | 110 |
dbh.disconnect |
| plugins/mssql/microsoft-sql-data-file-sizes | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# |
|
| 3 |
# Munin Plugin for MSSQL - Data file size monitoring |
|
| 4 |
# |
|
| 5 |
# Author: Wilfred Chau <openapp.developer@gmail.com> |
|
| 6 |
# Date: 2011-05-19 |
|
| 7 |
# Version: 1.0 |
|
| 8 |
# |
|
| 9 |
# This program is free software; you can redistribute it and/or modify |
|
| 10 |
# it under the terms of the GNU General Public License version 2 |
|
| 11 |
# as published by the Free Software Foundation. |
|
| 12 |
# |
|
| 13 |
# This program is distributed in the hope that it will be useful, |
|
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
# GNU General Public License for more details. |
|
| 17 |
# |
|
| 18 |
# You should have received a copy of the GNU General Public License along |
|
| 19 |
# with this program; if not, write to the Free Software Foundation, Inc., |
|
| 20 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 21 |
# |
|
| 22 |
# |
|
| 23 |
# Prerequistes: |
|
| 24 |
# 1) /etc/odbc.ini and /etc/freetds.conf |
|
| 25 |
# 2) rubygems |
|
| 26 |
# 3) ruby-dbi |
|
| 27 |
# |
|
| 28 |
# Usage: |
|
| 29 |
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins) |
|
| 30 |
# 2) chmod to allow executable to others |
|
| 31 |
# 3) create symbolic link in /etc/munin/plugins |
|
| 32 |
# ln -s /usr/share/munin/plugins/mssql_datafilesizes.rb /etc/munin/plugins/mssql_datafilesizes.rb |
|
| 33 |
# |
|
| 34 |
# Parameters: |
|
| 35 |
# autoconf |
|
| 36 |
# config (required) |
|
| 37 |
# |
|
| 38 |
# Config variables: |
|
| 39 |
# sqluser : mssql user who has view server state privilege |
|
| 40 |
# sqlpass : password for the mssql user |
|
| 41 |
# dsn : datasource name as defined in /etc/odbc.ini |
|
| 42 |
# instance: instance to monitor |
|
| 43 |
# |
|
| 2 |
|
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
Munin Plugin for MSSQL - Data file size monitoring |
|
| 6 |
|
|
| 7 |
Author: Wilfred Chau <openapp.developer@gmail.com> |
|
| 8 |
Date: 2011-05-19 |
|
| 9 |
Version: 1.0 |
|
| 10 |
|
|
| 11 |
This program is free software; you can redistribute it and/or modify |
|
| 12 |
it under the terms of the GNU General Public License version 2 |
|
| 13 |
as published by the Free Software Foundation. |
|
| 14 |
|
|
| 15 |
This program is distributed in the hope that it will be useful, |
|
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
GNU General Public License for more details. |
|
| 19 |
|
|
| 20 |
You should have received a copy of the GNU General Public License along |
|
| 21 |
with this program; if not, write to the Free Software Foundation, Inc., |
|
| 22 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 23 |
|
|
| 24 |
|
|
| 25 |
Prerequistes: |
|
| 26 |
1) /etc/odbc.ini and /etc/freetds.conf |
|
| 27 |
2) rubygems |
|
| 28 |
3) ruby-dbi |
|
| 29 |
|
|
| 30 |
Usage: |
|
| 31 |
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins) |
|
| 32 |
2) chmod to allow executable to others |
|
| 33 |
3) create symbolic link in /etc/munin/plugins |
|
| 34 |
ln -s /usr/share/munin/plugins/mssql_datafilesizes.rb /etc/munin/plugins/mssql_datafilesizes.rb |
|
| 35 |
|
|
| 36 |
Parameters: |
|
| 37 |
autoconf |
|
| 38 |
config (required) |
|
| 39 |
|
|
| 40 |
Config variables: |
|
| 41 |
sqluser : mssql user who has view server state privilege |
|
| 42 |
sqlpass : password for the mssql user |
|
| 43 |
dsn : datasource name as defined in /etc/odbc.ini |
|
| 44 |
instance: instance to monitor |
|
| 45 |
|
|
| 44 | 46 |
#%# family=auto |
| 45 | 47 |
#%# capabilities=autoconf |
| 46 | 48 |
|
| 49 |
=end |
|
| 50 |
|
|
| 51 |
|
|
| 47 | 52 |
require 'rubygems' |
| 48 | 53 |
require 'dbi' |
| 49 | 54 |
|
| ... | ... | |
| 56 | 61 |
# Queries |
| 57 | 62 |
# |
| 58 | 63 |
# |
| 59 |
dbh = DBI.connect("DBI:ODBC:#{dsn}",sqluser,sqlpass)
|
|
| 64 |
dbh = DBI.connect("DBI:ODBC:#{dsn}", sqluser, sqlpass)
|
|
| 60 | 65 |
|
| 61 | 66 |
instance_name_query = "SELECT distinct instance_name |
| 62 | 67 |
FROM sys.dm_os_performance_counters |
| ... | ... | |
| 67 | 72 |
and object_name = 'SQLServer:Databases' |
| 68 | 73 |
and instance_name = ?" |
| 69 | 74 |
|
| 70 |
all_instance_names = Array.new
|
|
| 75 |
all_instance_names = Array.new |
|
| 71 | 76 |
sth = dbh.execute(instance_name_query) |
| 72 | 77 |
sth.fetch do |row| |
| 73 |
all_instance_names.push(row[0].strip)
|
|
| 78 |
all_instance_names.push(row[0].strip)
|
|
| 74 | 79 |
end |
| 75 | 80 |
sth.finish |
| 76 | 81 |
|
| ... | ... | |
| 78 | 83 |
# autoconf |
| 79 | 84 |
# |
| 80 | 85 |
if ARGV[0] == "autoconf" |
| 81 |
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
|
| 82 |
puts "yes"
|
|
| 83 |
else
|
|
| 84 |
puts "no"
|
|
| 85 |
puts "Usage: #{__FILE__} autoconf|conf"
|
|
| 86 |
end
|
|
| 87 |
exit 0
|
|
| 86 |
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
|
| 87 |
puts "yes"
|
|
| 88 |
else
|
|
| 89 |
puts "no"
|
|
| 90 |
puts "Usage: #{__FILE__} autoconf|conf"
|
|
| 91 |
end
|
|
| 92 |
exit 0
|
|
| 88 | 93 |
# |
| 89 | 94 |
# config definition |
| 90 | 95 |
# |
| 91 | 96 |
elsif ARGV[0] == "config" |
| 92 |
puts "graph_args --base 1024k -r --lower-limit 0"
|
|
| 93 |
puts "graph_title MSSQL DB File Sizes"
|
|
| 94 |
puts "graph_category db"
|
|
| 95 |
puts "graph_info This graph shows DB File Sizes (MB)"
|
|
| 96 |
puts "graph_vlabel MB"
|
|
| 97 |
puts "graph_scale no"
|
|
| 98 |
puts "graph_period second"
|
|
| 99 |
|
|
| 100 |
all_instance_names.sort.each do |s|
|
|
| 101 |
puts "#{s}.label #{s}"
|
|
| 102 |
puts "#{s}.info INSTANCE: #{s}"
|
|
| 103 |
puts "#{s}.type GAUGE"
|
|
| 104 |
puts "#{s}.draw LINE1"
|
|
| 105 |
end
|
|
| 106 |
|
|
| 107 |
exit 0
|
|
| 97 |
puts "graph_args --base 1024k -r --lower-limit 0"
|
|
| 98 |
puts "graph_title MSSQL DB File Sizes"
|
|
| 99 |
puts "graph_category db"
|
|
| 100 |
puts "graph_info This graph shows DB File Sizes (MB)"
|
|
| 101 |
puts "graph_vlabel MB"
|
|
| 102 |
puts "graph_scale no"
|
|
| 103 |
puts "graph_period second"
|
|
| 104 |
|
|
| 105 |
all_instance_names.sort.each do |s|
|
|
| 106 |
puts "#{s}.label #{s}"
|
|
| 107 |
puts "#{s}.info INSTANCE: #{s}"
|
|
| 108 |
puts "#{s}.type GAUGE"
|
|
| 109 |
puts "#{s}.draw LINE1"
|
|
| 110 |
end
|
|
| 111 |
|
|
| 112 |
exit 0
|
|
| 108 | 113 |
end |
| 109 | 114 |
|
| 110 | 115 |
# |
| ... | ... | |
| 112 | 117 |
# |
| 113 | 118 |
sth = dbh.prepare(transaction_query) |
| 114 | 119 |
all_instance_names.sort.each do |k| |
| 115 |
sth.execute(k)
|
|
| 116 |
sth.fetch do |row|
|
|
| 117 |
puts "#{k.to_s}.value #{row[0].to_s}"
|
|
| 118 |
end
|
|
| 120 |
sth.execute(k)
|
|
| 121 |
sth.fetch do |row|
|
|
| 122 |
puts "#{k.to_s}.value #{row[0].to_s}"
|
|
| 123 |
end
|
|
| 119 | 124 |
end |
| 120 | 125 |
sth.finish |
| 121 | 126 |
dbh.disconnect |
| plugins/mssql/microsoft-sql-log-file-size | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# |
|
| 3 |
# Munin Plugin for MSSQL - log files monitoring |
|
| 4 |
# |
|
| 5 |
# Author: Wilfred Chau <openapp.developer@gmail.com> |
|
| 6 |
# Date: 2011-05-19 |
|
| 7 |
# Version: 1.0 |
|
| 8 |
# |
|
| 9 |
# This program is free software; you can redistribute it and/or modify |
|
| 10 |
# it under the terms of the GNU General Public License version 2 |
|
| 11 |
# as published by the Free Software Foundation. |
|
| 12 |
# |
|
| 13 |
# This program is distributed in the hope that it will be useful, |
|
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
# GNU General Public License for more details. |
|
| 17 |
# |
|
| 18 |
# You should have received a copy of the GNU General Public License along |
|
| 19 |
# with this program; if not, write to the Free Software Foundation, Inc., |
|
| 20 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 21 |
# |
|
| 22 |
# |
|
| 23 |
# Prerequistes: |
|
| 24 |
# 1) /etc/odbc.ini and /etc/freetds.conf |
|
| 25 |
# 2) rubygems |
|
| 26 |
# 3) ruby-dbi |
|
| 27 |
# |
|
| 28 |
# Usage: |
|
| 29 |
# 1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins) |
|
| 30 |
# 2) chmod to allow executable to others |
|
| 31 |
# 3) create symbolic link in /etc/munin/plugins |
|
| 32 |
# ln -s /usr/share/munin/plugins/mssql_logfilesizes.rb /etc/munin/plugins/mssql_logfilesizes.rb |
|
| 33 |
# |
|
| 34 |
# Parameters: |
|
| 35 |
# autoconf |
|
| 36 |
# config (required) |
|
| 37 |
# |
|
| 38 |
# Config variables: |
|
| 39 |
# sqluser : mssql user who has view server state privilege |
|
| 40 |
# sqlpass : password for the mssql user |
|
| 41 |
# dsn : datasource name as defined in /etc/odbc.ini |
|
| 42 |
# instance: instance to monitor |
|
| 43 |
# |
|
| 2 |
|
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
Munin Plugin for MSSQL - log files monitoring |
|
| 6 |
|
|
| 7 |
Author: Wilfred Chau <openapp.developer@gmail.com> |
|
| 8 |
Date: 2011-05-19 |
|
| 9 |
Version: 1.0 |
|
| 10 |
|
|
| 11 |
This program is free software; you can redistribute it and/or modify |
|
| 12 |
it under the terms of the GNU General Public License version 2 |
|
| 13 |
as published by the Free Software Foundation. |
|
| 14 |
|
|
| 15 |
This program is distributed in the hope that it will be useful, |
|
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
GNU General Public License for more details. |
|
| 19 |
|
|
| 20 |
You should have received a copy of the GNU General Public License along |
|
| 21 |
with this program; if not, write to the Free Software Foundation, Inc., |
|
| 22 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 23 |
|
|
| 24 |
|
|
| 25 |
Prerequistes: |
|
| 26 |
1) /etc/odbc.ini and /etc/freetds.conf |
|
| 27 |
2) rubygems |
|
| 28 |
3) ruby-dbi |
|
| 29 |
|
|
| 30 |
Usage: |
|
| 31 |
1) copy this script to the munin install plugins directory (e.g. /usr/share/munin/plugins) |
|
| 32 |
2) chmod to allow executable to others |
|
| 33 |
3) create symbolic link in /etc/munin/plugins |
|
| 34 |
ln -s /usr/share/munin/plugins/mssql_logfilesizes.rb /etc/munin/plugins/mssql_logfilesizes.rb |
|
| 35 |
|
|
| 36 |
Parameters: |
|
| 37 |
autoconf |
|
| 38 |
config (required) |
|
| 39 |
|
|
| 40 |
Config variables: |
|
| 41 |
sqluser : mssql user who has view server state privilege |
|
| 42 |
sqlpass : password for the mssql user |
|
| 43 |
dsn : datasource name as defined in /etc/odbc.ini |
|
| 44 |
instance: instance to monitor |
|
| 45 |
|
|
| 44 | 46 |
#%# family=auto |
| 45 | 47 |
#%# capabilities=autoconf |
| 46 | 48 |
|
| 49 |
=end |
|
| 50 |
|
|
| 51 |
|
|
| 47 | 52 |
require 'rubygems' |
| 48 | 53 |
require 'dbi' |
| 49 | 54 |
|
| ... | ... | |
| 56 | 61 |
# Queries |
| 57 | 62 |
# |
| 58 | 63 |
# |
| 59 |
dbh = DBI.connect("DBI:ODBC:#{dsn}",sqluser,sqlpass)
|
|
| 64 |
dbh = DBI.connect("DBI:ODBC:#{dsn}", sqluser, sqlpass)
|
|
| 60 | 65 |
|
| 61 | 66 |
instance_name_query = "SELECT distinct instance_name |
| 62 | 67 |
FROM sys.dm_os_performance_counters |
| ... | ... | |
| 67 | 72 |
AND object_name = 'SQLServer:Databases' |
| 68 | 73 |
AND instance_name = ?" |
| 69 | 74 |
|
| 70 |
all_instance_names = Array.new
|
|
| 75 |
all_instance_names = Array.new |
|
| 71 | 76 |
sth = dbh.execute(instance_name_query) |
| 72 | 77 |
sth.fetch do |row| |
| 73 |
all_instance_names.push(row[0].strip)
|
|
| 78 |
all_instance_names.push(row[0].strip)
|
|
| 74 | 79 |
end |
| 75 | 80 |
sth.finish |
| 76 | 81 |
|
| ... | ... | |
| 78 | 83 |
# autoconf |
| 79 | 84 |
# |
| 80 | 85 |
if ARGV[0] == "autoconf" |
| 81 |
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
|
| 82 |
puts "yes"
|
|
| 83 |
else
|
|
| 84 |
puts "no"
|
|
| 85 |
puts "Usage: #{__FILE__} autoconf|conf"
|
|
| 86 |
end
|
|
| 87 |
exit 0
|
|
| 86 |
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
|
| 87 |
puts "yes"
|
|
| 88 |
else
|
|
| 89 |
puts "no"
|
|
| 90 |
puts "Usage: #{__FILE__} autoconf|conf"
|
|
| 91 |
end
|
|
| 92 |
exit 0
|
|
| 88 | 93 |
# |
| 89 | 94 |
# config definition |
| 90 | 95 |
# |
| 91 | 96 |
elsif ARGV[0] == "config" |
| 92 |
puts "graph_args --base 1024k -r --lower-limit 0"
|
|
| 93 |
puts "graph_title MSSQL DB Log File Sizes"
|
|
| 94 |
puts "graph_category db"
|
|
| 95 |
puts "graph_info This graph shows DB Log File Sizes (MB)"
|
|
| 96 |
puts "graph_vlabel MB"
|
|
| 97 |
puts "graph_scale no"
|
|
| 98 |
puts "graph_period second"
|
|
| 99 |
|
|
| 100 |
all_instance_names.sort.each do |s|
|
|
| 101 |
puts "#{s}.label #{s}"
|
|
| 102 |
puts "#{s}.info INSTANCE: #{s}"
|
|
| 103 |
puts "#{s}.type GAUGE"
|
|
| 104 |
puts "#{s}.draw LINE1"
|
|
| 105 |
end
|
|
| 106 |
|
|
| 107 |
exit 0
|
|
| 97 |
puts "graph_args --base 1024k -r --lower-limit 0"
|
|
| 98 |
puts "graph_title MSSQL DB Log File Sizes"
|
|
| 99 |
puts "graph_category db"
|
|
| 100 |
puts "graph_info This graph shows DB Log File Sizes (MB)"
|
|
| 101 |
puts "graph_vlabel MB"
|
|
| 102 |
puts "graph_scale no"
|
|
| 103 |
puts "graph_period second"
|
|
| 104 |
|
|
| 105 |
all_instance_names.sort.each do |s|
|
|
| 106 |
puts "#{s}.label #{s}"
|
|
| 107 |
puts "#{s}.info INSTANCE: #{s}"
|
|
| 108 |
puts "#{s}.type GAUGE"
|
|
| 109 |
puts "#{s}.draw LINE1"
|
|
| 110 |
end
|
|
| 111 |
|
|
| 112 |
exit 0
|
|
| 108 | 113 |
end |
| 109 | 114 |
|
| 110 | 115 |
sth = dbh.prepare(logfilesize_query) |
| 111 | 116 |
all_instance_names.sort.each do |k| |
| 112 |
sth.execute(k) |
|
| 113 |
sth.fetch do |row| |
|
| 114 |
puts "#{k.to_s}.value #{row[0].to_s}"
|
|
| 115 |
end |
|
| 117 |
sth.execute(k) |
|
Formats disponibles : Unified diff