Client Management Suite

 View Only

Shell Scripts to Manage the Unix, Linux & Macintosh debug_level, hold_queue and server-1 client.conf settings 

May 01, 2009 03:17 PM

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 executable, 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.

--------------------------------------------------------------------------------
#!/bin/sh
# This script toggles the nsagent client.conf hold_queue value between 0 and 1
#
# get command line parm and show help screen
comparm=`echo $1`
case $comparm in 
-h|-i) 
echo 
echo 'USAGE:'
echo ' This utility requires root privileges or the use of sudo.'
echo ' No other parameters are required. "-h" or "-i" will show this help screen.'
echo ' The value of the hold_queue parameter will toggle between 0 and 1 each time this script is ran.'
echo ' Example: "sudo '$0'"'
echo
exit 0
esac
#
#
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
#
#
curVal=`grep hold_queue= $conf_file | awk 'BEGIN { FS="="; } { print $2 }'`
echo "hold_queue was set to: " $curVal
#
#
if [ $curVal == 0 ] ; then
sedCmd="$sedCmd sed -i prev s/hold_queue=0/hold_queue=1/ $conf_file"
else
sedCmd="$sedCmd sed -i prev s/hold_queue=1/hold_queue=0/ $conf_file"
fi
#
`$sedCmd`
#
#
curVal=`grep hold_queue= $conf_file | awk 'BEGIN { FS="="; } { print $2 }'`
echo "hold_queue is now set to: " $curVal

--------------------------------------------------------------------------------

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.

--------------------------------------------------------------------------------
#!/bin/sh
# This script sets debug level in the client.conf file to the value of the first command-line parameter
#
# get new debug_level value from command line; convert to uppercase for comparison
newDebugLevel=`echo $1 | tr '[:lower:]' '[:upper:]'`
case "$newDebugLevel" in
ERROR|WARNING|INFO|DEBUG|DBGVERBOSE|DEVNOTE) ;;
*) echo 
echo 'USAGE:'
echo ' Valid parameters are: ERROR | WARNING | INFO | DEBUG | DBGVERBOSE | DEVNOTE'
echo ' Parameters are NOT case sensitive'
echo ' This utility requires root privileges or the use of sudo.'
echo ' Example: "sudo '$0' error"'
echo
exit 0
;;
esac
#
#
# get path to the client.conf file based on system type
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 debug_level value
curDebugLevel=`grep debug_level= $conf_file | awk 'BEGIN { FS="="; } { print $2 }'`
echo "debug_level was set to: " $curDebugLevel
#
#
# set the new debug level and display the results
sedCmd=''
if [ $OSTYPE == 'Darwin' ] ; then
sedCmd="$sedCmd sed -i prevdbg s/debug_level=$curDebugLevel/debug_level=$newDebugLevel/ $conf_file"
else
sedCmd="sed -i prevdbg s/debug_level=$curDebugLevel/debug_level=$newDebugLevel/ $conf_file"
fi
res=`$sedCmd`
#echo 'res='$res
#
#
echo "restarting altiris agent process..."
installdir=`aex-helper query path`
if [ $OSTYPE == 'Darwin' ] ; then
rccmd=$installdir'/.bin/rcscript restart'
res=`$rccmd`
else
res=`/opt/altiris/notification/nsagent/bin/rcscript restart`
fi
#
#
curDebugLevel=`grep debug_level= $conf_file | awk 'BEGIN { FS="="; } { print $2 }'`
echo "debug_level is now set to: " $curDebugLevel
#
#
--------------------------------------------------------------------------------

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 server-1 value 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
#

Statistics
0 Favorited
0 Views
3 Files
0 Shares
0 Downloads
Attachment(s)
txt file
setdebuglevel.sh_.txt   1 KB   1 version
Uploaded - Feb 25, 2020
txt file
setholdq.sh_.txt   1 KB   1 version
Uploaded - Feb 25, 2020
txt file
setnsserver.sh_.txt   1 KB   1 version
Uploaded - Feb 25, 2020

Tags and Keywords

Related Entries and Links

No Related Resource entered.