Template:FAQ:Agent 19

From Net-SNMP Wiki
Jump to: navigation, search

Firstly, are you certain that this is what is happening?

The normal operation of the agent is to fork itself into the background, detaching itself from the controlling terminal so that it will continue running even when you log out, and freeing the command line for subsequent use. This looks at first sight as if the agent has died, but using 'ps' to show all processes should reveal that the agent is still running.

To prevent this behaviour (such as when attempting to debug the agent), you can start it with the '-f' flag. This suppresses the fork, and the agent will run as a 'normal' command. It's also often useful to use the '-Le' (or '-L') flag, to log messages to stdout.

On the other hand, if 'ps' shows that the agent is not running, then this is an error, and probably show that something went wrong in starting the agent up. Check the agent log file for any error messages, or run it with '-f -Le' and see what it reports.

One possible cause might be an existing agent (or some other process) that's already listening on the SNMP port. Trying to start a second agent will fail with an error about "opening the specified endpoint".

If you're starting the agent as a non-root user, then this may also fail with the very same error. By default, the agent (and trap handler) will attempt to listen on the standard SNMP port 161 (or 162 for the trap handler). These are defined as "privileged ports", and processes will need to be running as root in order to open them.

One way to tackle this is to start the agent as root, but use the -u option to switch to run as another user once the port has been opened. Alternatively, you can specify a different port to use instead. Anything greater than 1024 is available to non-root users. In this case, you'll also need to specify the same port when issuing client commands.