CalMon 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ .bundle
2
+ .idea
3
+ *.swp
4
+ *.class
5
+ *.jar
6
+ wiki/
7
+ *.gem
@@ -0,0 +1,3 @@
1
+ [submodule "support/JSON_bash"]
2
+ path = support/JSON_bash
3
+ url = https://github.com/dominictarr/JSON.sh.git
data/.rvmrc ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.8.7-head"
8
+
9
+ #
10
+ # Uncomment the following lines if you want to verify rvm version per project
11
+ #
12
+ # rvmrc_rvm_version="1.10.1-pre" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*255+$3" -ge "$4*65536+$5*255+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+ #
18
+
19
+ #
20
+ # Uncomment following line if you want options to be set only for given project.
21
+ #
22
+ # PROJECT_JRUBY_OPTS=( --1.9 )
23
+ #
24
+ # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
25
+ #
26
+ # chmod +x ${rvm_path}/hooks/after_use_jruby_opts
27
+ #
28
+
29
+ #
30
+ # First we attempt to load the desired environment directly from the environment
31
+ # file. This is very fast and efficient compared to running through the entire
32
+ # CLI and selector. If you want feedback on which environment was used then
33
+ # insert the word 'use' after --create as this triggers verbose mode.
34
+ #
35
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
36
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
37
+ then
38
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
39
+
40
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
41
+ then
42
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
43
+ fi
44
+ else
45
+ # If the environment file has not yet been created, use the RVM CLI to select.
46
+ if ! rvm --create "$environment_id"
47
+ then
48
+ echo "Failed to create RVM environment '${environment_id}'."
49
+ return 1
50
+ fi
51
+ fi
52
+
53
+ #
54
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
55
+ # it be automatically loaded. Uncomment the following and adjust the filename if
56
+ # necessary.
57
+ #
58
+ # filename=".gems"
59
+ # if [[ -s "$filename" ]]
60
+ # then
61
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
62
+ # fi
63
+
64
+ # If you use bundler, this might be useful to you:
65
+ if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
66
+ then
67
+ printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
68
+ gem install bundler
69
+ fi
70
+ if [[ -s Gemfile ]] && command -v bundle
71
+ then
72
+ bundle install
73
+ fi
74
+
75
+ if [[ $- == *i* ]] # check for interactive shells
76
+ then
77
+ echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
78
+ else
79
+ echo "Using: $GEM_HOME" # don't use colors in interactive shells
80
+ fi
81
+
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "CalMon/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "CalMon"
7
+ s.license = "MIT"
8
+ s.version = CalMon::VERSION
9
+ s.authors = %w{Randy D. Wallace Jr.}
10
+ s.email = %w{randy@randywallace.com}
11
+ s.homepage = ""
12
+ s.summary = %q{Collect timestamp data from services and use that data to add events to google calendar.}
13
+ s.description = <<EOF
14
+ With a JSON-RPC server, client services via a myriad of language options,
15
+ including bash+nc, ruby, and java, send messages that ultimately are used
16
+ to create events in Google Calendar. These events may be used to easily
17
+ identify when an event (a Cron Job, batch script, etc...) started, stopped,
18
+ and what its exit status was. For an organization that relies heavily upon
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. }
21
+ EOF
22
+
23
+ s.rubyforge_project = "CalMon"
24
+
25
+ s.files = `git ls-files`.split("\n")
26
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+ #s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
28
+ s.require_paths = %w{lib}
29
+
30
+ # s.add_development_dependency "rspec"
31
+ s.add_runtime_dependency "rake"
32
+ s.add_runtime_dependency "google-api-client"
33
+ s.add_runtime_dependency "jimson"
34
+ end
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ CalMon (0.0.1)
5
+ google-api-client
6
+ jimson
7
+ rake
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ addressable (2.2.7)
13
+ autoparse (0.3.1)
14
+ addressable (~> 2.2.3)
15
+ extlib (>= 0.9.15)
16
+ multi_json (>= 1.0.0)
17
+ blankslate (2.1.2.4)
18
+ extlib (0.9.15)
19
+ faraday (0.7.6)
20
+ addressable (~> 2.2)
21
+ multipart-post (~> 1.1)
22
+ rack (~> 1.1)
23
+ google-api-client (0.4.3)
24
+ addressable (>= 2.2.3)
25
+ autoparse (>= 0.3.1)
26
+ extlib (>= 0.9.15)
27
+ faraday (~> 0.7.0)
28
+ launchy (>= 2.0.0)
29
+ multi_json (>= 1.0.0)
30
+ signet (>= 0.3.1)
31
+ jimson (0.4.0)
32
+ blankslate (>= 2.1.2.3)
33
+ json (>= 1.5.1)
34
+ rack (>= 1.3)
35
+ rest-client (>= 1.6.3)
36
+ json (1.6.6)
37
+ jwt (0.1.4)
38
+ json (>= 1.2.4)
39
+ launchy (2.1.0)
40
+ addressable (~> 2.2.6)
41
+ mime-types (1.18)
42
+ multi_json (1.2.0)
43
+ multipart-post (1.1.5)
44
+ rack (1.4.1)
45
+ rake (0.9.2.2)
46
+ rest-client (1.6.7)
47
+ mime-types (>= 1.16)
48
+ signet (0.3.2)
49
+ addressable (~> 2.2.3)
50
+ faraday (~> 0.7.0)
51
+ jwt (>= 0.1.4)
52
+ multi_json (>= 1.0.0)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ CalMon!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Randy Wallace
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
File without changes
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc "test"
4
+ task :update do
5
+ system "git submodule update"
6
+ end
@@ -0,0 +1 @@
1
+ #!/bin/bash
@@ -0,0 +1,47 @@
1
+ // depends on http://software.dzhuvinov.com/download.html#download-jsonrpc2base and the client
2
+ import com.thetransactioncompany.jsonrpc2.client.*;
3
+ import com.thetransactioncompany.jsonrpc2.*;
4
+ import java.net.*;
5
+ import java.util.*;
6
+
7
+ public class JsonRPC {
8
+
9
+ public static void main(String[] args) {
10
+
11
+ URL serverURL = null;
12
+
13
+ try {
14
+ serverURL = new URL("http://127.0.0.1:8999");
15
+
16
+ } catch (MalformedURLException e) {
17
+ System.err.println(e.getMessage());
18
+ }
19
+
20
+ JSONRPC2Session mySession = new JSONRPC2Session(serverURL);
21
+
22
+ mySession.getOptions().setRequestContentType("text/html");
23
+ mySession.getOptions().setAllowedResponseContentTypes(new String[]{"text/html"});
24
+
25
+ List params = new ArrayList<Integer>();
26
+ params.add(1);
27
+ params.add(2);
28
+ params.add(3);
29
+
30
+ JSONRPC2Request request = new JSONRPC2Request("sum", params, 0);
31
+
32
+ JSONRPC2Response response = null;
33
+
34
+ try {
35
+ response = mySession.send(request);
36
+ } catch (JSONRPC2SessionException e) {
37
+ System.err.println(e.getMessage());
38
+ }
39
+
40
+ if (response.indicatesSuccess())
41
+ System.out.println(response.getResult());
42
+ else
43
+ System.out.println(response.getError().getMessage());
44
+
45
+ }
46
+ }
47
+
@@ -0,0 +1,61 @@
1
+ #!/bin/bash
2
+ #
3
+ # An example script on how to use netcat (nc) for those very
4
+ # old CentOS servers you don't want to install rvm/ruby/gems on...
5
+ #
6
+
7
+ DATE=$(date +'%Y-%m-%d %H:%M:%S')
8
+ l_info() { echo ${DATE} "INFO: $*"; }
9
+ l_debug() { echo ${DATE} "DEBUG: $*"; }
10
+ l_warn() { echo ${DATE} "WARN: $*"; }
11
+
12
+ HOST="localhost"
13
+ POST_URL="/RPC"
14
+ PORT="8999"
15
+ USER_AGENT="nc"
16
+
17
+ gen_json_req() {
18
+ METHOD=${1}
19
+ shift
20
+ PARAMS=$(echo $* | sed -e 's/ /,/g')
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
+ ]
29
+ EOF
30
+ )
31
+ }
32
+
33
+ gen_json_req sum 1 2 3
34
+
35
+ BODY=${REPLY}
36
+
37
+ SIZE=$(echo ${BODY} | wc -c)
38
+
39
+ MSG=$(cat <<EOF
40
+ POST ${POST_URL} HTTP/1.1
41
+ User-Agent: ${USER_AGENT}
42
+ Host: ${HOST}
43
+ Content-Type: text/json
44
+ Content-length: $(echo ${SIZE})
45
+
46
+ ${BODY}
47
+ EOF
48
+ )
49
+
50
+ l_debug "${MSG}" && echo
51
+ l_debug Sending Message to ${HOST}:${PORT}
52
+
53
+ RES=$(echo "${MSG}" | nc ${HOST} ${PORT} | grep 'jsonrpc')
54
+
55
+
56
+ echo "$RES" | $(dirname $0)/../support/JSON_bash/JSON.sh
57
+
58
+ if [[ $? -eq 0 ]]; then
59
+ echo; l_info Message successfully sent to ${HOST}:${PORT}
60
+ fi
61
+
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.dirname(__FILE__)
4
+
5
+ require "CalMon/version"
6
+
7
+ module CalMon
8
+
9
+ end
10
+
11
+ require 'rubygems'
12
+
13
+ require 'jimson'
14
+
15
+ class Test
16
+ extend Jimson::Handler
17
+
18
+ def sum(a,b,c)
19
+ a + b + c
20
+ end
21
+
22
+ def sub(a,b)
23
+ a - b
24
+ end
25
+ end
26
+
27
+ server = Jimson::Server.new(Test.new)
28
+ server.start
@@ -0,0 +1,3 @@
1
+ module CalMon
2
+ VERSION = "0.0.2"
3
+ end
File without changes
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: CalMon
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Randy
14
+ - D.
15
+ - Wallace
16
+ - Jr.
17
+ autorequire:
18
+ bindir: bin
19
+ cert_chain: []
20
+
21
+ date: 2012-04-30 00:00:00 Z
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: rake
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 3
32
+ segments:
33
+ - 0
34
+ version: "0"
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: google-api-client
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: jimson
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ description: |
66
+ With a JSON-RPC server, client services via a myriad of language options,
67
+ including bash+nc, ruby, and java, send messages that ultimately are used
68
+ to create events in Google Calendar. These events may be used to easily
69
+ identify when an event (a Cron Job, batch script, etc...) started, stopped,
70
+ and what its exit status was. For an organization that relies heavily upon
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. }
73
+
74
+ email:
75
+ - randy@randywallace.com
76
+ executables: []
77
+
78
+ extensions: []
79
+
80
+ extra_rdoc_files: []
81
+
82
+ files:
83
+ - .gitignore
84
+ - .gitmodules
85
+ - .rvmrc
86
+ - CalMon.gemspec
87
+ - Gemfile
88
+ - Gemfile.lock
89
+ - LICENSE
90
+ - README.rst
91
+ - Rakefile
92
+ - bin/CalMon
93
+ - doc/JsonRPC.java
94
+ - doc/bash_only.sh
95
+ - lib/CalMon.rb
96
+ - lib/CalMon/version.rb
97
+ - test/test_CalMon.rb
98
+ homepage: ""
99
+ licenses:
100
+ - MIT
101
+ post_install_message:
102
+ rdoc_options: []
103
+
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ requirements: []
125
+
126
+ rubyforge_project: CalMon
127
+ rubygems_version: 1.8.10
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: Collect timestamp data from services and use that data to add events to google calendar.
131
+ test_files:
132
+ - test/test_CalMon.rb