Class: Recmon::FilesizeSensor
- Defined in:
- lib/recmon/filesize-sensor.rb
Overview
Periodically checks the size of a designated file
Instance Method Summary collapse
-
#initialize(name, path, freq = 1200) ⇒ FilesizeSensor
constructor
The name is arbitrary (used in creating the log entries), and the path should be absolute (eg.
/var/log/messages). -
#sense ⇒ Object
Called by Monitor.
Methods inherited from Sensor
Constructor Details
#initialize(name, path, freq = 1200) ⇒ FilesizeSensor
The name is arbitrary (used in creating the log entries), and the path should be absolute (eg. /var/log/messages)
10 11 12 13 14 |
# File 'lib/recmon/filesize-sensor.rb', line 10 def initialize(name, path, freq=1200) super(name, freq) @path = path.strip() raise "Path not found: #{path}" unless File.exists?(@path) end |
Instance Method Details
#sense ⇒ Object
Called by Monitor. Determines the filesize in bytes.
17 18 19 20 |
# File 'lib/recmon/filesize-sensor.rb', line 17 def sense() size = File.stat(@path).size() || "unknown" return("#{@name} filesize=#{size} bytes") end |