368 Implementing a Tivoli Solution for Central Management of Large Distributed Environments
exit 5
fi
# Subscribe the endpoint to the appropriate profile manager
wsub -r @$profile_manager @Endpoint:$ep_label
if [ $? -eq 0 ]; then
echo “Endpoint $ep_label subscribed to Profile Manager $profile_manager
successfully.” >> $LOG_FILE
else
echo “Endpoint $ep_label failed to subscribe to Profile Manager
$profile_manager.” >> $LOG_FILE
echo “Either the profile manager or the endpoint is unreachable.” >>
$LOG_FILE
exit 6
fi
A.3.9 ep_login_notif.sh
This script in Example A-16 is used by the after_login policy to initiate an initial
inventory scan of new endpoints.
Example: A-16 ep_login_notif.sh
#!/bin/sh
set -x
ep_label=$1
INTERP=$2
POL_DIR=”/mnt/code/tivoli/scripts/policies”
JRE_DIR=”$POL_DIR/../../ITM/5.1.2/base/generic/Tools/JRE”
LOG_FILE=”$DBDIR/../policies/logs/wdistinv.log”
REGION=‘echo $ep_label | cut -d “_” -f2‘
STORE=‘echo $ep_label | cut -d “_” -f3 | cut -d “-” -f1‘
policy_region=$(wlookup -ar PolicyRegion|grep $REGION’_’EP|awk ‘{print $1}’)
TMR_NAME=$(idlattr -tgv ‘wlookup ServerManagedNode‘ label string |sed -e
“s/\”//g”)
# Check if the EP is running...
echo “Sleeping for 5 minutes waiting for the EP to complete the first normal
login, please wait...” >> $LOG_FILE
sleep 300
echo “Sleep complete!” >> $LOG_FILE
echo “Entering in Inventory section...” >> $LOG_FILE
wupdate -r Endpoint All >> $LOG_FILE
echo “wupdate complete!” >> $LOG_FILE
echo “Checking if the EP is alive...” >> $LOG_FILE
wep $ep_label status >> $LOG_FILE
Appendix A. Configuration files and scripts 369
RC=$?
if [ $RC -eq 0 ] ; then
# Distribute the Hardware inventory profile
echo “$ep_label” >> $LOG_FILE
wdistinv @InventoryConfig:HW @Endpoint:$ep_label >> $LOG_FILE
EC=$?
if [ $EC -eq 0 ] ; then
wpostemsg -m “Endpoint $ep_label started HW scan” -r HARMLESS EVENT
EVENT
else
inventory_config=$(wlookup -ar InventoryConfig|grep “HW”|grep $TMR|grep
$TMR_NAME|awk ‘{print $1}’)
wdistinv @InventoryConfig:$inventory_config @Endpoint:$ep_label >>
$LOG_FILE
RC=$?
if [ $RC -eq 0 ] ; then
wpostemsg -m “Endpoint $ep_label started HW scan” -r HARMLESS EVENT
EVENT
else
echo “Failed to submit the HW inventory scan.” >> $LOG_FILE
exit 1
fi
fi
# Distribute the Software inventory profile
echo “$ep_label” >> $LOG_FILE
wdistinv @InventoryConfig:SW @Endpoint:$ep_label >> $LOG_FILE
EC=$?
if [ $EC -eq 0 ] ; then
wpostemsg -m “Endpoint $ep_label started SW scan” -r HARMLESS EVENT
EVENT
else
inventory_config=$(wlookup -ar InventoryConfig|grep “SW”|grep $TMR|grep
$TMR_NAME|awk ‘{print $1}’)
wdistinv @InventoryConfig:$inventory_config @Endpoint:$ep_label >>
$LOG_FILE
RC=$?
if [ $RC -eq 0 ] ; then
wpostemsg -m “Endpoint $ep_label started SW scan” -r HARMLESS EVENT
EVENT
else
echo “Failed to submit the SW inventory scan.” >> $LOG_FILE
exit 2
fi
fi
else

Get Implementing a Tivoli Solution for Central Management of Large Distributed Environments now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.