asakra 0.0.4-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.idea/asakra.iml +89 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/asakra.gemspec +24 -0
- data/bin/asakra +10 -0
- data/esper/antlr-runtime-3.2.jar +0 -0
- data/esper/cglib-nodep-2.2.jar +0 -0
- data/esper/commons-logging-1.1.1.jar +0 -0
- data/esper/esper-4.5.0.jar +0 -0
- data/lib/asakra.rb +5 -0
- data/lib/asakra/batch.rb +34 -0
- data/lib/asakra/each.rb +31 -0
- data/lib/asakra/for-fluentd.log +58 -0
- data/lib/asakra/judge.rb +60 -0
- data/lib/asakra/log_for_fluentd.rb +14 -0
- data/lib/asakra/plugin_accessor.rb +44 -0
- data/lib/asakra/version.rb +3 -0
- data/setting/agents.txt +3 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3f5c1dbc2fae67bd41e2fef8a1e1d75f588f5ba1
|
4
|
+
data.tar.gz: 910208c464e5a8f2fa7b69c29f965a309cf82e1e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 59b0f0bb583c75bfb128af79271452f21b94ec43f59962ce177f41cb78c34e61d5017a16f263e7293313a41bdd56f36091c1c2c63243c46a5c0cff9204e0373f
|
7
|
+
data.tar.gz: 0b8e8e90ab83f5e674690c086fb387b3708cdf1cea860958b4642584121125cca98be3902b208ba45ab4185d251f70b779adf794d3a18c183e3b716fa5ad2ef5
|
data/.gitignore
ADDED
data/.idea/asakra.iml
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="CompassSettings">
|
4
|
+
<option name="compassSupportEnabled" value="true" />
|
5
|
+
</component>
|
6
|
+
<component name="FacetManager">
|
7
|
+
<facet type="gem" name="Ruby Gem">
|
8
|
+
<configuration>
|
9
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
10
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
11
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
12
|
+
</configuration>
|
13
|
+
</facet>
|
14
|
+
</component>
|
15
|
+
<component name="ModuleRunConfigurationManager">
|
16
|
+
<configuration default="false" name="asakra" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
|
17
|
+
<module name="asakra" />
|
18
|
+
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
19
|
+
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/bin" />
|
20
|
+
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
|
21
|
+
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
|
22
|
+
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
|
23
|
+
<envs />
|
24
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
25
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
26
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
27
|
+
<COVERAGE_PATTERN ENABLED="true">
|
28
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
29
|
+
</COVERAGE_PATTERN>
|
30
|
+
</EXTENSION>
|
31
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
32
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/bin/asakra" />
|
33
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
|
34
|
+
<RunnerSettings RunnerId="RubyRunner" />
|
35
|
+
<ConfigurationWrapper RunnerId="RubyRunner" />
|
36
|
+
<method />
|
37
|
+
</configuration>
|
38
|
+
<configuration default="false" name="judge" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
|
39
|
+
<module name="asakra" />
|
40
|
+
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
41
|
+
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/lib/asakra" />
|
42
|
+
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
|
43
|
+
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
|
44
|
+
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
|
45
|
+
<envs />
|
46
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
|
47
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
48
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
49
|
+
<COVERAGE_PATTERN ENABLED="true">
|
50
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
51
|
+
</COVERAGE_PATTERN>
|
52
|
+
</EXTENSION>
|
53
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
54
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/lib/asakra/judge.rb" />
|
55
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
|
56
|
+
<RunnerSettings RunnerId="RubyRunner" />
|
57
|
+
<ConfigurationWrapper RunnerId="RubyRunner" />
|
58
|
+
<method />
|
59
|
+
</configuration>
|
60
|
+
<configuration default="false" name="batch" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
|
61
|
+
<module name="asakra" />
|
62
|
+
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
63
|
+
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/lib/asakra" />
|
64
|
+
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
|
65
|
+
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
|
66
|
+
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
|
67
|
+
<envs />
|
68
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
|
69
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
70
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
71
|
+
<COVERAGE_PATTERN ENABLED="true">
|
72
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
73
|
+
</COVERAGE_PATTERN>
|
74
|
+
</EXTENSION>
|
75
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
76
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/lib/asakra/batch.rb" />
|
77
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
|
78
|
+
<RunnerSettings RunnerId="RubyRunner" />
|
79
|
+
<ConfigurationWrapper RunnerId="RubyRunner" />
|
80
|
+
<method />
|
81
|
+
</configuration>
|
82
|
+
</component>
|
83
|
+
<component name="NewModuleRootManager">
|
84
|
+
<content url="file://$MODULE_DIR$" />
|
85
|
+
<orderEntry type="jdk" jdkName="rbenv: jruby-1.7.9" jdkType="JRUBY_SDK" />
|
86
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
87
|
+
</component>
|
88
|
+
</module>
|
89
|
+
|
data/.idea/encodings.xml
ADDED
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
data/.idea/vcs.xml
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/asakra.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "asakra/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "asakra"
|
7
|
+
s.version = Asakra::VERSION
|
8
|
+
s.authors = ["RittaNarita"]
|
9
|
+
s.email = ["narittan@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{monitoring tool for fluentd itself with Esper and JRuby}
|
12
|
+
s.description = %q{monitoring tool for fluentd itself with Esper EPL qeury language,}
|
13
|
+
s.license = "GPLv2"
|
14
|
+
s.platform = "java"
|
15
|
+
|
16
|
+
s.rubyforge_project = "asakra"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib", "esper"]
|
22
|
+
|
23
|
+
s.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
end
|
data/bin/asakra
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/asakra.rb
ADDED
data/lib/asakra/batch.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'thread'
|
2
|
+
require 'asakra/each'
|
3
|
+
require 'asakra/judge'
|
4
|
+
|
5
|
+
module Asakra
|
6
|
+
class Batch
|
7
|
+
def start
|
8
|
+
agentsFile = open("setting/agents.txt")
|
9
|
+
agentsList = []
|
10
|
+
agentsFile.each {|e|
|
11
|
+
agentsList.push(e)
|
12
|
+
}
|
13
|
+
|
14
|
+
myListener = Asakra::MyListener.new()
|
15
|
+
judge = Asakra::Judge.new(myListener)
|
16
|
+
judge.setting
|
17
|
+
|
18
|
+
m = Mutex.new
|
19
|
+
ts = []
|
20
|
+
ts << Thread.start {
|
21
|
+
m.synchronize {
|
22
|
+
for e in agentsList
|
23
|
+
each = Asakra::Each.new(e, judge)
|
24
|
+
each.run
|
25
|
+
sleep rand * 0.1
|
26
|
+
end
|
27
|
+
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
ts.each {|t| t.join }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/asakra/each.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
require 'asakra/plugin_accessor'
|
3
|
+
require 'asakra/log_for_fluentd'
|
4
|
+
|
5
|
+
module Asakra
|
6
|
+
class Each
|
7
|
+
|
8
|
+
def initialize(hostname, judge)
|
9
|
+
@hostname = hostname
|
10
|
+
@judge = judge
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
# 1.get metrics every host
|
15
|
+
# 2.output json for fluentd tail-input
|
16
|
+
# 3.judge each host's statement with esper
|
17
|
+
|
18
|
+
# 1.get metrics
|
19
|
+
plugin = Asakra::PluginAccessor.new()
|
20
|
+
metrics = plugin.getHash(@hostname)
|
21
|
+
|
22
|
+
# 2. output json
|
23
|
+
log = Asakra::FileLogger.new()
|
24
|
+
log.run(metrics)
|
25
|
+
|
26
|
+
# 3.judge with esper
|
27
|
+
# jugde.getEPSeatvice
|
28
|
+
@judge.send(metrics)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Logfile created on 2014-09-23 01:17:55 +0900 by logger.rb/v1.2.7
|
2
|
+
I, [2014-09-23T01:17:55.208000 #20167] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>11}
|
3
|
+
I, [2014-09-23T01:17:55.241000 #20167] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>5}
|
4
|
+
I, [2014-09-23T01:17:55.307000 #20167] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>6}
|
5
|
+
I, [2014-09-23T01:19:14.749000 #20185] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>3}
|
6
|
+
I, [2014-09-23T01:19:14.826000 #20185] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>4}
|
7
|
+
I, [2014-09-23T01:19:14.906000 #20185] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>5}
|
8
|
+
I, [2014-09-23T01:20:01.266000 #20187] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>6}
|
9
|
+
I, [2014-09-23T01:20:01.300000 #20187] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>10}
|
10
|
+
I, [2014-09-23T01:20:01.348000 #20187] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>0}
|
11
|
+
I, [2014-09-23T09:43:22.874000 #21940] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>8}
|
12
|
+
I, [2014-09-23T09:43:22.891000 #21940] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>5}
|
13
|
+
I, [2014-09-23T09:43:22.900000 #21940] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>12}
|
14
|
+
I, [2014-09-23T12:29:53.503000 #24503] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>11}
|
15
|
+
I, [2014-09-23T12:29:53.582000 #24503] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>14}
|
16
|
+
I, [2014-09-23T12:29:53.656000 #24503] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>8}
|
17
|
+
I, [2014-09-23T12:33:01.376000 #24548] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>1}
|
18
|
+
I, [2014-09-23T12:33:01.476000 #24548] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>4}
|
19
|
+
I, [2014-09-23T12:33:01.554000 #24548] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>10}
|
20
|
+
I, [2014-09-23T12:33:14.252000 #24572] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>0}
|
21
|
+
I, [2014-09-23T12:33:14.340000 #24572] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>8}
|
22
|
+
I, [2014-09-23T12:33:14.399000 #24572] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>1}
|
23
|
+
I, [2014-09-23T12:34:17.404000 #24600] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>10}
|
24
|
+
I, [2014-09-23T12:34:17.507000 #24600] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>2}
|
25
|
+
I, [2014-09-23T12:34:17.611000 #24600] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>7}
|
26
|
+
I, [2014-09-23T12:34:45.462000 #24623] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>6}
|
27
|
+
I, [2014-09-23T12:34:45.501000 #24623] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>0}
|
28
|
+
I, [2014-09-23T12:34:45.518000 #24623] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>6}
|
29
|
+
I, [2014-09-23T12:34:56.607000 #24645] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>12}
|
30
|
+
I, [2014-09-23T12:34:56.716000 #24645] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>12}
|
31
|
+
I, [2014-09-23T12:34:56.812000 #24645] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>13}
|
32
|
+
I, [2014-09-23T12:39:34.253000 #24689] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>13}
|
33
|
+
I, [2014-09-23T12:39:34.310000 #24689] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>9}
|
34
|
+
I, [2014-09-23T12:39:34.388000 #24689] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>10}
|
35
|
+
I, [2014-09-23T12:43:49.436000 #24725] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>0}
|
36
|
+
I, [2014-09-23T12:43:49.501000 #24725] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>12}
|
37
|
+
I, [2014-09-23T12:43:49.573000 #24725] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>3}
|
38
|
+
I, [2014-09-23T12:49:10.484000 #24779] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>11}
|
39
|
+
I, [2014-09-23T12:49:10.523000 #24779] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>0}
|
40
|
+
I, [2014-09-23T12:49:10.560000 #24779] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>9}
|
41
|
+
I, [2014-09-23T12:55:05.201000 #24842] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>6}
|
42
|
+
I, [2014-09-23T12:55:05.276000 #24842] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>5}
|
43
|
+
I, [2014-09-23T12:55:05.336000 #24842] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>2}
|
44
|
+
I, [2014-09-23T12:55:50.233000 #24867] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>14}
|
45
|
+
I, [2014-09-23T12:55:50.259000 #24867] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>14}
|
46
|
+
I, [2014-09-23T12:55:50.354000 #24867] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>2}
|
47
|
+
I, [2014-09-23T12:56:18.149000 #24897] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>14}
|
48
|
+
I, [2014-09-23T12:56:18.190000 #24897] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>0}
|
49
|
+
I, [2014-09-23T12:56:18.255000 #24897] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>1}
|
50
|
+
I, [2014-09-23T12:56:22.035000 #24917] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>2}
|
51
|
+
I, [2014-09-23T12:56:22.055000 #24917] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>13}
|
52
|
+
I, [2014-09-23T12:56:22.066000 #24917] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>8}
|
53
|
+
I, [2014-09-23T13:06:02.684000 #25324] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>13}
|
54
|
+
I, [2014-09-23T13:06:02.742000 #25324] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>0}
|
55
|
+
I, [2014-09-23T13:06:02.772000 #25324] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>11}
|
56
|
+
I, [2014-09-23T13:28:59.043000 #26943] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>13}
|
57
|
+
I, [2014-09-23T13:28:59.108000 #26943] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>8}
|
58
|
+
I, [2014-09-23T13:28:59.209000 #26943] INFO -- : {"pluginId"=>"plugin01", "retryCount"=>9}
|
data/lib/asakra/judge.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'java'
|
2
|
+
require 'esper-4.5.0.jar'
|
3
|
+
require 'esper/commons-logging-1.1.1.jar'
|
4
|
+
require 'esper/antlr-runtime-3.2.jar'
|
5
|
+
require 'esper/cglib-nodep-2.2.jar'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
module Asakra
|
9
|
+
# Create a listener object when matched
|
10
|
+
class MyListener
|
11
|
+
include com.espertech.esper.client.UpdateListener
|
12
|
+
|
13
|
+
def update(newEvents, oldEvents)
|
14
|
+
puts "matched: "
|
15
|
+
newEvents.each do |event|
|
16
|
+
puts "- " + event.getUnderlying.inspect
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Judge
|
22
|
+
|
23
|
+
def initialize(listener)
|
24
|
+
@listener = listener
|
25
|
+
@ep_service = com.espertech.esper.client.EPServiceProviderManager.getDefaultProvider
|
26
|
+
end
|
27
|
+
|
28
|
+
def setting
|
29
|
+
# And the configuration
|
30
|
+
ep_config = @ep_service.getEPAdministrator.getConfiguration
|
31
|
+
|
32
|
+
# event(POJO when using java)
|
33
|
+
# Prepare the OrderEvent type
|
34
|
+
order_event_type = {
|
35
|
+
"pluginId" => "string",
|
36
|
+
"retryCount" => "double"
|
37
|
+
}
|
38
|
+
ep_config.addEventType("OrderEvent", order_event_type)
|
39
|
+
|
40
|
+
# EPLの設定
|
41
|
+
# Create EPL expression
|
42
|
+
# expression = "select * from OrderEvent where cast(retryCount,double) > 1"
|
43
|
+
expression = "select * from OrderEvent where cast(retryCount,double) > 1"
|
44
|
+
#expression = "select avg(price) from OrderEvent"
|
45
|
+
statement = @ep_service.getEPAdministrator.createEPL(expression)
|
46
|
+
|
47
|
+
# Register listener to statement
|
48
|
+
# listener = Asakra::MyListener.new
|
49
|
+
statement.addListener(@listener)
|
50
|
+
end
|
51
|
+
|
52
|
+
def send(metrics)
|
53
|
+
|
54
|
+
# send event to listner
|
55
|
+
epr_runtime = @ep_service.getEPRuntime
|
56
|
+
epr_runtime.sendEvent(metrics, "OrderEvent")
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Asakra
|
4
|
+
# output into log file for fluentd tail-input plugin
|
5
|
+
class FileLogger
|
6
|
+
def run(mes)
|
7
|
+
log = Logger.new("for-fluentd.log")
|
8
|
+
|
9
|
+
# log.debug(mes)
|
10
|
+
log.info(mes)
|
11
|
+
# log.warn("This is warning message")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Asakra
|
6
|
+
class PluginAccessor
|
7
|
+
|
8
|
+
def getHash(hostname)
|
9
|
+
hash = {"pluginId"=>"plugin01",
|
10
|
+
"retryCount"=>rand(15)}
|
11
|
+
|
12
|
+
return hash
|
13
|
+
end
|
14
|
+
|
15
|
+
def getHash_test(hostname, limit = 10)
|
16
|
+
raise ArgumentError, 'too many HTTP redirects' if limit == 0
|
17
|
+
#confirm uri
|
18
|
+
location = "http://"+hostname+":24220/api/json"
|
19
|
+
uri = URI.parse(location)
|
20
|
+
begin
|
21
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
22
|
+
http.open_timeout = 5
|
23
|
+
http.read_timeout = 10
|
24
|
+
http.get(uri.request_uri)
|
25
|
+
end
|
26
|
+
case response
|
27
|
+
when Net::HTTPSuccess
|
28
|
+
json = response.body
|
29
|
+
JSON.parse(json)
|
30
|
+
when Net::HTTPRedirection
|
31
|
+
location = response['location']
|
32
|
+
warn "redirected to #{location}"
|
33
|
+
get_json(location, limit - 1)
|
34
|
+
else
|
35
|
+
puts [uri.to_s, response.value].join(" : ")
|
36
|
+
# handle error
|
37
|
+
end
|
38
|
+
rescue => e
|
39
|
+
puts [uri.to_s, e.class, e].join(" : ")
|
40
|
+
# handle error
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/setting/agents.txt
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: asakra
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- RittaNarita
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '1.3'
|
25
|
+
prerelease: false
|
26
|
+
type: :development
|
27
|
+
description: monitoring tool for fluentd itself with Esper EPL qeury language,
|
28
|
+
email:
|
29
|
+
- narittan@gmail.com
|
30
|
+
executables:
|
31
|
+
- asakra
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- .idea/asakra.iml
|
37
|
+
- .idea/encodings.xml
|
38
|
+
- .idea/misc.xml
|
39
|
+
- .idea/modules.xml
|
40
|
+
- .idea/scopes/scope_settings.xml
|
41
|
+
- .idea/vcs.xml
|
42
|
+
- Gemfile
|
43
|
+
- Rakefile
|
44
|
+
- asakra.gemspec
|
45
|
+
- bin/asakra
|
46
|
+
- esper/antlr-runtime-3.2.jar
|
47
|
+
- esper/cglib-nodep-2.2.jar
|
48
|
+
- esper/commons-logging-1.1.1.jar
|
49
|
+
- esper/esper-4.5.0.jar
|
50
|
+
- lib/asakra.rb
|
51
|
+
- lib/asakra/batch.rb
|
52
|
+
- lib/asakra/each.rb
|
53
|
+
- lib/asakra/for-fluentd.log
|
54
|
+
- lib/asakra/judge.rb
|
55
|
+
- lib/asakra/log_for_fluentd.rb
|
56
|
+
- lib/asakra/plugin_accessor.rb
|
57
|
+
- lib/asakra/version.rb
|
58
|
+
- setting/agents.txt
|
59
|
+
homepage: ''
|
60
|
+
licenses:
|
61
|
+
- GPLv2
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
- esper
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project: asakra
|
80
|
+
rubygems_version: 2.1.9
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: monitoring tool for fluentd itself with Esper and JRuby
|
84
|
+
test_files: []
|