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