Question
How can the hold_queue, debug_level and Server-1 values in the Agent for UNIX or Macintosh client.conf file be reset without using an editor?
Answer
Quite often, when troubleshooting Unix and Macintosh agent issues, it is helpful to modify certain values in the agent's client.conf file. Among those values are hold_queue and debug_level. The following (and attached) shell scripts can be used in place of using an editor to make the modifications to the client.conf file.
The hold_queue value, when set to a value of 1, will cause all nse files that are normally sent to the NS server to be left in the outgoing queue directory on the client. In this case, the files are NOT sent to the NS server. The nse files can then be evaluated to determine if correct inventory or status is being reported.
The debug_level is used to gather more or less detailed logging information for the various unix and mac processes running on a client computer.
The Server-1 value can be modified to direct the client computer to a different NS server. Simply changing the 'Server-1' value in the client.conf file and restarting the agent process will cause the agent to communicate to the new value. If the value specified in 'Server-1' is not a valid NS server, communication will obviously fail. The same results can be achieved by stopping the agent service and running 'aex-configure' with a config.xml file with a new NS server name value or by using the '-iconfigure' command line parameter and specifying a new NS server name at the first prompt.
These scripts require the use of root privileges or 'sudo' to modify the client.conf file and to restart the agent. If the agent restart process fails or stalls, enter 'ctrl-c' to break the currently running process and rerun the shell script using sudo, e.g., "sudo ./setholdq.sh"
To use these scripts, copy and paste them into an editor on the client. It is recommended that the scripts be named with a .sh extension, e.g., setholdq.sh, setdebuglevel.sh and setnsserver.sh. After creating the files, run chmod to make the files executeable, e.g., "chmod 755 setholdq.sh" or "chmod u_x setholdq.sh". The scripts will not run if they are not executable.
Alternatively, the scripts are attached to this KB article where you can download them. Be sure to remove the '.txt' extension, leaving the .sh extension, and run chmod to make them executable, as explained above.
These scripts show the before and after values of the name/value pair being modified.
To manage the hold_queue value, use the following script. A hold_queue value of 1 will prevent any data from being sent to the NS server. A value of 0 will allow data to be sent to the NS server. This script simply toggles the value between 0 and 1. It has no command line parameters except for -h (or -i) to view the command line usage description.
To manage the debug_level value, use the following script. This script requires that a value be entered on the command line. The only acceptable values are: error, warning, info, debug, dbgverbose and devnote. 'Error' is the least detailed and 'Devnote' is the most detailed. Typically, devnote will be used when troubleshooting. Values are NOT case sensitive.
To direct a client computer to a different NS server, use the following script. After restarting the agent process, which is done by this script, the agent will begin communicating to the specified NS server. It may be helpful to manually run 'aex-sendbasicinv' and 'aex-refreshpolicies' to speed resource creation on the NS and configuration update on the client.
#!/bin/sh
# This script sets the Server entry in the client.conf file to the value of the first command-line parameter
#
newServer=`echo $1`
if [ -z $newServer ] ; then
echo
echo 'Usage:'
echo ' A server name is required. Please specify a new server name on the command line.'
echo ' root privileges or sudo is required.'
echo ' Example: "sudo resetserver.sh newnsname"'
echo
exit 0
fi
#
#
# get ostype (darwin or anything else)
case `uname -s` in
*[Dd]arwin*) OSTYPE=Darwin ;;
*) OSTYPE=other ;;
esac
#
#
# get path to the client.conf file from client.conf using aex-helper - works on unix, linux & mac
conf_file=`aex-helper query config`
echo 'Path to client.conf is: ' $conf_file
#
# show the current Server value. aex-helper is not dependent on the agent process running
#curServer=`grep Server-1= $conf_file | awk 'BEGIN { FS="="; } { print $2 }'`
curServer=`aex-helper query ns`
echo "Server was set to: " $curServer
#
#
# set the new debug level and display the results and create a backup with 'prevserver' appended to the filename
sedCmd="sed -i prevserver s/Server-1=$curServer/Server-1=$newServer/ $conf_file"
#echo 'sedCmd is: ' $sedCmd
res=`$sedCmd`
#
#
echo "restarting altiris agent process..."
installdir=`aex-helper query path`
if [ $OSTYPE == 'Darwin' ] ; then
rccmd=$installdir'/.bin/rcscript restart'
echo $rccmd
res=`$rccmd`
else
res=`/opt/altiris/notification/nsagent/bin/rcscript restart`
fi
echo $res
#
curServer=`aex-helper query ns`
echo "Server is now set to: " $curServer
#