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