ModSnmp Manual v3.07 - 13.3. Running under Unix/Linux

Download manual: PDF HTML

13.3. Running under Unix/Linux

13.3.1. Configuring

You will initially need to run ModSnmp with a GUI in order to register the program and to create a configuration file. If the computer that you want to run ModSnmp on does not have an X-server, you should use ssh to login to the ModSnmp computer from a computer that does have an X-server. You can then use ssh to tunnel the ModSnmp GUI output to the X-server.

13.3.2. Starting automatically

In order to run ModSnmp as a server under Unix/Linux, you will have to arrange for ModSnmp to be started automatically at boot time. Unix/Linux systems vary in how they start processes at boot time (e.g SysV init, systemd). If you are not sure what method is used by your particular version of Unix/Linux, you should consult your system documentation.

13.3.2.1. systemd

This is the preferred method of starting ModSnmp if it is available, since it allows manual stopping & starting and it will automatically restart ModSnmp if it fails.

To start ModSnmp using systemd, download the file modsnmp.service from http://wingpath.co.uk/modbus/resource.php?product=modsnmp. and put it in the '/etc/systemd/system' directory. You will need to edit the "Environment" lines in modsnmp.service to suit your setup.

As root, use the command:

systemctl enable modsnmp

to enable automatic starting of ModSnmp at boot time.

You can check the status of ModSnmp using the command:

systemctl status modsnmp

If ModSnmp failed to start, this will provide information on why it failed.

You may manually stop ModSnmp using the command:

systemctl stop modsnmp

and restart it using the command:

systemctl start modsnmp
13.3.2.2. SysV init

If your system uses System V init for system initialization, you can use the example shell script from http://wingpath.co.uk/modbus/resource.php?product=modsnmp. You will need to change the pathname definitions to suit your setup.

The details of how to get this script run at boot time vary with different versions of Unix/Linux. You may, for example, need to put this script in the /etc/init.d directory and run a script such as chkconfig or update-rc.d to set up appropriately named links to it from the /etc/rcN.d directories.

If ModSnmp fails to start, you should look at the OUTPUT file for information on the cause of the failure.

You can manually stop and start ModSnmp using the commands rc.modsnmap stop and rc.modsnmp start. However, the SysV init method of starting will not automatically restart ModSnmp if it fails.

13.3.2.3. rc.local

If your Unix/Linux system has a file called '/etc/rc.local' or '/etc/rc.d/rc.local', you can start ModSnmp by adding something like the following to the file:

JAVA=/usr/bin/java
JARFILE=/home/modsnmp/modsnmp3.01.jar
PIDFILE=/var/run/modsnmp.pid
CONFIGFILE=/home/modsnmp/config.xml
OUTPUT=/home/modsnmp/modsnmp.out
$JAVA -jar $JARFILE -nogui $CONFIGFILE &<$OUTPUT &

You will need to change the definitions (USER, JARFILE, etc.) to suit your setup.

If ModSnmp fails to start, you should look at the OUTPUT file for information on the cause of the failure.

This method of starting ModSnmp does not provide an easy way to stop and restart ModSnmp. A variation of this method is to use the rc.modsnmp script, and run that from rc.local using the commands:

if [ -x /etc/init.d/rc.modsnmp ]
then
    /etc/init.d/rc.modsnmp start
fi

You could then manually stop and start ModSnmp using the commands rc.modsnmap stop and rc.modsnmp start.