dns_one 0.4.36 → 0.4.37

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: ee8de62e1bba4beb93662df0810aa494f48094da
4
- data.tar.gz: da8932c29eff61baa88bd3d938233aa8e515866b
3
+ metadata.gz: c2fc5f20cb89e4598dafa6f6629380674f751cb9
4
+ data.tar.gz: b607a3f8d376cd5f72c3f7a3fa19e7a8fa7efb18
5
5
  SHA512:
6
- metadata.gz: 460098f009765a754856ab187c5db919a1b6806064d8e3da71302603919f5b8b7a375d8574401efc6bbb94b87d3f055ddaea34341640656664d6d9dd07c8a6ae
7
- data.tar.gz: d82e6e8c62d83bf6a63b6077d27a52b8dd64c2611dfd6b2a363084267ed444f18d118d0490a70828c199e34f50f438584abf1bc82c5df603d0b473329522611e
6
+ metadata.gz: bd0c5a0208678999846c0832902699825e82e8bc9cfb301e8fbb2610f472b4bbf52462ca1714121e80b7833fefc1f19b3217660b6bc0f0457bd725e584002f2e
7
+ data.tar.gz: 0073ae574a4db7381f79bb11840924044f9b189dad97e775121bd5fec7ff52b91330aa6658d1a1aba6a594cb75d9cb34bef640dfedfb16b58d1f3f6c1ebb32bb
@@ -1,3 +1,3 @@
1
1
  module DnsOne
2
- VERSION = "0.4.36"
2
+ VERSION = "0.4.37"
3
3
  end
data/util/dnsone_munin_ CHANGED
@@ -19,20 +19,29 @@ class MuninDnsOne
19
19
 
20
20
  GRAPHS = {
21
21
  rcode: {
22
- vlabel: 'Return Code count',
23
- fields: %w(not_imp refused yx_domain yxrr_set nxrr_set not_auth not_zone badvers no_error badsig badkey badtime badmode nx_domain badalg badname form_err serv_fail)
22
+ percent: true,
23
+ vlabel: '%',
24
+ fields: %w(not_imp refused yx_domain yxrr_set nxrr_set not_auth not_zone badvers no_error badsig badkey badtime badmode nx_domain badalg badname form_err serv_fail).sort
24
25
  },
25
26
  req_resource: {
26
- vlabel: 'Request resource count',
27
+ percent: true,
28
+ vlabel: '%',
27
29
  fields: %w(a aaaa any cname hinfo minfo mx ns ptr soa txt wks)
28
30
  },
29
31
  cache: {
30
- vlabel: 'count',
32
+ percent: true,
33
+ vlabel: '%',
31
34
  fields: {
32
35
  hit: 'Domain found in cache.',
33
36
  miss: 'Domain not found in cache, requiring a backend access.',
34
37
  },
35
38
  },
39
+ requests: {
40
+ vlabel: 'count',
41
+ fields: {
42
+ requests: 'requests',
43
+ },
44
+ }
36
45
  }
37
46
 
38
47
  def initialize argv
@@ -58,29 +67,49 @@ class MuninDnsOne
58
67
  GRAPHS[@param.graph]
59
68
  end
60
69
 
70
+ def fields
71
+ if graph[:fields].is_a? Hash
72
+ graph[:fields]
73
+ else
74
+ _fields = {}
75
+ graph[:fields].each do |field|
76
+ _fields[field.to_sym] = field
77
+ end
78
+ _fields
79
+ end
80
+ end
81
+
61
82
  def config
62
83
  puts <<-CONFIG
63
- graph_category Passenger
84
+ graph_category DnsOne
64
85
  graph_title #{@param.graph}
65
86
  graph_vlabel #{graph[:vlabel]}
66
87
  graph_args --base 1000 -l 0
67
- graph_info GI
68
88
 
69
89
  CONFIG
70
90
 
71
- graph[:fields].each do |f|
72
- k = Array === f ? f[0] : f
73
- v = Array === f ? f[1] : f
74
- puts "#{k}.label #{v}"
91
+ fields.each_pair do |k, v|
92
+ puts "#{k}.label #{k}"
75
93
  end
76
94
 
77
95
  exit 0
78
96
  end
79
97
 
80
98
  def run
81
- get_stats[@param.graph.to_s].each_pair do |k, v|
82
- puts "#{k}.value #{v}"
99
+ stats = get_stats[@param.graph.to_s]
100
+
101
+ if graph[:percent]
102
+ sum = stats.values.reduce(:+).to_f
103
+ end
104
+
105
+ fields.keys.each do |k|
106
+ value = stats[k] || 0.0
107
+ if graph[:percent]
108
+ value *= 100 / sum
109
+ end
110
+ puts "#{k}.value #{ value }"
83
111
  end
112
+
84
113
  exit 0
85
114
  end
86
115
 
@@ -113,20 +142,27 @@ CONFIG
113
142
  def fetch_stats
114
143
  stat = {}
115
144
  section = nil
145
+
116
146
  `dns_one stats`.each_line do |l|
117
147
  if l =~ /---\s*(\S+)\s*---/
118
148
  section = $1
119
149
  elsif l =~ /^(.*?)\s+(.*)$/
120
150
  key = $1.to_sym
121
- val = $2.strip
151
+ val = $2.strip.to_f
122
152
  stat[section] ||= {}
123
153
  stat[section][key] = val
124
154
  end
125
155
  end
156
+
157
+ stat["requests"] = {
158
+ requests: stat["cache"].values.reduce(:+).to_i
159
+ }
160
+
126
161
  stat
127
162
  end
128
163
 
129
164
  def install
165
+ # Links
130
166
  links = []
131
167
  GRAPHS.keys.each do |graph_key|
132
168
  links << graph_key
@@ -135,6 +171,10 @@ CONFIG
135
171
  links.each do |link|
136
172
  system "ln -s #{target} /etc/munin/plugins/dnsone_#{link}"
137
173
  end
174
+
175
+ # munin_node_conf
176
+ munin_node_conf = "[dnsone_*]\nuser root\n\n"
177
+ File.open('/etc/munin/plugin-conf.d/munin-node', 'a').write munin_node_conf
138
178
  end
139
179
 
140
180
  def error msg
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dns_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.36
4
+ version: 0.4.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Lobato
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-17 00:00:00.000000000 Z
11
+ date: 2018-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler