CalMon 0.0.4 → 0.0.5
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/CalMon.gemspec +1 -1
- data/Gemfile.lock +1 -1
- data/doc/bash_only.sh +6 -11
- data/lib/CalMon.rb +5 -0
- data/lib/CalMon/ObserveRPC.rb +8 -0
- data/lib/CalMon/RPC.rb +22 -0
- data/lib/CalMon/Server.rb +8 -0
- data/lib/CalMon/version.rb +7 -1
- metadata +5 -5
data/CalMon.gemspec
CHANGED
|
@@ -17,7 +17,7 @@ to create events in Google Calendar. These events may be used to easily
|
|
|
17
17
|
identify when an event (a Cron Job, batch script, etc...) started, stopped,
|
|
18
18
|
and what its exit status was. For an organization that relies heavily upon
|
|
19
19
|
the success, timeliness, and regularlity of many many batch jobs, a tool
|
|
20
|
-
like that can prove to be a real benefit to systems administrators.
|
|
20
|
+
like that can prove to be a real benefit to systems administrators.
|
|
21
21
|
EOF
|
|
22
22
|
|
|
23
23
|
s.rubyforge_project = "CalMon"
|
data/Gemfile.lock
CHANGED
data/doc/bash_only.sh
CHANGED
|
@@ -19,19 +19,9 @@ gen_json_req() {
|
|
|
19
19
|
shift
|
|
20
20
|
PARAMS=$(echo $* | sed -e 's/ /,/g')
|
|
21
21
|
REPLY=$(cat <<EOF
|
|
22
|
-
[
|
|
23
|
-
{"jsonrpc": "2.0", "method": "${METHOD}", "params": [${PARAMS}], "id": 1},
|
|
24
|
-
{"jsonrpc": "2.0", "method":"system.listMethods", "id":2},
|
|
25
|
-
{"jsonrpc": "2.0", "method":"system.isAlive", "id":3},
|
|
26
|
-
{"jsonrpc": "2.0", "method":"system.isAlive", "id":4},
|
|
27
|
-
{"jsonrpc": "2.0", "method": "sub", "params": [40,20], "id": 5}
|
|
28
|
-
]
|
|
22
|
+
{"jsonrpc": "2.0", "method": "${METHOD}", "params": [${PARAMS}], "id": 1}
|
|
29
23
|
EOF
|
|
30
24
|
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
gen_json_req start_time '"2012-01-12 12:15:33"'
|
|
34
|
-
|
|
35
25
|
BODY=${REPLY}
|
|
36
26
|
|
|
37
27
|
SIZE=$(echo ${BODY} | wc -c)
|
|
@@ -58,4 +48,9 @@ echo "$RES" | $(dirname $0)/../support/JSON_bash/JSON.sh
|
|
|
58
48
|
if [[ $? -eq 0 ]]; then
|
|
59
49
|
echo; l_info Message successfully sent to ${HOST}:${PORT}
|
|
60
50
|
fi
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
gen_json_req start_time '"2012-01-12 12:15:33"'
|
|
54
|
+
gen_json_req stop_time '"2012-01-12 12:16:33"'
|
|
55
|
+
gen_json_req running_time '"2012-01-12 12:17:33"'
|
|
61
56
|
|
data/lib/CalMon.rb
CHANGED
data/lib/CalMon/ObserveRPC.rb
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Randy D. Wallace Jr. (mailto:randy@randywallace.com)
|
|
3
|
+
# Copyright:: Copyright (c) 2012 Randy D. Wallace Jr.
|
|
4
|
+
# License:: MIT
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
# This class bridges the gap between the JsonRPC Server and additional
|
|
8
|
+
# handlers for what the client sends to the server.
|
|
1
9
|
|
|
2
10
|
module CalMon
|
|
3
11
|
class ObserveRPC
|
data/lib/CalMon/RPC.rb
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Randy D. Wallace Jr. (mailto:randy@randywallace.com)
|
|
3
|
+
# Copyright:: Copyright (c) 2012 Randy D. Wallace Jr.
|
|
4
|
+
# License:: MIT
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
# This class provides the RPC methods actually handled by the
|
|
8
|
+
# JsonRPC Server. Note that unless the observer is notified the
|
|
9
|
+
# data sent by the remote client won't get anywhere.
|
|
10
|
+
|
|
1
11
|
require 'observer'
|
|
2
12
|
|
|
3
13
|
module CalMon
|
|
@@ -16,6 +26,18 @@ module CalMon
|
|
|
16
26
|
"Success"
|
|
17
27
|
end
|
|
18
28
|
|
|
29
|
+
def stop_time timestamp
|
|
30
|
+
changed
|
|
31
|
+
notify_observers(Time.parse(timestamp), __method__.to_s)
|
|
32
|
+
"Success"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def running_time timestamp
|
|
36
|
+
changed
|
|
37
|
+
notify_observers(Time.parse(timestamp), __method__.to_s)
|
|
38
|
+
"Success"
|
|
39
|
+
end
|
|
40
|
+
|
|
19
41
|
def sum(a, b, c)
|
|
20
42
|
a + b + c
|
|
21
43
|
end
|
data/lib/CalMon/Server.rb
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Randy D. Wallace Jr. (mailto:randy@randywallace.com)
|
|
3
|
+
# Copyright:: Copyright (c) 2012 Randy D. Wallace Jr.
|
|
4
|
+
# License:: MIT
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
# This class handles attaching the observer to the JsonRPC server and
|
|
8
|
+
# starting the server.
|
|
1
9
|
|
|
2
10
|
require "CalMon/RPC"
|
|
3
11
|
require "CalMon/ObserveRPC"
|
data/lib/CalMon/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: CalMon
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 21
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 5
|
|
10
|
+
version: 0.0.5
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Randy
|
|
@@ -18,7 +18,7 @@ autorequire:
|
|
|
18
18
|
bindir: bin
|
|
19
19
|
cert_chain: []
|
|
20
20
|
|
|
21
|
-
date: 2012-05-
|
|
21
|
+
date: 2012-05-06 00:00:00 Z
|
|
22
22
|
dependencies:
|
|
23
23
|
- !ruby/object:Gem::Dependency
|
|
24
24
|
name: rake
|
|
@@ -69,7 +69,7 @@ description: |
|
|
|
69
69
|
identify when an event (a Cron Job, batch script, etc...) started, stopped,
|
|
70
70
|
and what its exit status was. For an organization that relies heavily upon
|
|
71
71
|
the success, timeliness, and regularlity of many many batch jobs, a tool
|
|
72
|
-
like that can prove to be a real benefit to systems administrators.
|
|
72
|
+
like that can prove to be a real benefit to systems administrators.
|
|
73
73
|
|
|
74
74
|
email:
|
|
75
75
|
- randy@randywallace.com
|