Hitachi

JP1 Version 12 JP1/Extensible SNMP Agent Description, Operator's Guide and Reference


2.10.3 Creating the shell commands to be executed during SNMP request

You must create shell commands that you specified in the /etc/SnmpAgent.d/snmpd.extend file. The following explains how to create them.

The shell commands are UNIX shell scripts or programs. The /opt/OV/prg_samples/eagent directory contains an example of creating the /etc/SnmpAgent.d/snmpd.extend file. This example contains sample shell commands.

Note the following when determining command names:

The following procedure shows how to create a command.

Procedure

  1. Log in to the system on which you want to execute the command.

  2. Write a shell script or program.

  3. Verify the operation of the shell command.

  4. Check the exit code.

  5. Check the arguments of the shell command.

The procedure for creating commands is as follows:

Organization of this subsection

(1) Logging in to the system

Log in to the system on which you want to execute the commands.

(2) Writing a script or program

The following explains how to write a shell script or program.

(3) Verifying the operation of your shell command

Execute the shell command to make sure that it executes successfully.

To check whether the fmailListMsg-related command in the /etc/SnmpAgent.d/snmpd.extend file executes successfully, execute the following command:

/usr/bin/mailq

If the execution is successful, the command outputs a mail message list to standard output.

(4) Checking the exit code

Execute the following command and check the exit code. If the exit code is 0, your shell command has normally terminated.

echo $?

(5) Checking the arguments of your shell command

If your shell command has arguments, verify the arguments.

The following example checks the definition and arguments in the /etc/SnmpAgent.d/snmpd.extend file:

Definition in the /etc/SnmpAgent.d/snmpd.extend file
READ-COMMAND:/opt/OV/prg_samples/eagent/num_widgets $i $c $o $s
Checking the arguments
num_widgets 15.2.3.149 public 1.3.6.4.4242.3.1 Gauge