Thursday, March 13, 2008

UPDATE - ITM 6.1 Unix/Linux/Windows Agent Upgrades from a Windows HUB

Below is a script/batch file that will run on a Windows HUB or REMOTE TEM Server and take two arguments that will upgrade OS agents using a depot on the server where it is run.

This script has been validated in 2 separate Windows 2003 production environments as well as numerous test systems.

This may seem trivial and it is - but it's huge time saver plus I have it logging so you can track your agent upgrades. I just ran it at two customer sites and it was "set it and forget it". I came back a few hours later and my agents were upgraded.

I capture the resulting error code for troubleshooting later, I have also the timeout to 10 minutes instead of the default 5 minutes. This is a fully supportable solution because we are using the standard depot and simply putting a wrapper around the commands and changing the number of files in a depot structure.

This is a batch file, or .bat file. Copy the following text all the way down to and including the work "exit" and paste it into a new file. Save it on your Windows HUB and Remote TEMS. Before running this file, login using the tacmd login command.

Run the program with with 2 argument. The first is the agent/product code you want to upgrade - acceptable values are NT, UX and LZ for Windows, Unix and Linux OS agent. The next is the versions of those agents that you want to upgrade, acceptable values are 06.10.00.00, 06.10.02.00, 06.10.03.00, 06.10.04.00 and 06.10.01.00. Logging occurs in the directory where the program is run from.


@echo off
REM This script takes 2 input options. The first is an agent Product code. Valid options would
REM be NT UX and LZ.
REM The second option is the version of agents that you want to upgrade. Valid options are
REM 06.10.00.00, 06.10.04.00, 06.10.03.00, 06.10.02.00, 06.10.01.00


set TACMD_TIMEOUT=10
tacmd listsystems -t %1 | findstr %2 >upglist.txt

if ERRORLEVEL 0 GOTO UPGRADE
echo not upgradeing

:UPGRADE
echo do the upgrade
for /F %%f IN (upglist.txt) do ( FOR /F "TOKENS=*" %%A IN ('TIME /T') DO SET TIME=%%A
FOR /F "TOKENS=*" %%B IN ('DATE /T') DO SET DATE=%%B
echo %DATE%,%TIME%-Currently Upgrading-%%f
echo %DATE%,%TIME%,Currently Upgrading-%%f,was %2 >>agent_upgrade.txt
tacmd updateagent -t %1 -n %%f -f
echo Result Code for %%f is %ERRORLEVEL% >>agent_upgrade.txt)

:END
exit

UPDATE - Here is a shell script version that works on Unix and Linux

#!/bin/sh
LOG=agent_upgrade.log
DATE=`date`
for x in `./tacmd listsystems -t $1 | grep $2 | cut -f1 -d" "`
do
echo tacmd updateagent -t $1 -n $x -f
if [ "$?" = 0 ]
then
echo $DATE - Upgrade on $x successful >>$LOG
else
echo $DATE - Upgrade on $x failed >>$LOG
fi
done



No comments: