logmon UNIX command profile that runs for several minutes is not returning output

Document ID : KB000033928
Last Modified Date : 10/09/2018
Show Technical Document Details
Introduction:
The UNIX logmon command profile must be able to execute the command successfully from the "sh -c" UNIX command.

An example of a command that may fail when executed from the "sh -c" command is as follows:

sh -c fline=0;interval=10;timeref=`date +%s`;while [ `date +%s` -lt ` echo $timeref+30|bc` ] ;do while read -r line; do nline=`echo $line | awk '{print $12}'`; fline=`expr $fline + $nline`; done < /proc/diskstats; sleep ${interval}; done; echo $fline

On some Linux systems, this sh command will hang and never return to the prompt.

If the sh command hangs and never returns, the logmon probe will experience the same behavior.? In those cases, you can include the command that the logmon profile should execute in a shell script file.? Add execute permissions to the shell script and then provide the absolute path to the shell script file for the command in the logmon profile to monitor the outputs of the desired command.

Here is how you would do this for the command provided in the example above:

1.Create the iostat.sh file in the /opt/nimsoft/probes/system/logmon directory with the following contents:

#! /bin/sh
fline=0;interval=10;timeref=`date +%s`;while [ `date +%s` -lt `echo $timeref+30|bc` ] ;do while read -r line; do nline=`echo $line | awk '{print $12}'`; fline=`expr $fline + $nline`; done < /proc/diskstats; sleep ${interval}; done; echo $fline

2 Add execute permissions to the file:

 chmod +x /opt/nimsoft/probes/system/logmon/iostat.sh

3.Change the logmon profile and replace the command with the pathname to the shell script:

 /opt/nimsoft/probes/system/logmon/iostat.sh

4. Save the change to the logmon configuration, apply the change and restart the probe.

The logmon probe will now monitor the outputs of the shell script.
Instructions:
Please Update This Required Field