Class: MonitorType_Drive

Inherits:
MonitorType_Threshold show all
Defined in:
lib/MonitorType/Drive.rb

Instance Method Summary collapse

Methods inherited from MonitorType_Threshold

#check, #initialize, #process

Methods inherited from MonitorType

#alert, #initialize, #process, #run, #teardown

Constructor Details

This class inherits a constructor from MonitorType_Threshold

Instance Method Details

#extractParamsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/MonitorType/Drive.rb', line 7

def extractParams
	if @params[:path].nil? then
		string = "*** Drive parameter missing, drive\n"
		string = "#{string}*** :drive => <name of the drive to be monitored>"
		raise MonitorTypeParameterMissingError.new(string)
	end
	@path = @params[:path]

	log "#{@process_name}", "result: #{(@process_name =~ /^(.*\[{1}.+\]{1}.*)$|^(\w+)$/) == 0}"

	if @params[:min].nil? then
		string = "*** Min parameter missing, min\n"
		string = "#{string}*** :min => <the minimum amount of free space on the drive to be monitored>"
		raise MonitorTypeParameterMissingError.new(string)
	end

 	log "*** Max value will be ignored, setting to nil" unless @params[:max].nil?
 	@max = nil

	@context_sentence = "Checking that available drive space is greater than min, #{@process_name}"
end

#getValueObject



42
43
44
# File 'lib/MonitorType/Drive.rb', line 42

def getValue
	return ((Filesystem.stat(@path).blocks_available.to_f / Filesystem.stat(@path).blocks.to_f) * 100).round(2)
end

#setupObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/MonitorType/Drive.rb', line 29

def setup
	begin
	#Check that the path exists
	drive = Filesystem.stat(@path)

	rescue=>e
		string = "*** Unable to mount the specifed path\n"
		string = "#{string}*** path: #{@path}\n"
     string = "#{string}*** Please fix the error and run again\n"
		raise MonitorTypeExceptionHandled.new("Unable to mount path: #{@path}")
	end
end