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