Sending Application Level Traps

I have just recently started using Solstice Enterprise Agent's,a.k.a. SEA, (run-time environment along with it's SDK) and am having some trouble understanding how a developer is supposed to send application (custom software) traps to a sub-agent.

I understand how the sub-agent sends traps to the Master agent (via SSASendTrap()) but how does the sub-agent get notified of application traps (e.g. a critical error occurs in your code somewhere and you want to send an SNMP trap?) I was assuming that the SDK would provide an API for this but I have not been able to find it anywhere.

Am I missing something? Is the application developer supposed to create the socket to the sub-agent directly and somehow send a trap message without using any SEA APIs?

Thanks in advance.

[798 byte] By [nicknemati] at [2007-11-26 5:52:47]
# 1
In the agent_loop() function that gets periodically called by the master agent, you can have it check a global value that you set when there is a trap waiting from your application. Then your job would be to get that trap info and call SSASendTrap() ...
dvyyyyyy at 2007-7-6 13:03:46 > top of Java-index,Administration Tools,Solstice Enterprise Agents...
# 2

I'm still a bit unclear as to how my application (running as a separate process ID) would communicate with the snmp sub-agent (running as a daemon process.) You suggested using a global value, but that's only global to one of the processes.

Do we have to use some kind of IPC (pipes, sockets, etc.) to communicate? I was hoping there would have been an API provided for the application <--> sub-agent trap generation.

nicknemati at 2007-7-6 13:03:46 > top of Java-index,Administration Tools,Solstice Enterprise Agents...
# 3

If you have 2 different processes, one which runs your main process that you are monitoring and the other that is the actual agent which receives SNMP polls and sends traps, yes, you will need some sort of IPC communication between the two of them. I think that the provided agent was developed to be one big standalone process, which is very unrealistic.

I ended up using RPC to get back and forth from the SNMP agent to the main process. If you're brave, shared memory is an option as well.. You can't use pipe as that requires both ends to wait on each other and you don't want your SNMP agent blocked. Socket might be OK too.

Anyway, for me, it was like this:

within agent_loop

while (RPCLoadQueuedTrap(&trap))

{

SendTrap(trap);

}

with the RPC call above going back to a waiting queue of traps in the main process.

dvyyyyyy at 2007-7-6 13:03:46 > top of Java-index,Administration Tools,Solstice Enterprise Agents...
# 4

Yes, we are using 2 processes (one for the sub-agent and one which is our actual application.)

So basically your saying that I have to use some kind of IPC since there is no Solstice provided API to wrap the communication between the application and the sub-agent?

On a similar note, I did find the snmp_trapsend() utility. But to your point, that seems to circumvent the sub-agent and master-agent and go straight to the NMS (network monitoring system.) Is that an accurate statement, or can it be rigged to go to either the sub-agent or master agent?

Thanks again!

nicknemati at 2007-7-6 13:03:46 > top of Java-index,Administration Tools,Solstice Enterprise Agents...
# 5

Some kind of IPC is required, yes. If you find out a different way, let me know! Otherwise, the way to do it would be to overload the get_X functions with the actual source. But like my project, it sounds like that won't work for you either.

The SSASendTrap() goes through the master running on your Sun (snmpdx is the process). If you have SU capability and set snmpdx running with a -d 4 option, and then you run your agent, you will see the trap get dispatched to the master, and the master will tell you who it sent the traps to (which will correspond to the configured IPs).

So,

YOUR_MAIN_PROCESS

talks to (through IPC of some sort)

YOUR_SNMP_SUB_AGENT

talks to

SUN_MASTER_AGENT

talks to

NMS

dvyyyyyy at 2007-7-6 13:03:46 > top of Java-index,Administration Tools,Solstice Enterprise Agents...