recmon 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +3 -0
  2. data/README +5 -0
  3. data/lib/recmon/monitor.rb +7 -4
  4. metadata +3 -3
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == Version 1.1.1
2
+ - Added ability to name the process (eg. "ruby: mymonitor" in the process list)
3
+
1
4
  == Version 1.1.0
2
5
  - Eliminated dependency on Daemons gem
3
6
 
data/README CHANGED
@@ -15,6 +15,11 @@ Create a monitor to obtain readings from the sensors at the right time:
15
15
 
16
16
  s = Recmon::Monitor.new()
17
17
 
18
+ or customise the monitor with a different log file, process name, and frequency:
19
+
20
+ s = Recmon::Monitor.new("/var/log/my.log", "mymonitor", 25)
21
+ # appears in process list as => "ruby: mymonitor"
22
+
18
23
  Now add sensors for each aspect you want to monitor:
19
24
 
20
25
  s.web("Website", "http://www.example.com/index.html")
@@ -14,8 +14,10 @@ class Monitor
14
14
  # The default frequency of 10 seconds is frequent enough to be near-real-time
15
15
  # without any burden on the processor. This is the frequency on which the
16
16
  # monitor checks if any sensors are due - not the frequency for each sensor.
17
- def initialize(log="/var/log/recmon.log", freq=10)
17
+ # The +name+ is used in the process list (ps, top).
18
+ def initialize(log="/var/log/recmon.log", name="recmond", freq=10)
18
19
  @logfile = log
20
+ @name = name
19
21
  @freq = freq # seconds
20
22
  @log = ""
21
23
  @sensors = []
@@ -34,13 +36,14 @@ class Monitor
34
36
  open_log()
35
37
  log("Recmon is monitoring.")
36
38
  # daemonise the process
39
+ $0 = @name
37
40
  fork do
38
41
  Process.setsid
39
42
  exit if fork
40
- File.umask 0000
43
+ File.umask 0027 # default mode => 0750
41
44
  STDIN.reopen "/dev/null"
42
- STDOUT.reopen "/dev/null"
43
- STDERR.reopen "/dev/null"
45
+ STDOUT.reopen @log
46
+ STDERR.reopen @log
44
47
  monitor()
45
48
  while sleep(@freq)
46
49
  monitor()
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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Richard Kernahan