Re: [tkined] Urgent help needed, please.

Doug Hughes (Doug.Hughes@Eng.Auburn.EDU)
Tue, 14 Oct 1997 12:08:54 -0500

>Well now, it has been a while since I've asked a question on this mailing
>list. Once again, tough, dire need calls me. I have a customer that needs
>to be able to do the following:
>
>- Provide a list of routers that are in a network.
>- Provide a community string.
>- Contact every router and do a smnp set for evry router for a given snmp
>trap,
> the oid to set will be provided.
>- Report failure where the community string is incorrect (or, if possible,
>provide
> multiple community strings to the program, and have it check each of them
>for each
> router, until one is found that works.)
>
>
>Well, now that the description is out of the way, let me say a few things.
>I have ~24 hours to get him something that works. I'd like it to handle
>multiple community strings, and to be asynch. (event driven). However,
>he'll take anything that works, for now, and I can improve on it later. I
>was hoping that somebody might have some code that does something like
>this, that I can either a)use as an example, or b)give him to use until I
>can come up with something to do exactly what he wants. Even a pointer to
>some good information or sample code would be helpful.
>
>I apologize if helpful answers to my quest can be found everywhere that is
>obvious (the FAQ, the sample code provided with Scotty, etc), but I haven't
>even looked anywhere yet. I wanted to get the mailing out quickly, so I did
>so before even looking anywhere.
>

Well, I don't have a concrete example, but it seems to me a simple loop
would do the trick.

set s [snmp session]
foreach router {ip1 ip2 ip3 ip4 ... ipn} {
$s configure -address $router
# You may need to modify the below line
# I'm not sure a community failure would trigger a catch, but
# I would think so
catch {$s set $oid} err

}

Now, say you want to do multiple community strings.
There are a couple of ways that I'd think about doing it (off the top of my head)
1) have an associative array of community strings indexed by IP address
e.g. $s configure -address $router -community $ctable($router)
2) supply community strings to foreach loop
e.g.
foreach router {{ip1 setme} {ip2 rwcommunity} {ip3 othercommunity}} {
$configure -address [lindex $router 0] -community [lindex $router 1]
...
}

This just requires scotty, it's quick, it's easy, and you can set it up
to read from files if you want.

--
____________________________________________________________________________
Doug Hughes					Engineering Network Services
System/Net Admin  				Auburn University
			doug@eng.auburn.edu

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.