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