ADSM-L

Re: [ADSM-L] finding possible values for a particular column

2015-04-10 13:28:20
Subject: Re: [ADSM-L] finding possible values for a particular column
From: Dwight Cook <cookde AT COX DOT NET>
To: ADSM-L AT VM.MARIST DOT EDU
Date: Fri, 10 Apr 2015 12:26:25 -0500
This is yesterday.ksh


#!/bin/ksh
# if called with no parameters, gives you yesterday's date in mm/dd/yyyy
format
# if passed "mm dd yyyy" it will return the previous day in mm/dd/yyyy
format
#

if [ $# -ne 0 ]
then
  if [ $# -ne 3 ]
  then
    echo usage : yesterday.ksh [ mm dd yyyy ]
    exit
  else
    MM=$1
    DD=$2
    YYYY=$3
  fi
else
  MM=$(date +%m)
  DD=$(date +%d)
  YYYY=$(date +%Y)
fi
if [ $DD = '01' ]
then
  WKMTH=$MM
  WKYR=$YYYY
  case $WKMTH in
        01)     LASTMTH=12
                let "WKYR=WKYR-1";;
        02)     LASTMTH=01;;
        03)     LASTMTH=02;;
        04)     LASTMTH=03;;
        05)     LASTMTH=04;;
        06)     LASTMTH=05;;
        07)     LASTMTH=06;;
        08)     LASTMTH=07;;
        09)     LASTMTH=08;;
        10)     LASTMTH=09;;
        11)     LASTMTH=10;;
        12)     LASTMTH=11;;
  esac
  for PREVDAY in $(cal $LASTMTH $WKYR | grep [0-9] | tail -1)
     do
     echo $PREVDAY > /dev/null
     done
  echo $LASTMTH/$PREVDAY/$WKYR
else
  case $DD in
        02)     PREVDAY=01;;
        03)     PREVDAY=02;;
        04)     PREVDAY=03;;
        05)     PREVDAY=04;;
        06)     PREVDAY=05;;
        07)     PREVDAY=06;;
        08)     PREVDAY=07;;
        09)     PREVDAY=08;;
        10)     PREVDAY=09;;
        *)      let PREVDAY=DD-1;;
  esac
  echo $MM/$PREVDAY/$YYYY
fi
exit

-----Original Message-----
From: ADSM: Dist Stor Manager [mailto:ADSM-L AT VM.MARIST DOT EDU] On Behalf Of
Rhodes, Richard L.
Sent: Friday, April 10, 2015 11:22 AM
To: ADSM-L AT VM.MARIST DOT EDU
Subject: Re: [ADSM-L] finding possible values for a particular column

Hmmm . . . Linux . . . We're on AIX and its date doesn't handle that.  Have
to see about getting gnu date for aix.

Thanks!

Rick


-----Original Message-----
From: ADSM: Dist Stor Manager [mailto:ADSM-L AT VM.MARIST DOT EDU] On Behalf Of
Hanover, Cameron
Sent: Friday, April 10, 2015 10:36 AM
To: ADSM-L AT VM.MARIST DOT EDU
Subject: Re: finding possible values for a particular column

It's just a bash script, so:
yesterday=`date -d yesterday +%m/%d/%Y`
today=`date +%m/%d/%Y`

-
Cameron Hanover
chanover AT umich DOT edu

"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety."
--Benjamin Franklin

> On Apr 9, 2015, at 3:18 PM, Rhodes, Richard L.
<rrhodes AT FIRSTENERGYCORP DOT COM> wrote:
>
> Hi Cameron,
>
> I'd be interested how you get the value for var ${yesterday} in your
script?  (assuming you compute it off of ${today} ?)
>
> I've wanted to derive an earlier date (like the date of a week ago) in a
script a number of times and couldn't come up with a simple way to do it.
>
> Rick
>
>
> -----Original Message-----
> From: ADSM: Dist Stor Manager [mailto:ADSM-L AT VM.MARIST DOT EDU] On Behalf 
> Of
Hanover, Cameron
> Sent: Thursday, April 09, 2015 1:15 PM
> To: ADSM-L AT VM.MARIST DOT EDU
> Subject: Re: finding possible values for a particular column
>
> Rather than figure out all the possible conditions, I just scripted for
the ones I cared about and warned on the rest:
>
> for STATUS in `tsm_run_command_as_admin $INSTANCE -tab "select status from
events where domain_name like upper('${PREFIX}%') and
scheduled_start>'${yesterday} 09:00' and scheduled_start<'${today} 09:00'"`;
do
>       if [[ "$STATUS" == Failed* ]]; then
>               NODESFAILED="YES"
>       elif [ "$STATUS" = "Missed" ]; then
>               NODESMISSED="YES"
>       # Some unknown exception will produce a "WARNING"
>       elif [ ! "$STATUS" = "Completed" ] && [ ! "$STATUS" = "In Progress"
] && [ ! "$STATUS" = "Started" ] && [ ! "$STATUS" = "Pending" ]; then
>               EXCEPTIONFOUND="YES"
>       fi
> done
> .
> if [ "$NODESFAILED" = "YES" ]; then
>       SUBJECT="[TSMCLIENT] NODES FAILED: $LABEL Daily Report"
> elif [ "$NODESMISSED" = "YES" ]; then
>       SUBJECT="[TSMCLIENT] NODES MISSED: $LABEL Daily Report"
> elif [ "$EXCEPTIONFOUND" = "YES" ]; then
>       SUBJECT="[TSMCLIENT] WARNING: $LABEL Daily Report"
> else
>       SUBJECT="[TSMCLIENT] $LABEL Daily Report"
> fi
>
>
> Hopefully the variable names are obvious.  Might have been better with
`case`, but this works.
>
> --
> Cameron Hanover
> chanover AT umich DOT edu
>
> "A computer once beat me at chess, but it was no match for me at kick
boxing."
> --Emo Philips
>
>> On Apr 8, 2015, at 2:55 PM, Lee, Gary <GLEE AT BSU DOT EDU> wrote:
>>
>> Is there a list somewhere of the possible values for different columns in
the tsm database?
>>
>> What I am particularly looking for are all the possible values of the
status column in the events table.
>>
>> Writing a script to notify backup schedules which have gone amiss.
>>
>> Don't care about restarted, in progress, etc.  just error conditions.
>>
>> Thanks for any pointers.
>
>
> -----------------------------------------
> The information contained in this message is intended only for the
personal and confidential use of the recipient(s) named above. If the reader
of this message is not the intended recipient or an agent responsible for
delivering it to the intended recipient, you are hereby notified that you
have received this document in error and that any review, dissemination,
distribution, or copying of this message is strictly prohibited. If you have
received this communication in error, please notify us immediately, and
delete the original message.


-----------------------------------------
The information contained in this message is intended only for the personal
and confidential use of the recipient(s) named above. If the reader of this
message is not the intended recipient or an agent responsible for delivering
it to the intended recipient, you are hereby notified that you have received
this document in error and that any review, dissemination, distribution, or
copying of this message is strictly prohibited. If you have received this
communication in error, please notify us immediately, and delete the
original message.