Link to home
Start Free TrialLog in
Avatar of TSMIL
TSMIL

asked on

Filter tsm reprot

hi ,
i run this script -
#!/bin/bash -x
ID=test
PAS=test
HOST=$HOSTNAME
TODAY=$(date +"%Y.%m.%d")
tsm_output=/tmp/status.$TODAY.$HOST.txt
cat </dev/null> $tsm_output
/usr/bin/dsmadmc -id=$ID -passw=$PAS  << EOF >> $tsm_output
select cast(entity as char(18)) Node, -
cast(activity as char(6)) Task, -
date(start_time) Date, -
time(start_time) Time, -
successful -
from summary -
where activity='BACKUP' and -
    entity in ( 'NODENAME','NODENAME' ) -
and ( -
   (date(START_TIME)=date(current_timestamp-1 day) and hour(start_time)>=18) -
  or -
   (date(START_TIME)=date(current_timestamp) and hour(start_time)<8) -
      ) -
order by START_TIME
quit
EOF
/usr/bin/mutt -s "Missed/Failed schedule report" -a $tsm_output TEST@gmail.com < /dev/null

the result that i got is attached to this question

how can I filter so that the result look like this

NODENAME_NEW1   yes          
NODENAME_NEW2   yes          
NODENAME_NEW2   yes          
NODENAME_NEW1   no
NODENAME_NEW2   no

Thx
filter.txt
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Do you want to change the query itself so that its output is in the new format you posted, or do you want to leave the query result as it is and just filter it for sending?

If you want to keep the original output and just filter for sending add before the "/usr/bin/mutt" line:

awk '{printf "%-20s%-5s\n",$1,$NF}' $tsm_output > ${tsm_output}.tmp

and change the "mutt" command like this:

/usr/bin/mutt -s "Missed/Failed schedule report" -a ${tsm_output}.tmp TEST@gmail.com < /dev/null
rm ${tsm_output}.tmp
If you want to change the query itself:

#!/bin/bash -x
ID=test
PAS=test
HOST=$HOSTNAME
TODAY=$(date +"%Y.%m.%d")
tsm_output=/tmp/status.$TODAY.$HOST.txt
cat </dev/null> $tsm_output
/usr/bin/dsmadmc -id=$ID -passw=$PAS  << EOF >> $tsm_output
select cast(entity as char(18)) Node, -
successful -
from summary -

where activity='BACKUP' and -
    entity in ( 'NODENAME','NODENAME' ) -
and ( -
   (date(START_TIME)=date(current_timestamp-1 day) and hour(start_time)>=18) -
  or -
   (date(START_TIME)=date(current_timestamp) and hour(start_time)<8) -
      ) -
order by START_TIME
quit
EOF
/usr/bin/mutt -s "Missed/Failed schedule report" -a $tsm_output TEST@gmail.com < /dev/null

means: remove the 3 lines after "select cast(entity as char(18)) Node, -" and before "successful -"
Avatar of TSMIL
TSMIL

ASKER

hi

this is not want i want to got

i attach the output file to here

i want to see if there nodename1 several  time = yes i want to display only one time

nodename1 yes
nodename1 yes
nodename1 no
nodename1 yes

 i want the display will be

nodename1 yes
nodename1 no
Ex.txt
Again: do you want a modified report, or do you want to keep the original output and just create a modified temporary file for sending?

Anyway, the modified report would look like this:

#!/bin/bash -x
ID=test
PAS=test
HOST=$HOSTNAME
TODAY=$(date +"%Y.%m.%d")
tsm_output=/tmp/status.$TODAY.$HOST.txt
cat </dev/null> $tsm_output
/usr/bin/dsmadmc -id=$ID -passw=$PAS  << EOF >> $tsm_output
select max(cast(entity as char(18))||'  '||successful) as  -
   "Node                Success"   -
from summary -
where activity='BACKUP' and -
    entity in ( 'NODENAME','NODENAME' ) -
and ( -
   (date(START_TIME)=date(current_timestamp-1 day) and hour(start_time)>=18) -
  or -
   (date(START_TIME)=date(current_timestamp) and hour(start_time)<8) -
      ) -
group by  entity||successful
quit
EOF
/usr/bin/mutt -s "Missed/Failed schedule report" -a $tsm_output TEST@gmail.com < /dev/null

On the other hand, if you need a modified, temporary file for sending please let me know!
Avatar of TSMIL

ASKER

hi again

im sorry - what i want that even if node will appear several times in the report i will only see it one time  

this the original report - as you can see nodename 1 appear 4 times

nodename1 yes
nodename1 yes
nodename1 no
nodename1 yes

and this is what i want to display

nodename1 no
nodename1 yes
I know what you want.

Did you test the new report I posted in my previous comment?
Avatar of TSMIL

ASKER

yes

it will show like this

nodename1 yes
nodename1 yes
nodename1 no
nodename1 yes
Sorry, cannot confirm. It works for me.

I mean this suggestion just above in comment # 40818748:

#!/bin/bash -x
ID=test
PAS=test
HOST=$HOSTNAME
TODAY=$(date +"%Y.%m.%d")
tsm_output=/tmp/status.$TODAY.$HOST.txt
cat </dev/null> $tsm_output
/usr/bin/dsmadmc -id=$ID -passw=$PAS  << EOF >> $tsm_output
select max(cast(entity as char(18))||'  '||successful) as  -
   "Node                Success"   -
from summary -
where activity='BACKUP' and -
    entity in ( 'NODENAME','NODENAME' ) -
and ( -
   (date(START_TIME)=date(current_timestamp-1 day) and hour(start_time)>=18) -
  or -
   (date(START_TIME)=date(current_timestamp) and hour(start_time)<8) -
      ) -
group by  entity||successful
quit
EOF
/usr/bin/mutt -s "Missed/Failed schedule report" -a $tsm_output TEST@gmail.com < /dev/null

Open in new window

Do you ever read any of my answers up to the end?
Avatar of TSMIL

ASKER

maybe because the server get one time to backup
in my case is reach every 15 min because of this is will get the same node name  and status so much times

i want to display only unique node name and his status

if i got 3 times that the same node name got yes and no for backup status i want to display him only one time like

node name no and also the start time
node name yes and also the start time

i think that the only its work it if i can play with the display after the SELECT

hope you can help me
Sorry, I already told you - it works for me (without the start time).

You cannot reliably display the start time along with the desired output if you have more than one failed and/or more than one one successful run in the given interval.

Which of the start times is TSM supposed to select when there are several suucessful or failed runs for the same node?
Avatar of TSMIL

ASKER

ok i will try this

which script work for you ?
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial