Chinaunix

标题: 如何找出空闲时间已超过15分钟的session? [打印本页]

作者: James_Guan    时间: 2006-01-04 12:13
标题: 如何找出空闲时间已超过15分钟的session?
请问informix中,如何找出空闲时间已超过15分钟的session?
作者: czw1413_cn    时间: 2006-01-04 18:42
提示: 作者被禁止或删除 内容自动屏蔽
作者: IFMXDBA    时间: 2006-01-04 20:03
标题: 回复 1楼 James_Guan 的帖子
try onstat -g ntt
作者: James_Guan    时间: 2006-01-05 09:41
IFMXDBA的方法似乎不错。
另外我看到sysmaster中的syssessions表似乎也有记录,
connected字段是表示连接时间,可是我实在看不懂那一串数字表示什么,
请问有哪位能解释一下吗?
作者: wenlq    时间: 2006-01-05 10:58
select *
from sysmaster:syssessions
where  current -DBINFO( 'UTC_TO_DATETIME', connected )
> interval(15:00 ) minute to second

这个可以看 连接时间超15分钟的,但怎么判断空闲
作者: IFMXDBA    时间: 2006-01-06 09:12
标题: 回复 5楼 wenlq 的帖子
onstat -g ntt and SMI interface (sysmaster ) will tell you the timestamp of last open and last write/read operation. If we diff those two time stamp, we may roughly get some idea of the idle time.
作者: sam_8286    时间: 2006-01-06 10:50
要这个信息派什么用处呢?
作者: James_Guan    时间: 2006-01-06 11:26
因为我们server的性能有限,而user很多,而且有些user习惯不好,打开一个程序,然后就离开了。
但是该程序还连接在db中,还是会占用mem等资源,所以,我想把他们找出来,然后kill掉他们的进程,以腾出资源给别人用。
作者: James_Guan    时间: 2006-01-06 11:29
原帖由 IFMXDBA 于 2006-1-6 09:12 发表
onstat -g ntt and SMI interface (sysmaster ) will tell you the timestamp of last open and last write/read operation. If we diff those two time stamp, we may roughly get some idea of the idle time.

IFMXDBA可否详细点,sysmaster中哪几个表中会有这些记录?
作者: 大蚂蚁    时间: 2006-01-06 13:48
原帖由 James_Guan 于 2006-1-6 11:26 发表
因为我们server的性能有限,而user很多,而且有些user习惯不好,打开一个程序,然后就离开了。
但是该程序还连接在db中,还是会占用mem等资源,所以,我想把他们找出来,然后kill掉他们的进程,以腾出资源给别人 ...

不要把所有都丢给服务器做,这个可以在客户端上做的嘛
作者: IFMXDBA    时间: 2006-01-07 09:02
标题: 回复 9楼 James_Guan 的帖子
Here is an example for you:-
Following is a simplified script, you can write your own.  Put it into cron table and let system check/kill the idle session periodically.


#8<----- cut from here ---->8#
#!/bin/ksh
# KillEliteQ.sh
# Kill EliteQ sessions which is idle for more than 1 hour
# Must be run at currly by root, or user in informix group
#
. /informixd/ids94/dmsenv.sh
dbaccess master_dms << EOF 1>/dev/null 2>&1
  set isolation dirty read;
  unload to /tmp/EliteQ.idle delimiter " "
  select {+ ordered }
       b.sid
     from sysmaster:syssqlstat a, sysmaster:sysrstcb b, sysmaster:sysscblst c, EliteQSes
    where b.sid = a.sqs_sessionid
      and c.sid = a.sqs_sessionid
      and b.sid = EliteQSes.sid
      and b.nreads = EliteQSes.nreads;
EOF

for sid in `cat /tmp/EliteQ.idle`
  do
    onstat -g ses |grep $sid
    #onmode -z $sid
    #echo "onmode -z $sid"
  done

rm /tmp/EliteQ.idle

dbaccess master_dms << EOF 1>/dev/null 2>&1
  delete from EliteQSes where 1=1 ;
  insert into EliteQSes
    select {+ ordered }
           b.sid, b.nreads
     from sysmaster:syssqlstat a, sysmaster:sysrstcb b, sysmaster:sysscblst c
    where b.sid = a.sqs_sessionid
      and c.sid = a.sqs_sessionid ;
EOF
作者: kevinlewis    时间: 2006-05-10 11:23
強!         頂 !
ding ding
作者: syitssa    时间: 2006-05-10 15:52
onstat -g ntt 好像不错
作者: IFMXDBA    时间: 2006-05-13 11:30
标题: 回复 1楼 James_Guan 的帖子
Post my previous notes again:-

Here is an example for you:-
Following is a simplified script, you can write your own.  Put it into cron table and let system check/kill the idle session periodically.


#8<----- cut from here ---->8#
#!/bin/ksh
# KillEliteQ.sh
# Kill EliteQ sessions which is idle for more than 1 hour
# Must be run at the server where Informix resides
# and must be run by root, informix or user in informix group
#
. /informixd/ids94/dmsenv.sh
dbaccess master_dms << EOF 1>/dev/null 2>&1
  set isolation dirty read;
  unload to /tmp/EliteQ.idle delimiter " "
  select {+ ordered }
       b.sid
     from sysmaster:syssqlstat a, sysmaster:sysrstcb b, sysmaster:sysscblst c, EliteQSes
    where b.sid = a.sqs_sessionid
      and c.sid = a.sqs_sessionid
      and b.sid = EliteQSes.sid
      and b.nreads = EliteQSes.nreads;
EOF

for sid in `cat /tmp/EliteQ.idle`
  do
    onstat -g ses |grep $sid
    onmode -z $sid
    #echo "onmode -z $sid"
  done

rm /tmp/EliteQ.idle

dbaccess master_dms << EOF 1>/dev/null 2>&1
  delete from EliteQSes where 1=1 ;
  insert into EliteQSes
    select {+ ordered }
           b.sid, b.nreads
     from sysmaster:syssqlstat a, sysmaster:sysrstcb b, sysmaster:sysscblst c
    where b.sid = a.sqs_sessionid
      and c.sid = a.sqs_sessionid ;
EOF
作者: centuar    时间: 2006-05-17 00:15
同意楼上的建议。若真的希望通过数据库进行控制,是否可以考虑修改sqlhosts文件,使用option项,把k设为0,关掉keep-alive项?




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2