Class: Opstat::Plugins::OracleSessions
- Inherits:
-
Task
- Object
- Task
- Opstat::Plugins::OracleSessions
- Defined in:
- lib/plugins/oracle_sessions.rb
Instance Method Summary collapse
-
#initialize(name, queue, config) ⇒ OracleSessions
constructor
A new instance of OracleSessions.
- #parse ⇒ Object
- #sql_cmd ⇒ Object
Constructor Details
#initialize(name, queue, config) ⇒ OracleSessions
Returns a new instance of OracleSessions.
7 8 9 10 11 12 13 |
# File 'lib/plugins/oracle_sessions.rb', line 7 def initialize (name, queue, config) super(name, queue, config) self @su_user = config['su_user'] @db_user = config['db_user'] @db_password = config['db_password'] end |
Instance Method Details
#parse ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/plugins/oracle_sessions.rb', line 33 def parse report = [] @cmd ||= sql_cmd.result(binding) oracle_output = IO.popen(@cmd) report = oracle_output.readlines.join oracle_output.close return report end |
#sql_cmd ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/plugins/oracle_sessions.rb', line 15 def sql_cmd @query ||= ERB.new <<-EOF su - <%= @su_user %> -c 'echo " set pagesize 10000 set heading on column dummy noprint column used format 999999999999 heading \"Used\" column free format 999999999999 heading \"Free\" SELECT (SELECT COUNT(*) FROM V\\\$SESSION) as used, (VP\.VALUE - (select count(*) from v\\\$Session)) as free FROM V\\\$PARAMETER VP WHERE VP\.NAME = '"'sessions'"'; "|sqlplus -S <%= @db_user %>/<%= @db_password %>' EOF end |