1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 10:39:53 +00:00

Ruby plugins: apply code changes as suggested by "rubocop --auto-correct"

This commit is contained in:
Lars Kruse 2020-08-25 17:06:15 +02:00
parent b0b39b018e
commit 809639ab65
33 changed files with 904 additions and 910 deletions

View file

@ -21,39 +21,36 @@ 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
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
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)
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
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'
@ -69,7 +66,7 @@ tnsname = "(DESCRIPTION =
def runQuery(name, query)
rows = $conn.exec(query)
puts "#{name}.value #{rows.fetch().to_s}"
puts "#{name}.value #{rows.fetch}"
rows.close
end
@ -82,31 +79,32 @@ pga_target_query = "SELECT TO_CHAR(ROUND(decode(unit,'bytes',(value)/(1024*1024)
pga_query = "SELECT TO_CHAR(ROUND(decode(unit,'bytes',(value)/(1024*1024),value),2)) pga
from V$PGASTAT where name = 'total PGA inuse'"
pga_components = { "pga_target" => pga_target_query,
"pga_in_use" => pga_query }
pga_components = { 'pga_target' => pga_target_query,
'pga_in_use' => pga_query }
#
# autoconf
#
if ARGV[0] == "autoconf"
case ARGV[0]
when 'autoconf'
if tnsname.length > 1 && orauser.length > 1 && orapass.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"
when 'config'
puts 'graph_args --base 1024k -r --lower-limit 0'
puts "graph_title Oracle PGA from #{dbname}"
puts "graph_category db"
puts "graph_info This graph shows the PGA memory usage (in MB)"
puts "graph_vlabel MB"
puts "graph_scale no"
puts "graph_period second"
puts 'graph_category db'
puts 'graph_info This graph shows the PGA memory usage (in MB)'
puts 'graph_vlabel MB'
puts 'graph_scale no'
puts 'graph_period second'
pga_components.keys.each do |p|
puts "#{p}.label #{p}"