I've been asked how one might be notified if a USB hardware key ("token") is about to expire because the only obvious methods are to manually check using the token command or to watch the original console from which awsstart was started. I've put together a very small bash script that can be run as a daily cron job that checks the expiration date and sends an e-mail when expiration is approaching. This works for RD&T 8.5 only and should be considered as a sample, not necessarily production level tested.
#!/bin/bash # # Send an e-mail when a RDT USB hardware key activation is about to expire. # This works with Rational Development and Test Environment only. # For previous releases (RDzUT), the EXPDATE and SERIAL regular expressions # would need to be modified because the format of the "token" command changed. # This is a sample only. It is provided here as a convenience. # # This code was only run on one system. It should not be considered fully tested!!! # ---- ---- --- ---- --- -- --- ------ -- ------ --- -- ---------- ----- --------- # # Setup: # - Ensure that sendmail is configured and that the "mail" command can send a note. # - Set the EMAILADDRESS and THRESHOLD variables below. # - Ensure PATH and LD_LIBRARY_PATH exports below are set correctly # - Ensure that awsstart is running for the token command to work # - Once this script works from the command line, setup a cron job with crontab -e. # An example cron entry is: # @daily /home/ibmsys1/expiredTokenCheck.sh # # Suggested changes: # Instead of (or in addition to) email, you may want to FTP a file to your # z/OS system, run a z/OS console command through "oprmsg" or take other actions. EMAILADDRESS=rdtadmin@yourcompany.com # email address to receive notificaitons THRESHOLD=30 # number of days before expiration to start notification export PATH=/usr/z1090/bin:$PATH # location of token command export LD_LIBRARY_PATH=/usr/z1090/bin:$LD_LIBRARY_PATH # location of libman.so EXPDATE=`token|head -n 1 | sed -e "s/.*EXP=//"` SERIAL=`token|head -n 1 | sed -e "s/.*Lic=.*(//" -e "s/).*//"` if [ ! -z $SERIAL ]; then # if serial number was found TOKENDATE=`date -d $(token|head -n 1 | sed -e "s/.*EXP=//g" ) +"%s"` # get expire date TODAY=`date +%s` # get today date in seconds DAYSLEFT=$(( ($TOKENDATE-$TODAY)/(24*3600) )) # get days left echo Today\'s Date: $(date), echo USB Token file time remaining: $DAYSLEFT Days if [ $THRESHOLD -ge $DAYSLEFT ]; then # if days left <= threshold send mail or other action(s). # This is where you would send an email or take other actions. # NOTE=/tmp/$(id -un).txt # create temporary file name NOTE=`mktemp` echo "**** USB Serial $SERIAL will expire within $THRESHOLD days. ($DAYSLEFT remaining)" > $NOTE echo "**** A new license file is will be required by $EXPDATE" >> $NOTE echo >> $NOTE ; token >> $NOTE ; echo >> $NOTE ; echo Hostname: `hostname` >> $NOTE echo Sending $NOTE to $EMAILADDRESS for serial $SERIAL... cat $NOTE mail -s "RDT-$SERIAL-expiration-warning-$DAYSLEFT-days" $EMAILADDRESS < $NOTE rm $NOTE fi fi
Doug Nadel
RD&T
SystemAdmin