RE: SNMP subagent in C + exec_command or similar

Hársszegi Tibor <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <0AB49E373B7E1448B1F61F060A0776AF045035C7B6@sgmail1>
Hi,

have tried exec_command not much luck :(
I am trying to run scripts, like

cat /proc/cpuinfo | grep vendor_id | awk '{print $3}'

and similar.
No matter how I tried using SHPROC or EXECPROC (although I don't really
see SHPROC being handled at all anywhere in net-snmp)
I didn't get the pipes being executed at all.
Naturally I had to replace the command like this:

/bin/cat /proc/cpuinfo | /usr/bin/grep vendor_id | /usr/bin/awk '{print $3}'

but the output was

"processor      : 0"

so 'grep' was not taking place at all :(
Any idea how to overcome this and make sure that system() is called instead of execv()
?
Thanks,

> -----Original Message-----
> From: Wes Hardaker [mailto:[email protected]]
> Sent: Thursday, May 06, 2010 10:35 PM
> To: Hársszegi Tibor
> Cc: [email protected]
> Subject: Re: SNMP subagent in C + exec_command or similar
>
> >>>>> On Tue, 4 May 2010 12:22:50 +0200, Hársszegi Tibor
> <[email protected]> said:
>
> HT> I need to create a subagent within C.
> HT> Majority of the code executes 'scripts' like
>
> Well, that architecture will be hard to make work quickly.
> At a minimum I'd suggest using a caching mechanism so you
> don't fire the script off per ever call.
>
> HT> I know that for this only I would NOT need .C agents at all,
> HT> snmpd.conf + extend would be just fine. However it is
> also needed to
> HT> trace whenever someone changes a given OID so that a trap
> event can
> HT> ge sent to a remote host.
>
> (in theory you could also accomplish this by inserting a
> handler somewhere in between the main agent and the
> end-script execution, but that's probably more advanced :-)
>
> The problem with forking is that you'll end up duplicating
> the entire agent memory, which is expensive.
>
> HT> I have also tried to use the exec_command() within
> util_funcs, but I
> HT> can't even use that, as "struct extensible" is not being
> defined in
> HT> any of the publicly available headers.
>
> You can go steal it from the agent/mibgroup directory.  It's
> actually a header we've wanted to install for a long time but
> haven't.  The function is defined in the libnetsnmpmibs
> library when you do your linking.
>
> --
> Wes Hardaker
> Cobham Analytic Solutions
>



------------------------------------------------------------------------------

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.