Code

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