recmon 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,6 @@
1
- == Version 1.0.5
1
+ == Version 1.0.6
2
2
  - daemonize the process
3
+ - refined the sizing mechanisms (diskfree MB, diskspace MB, filesize bytes)
3
4
 
4
5
  == Version 1.0.4
5
6
  - Added DiskfreeSensor
data/README CHANGED
@@ -76,7 +76,7 @@ A DiskfreeSensor tracks how much disk space is available on a mounted disk parti
76
76
 
77
77
  s.diskfree(name, freq=1200)
78
78
  s.diskfree("/var")
79
- # log entry => "2012-09-13T16:09:02+10:00 mountpoint=/var usage=45%"
79
+ # log entry => "2012-09-13T16:09:02+10:00 mountpoint=/var available=4576 MB"
80
80
 
81
81
  === diskspace: track the diskspace used by a folder
82
82
  A DiskspaceSensor tracks how much disk space is being consumed by a set of files (log files or database files) in a folder:
@@ -92,7 +92,7 @@ A FilesizeSensor tracks the size of a given file every 10 minutes:
92
92
 
93
93
  s.filesize(name, path, freq=1200)
94
94
  s.filesize("Messages", "/var/log/messages")
95
- # log entry => "2012-09-13T16:09:02+10:00 Messages filesize=78 KB"
95
+ # log entry => "2012-09-13T16:09:02+10:00 Messages filesize=78045 bytes"
96
96
 
97
97
  === ping: check if a server is alive
98
98
  The PingSensor pings a server to ensure it is accessible through the network
@@ -20,10 +20,10 @@ class DiskfreeSensor < Sensor
20
20
  usage = "unknown"
21
21
  if line
22
22
  parts = line.split(/\s+/)
23
- usage = parts[4]
23
+ avail = parts[3].to_i()/1024
24
24
  end
25
25
  end
26
- return("mountpoint=#{@name} usage=#{usage}%")
26
+ return("mountpoint=#{@name} available=#{avail} MB")
27
27
  end
28
28
 
29
29
  end
@@ -17,7 +17,7 @@ class DiskspaceSensor < Sensor
17
17
  # Called by Monitor. Executes du(1) to determine the disk usage in Megabytes.
18
18
  def sense()
19
19
  begin
20
- size = `sudo /usr/bin/du -sk #{@path}`.to_i().to_s()
20
+ size = `sudo /usr/bin/du -sk #{@path}`.to_i()/1024
21
21
  rescue
22
22
  size = "unknown"
23
23
  end
@@ -13,14 +13,10 @@ class FilesizeSensor < Sensor
13
13
  raise "Path not found: #{path}" unless File.exists?(@path)
14
14
  end
15
15
 
16
- # Called by Monitor. Determines the filesize in Kilobytes.
16
+ # Called by Monitor. Determines the filesize in bytes.
17
17
  def sense()
18
- begin
19
- size = `sudo /bin/ls -sk #{@path}`.to_i
20
- rescue
21
- size = "unknown"
22
- end
23
- return("#{@name} filesize=#{size} KB")
18
+ size = File.stat(@path).size() || "unknown"
19
+ return("#{@name} filesize=#{size} bytes")
24
20
  end
25
21
 
26
22
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recmon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 5
10
- version: 1.0.5
9
+ - 6
10
+ version: 1.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Richard Kernahan