mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Ruby plugins: apply code changes as suggested by "rubocop --auto-correct"
This commit is contained in:
parent
b0b39b018e
commit
809639ab65
33 changed files with 904 additions and 910 deletions
|
@ -21,34 +21,32 @@ 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
|
||||
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
|
||||
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)
|
||||
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
|
||||
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'
|
||||
|
||||
|
@ -74,7 +72,7 @@ transaction_query = "select cntr_value from sys.dm_os_performance_counters
|
|||
and object_name = 'SQLServer:Databases'
|
||||
and instance_name = ?"
|
||||
|
||||
all_instance_names = Array.new
|
||||
all_instance_names = []
|
||||
sth = dbh.execute(instance_name_query)
|
||||
sth.fetch do |row|
|
||||
all_instance_names.push(row[0].strip)
|
||||
|
@ -84,25 +82,26 @@ sth.finish
|
|||
#
|
||||
# autoconf
|
||||
#
|
||||
if ARGV[0] == "autoconf"
|
||||
case ARGV[0]
|
||||
when 'autoconf'
|
||||
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
||||
puts "yes"
|
||||
puts 'yes'
|
||||
else
|
||||
puts "no"
|
||||
puts 'no'
|
||||
puts "Usage: #{__FILE__} autoconf|conf"
|
||||
end
|
||||
exit 0
|
||||
#
|
||||
# config definition
|
||||
#
|
||||
elsif ARGV[0] == "config"
|
||||
puts "graph_args --base 1000 -r --lower-limit 0"
|
||||
puts "graph_title MSSQL Transactions/s"
|
||||
puts "graph_category db"
|
||||
puts "graph_info This graph shows transactions/s"
|
||||
puts "graph_vlabel transactions/s"
|
||||
puts "graph_scale no"
|
||||
puts "graph_period second"
|
||||
when 'config'
|
||||
puts 'graph_args --base 1000 -r --lower-limit 0'
|
||||
puts 'graph_title MSSQL Transactions/s'
|
||||
puts 'graph_category db'
|
||||
puts 'graph_info This graph shows transactions/s'
|
||||
puts 'graph_vlabel transactions/s'
|
||||
puts 'graph_scale no'
|
||||
puts 'graph_period second'
|
||||
|
||||
all_instance_names.sort.each do |s|
|
||||
puts "#{s}.label #{s}"
|
||||
|
@ -122,7 +121,7 @@ all_instance_names.sort.each do |k|
|
|||
sth.execute(k)
|
||||
sth.fetch do |row|
|
||||
# since type is DERIVE, need to convert value to integer then to string
|
||||
puts "#{k.to_s}.value #{row[0].to_i.to_s}"
|
||||
puts "#{k}.value #{row[0].to_i}"
|
||||
end
|
||||
end
|
||||
sth.finish
|
||||
|
|
|
@ -21,33 +21,31 @@ 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
|
||||
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
|
||||
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)
|
||||
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
|
||||
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'
|
||||
|
||||
|
@ -74,37 +72,38 @@ buffercachehitratio_query = "select (a.cntr_value * 1.0 / b.cntr_value) * 100.0
|
|||
#
|
||||
# autoconf
|
||||
#
|
||||
if ARGV[0] == "autoconf"
|
||||
case ARGV[0]
|
||||
when 'autoconf'
|
||||
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
||||
puts "yes"
|
||||
puts 'yes'
|
||||
else
|
||||
puts "no"
|
||||
puts 'no'
|
||||
puts "Usage: #{__FILE__} autoconf|conf"
|
||||
end
|
||||
exit 0
|
||||
#
|
||||
# config definition
|
||||
#
|
||||
elsif ARGV[0] == "config"
|
||||
puts "graph_args --base 1000 -r --lower-limit 0"
|
||||
puts "graph_title MSSQL Buffer Cache Hit Ratio "
|
||||
puts "graph_category db"
|
||||
puts "graph_info This graph shows Buffer Cache Hit Ratio"
|
||||
puts "graph_vlabel %"
|
||||
puts "graph_scale no"
|
||||
puts "graph_period second"
|
||||
when 'config'
|
||||
puts 'graph_args --base 1000 -r --lower-limit 0'
|
||||
puts 'graph_title MSSQL Buffer Cache Hit Ratio '
|
||||
puts 'graph_category db'
|
||||
puts 'graph_info This graph shows Buffer Cache Hit Ratio'
|
||||
puts 'graph_vlabel %'
|
||||
puts 'graph_scale no'
|
||||
puts 'graph_period second'
|
||||
|
||||
puts "bc_hitratio.label BufferCacheHitRatio"
|
||||
puts "bc_hitratio.info BufferCacheHitRatio"
|
||||
puts "bc_hitratio.type GAUGE"
|
||||
puts "bc_hitratio.draw LINE1"
|
||||
puts 'bc_hitratio.label BufferCacheHitRatio'
|
||||
puts 'bc_hitratio.info BufferCacheHitRatio'
|
||||
puts 'bc_hitratio.type GAUGE'
|
||||
puts 'bc_hitratio.draw LINE1'
|
||||
|
||||
exit 0
|
||||
end
|
||||
|
||||
sth = dbh.execute(buffercachehitratio_query)
|
||||
sth.fetch do |row|
|
||||
puts "bc_hitratio.value #{row[0].strip.to_s}"
|
||||
puts "bc_hitratio.value #{row[0].strip}"
|
||||
end
|
||||
sth.finish
|
||||
dbh.disconnect
|
||||
|
|
|
@ -21,34 +21,32 @@ 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
|
||||
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
|
||||
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)
|
||||
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
|
||||
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'
|
||||
|
||||
|
@ -72,7 +70,7 @@ transaction_query = "select cntr_value/1024.0 from sys.dm_os_performance_counter
|
|||
and object_name = 'SQLServer:Databases'
|
||||
and instance_name = ?"
|
||||
|
||||
all_instance_names = Array.new
|
||||
all_instance_names = []
|
||||
sth = dbh.execute(instance_name_query)
|
||||
sth.fetch do |row|
|
||||
all_instance_names.push(row[0].strip)
|
||||
|
@ -82,25 +80,26 @@ sth.finish
|
|||
#
|
||||
# autoconf
|
||||
#
|
||||
if ARGV[0] == "autoconf"
|
||||
case ARGV[0]
|
||||
when 'autoconf'
|
||||
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
||||
puts "yes"
|
||||
puts 'yes'
|
||||
else
|
||||
puts "no"
|
||||
puts 'no'
|
||||
puts "Usage: #{__FILE__} autoconf|conf"
|
||||
end
|
||||
exit 0
|
||||
#
|
||||
# config definition
|
||||
#
|
||||
elsif ARGV[0] == "config"
|
||||
puts "graph_args --base 1024k -r --lower-limit 0"
|
||||
puts "graph_title MSSQL DB File Sizes"
|
||||
puts "graph_category db"
|
||||
puts "graph_info This graph shows DB File Sizes (MB)"
|
||||
puts "graph_vlabel MB"
|
||||
puts "graph_scale no"
|
||||
puts "graph_period second"
|
||||
when 'config'
|
||||
puts 'graph_args --base 1024k -r --lower-limit 0'
|
||||
puts 'graph_title MSSQL DB File Sizes'
|
||||
puts 'graph_category db'
|
||||
puts 'graph_info This graph shows DB File Sizes (MB)'
|
||||
puts 'graph_vlabel MB'
|
||||
puts 'graph_scale no'
|
||||
puts 'graph_period second'
|
||||
|
||||
all_instance_names.sort.each do |s|
|
||||
puts "#{s}.label #{s}"
|
||||
|
@ -119,7 +118,7 @@ sth = dbh.prepare(transaction_query)
|
|||
all_instance_names.sort.each do |k|
|
||||
sth.execute(k)
|
||||
sth.fetch do |row|
|
||||
puts "#{k.to_s}.value #{row[0].to_s}"
|
||||
puts "#{k}.value #{row[0]}"
|
||||
end
|
||||
end
|
||||
sth.finish
|
||||
|
|
|
@ -21,34 +21,32 @@ 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
|
||||
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
|
||||
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)
|
||||
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
|
||||
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'
|
||||
|
||||
|
@ -72,7 +70,7 @@ logfilesize_query = "SELECT cntr_value/1024.0 from sys.dm_os_performance_counter
|
|||
AND object_name = 'SQLServer:Databases'
|
||||
AND instance_name = ?"
|
||||
|
||||
all_instance_names = Array.new
|
||||
all_instance_names = []
|
||||
sth = dbh.execute(instance_name_query)
|
||||
sth.fetch do |row|
|
||||
all_instance_names.push(row[0].strip)
|
||||
|
@ -82,25 +80,26 @@ sth.finish
|
|||
#
|
||||
# autoconf
|
||||
#
|
||||
if ARGV[0] == "autoconf"
|
||||
case ARGV[0]
|
||||
when 'autoconf'
|
||||
if all_instance_names.length > 1 && sqluser.length > 1 && sqlpass.length > 1
|
||||
puts "yes"
|
||||
puts 'yes'
|
||||
else
|
||||
puts "no"
|
||||
puts 'no'
|
||||
puts "Usage: #{__FILE__} autoconf|conf"
|
||||
end
|
||||
exit 0
|
||||
#
|
||||
# config definition
|
||||
#
|
||||
elsif ARGV[0] == "config"
|
||||
puts "graph_args --base 1024k -r --lower-limit 0"
|
||||
puts "graph_title MSSQL DB Log File Sizes"
|
||||
puts "graph_category db"
|
||||
puts "graph_info This graph shows DB Log File Sizes (MB)"
|
||||
puts "graph_vlabel MB"
|
||||
puts "graph_scale no"
|
||||
puts "graph_period second"
|
||||
when 'config'
|
||||
puts 'graph_args --base 1024k -r --lower-limit 0'
|
||||
puts 'graph_title MSSQL DB Log File Sizes'
|
||||
puts 'graph_category db'
|
||||
puts 'graph_info This graph shows DB Log File Sizes (MB)'
|
||||
puts 'graph_vlabel MB'
|
||||
puts 'graph_scale no'
|
||||
puts 'graph_period second'
|
||||
|
||||
all_instance_names.sort.each do |s|
|
||||
puts "#{s}.label #{s}"
|
||||
|
@ -116,7 +115,7 @@ sth = dbh.prepare(logfilesize_query)
|
|||
all_instance_names.sort.each do |k|
|
||||
sth.execute(k)
|
||||
sth.fetch do |row|
|
||||
puts "#{k.to_s}.value #{row[0].to_s}"
|
||||
puts "#{k}.value #{row[0]}"
|
||||
end
|
||||
end
|
||||
sth.finish
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue