[Groonga-commit] groonga/groonga at 5dccbde [master] munin: support HTTP protocol

Back to archive index

HAYASHI Kentaro null+****@clear*****
Thu Dec 26 13:36:14 JST 2013


HAYASHI Kentaro	2013-12-26 13:36:14 +0900 (Thu, 26 Dec 2013)

  New Revision: 5dccbde83bd52e3d4eacae907a296ca5457f7052
  https://github.com/groonga/groonga/commit/5dccbde83bd52e3d4eacae907a296ca5457f7052

  Message:
    munin: support HTTP protocol

  Modified files:
    data/munin/groonga_status

  Modified: data/munin/groonga_status (+13 -3)
===================================================================
--- data/munin/groonga_status    2013-12-26 12:38:38 +0900 (1a7bb11)
+++ data/munin/groonga_status    2013-12-26 13:36:14 +0900 (e9daee9)
@@ -3,6 +3,7 @@
 #%# family=auto
 #%# capabilities=autoconf
 
+require 'net/http'
 begin
   require 'json'
 rescue LoadError
@@ -13,6 +14,7 @@ end
 label = ENV["label"]
 @groonga = ENV["groonga"] || "groonga"
 @host = ENV["host"] || "localhost"
+ �� protocol = ENV["protocol"] || "http"
 @port = ENV["port"] || 10041
 
 command = ARGV.shift
@@ -36,9 +38,17 @@ def parse(success, result)
 end
 
 def run(command, *args)
-  groonga = "#{@groonga} -p #{@port} -c #{@host}"
-  result = `#{groonga} #{command} #{args.join(' ')} 2>&1`
-  parse($?.success?, result)
+  case @protocol
+  when "gqtp"
+    groonga = "#{@groonga} -p #{@port} -c #{@host}"
+    result = `#{groonga} #{command} #{args.join(' ')} 2>&1`
+    parse($?.success?, result)
+  when "http"
+    Net::HTTP.start(@host, @port) do |http|
+      result = http.get("/d/#{command}")
+    end
+    parse(result.code == "200", result.body)
+  end
 end
 
 def parse_list(header, list)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index