RE: convert 'connected' to a datetime
Posted in 1998
The following script should aid in this endeavor.
I had a similar requirement. If you are not in the Pacific
time zone, you will need to adjust the script accordingly.
#!/usr/bin/ksh
#
# Script: sessions.sh
# PURPOSE: Show active Informix sessions with user, database, start
time
# USAGE: sessions.sh
#
# SAMPLE DISPLAY:
#
# sid user database tty start_time_pdt
pid
#
# 97 busobj busobj IVSD58004 1998-08-28 13:25
235
# 98 busobj busobj IVSD58004 1998-08-28 13:26
235
# 266 rbernste sysmaster 1998-08-29 14:59
28352
#
TIMEZONE=`date +%Z` # Get time zone from UNIX
if [[ $TIMEZONE = 'PDT' ]]
then
TIMEDIFF=7 # Pacific daylight savings time
elif [[ $TIMEZONE = 'PST' ]]
then
TIMEDIFF=8 # Pacific daylight time
else
TIMEDIFF=0 # Unsuppported time zone
fi
dbaccess sysmaster 2>/dev/null <<- EOF!
SELECT sid AS sid, -- Informix sessionid
username AS User, -- User name
sqs_dbname[1,16] AS Database, -- Database name
RPAD(tty,10,' ') AS tty, -- Workstation name
DATETIME (1970-01-01 00:00) YEAR TO MINUTE -- Start of UNIX
time
RPAD(tty,10,' ') AS tty, -- Workstation name
DATETIME (1970-01-01 00:00) YEAR TO MINUTE -- Start of UNIX
time
+ (connected/60) UNITS MINUTE -- UNIX time in
seconds
- (${TIMEDIFF}) UNITS HOUR -- Time zone
adjustment
AS start_time_$TIMEZONE,
pid -- UNIX process id
FROM syssessions, syssqlstat
WHERE sid = sqs_sessionid
ORDER BY start_time_$TIMEZONE;
EOF!
Good luck...
Rick
-----Original Message-----
From: Nicole Guffey [mailto:NGuffey@jdriscoll.com]
Sent: Wednesday, September 23, 1998 08:45
To: Informix List Serv (E-mail)
Subject: convert 'connected' to a datetime
I need to convert sysmaster.syssessions.connected from integer to datetime
year to second. Does anyone know how this can be done, or another way to
determine the datetime year to second that a connection was established?
Thank you,
Nicole Guffey
DBA
J. Driscoll & Associates
nguffey@jdriscoll.com