Add SNMPv3 authentication and encryption support
[collectd.git] / src / collectd-snmp.pod
1 =head1 NAME
2
3 collectd-snmp - Documentation of collectd's C<snmp plugin>
4
5 =head1 SYNOPSIS
6
7   LoadPlugin snmp
8   # ...
9   <Plugin snmp>
10     <Data "powerplus_voltge_input">
11       Type "voltage"
12       Table false
13       Instance "input_line1"
14       Scale 0.1
15       Values "SNMPv2-SMI::enterprises.6050.5.4.1.1.2.1"
16     </Data>
17     <Data "hr_users">
18       Type "users"
19       Table false
20       Instance ""
21       Shift -1
22       Values "HOST-RESOURCES-MIB::hrSystemNumUsers.0"
23     </Data>
24     <Data "std_traffic">
25       Type "if_octets"
26       Table true
27       Instance "IF-MIB::ifDescr"
28       Values "IF-MIB::ifInOctets" "IF-MIB::ifOutOctets"
29     </Data>
30
31     <Host "some.switch.mydomain.org">
32       Address "192.168.0.2"
33       Version 1
34       Community "community_string"
35       Collect "std_traffic"
36       Interval 120
37     </Host>
38     <Host "some.server.mydomain.org">
39       Address "192.168.0.42"
40       Version 2
41       Community "another_string"
42       Collect "std_traffic" "hr_users"
43     </Host>
44     <Host "secure.router.mydomain.org">
45       Address "192.168.0.7"
46       Version 3
47       SecurityLevel "authPriv"
48       Username "cosmo"
49       AuthProtocol "SHA"
50       AuthPassphrase "setec_astronomy"
51       PrivacyProtocol "AES"
52       PrivacyPassphrase "too_many_secrets"
53       Collect "std_traffic"
54     </Host>
55     <Host "some.ups.mydomain.org">
56       Address "192.168.0.3"
57       Version 1
58       Community "more_communities"
59       Collect "powerplus_voltge_input"
60       Interval 300
61     </Host>
62   </Plugin>
63
64 =head1 DESCRIPTION
65
66 The C<snmp plugin> queries other hosts using SNMP, the simple network
67 management protocol, and translates the value it receives to collectd's
68 internal format and dispatches them. Depending on the write plugins you have
69 loaded they may be written to disk or submitted to another instance or
70 whatever you configured.
71
72 Because querying a host via SNMP may produce a timeout multiple threads are
73 used to query hosts in parallel. Depending on the number of hosts between one
74 and ten threads are used.
75
76 =head1 CONFIGURATION
77
78 Since the aim of the C<snmp plugin> is to provide a generic interface to SNMP,
79 it's configuration is not trivial and may take some time.
80
81 Since the C<Net-SNMP> library is used you can use all the environment variables
82 that are interpreted by that package. See L<snmpcmd(1)> for more details.
83
84 There are two types of blocks that can be contained in the
85 C<E<lt>PluginE<nbsp>snmpE<gt>> block: B<Data> and B<Host>:
86
87 =head2 The B<Data> block
88
89 The B<Data> block defines a list of values or a table of values that are to be
90 queried. The following options can be set:
91
92 =over 4
93
94 =item B<Type> I<type>
95
96 collectd's type that is to be used, e.E<nbsp>g. "if_octets" for interface
97 traffic or "users" for a user count. The types are read from the B<TypesDB>
98 (see L<collectd.conf(5)>), so you may want to check for which types are
99 defined. See L<types.db(5)> for a description of the format of this file.
100
101 =item B<Table> I<true|false>
102
103 Define if this is a single list of values or a table of values. The difference
104 is the following:
105
106 When B<Table> is set to B<false>, the OIDs given to B<Values> (see below) are
107 queried using the C<GET> SNMP command (see L<snmpget(1)>) and transmitted to
108 collectd. B<One> value list is dispatched and, eventually, one file will be
109 written.
110
111 When B<Table> is set to B<true>, the OIDs given to B<Values> (see below) are
112 queried using the C<GETNEXT> SNMP command until the subtree is left. After all
113 the lists (think: all columns of the table) have been read B<several> values
114 sets will be dispatches and, eventually, several files will be written. If you
115 configure a B<Type> (see above) which needs more than one data source (for
116 example C<if_octets> which needs C<rx> and C<tx>) you will need to specify more
117 than one (two, in the example case) OIDs with the B<Values> option. This has
118 nothing to do with the B<Table> setting.
119
120 For example, if you want to query the number of users on a system, you can use
121 C<HOST-RESOURCES-MIB::hrSystemNumUsers.0>. This is one value and belongs to one
122 value list, therefore B<Table> must be set to B<false>. Please note that, in
123 this case, you have to include the sequence number (zero in this case) in the
124 OID.
125
126 Counter example: If you want to query the interface table provided by the
127 C<IF-MIB>, e.E<nbsp>g. the bytes transmitted. There are potentially many
128 interfaces, so you will want to set B<Table> to B<true>. Because the
129 C<if_octets> type needs two values, received and transmitted bytes, you need to
130 specify two OIDs in the B<Values> setting, in this case likely
131 C<IF-MIB::ifHCInOctets> and C<IF-MIB::ifHCOutOctets>. But, this is because of
132 the B<Type> setting, not the B<Table> setting.
133
134 Since the semantic of B<Instance> and B<Values> depends on this setting you
135 need to set it before setting them. Doing vice verse will result in undefined
136 behavior.
137
138 =item B<Instance> I<Instance>
139
140 Sets the type-instance of the values that are dispatched. The meaning of this
141 setting depends on whether B<Table> is set to I<true> or I<false>:
142
143 If B<Table> is set to I<true>, I<Instance> is interpreted as an SNMP-prefix
144 that will return a list of values. Those values are then used as the actual
145 type-instance. An example would be the C<IF-MIB::ifDescr> subtree.
146 L<variables(5)> from the SNMP distribution describes the format of OIDs.
147
148 If B<Table> is set to I<true> and B<Instance> is omitted, then "SUBID" will be
149 used as the instance.
150
151 If B<Table> is set to I<false> the actual string configured for I<Instance> is
152 copied into the value-list. In this case I<Instance> may be empty, i.E<nbsp>e.
153 "".
154
155 =item B<InstancePrefix> I<String>
156
157 If B<Table> is set to I<true>, you may feel the need to add something to the
158 instance of the files. If set, I<String> is prepended to the instance as
159 determined by querying the agent. When B<Table> is set to I<false> this option
160 has no effect.
161
162 The C<UPS-MIB> is an example where you need this setting: It has voltages of
163 the inlets, outlets and the battery of an UPS. However, it doesn't provide a
164 descriptive column for these voltages. In this case having 1, 2,E<nbsp>... as
165 instances is not enough, because the inlet voltages and outlet voltages may
166 both have the subids 1, 2,E<nbsp>... You can use this setting to distinguish
167 between the different voltages.
168
169 =item B<Values> I<OID> [I<OID> ...]
170
171 Configures the values to be queried from the SNMP host. The meaning slightly
172 changes with the B<Table> setting. L<variables(5)> from the SNMP distribution
173 describes the format of OIDs.
174
175 If B<Table> is set to I<true>, each I<OID> must be the prefix of all the
176 values to query, e.E<nbsp>g. C<IF-MIB::ifInOctets> for all the counters of
177 incoming traffic. This subtree is walked (using C<GETNEXT>) until a value from
178 outside the subtree is returned.
179
180 If B<Table> is set to I<false>, each I<OID> must be the OID of exactly one
181 value, e.E<nbsp>g. C<IF-MIB::ifInOctets.3> for the third counter of incoming
182 traffic.
183
184 =item B<Scale> I<Value>
185
186 The gauge-values returned by the SNMP-agent are multiplied by I<Value>.  This
187 is useful when values are transfered as a fixed point real number. For example,
188 thermometers may transfer B<243> but actually mean B<24.3>, so you can specify
189 a scale value of B<0.1> to correct this. The default value is, of course,
190 B<1.0>.
191
192 This value is not applied to counter-values.
193
194 =item B<Shift> I<Value>
195
196 I<Value> is added to gauge-values returned by the SNMP-agent after they have
197 been multiplied by any B<Scale> value. If, for example, a thermometer returns
198 degrees Kelvin you could specify a shift of B<273.15> here to store values in
199 degrees Celsius. The default value is, of course, B<0.0>.
200
201 This value is not applied to counter-values.
202
203 =back
204
205 =head2 The Host block
206
207 The B<Host> block defines which hosts to query, which SNMP community and
208 version to use and which of the defined B<Data> to query.
209
210 The argument passed to the B<Host> block is used as the hostname in the data
211 stored by collectd.
212
213 =over 4
214
215 =item B<Address> I<IP-Address>|I<Hostname>
216
217 Set the address to connect to.
218
219 =item B<Version> B<1>|B<2>|B<3>
220
221 Set the SNMP version to use. When giving B<2> version C<2c> is actually used.
222
223 =item B<Community> I<Community>
224
225 Pass I<Community> to the host. (Ignored for SNMPv3).
226
227 =item B<Username> I<Username>
228
229 Sets the I<Username> to use for SNMPv3 security.
230
231 =item B<SecurityLevel> I<authPriv>|I<authNoPriv>|I<noAuthNoPriv>
232
233 Selects the security level for SNMPv3 security.
234
235 =item B<Context> I<Context>
236
237 Sets the I<Context> for SNMPv3 security.
238
239 =item B<AuthProtocol> I<MD5>|I<SHA>
240
241 Selects the authentication protocol for SNMPv3 security.
242
243 =item B<AuthPassphrase> I<Passphrase>
244
245 Sets the authentication passphrase for SNMPv3 security. 
246
247 =item B<PrivacyProtocol> I<AES>|I<DES>
248
249 Selects the privacy (encryption) protocol for SNMPv3 security.
250
251 =item B<PrivacyPassphrase> I<Passphrase>
252
253 Sets the privacy (encryption) passphrase for SNMPv3 security. 
254
255 =item B<Collect> I<Data> [I<Data> ...]
256
257 Defines which values to collect. I<Data> refers to one of the B<Data> block
258 above. Since the config file is read top-down you need to define the data
259 before using it here.
260
261 =item B<Interval> I<Seconds>
262
263 Collect data from this host every I<Seconds> seconds. This option is meant for
264 devices with not much CPU power, e.E<nbsp>g. network equipment such as
265 switches, embedded devices, rack monitoring systems and so on. Since the
266 B<Step> of generated RRD files depends on this setting it's wise to select a
267 reasonable value once and never change it.
268
269 =back
270
271 =head1 SEE ALSO
272
273 L<collectd(1)>,
274 L<collectd.conf(5)>,
275 L<snmpget(1)>,
276 L<snmpgetnext(1)>,
277 L<variables(5)>,
278 L<unix(7)>
279
280 =head1 AUTHORS
281
282 Florian Forster E<lt>octo@verplant.orgE<gt>
283 Michael Pilat E<lt>mike@mikepilat.comE<gt>
284
285 =cut