Merge branch 'collectd-5.8'
[collectd.git] / src / collectd-snmp.pod
1 =encoding UTF-8
2
3 =head1 NAME
4
5 collectd-snmp - Documentation of collectd's C<snmp plugin>
6
7 =head1 SYNOPSIS
8
9   LoadPlugin snmp
10   # ...
11   <Plugin snmp>
12     <Data "powerplus_voltge_input">
13       Table false
14       Type "voltage"
15       TypeInstance "input_line1"
16       Scale 0.1
17       Values "SNMPv2-SMI::enterprises.6050.5.4.1.1.2.1"
18     </Data>
19     <Data "hr_users">
20       Table false
21       Type "users"
22       Shift -1
23       Values "HOST-RESOURCES-MIB::hrSystemNumUsers.0"
24     </Data>
25     <Data "std_traffic">
26       Table true
27       Type "if_octets"
28       TypeInstanceOID "IF-MIB::ifDescr"
29       #FilterOID "IF-MIB::ifOperStatus"
30       #FilterValues "1", "2"
31       Values "IF-MIB::ifInOctets" "IF-MIB::ifOutOctets"
32     </Data>
33
34     <Host "some.switch.mydomain.org">
35       Address "192.168.0.2"
36       Version 1
37       Community "community_string"
38       Collect "std_traffic"
39       Interval 120
40       Timeout 10
41       Retries 1
42     </Host>
43     <Host "some.server.mydomain.org">
44       Address "192.168.0.42"
45       Version 2
46       Community "another_string"
47       Collect "std_traffic" "hr_users"
48     </Host>
49     <Host "secure.router.mydomain.org">
50       Address "192.168.0.7:165"
51       Version 3
52       SecurityLevel "authPriv"
53       Username "cosmo"
54       AuthProtocol "SHA"
55       AuthPassphrase "setec_astronomy"
56       PrivacyProtocol "AES"
57       PrivacyPassphrase "too_many_secrets"
58       Collect "std_traffic"
59     </Host>
60     <Host "some.ups.mydomain.org">
61       Address "tcp:192.168.0.3"
62       Version 1
63       Community "more_communities"
64       Collect "powerplus_voltge_input"
65       Interval 300
66       Timeout 5
67       Retries 5
68     </Host>
69   </Plugin>
70
71 =head1 DESCRIPTION
72
73 The C<snmp plugin> queries other hosts using SNMP, the simple network
74 management protocol, and translates the value it receives to collectd's
75 internal format and dispatches them. Depending on the write plugins you have
76 loaded they may be written to disk or submitted to another instance or
77 whatever you configured.
78
79 Because querying a host via SNMP may produce a timeout multiple threads are
80 used to query hosts in parallel. Depending on the number of hosts between one
81 and ten threads are used.
82
83 =head1 CONFIGURATION
84
85 Since the aim of the C<snmp plugin> is to provide a generic interface to SNMP,
86 its configuration is not trivial and may take some time.
87
88 Since the C<Net-SNMP> library is used you can use all the environment variables
89 that are interpreted by that package. See L<snmpcmd(1)> for more details.
90
91 There are two types of blocks that can be contained in the
92 C<E<lt>PluginE<nbsp>snmpE<gt>> block: B<Data> and B<Host>:
93
94 =head2 The B<Data> block
95
96 The B<Data> block defines a list of values or a table of values that are to be
97 queried. The following options can be set:
98
99 =over 4
100
101 =item B<Type> I<type>
102
103 collectd's type that is to be used, e.E<nbsp>g. "if_octets" for interface
104 traffic or "users" for a user count. The types are read from the B<TypesDB>
105 (see L<collectd.conf(5)>), so you may want to check for which types are
106 defined. See L<types.db(5)> for a description of the format of this file.
107
108 =item B<Table> I<true|false>
109
110 Define if this is a single list of values or a table of values. The difference
111 is the following:
112
113 When B<Table> is set to B<false>, the OIDs given to B<Values> (see below) are
114 queried using the C<GET> SNMP command (see L<snmpget(1)>) and transmitted to
115 collectd. B<One> value list is dispatched and, eventually, one file will be
116 written.
117
118 When B<Table> is set to B<true>, the OIDs given to B<Values>, B<TypeInstanceOID>,
119 B<PluginInstanceOID>, B<HostOID> and B<FilterOID> (see below) are queried using
120 the C<GETNEXT> SNMP command until the subtree is left. After all
121 the lists (think: all columns of the table) have been read B<several> values
122 sets will be dispatches and, eventually, several files will be written. If you
123 configure a B<Type> (see above) which needs more than one data source (for
124 example C<if_octets> which needs C<rx> and C<tx>) you will need to specify more
125 than one (two, in the example case) OIDs with the B<Values> option. This has
126 nothing to do with the B<Table> setting.
127
128 For example, if you want to query the number of users on a system, you can use
129 C<HOST-RESOURCES-MIB::hrSystemNumUsers.0>. This is one value and belongs to one
130 value list, therefore B<Table> must be set to B<false>. Please note that, in
131 this case, you have to include the sequence number (zero in this case) in the
132 OID.
133
134 Counter example: If you want to query the interface table provided by the
135 C<IF-MIB>, e.E<nbsp>g. the bytes transmitted. There are potentially many
136 interfaces, so you will want to set B<Table> to B<true>. Because the
137 C<if_octets> type needs two values, received and transmitted bytes, you need to
138 specify two OIDs in the B<Values> setting, in this case likely
139 C<IF-MIB::ifHCInOctets> and C<IF-MIB::ifHCOutOctets>. But, this is because of
140 the B<Type> setting, not the B<Table> setting.
141
142 Since the semantic of B<Instance> and B<Values> depends on this setting you
143 need to set it before setting them. Doing vice versa will result in undefined
144 behavior.
145
146 =item B<Plugin> I<Plugin>
147
148 Use I<Plugin> as the plugin name of the values that are dispatched.
149 Defaults to C<snmp>.
150
151 =item B<PluginInstance> I<Instance>
152
153 Sets the plugin-instance of the values that are dispatched to I<Instance> value.
154
155 When B<Table> is set to I<true> and B<PluginInstanceOID> is set then this option
156 has no effect.
157
158 Defaults to an empty string.
159
160 =item B<TypeInstance> I<Instance>
161
162 Sets the type-instance of the values that are dispatched to I<Instance> value.
163
164 When B<Table> is set to I<true> and B<TypeInstanceOID> is set then this option
165 has no effect.
166
167 Defaults to an empty string.
168
169 =item B<TypeInstanceOID> I<OID>
170
171 =item B<PluginInstanceOID> I<OID>
172
173 =item B<HostOID> I<OID>
174
175 If B<Table> is set to I<true>, I<OID> is interpreted as an SNMP-prefix that will
176 return a list of values. Those values are then used as the actual type-instance,
177 plugin-instance or host of dispatched metrics. An example would be the
178 C<IF-MIB::ifDescr> subtree. L<variables(5)> from the SNMP distribution describes
179 the format of OIDs. When option is set to empty string, then "SUBID" will be used
180 as the value.
181
182 Prefix may be set for values with use of appropriate B<TypeInstancePrefix>,
183 B<PluginInstancePrefix> and B<HostPrefix> options.
184
185 When B<Table> is set to I<false> these options has no effect.
186
187 Defaults: When no one of these options is configured explicitly,
188 B<TypeInstanceOID> defaults to an empty string.
189
190 =item B<TypeInstancePrefix>
191
192 =item B<PluginInstancePrefix>
193
194 =item B<HostPrefix>
195
196 These options are intented to be used together with B<TypeInstanceOID>,
197 B<PluginInstanceOID> and B<HostOID> respectively.
198
199 If set, I<String> is preprended to values received by querying the agent.
200
201 When B<Table> is set to I<false> these options has no effect.
202
203 The C<UPS-MIB> is an example where you need this setting: It has voltages of
204 the inlets, outlets and the battery of an UPS. However, it doesn't provide a
205 descriptive column for these voltages. In this case having 1, 2,E<nbsp>... as
206 instances is not enough, because the inlet voltages and outlet voltages may
207 both have the subids 1, 2,E<nbsp>... You can use this setting to distinguish
208 between the different voltages.
209
210 =item B<Instance> I<Instance>
211
212 Attention: this option exists for backwards compatibility only and will be
213 removed in next major release. Please use B<TypeInstance> / B<TypeInstanceOID>
214 instead.
215
216 The meaning of this setting depends on whether B<Table> is set to I<true> or
217 I<false>.
218
219 If B<Table> is set to I<true>, option behaves as B<TypeInstanceOID>.
220 If B<Table> is set to I<false>, option behaves as B<TypeInstance>.
221
222 Note what B<Table> option must be set before setting B<Instance>.
223
224 =item B<InstancePrefix> I<String>
225
226 Attention: this option exists for backwards compatibility only and will be
227 removed in next major release. Please use B<TypeInstancePrefix> instead.
228
229 =item B<Values> I<OID> [I<OID> ...]
230
231 Configures the values to be queried from the SNMP host. The meaning slightly
232 changes with the B<Table> setting. L<variables(5)> from the SNMP distribution
233 describes the format of OIDs.
234
235 If B<Table> is set to I<true>, each I<OID> must be the prefix of all the
236 values to query, e.E<nbsp>g. C<IF-MIB::ifInOctets> for all the counters of
237 incoming traffic. This subtree is walked (using C<GETNEXT>) until a value from
238 outside the subtree is returned.
239
240 If B<Table> is set to I<false>, each I<OID> must be the OID of exactly one
241 value, e.E<nbsp>g. C<IF-MIB::ifInOctets.3> for the third counter of incoming
242 traffic.
243
244 =item B<Scale> I<Value>
245
246 The gauge-values returned by the SNMP-agent are multiplied by I<Value>.  This
247 is useful when values are transferred as a fixed point real number. For example,
248 thermometers may transfer B<243> but actually mean B<24.3>, so you can specify
249 a scale value of B<0.1> to correct this. The default value is, of course,
250 B<1.0>.
251
252 This value is not applied to counter-values.
253
254 =item B<Shift> I<Value>
255
256 I<Value> is added to gauge-values returned by the SNMP-agent after they have
257 been multiplied by any B<Scale> value. If, for example, a thermometer returns
258 degrees Kelvin you could specify a shift of B<273.15> here to store values in
259 degrees Celsius. The default value is, of course, B<0.0>.
260
261 This value is not applied to counter-values.
262
263 =item B<Ignore> I<Value> [, I<Value> ...]
264
265 The ignore values allows one to ignore TypeInstances based on their name and
266 the patterns specified by the various values you've entered. The match is a
267 glob-type shell matching.
268
269 When B<Table> is set to I<false> then this option has no effect.
270
271 =item B<InvertMatch> I<true|false(default)>
272
273 The invertmatch value should be use in combination of the Ignore option.
274 It changes the behaviour of the Ignore option, from a blacklist behaviour
275 when InvertMatch is set to false, to a whitelist when specified to true.
276
277 =item B<FilterOID> I<OID>
278
279 =item B<FilterValues> I<Value> [, I<Value> ...]
280
281 =item B<FilterIgnoreSelected> I<true|false(default)>
282
283 When B<Table> is set to I<true>, these options allow to configure filtering
284 based on MIB values.
285
286 The B<FilterOID> declares I<OID> to fill table column with values.
287 The B<FilterValues> declares values list to do match. Whether table row will be
288 collected or ignored depends on the B<FilterIgnoreSelected> setting.
289 As with other plugins that use the daemon's ignorelist functionality, a string
290 that starts and ends with a slash is interpreted as a regular expression.
291
292 If no selection is configured at all, B<all> table rows are selected.
293
294 When B<Table> is set to I<false> then these options has no effect.
295
296 See B<Table> and F</"IGNORELISTS"> for details.
297
298 =back
299
300 =head2 The Host block
301
302 The B<Host> block defines which hosts to query, which SNMP community and
303 version to use and which of the defined B<Data> to query.
304
305 The argument passed to the B<Host> block is used as the hostname in the data
306 stored by collectd.
307
308 =over 4
309
310 =item B<Address> I<IP-Address>|I<Hostname>
311
312 Set the address to connect to. Address may include transport specifier and/or
313 port number.
314
315 =item B<Version> B<1>|B<2>|B<3>
316
317 Set the SNMP version to use. When giving B<2> version C<2c> is actually used.
318
319 =item B<Community> I<Community>
320
321 Pass I<Community> to the host. (Ignored for SNMPv3).
322
323 =item B<Username> I<Username>
324
325 Sets the I<Username> to use for SNMPv3 security.
326
327 =item B<SecurityLevel> I<authPriv>|I<authNoPriv>|I<noAuthNoPriv>
328
329 Selects the security level for SNMPv3 security.
330
331 =item B<Context> I<Context>
332
333 Sets the I<Context> for SNMPv3 security.
334
335 =item B<AuthProtocol> I<MD5>|I<SHA>
336
337 Selects the authentication protocol for SNMPv3 security.
338
339 =item B<AuthPassphrase> I<Passphrase>
340
341 Sets the authentication passphrase for SNMPv3 security. 
342
343 =item B<PrivacyProtocol> I<AES>|I<DES>
344
345 Selects the privacy (encryption) protocol for SNMPv3 security.
346
347 =item B<PrivacyPassphrase> I<Passphrase>
348
349 Sets the privacy (encryption) passphrase for SNMPv3 security. 
350
351 =item B<Collect> I<Data> [I<Data> ...]
352
353 Defines which values to collect. I<Data> refers to one of the B<Data> block
354 above. Since the config file is read top-down you need to define the data
355 before using it here.
356
357 =item B<Interval> I<Seconds>
358
359 Collect data from this host every I<Seconds> seconds. This option is meant for
360 devices with not much CPU power, e.E<nbsp>g. network equipment such as
361 switches, embedded devices, rack monitoring systems and so on. Since the
362 B<Step> of generated RRD files depends on this setting it's wise to select a
363 reasonable value once and never change it.
364
365 =item B<Timeout> I<Seconds>
366
367 How long to wait for a response. The C<Net-SNMP> library default is 1 second.
368
369 =item B<Retries> I<Integer>
370
371 The number of times that a query should be retried after the Timeout expires.
372 The C<Net-SNMP> library default is 5.
373
374 =back
375
376 =head1 SEE ALSO
377
378 L<collectd(1)>,
379 L<collectd.conf(5)>,
380 L<snmpget(1)>,
381 L<snmpgetnext(1)>,
382 L<variables(5)>,
383 L<unix(7)>
384
385 =head1 AUTHORS
386
387 Florian Forster E<lt>octo@collectd.orgE<gt>
388 Michael Pilat E<lt>mike@mikepilat.comE<gt>
389
390 =cut