recmon 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/README +5 -0
- data/lib/recmon/monitor.rb +7 -4
- metadata +3 -3
data/CHANGELOG
CHANGED
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")
|
data/lib/recmon/monitor.rb
CHANGED
@@ -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
|
-
|
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
|
43
|
+
File.umask 0027 # default mode => 0750
|
41
44
|
STDIN.reopen "/dev/null"
|
42
|
-
STDOUT.reopen
|
43
|
-
STDERR.reopen
|
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richard Kernahan
|