Class: MonitorType_FluidDb
- Inherits:
-
MonitorType_Threshold
- Object
- MonitorType
- MonitorType_Threshold
- MonitorType_FluidDb
- Defined in:
- lib/MonitorType/FluidDb.rb
Instance Method Summary collapse
-
#initialize(params) ⇒ MonitorType_FluidDb
constructor
A new instance of MonitorType_FluidDb.
- #process ⇒ Object
- #sanitise ⇒ Object
Methods inherited from MonitorType_Threshold
Methods inherited from MonitorType
Constructor Details
#initialize(params) ⇒ MonitorType_FluidDb
Returns a new instance of MonitorType_FluidDb.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/MonitorType/FluidDb.rb', line 27 def initialize( params ) super( params ) if params[:uri].nil? then puts "*** FluidDb parameter missing, uri" puts "*** :uri => <uri pointing to db to be monitored>" abort end begin @uri = URI.parse( params[:uri] ) rescue URI::InvalidURIError=>e puts "*** FluidDb encountered an error while parsing the uri" puts "*** uri: #{params[:uri]}" puts "*** Please fix the uri and run again" abort() end if params[:sql].nil? then puts "*** FluidDb parameter missing, sql" puts "*** :sql => <sql statement, producing a single column, single row which yeidls a number>" abort end @sql = params[:sql] self.sanitise rescue MonitorTypeExceptionHandled => e puts e. abort() end |
Instance Method Details
#process ⇒ Object
55 56 57 58 59 |
# File 'lib/MonitorType/FluidDb.rb', line 55 def process value = @fluidDb.queryForValue( @sql, [] ) self.check( value, "Checking result of sql query, #{@sql}" ) end |
#sanitise ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/MonitorType/FluidDb.rb', line 6 def sanitise begin @fluidDb = FluidDb.Db( @uri ) rescue Exception=>e puts "*** FluidDb encountered an error while connecting to the db" puts "*** Error: #{e.message}" puts "*** uri: #{@uri}" puts "*** Please fix the error and run again" abort() end begin value = @fluidDb.queryForValue( @sql, [] ) rescue Exception=>e puts "*** FluidDb encountered an error while running the sql" puts "*** sql: #{@sql}" puts "*** Please fix the query and run again" abort() end end |