Module: ZabbixRubyClient::Plugins::Nginx
Instance Method Summary
collapse
getline, getlines, httprequest, perform
Instance Method Details
#collect(*args) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/zabbix-ruby-client/plugins/nginx.rb', line 10
def collect(*args)
host = args[0]
info = get_status
time = Time.now.to_i
back = []
back << "#{host} nginx[total] #{time} #{info[:total]}"
back << "#{host} nginx[reading] #{time} #{info[:reading]}"
back << "#{host} nginx[writing] #{time} #{info[:writing]}"
back << "#{host} nginx[waiting] #{time} #{info[:waiting]}"
back << "#{host} nginx[accepted] #{time} #{info[:accepted]}"
back << "#{host} nginx[handled] #{time} #{info[:handled]}"
back << "#{host} nginx[requests] #{time} #{info[:requests]}"
return back
end
|
#get_status ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/zabbix-ruby-client/plugins/nginx.rb', line 26
def get_status
ret = {}
open "http://127.0.0.1:8090/nginx_status" do |f|
f.each_line do |line|
ret[:total] = $1 if line =~ /^Active connections:\s+(\d+)/
if line =~ /^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/
ret[:reading] = $1
ret[:writing] = $2
ret[:waiting] = $3
end
ret[:accepted], ret[:handled], ret[:requests] = [$1, $2, $3] if line =~ /^\s+(\d+)\s+(\d+)\s+(\d+)/
end
end
ret
end
|