gri 10.0.5 → 10.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18b74441643b4d4919d26663b826f09ed5e79342
4
- data.tar.gz: eecd64dcd712c1f52a9bbfc7ff7b4c21a32557ad
3
+ metadata.gz: 3e8b36dc97ced45aa0de1a72697dcd52ff48e555
4
+ data.tar.gz: d0b0fbdab14c4dcd5fc35b6c079d1ddd371a8bde
5
5
  SHA512:
6
- metadata.gz: 6399065907869a2d48bac6d93dbf7b43f34782278a41b8f716d2599a84711b3c6fe852660d0dc78375dbaec570ab186b31dffcbb1adf1100e39d9ba365aacdca
7
- data.tar.gz: 2efbd5d418c136348a4344dff121a4d2cd3d45e1cc215c455dc99efa9ba8cb5a72dd786689bca9c9a3c38771d9f8e731aa8a197ed0b2da828b988eecae549dda
6
+ metadata.gz: b0cee0365f9753f8792bd614d5e591af2ef0dc49440e3392c4d652541c8de4bd5b63fd4a4a196a40c21e12027b8c9542a1dcdd0dd50b7492263cc82fd37a98f5
7
+ data.tar.gz: 0a22e850b4dbe14f60a76edbadfebffadf929acc5f1ef7796cedcd4331a17ef994688dbf9d5512e6b9066d507fa6f3055bd9d5311c0972ac1d07866bb0970891
data/.drone.yml CHANGED
@@ -1,7 +1,8 @@
1
- image: bradrydzewski/ruby:2.0.0
1
+ image: drone:gri
2
2
  env:
3
3
  - TZ=Asia/Tokyo
4
+ - HOME=/
4
5
  script:
5
- - sudo apt-get install rrdtool
6
+ - source /etc/profile.d/rbenv.sh; rbenv global 2.1
6
7
  - bundle install
7
8
  - bundle exec rake test
data/README.md CHANGED
@@ -130,3 +130,11 @@ font DEFAULT:0:IPAPGothic
130
130
  * option-if-host *PAT* *option*
131
131
 
132
132
  Option to be added to the default when the host name matches PAT (regexp). Multiple options can be specified.
133
+
134
+ ### Operations
135
+
136
+ * trad: in-service acl-permit update
137
+ * send SIGUSR1 to trad
138
+ * trad: graceful shutdown
139
+ * send SIGWINCH to trad
140
+
@@ -25,17 +25,17 @@ module Fluent
25
25
  class GriOutput < BufferedOutput
26
26
  Plugin.register_output('gri', self)
27
27
 
28
- config_param :gra_dir, :string, :default=>'/usr/local/gri/gra'
29
-
30
- def configure conf
31
- super
32
- end
28
+ config_param :config_path, :string, :default=>'/usr/local/gri/gri.conf'
29
+ config_param :gra_dir, :string, :default=>nil
33
30
 
34
31
  def start
35
32
  super
36
33
  #::Log.init '/tmp/fluent.log'
37
- GRI::Plugin.load_plugins []
38
- GRI::Config.init
34
+ GRI::Config.init @config_path
35
+ root_dir = GRI::Config['root-dir'] ||= GRI::Config::ROOT_PATH
36
+ plugin_dirs = GRI::Config.getvar('plugin-dir') || [root_dir + '/plugin']
37
+ GRI::Plugin.load_plugins plugin_dirs
38
+ @gra_dir ||= GRI::Config['gra-dir'] || root_dir + '/gra'
39
39
  end
40
40
 
41
41
  def format tag, time, record
@@ -17,6 +17,7 @@ module GRI
17
17
  acls.push(/^127\.0\.0\.1$/)
18
18
  acls.push(/^::ffff:127\.0\.0\.1$/)
19
19
  acls.push(/^::1$/)
20
+ puts "acls: #{acls.join(',')}" if $debug
20
21
  acls
21
22
  end
22
23
 
@@ -79,6 +80,7 @@ module GRI
79
80
  end
80
81
 
81
82
  def run options={}
83
+ status = :init
82
84
  optparser = optparse options
83
85
  optparser.parse!
84
86
  Process.daemon true if options[:daemonize] and !$debug
@@ -91,12 +93,30 @@ module GRI
91
93
  Dir.mkdir log_dir unless File.exist? log_dir
92
94
  Log.init "#{log_dir}/#{optparser.program_name}.log"
93
95
 
96
+ Signal.trap(:USR1){
97
+ Log.info "reloading acls"
98
+ config = GRI::Config.init config_path
99
+ @acls = load_acls config
100
+ }
101
+
102
+ Signal.trap(:WINCH){
103
+ Log.info "going to shutdown"
104
+ status = :shutdown
105
+ }
106
+
94
107
  bind_address = options[:bind_address] || '0.0.0.0'
95
108
  port = options[:port] || 7079
96
109
  server_sock = TCPServer.new bind_address, port
97
110
  rs0 = [server_sock]
98
111
  params = {}
99
- while true
112
+ status = :start
113
+ while status != :stop
114
+ if status == :shutdown and rs0.size == 1 and rs0[0].kind_of?(TCPServer)
115
+ Log.info "shutting down"
116
+ server_sock.close
117
+ status = :stop
118
+ next
119
+ end
100
120
  next unless (a = IO.select(rs0, nil, nil, 1))
101
121
  rs, = a
102
122
  for io in rs
@@ -105,7 +125,11 @@ module GRI
105
125
  sock = server_sock.accept
106
126
  peername = sock.peeraddr[2]
107
127
  peeraddr = sock.peeraddr[3]
108
- if allowed?(@acls, peeraddr)
128
+ if status == :shutdown
129
+ sock.close
130
+ Log.info "#{peeraddr}: reject due to shutting down"
131
+ next
132
+ elsif allowed?(@acls, peeraddr)
109
133
  puts "#{peeraddr}: accespt #{sock.object_id}" if $debug
110
134
  else
111
135
  sock.close
@@ -146,6 +170,9 @@ module GRI
146
170
  end
147
171
  end
148
172
  end
173
+
174
+ Log.info "stopped"
175
+ exit 0
149
176
  end
150
177
 
151
178
  def optparse opts
@@ -1,3 +1,3 @@
1
1
  module GRI
2
- VERSION = "10.0.5"
2
+ VERSION = "10.0.6"
3
3
  end
@@ -41,8 +41,10 @@ module GRI
41
41
  now = Time.now.to_i
42
42
  hrecords = {}
43
43
  updaters = {}
44
+ hosts = {}
44
45
  for record in records
45
46
  if (host = record['_host']) and (key = record['_key'])
47
+ hosts[host] = true
46
48
  if key == 'SYS'
47
49
  @sysinfos[host] = record
48
50
  else
@@ -77,6 +79,9 @@ module GRI
77
79
  Utils.update_ltsv_file path, '_key', h
78
80
  }
79
81
  updaters.each {|k, u| u.close}
82
+ hosts.each {|host,|
83
+ @sysinfos[host] ||= {'_host'=>host.dup, '_time'=>now, '_mtime'=>now}
84
+ }
80
85
  end
81
86
 
82
87
  def finalize
@@ -1,4 +1,4 @@
1
- FROM centos:centos6
1
+ FROM centos:centos7
2
2
 
3
3
  # cron
4
4
  RUN yum install -y cronie
@@ -10,24 +10,21 @@ RUN yum install -y httpd
10
10
  # ruby
11
11
  RUN yum install -y rubygems
12
12
  RUN gem install gri --no-ri --no-rdoc
13
- RUN cp /usr/bin/grapher /var/www/cgi-bin/
13
+ RUN cp /usr/local/bin/grapher /var/www/cgi-bin/
14
14
 
15
15
  # rrdtool
16
- RUN yum install -y wget cairo gettext pango tcp_wrappers-libs libdbi
17
- RUN yum install -y xorg-x11-fonts-Type1 ipa-gothic-fonts ipa-pgothic-fonts
18
- RUN (cd /tmp; wget http://pkgs.repoforge.org/rrdtool/rrdtool-1.4.7-1.el6.rfx.x86_64.rpm)
19
- RUN (cd /tmp; rpm --nodeps -i rrdtool-1.4.7-1.el6.rfx.x86_64.rpm)
16
+ RUN yum install -y rrdtool
20
17
 
21
18
  # admin
22
19
  RUN useradd -u 10000 admin
23
20
 
24
21
  # setup
25
22
  RUN mkdir -p /usr/local/gri; chown admin /usr/local/gri
26
- RUN echo '*/5 * * * * admin /usr/bin/gri' >>/etc/crontab
23
+ RUN echo '*/5 * * * * admin /usr/local/bin/gri' >>/etc/crontab
27
24
  RUN cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
25
+ RUN echo '/usr/sbin/crond&&/usr/sbin/httpd 2>/dev/null&&while true; do /bin/bash; done' > /tmp/boot.sh
26
+ CMD ["/bin/bash", "/tmp/boot.sh"]
28
27
 
29
- # sudo docker build -t gri -rm .
30
- # sudo docker run -p 10080:80 -v /somewhere/gri:/usr/local/gri:rw -i -t gri /bin/bash
31
- # bash# /etc/rc.d/init.d/crond start
32
- # bash# /etc/init.d/httpd start
33
- # bash# vi /usr/local/gri/gritab
28
+ # sudo docker build -t gri .
29
+ # sudo docker run -d -p 10080:80 -v /somewhere/gri:/usr/local/gri:rw -i -t gri
30
+ # vi /somewhere/gri/gritab
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gri
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.5
4
+ version: 10.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - maebashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack