meta data for this page
  •  

Szebb 'q session' kimenet

6-os szerver verzióhoz írt lekérdezés, mely sortörés nélkül írja ki a 'q session' kimenetét, adatátviteli sebességekkel és session start idővel kiegészítve.

tsm_q_sess.sh
#!/bin/sh
TSMSERVER='tsmsrv01'
ID='tsm_user'
PA='tsm_pass'
 
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
LIGHT_GREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHT_CYAN='\033[1;36m'
DEFAULT='\033[0m'
SQL="SELECT SESSION_ID, CLIENT_NAME, substr(char(start_time),1,19) AS START_TIME,substr(char(days(current_timestamp) - days(start_time)),1,2) AS \"(D)\" ,substr(char((current_timestamp - start_time)hours),1,2) AS \"(HH)\", substr(char((current_timestamp - start_time)minutes),1,2) AS \"(MM)\", STATE,WAIT_SECONDS, cast(float(bytes_sent) /1024/1024 AS DEC(12,2)) AS \"Sent MB\", cast((cast(bytes_sent as dec(18,0))/cast(timestampdiff(2,char(current_timestamp-start_time)) as decimal(18,0))) / 1024 / 1024 AS DEC (10,2)) AS \"Sent MB/s\",cast(float(bytes_received) /1024/1024 AS DEC(10,2)) AS \"Rec. MB\", cast((cast(bytes_received as dec(18,0))/cast(timestampdiff(2,char(current_timestamp-start_time)) as decimal(18,0))) / 1024 / 1024 AS DEC (10,2)) AS \"Rec. MB/s\"  FROM sessions" # AND (BYTES_RECEIVED>1024*1024 OR BYTES_SENT>1024*1024)"
 
echo "SESSION_ID   CLIENT_NAME            START_TIME            ELAPTIME     STATUS               Sent MB      Sent MB/s    Recieved MB      Rec. MB/s"
echo "----------   --------------------   -------------------   ----------   -------------   ------------   ------------   ------------   ------------"
echo -e $GREEN$TSMSERVER$DEFAULT
dsmadmc -pa=$PA -id=$ID -dataonly=y -commadel -displ=list -se=$TSMSERVER "$SQL WHERE SESSION_TYPE='Node'" | awk -F',' '{printf "%10s   %-20s   %19s  %2dd %2dh %2dm   %-6s (%3ss)   %12s   %12s   %12s   %12s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12}'