SNMP subagent in C + exec_command or similar

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

I need to create a subagent within C.
Majority of the code executes 'scripts' like

dmidecode | egrep -A 2 \"BIOS Information\" | egrep \"Version:\" | cut -d ' ' -f 2

and store that as an OID's value.
I know that for this only I would NOT need .C agents at all, snmpd.conf + extend
would be just fine. However it is also needed to trace whenever someone changes
a given OID so that a trap event can ge sent to a remote host.

However I ran into strange issues.
First I have tried to use my own program that executes a given command and returns
the output of it. Basically it uses dup2()s, fork() and system() to launch the new
command. I have tested the code and it works fine within a standalone executable;
system() gets blocked until the command is running. But if I do the same from my
subagent, system() finishes AT ONCE (without any error though).

I have also tried to use the exec_command() within util_funcs, but I can't even
use that, as "struct extensible" is not being defined in any of the publicly
available headers.

Ahyeah, running net-snmp 5.4.2.1 on a Linux machine

Can anyone provide me an working subagent code that uses either exec_command()
or some alternative to run a user given command?
Thanks,



------------------------------------------------------------------------------
_______________________________________________
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.