Page 1 of 1

[Nagios-devel] RE: SNMP community in host configuration

Posted: Tue Dec 21, 2004 7:03 am
by Guest
This is a multi-part message in MIME format.

------=_NextPart_000_002C_01C4E776.9DBA83A0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hi,

I updated my patch. Works with today's CVS : "patch -p0 SomeData"
- In services : "$HOSTMACRO$"

- In nagios.cfg, the option is now named "host_snmp_login", same syntax.

As usual, feedbacks are welcome !

Patrick
nagios AT proy.org

> How to patch :
> - it work with the CVS version of 19 Dec 2004
> - in the "nagios-cvs" directory : "patch -p0
> Note : only works with template based config files.
>
> 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 # stores snmp version
> snmp_login # stores snmp login (for v3)
> snmp_pass # stores snmp password for v3 or
> community for
> v1
> None of them are compulsory of course
> - In the host template (will then only overwrite what's not in host
> definition)
> Same syntax
>
> - In the nagios.cfg file :
> snmp_login=1,,/
> snmp_login=3,,,/
>
> 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
>
> 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
>
> example :
> hostuser3 SomeInformation
>
> - Of course, host templates can have hostuser too. (will be put in
> host definition is the host doesn't have the hostuser already).
>
> - Available as macro :
> $HOSTUSER$
>
> 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.
>
>
> Please test it and give me feedback !
>
>
> Patrick
> nagios AT proy.org
>

------=_NextPart_000_002C_01C4E776.9DBA83A0
Content-Type: application/octet-stream;
name="patch_nag_snmp_2004.12.21.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="patch_nag_snmp_2004.12.21.patch"

--- common/objects.c Tue Nov 30 18:16:23 2004=0A=
+++ common/objects.c Tue Dec 21 15:34:58 2004=0A=
@@ -29,6 +29,9 @@=0A=
=0A=
#ifdef NSCORE=0A=
#include "../include/nagios.h"=0A=
+/* get snmp data in main config file to put in hosts */=0A=
+extern snmp_data *snmp_config[MAX_SNMP_DATA];=0A=
+extern int snmp_config_num;=0A=
#endif=0A=
=0A=
#ifdef NSCGI=0A=
@@ -923,12 +926,16 @@=0A=
=0A=
=0A=
/* add a new host definition */=0A=
-host *add_host(char *name, char *alias, char *address, char =
*check_period, int check_interval, int max_attempts, int notify_up, int =
notify_down, int notify_unreachable, int notify_flapping, int =
notification_interval, char *notification_period, int =
notifications_enabled, char *check_command, int checks_enabled, int =
accept_passive_checks, char *event_handler, int event_handler_enable

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]