[Nagiosplug-devel] SNMP community in host configuration
Andreas Ericsson
ae at op5.se
Sun Dec 19 08:34:02 CET 2004
Patrick Proy wrote:
>>Yes i am willing to test it ;-)
>>--
>>Benoit Mortier
>
>
> OK, so here it is ! :-)
>
> Maybe this thread should now be nagios-devel ML but it started here... And
> it's only for test now
>
It should have been there from the beginning. I'm cross-posting to
nagios-devel now. Please continue there, as Ethan doesn't read the
nagiosplug lists as carefully as he does the nagios-devel one.
> How to patch :
> - it work with the CVS version of 19 Dec 2004
> - in the "nagios-cvs" directory : "patch -p0 < patch_nag_snmp.patch"
>
> Note : only works with template based config files.
>
That's the only kind available, so that should be just fine.
> I tested it on Linux only for now, but as nothing is platform specific, it
> should be OK.
> Here are the modified files (if a new CVS version is out) :
> - common/objects.c base/config.c base/nagios.c base/utils.c include/common.h
> include/objects.h include/nagios.h.in xdata/xodtemplate.c
> xdata/xodtemplate.h
>
>
> What it does :
>
> 1) SNMP for each host
>
> You can put snmp information in three ways :
> - In the host definition :
> snmp_version <int> # stores snmp version
> snmp_login <string> # stores snmp login (for v3)
> snmp_pass <string> # stores snmp password for v3 or community for
> v1
Why not throw in snmp_community as well, and save the users the need to
ask where to put it (users don't read documentation; That's just the way
it is).
> None of them are compulsory of course
> - In the host template (will then only overwrite what's not in host
> definition)
> Same syntax
>
This would more or less be expected, naturally.
> - In the nagios.cfg file :
> snmp_login=1,<comunity>,<network>/<mask>
> snmp_login=3,<login>,<pass>,<network>/<mask>
>
> This is generic snmp login for networks : it will be put in the host
> snmp info if the host hasn't got any, and if it's address matches the
> network/mask definition. Mask with best precision will be chosen first.
> Example :
> snmp_login=1,private,10.100.0.0/16
> snmp_login=3,login1,pass1,10.100.0.3/32
>
I don't think it's a very good idea to involve snmp configuration in the
nagios.cfg file, for a couple of reasons.
1) It will fail miserably if the address field consists of a hostname
instead of an ip-address. Having nagios resolve domain names wouldn't be
a good idea (for obvious reasons). Using templates should definitely be
enough.
2) The syntax is a bit stupid. Why add a config file entry for 65535
hosts in one place when it could just as easily be in a template? With
that many hosts using roughly the same settings you would most likely
want to set up the templates good and properly anyways.
3) If nagios ever decides to add it's own MIB so that other programs can
query it via SNMP, it will cause legacy clashes and users won't know
where to configure what.
I believe it would be prudent to simply drop this second way of
configuring things and sticking to keeping it in the host object
definition (which is a very good idea).
> This means :
> - on the 10.100.0.0/16 network : v1, private
> - for the 10.100.0.3 host : v3 : login1, pass1
>
> 10.100.3.45 : will get v1, private
> 10.100.0.3 : will get v3, login1, pass1
>
> - The information is available as macro :
> - $SNMPVERSION$
> - $SNMPLOGIN$
> - $SNMPPASS$
>
>
> 2) user variables for host
>
> - Each host can have up to 10 user variables (you can put more or less, just
> by modifying a number in the code), specified in its definition :
> hostuser<n> <string>
>
> example :
> hostuser3 SomeInformation
>
> - Of course, host templates can have hostuser<n> too. (will be put in host
> definition is the host doesn't have the hostuser<n> already).
>
> - Available as macro :
> $HOSTUSER<n>$
>
The intuitive connection between the name 'hostuser' and what I think it
would most likely represent clashes a bit with the way contacts work
(john, mike and joe are users, and they're responsible for the web-*
servers, f.e.). I would really prefer if they were named "hostmacro"
instead.
Ofcourse, the presence of hostmacros sort of voids the necessity for the
snmp_* variables, but the decision is Ethan's, so I can only air my
opinions.
> TODO :
> - I forgot snmp v2c : maybe 2 will be okay but it would be cleaner to have
> "2c".
> - Hostuser are from 0->9..., maybe it would be cleaner to put 1->10.
>
The nagios core can have lenient parsing of the version string and make
2c parse as 2 (it will anyway if fed to strtoul()), so that shouldn't be
a problem.
1->10 is cleaner and consistent with how things work now.
>
> Please test it and give me feedback !
>
>
> Patrick
> nagios AT proy.org
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Lead Developer
More information about the Devel
mailing list