GBase 8a 默认能获得所有的故障event信息,当event比较多时,需要人工将信息进行筛选。本文通过pyton调用gcware库获得指定表的所有event信息。
目录导航
参考
脚本程序
[gbase@rh6-1 zxq]$ cat getEventByTablename.py
#!/usr/bin/env python
import sys
if len(sys.argv)!=3:
print('Usage: dbname table')
exit(1)
import gcware
tablename=sys.argv[1]+'.'+sys.argv[2]
print 'check',tablename,' ...'
print '-----dmlevent---------'
all=gcware.getdmlfevents()
for o in all:
if o['tablename']==tablename:
print('eventid=%s' %(o['eventid']))
print('tabletype=%s' %(o['tabletype']))
for n in o['dmldatacopyids']:
print 'nodeipaddr='+n['nodeipaddr']
print 'segname='+n['segname']
print
print '-----ddlevent---------'
all=gcware.getddlfevents()
for o in all:
if o['tablename']==tablename:
print('eventid=%s' %(o['eventid']))
print('tabletype=%s' %(o['tabletype']))
# print('datacopyids=',o['datacopyids'])
for n in o['datacopyids']:
print 'nodeipaddr='+n['nodeipaddr']
print 'segname='+n['segname']
print '-----dmlstorageevent---------'
all=gcware.getdmlstoragefevents()
for o in all:
if o['tablename']==tablename:
print('eventid=%s' %(o['eventid']))
print('tabletype=%s' %(o['tabletype']))
n=o['datacopyid']
print 'nodeipaddr='+n['nodeipaddr']
print 'segname='+n['segname']
print
运行样例
[gbase@rh6-1 zxq]$ gcadmin showdmlevent
Event count:1
Event ID: 25
ObjectName: testdb.t5
Fail Data Copy:
------------------------------------------------------
SegName: n1 SCN: 4587547 NodeIP: 10.0.2.201 FAILURE
SegName: n2 SCN: 4587547 NodeIP: 10.0.2.201 FAILURE
[gbase@rh6-1 zxq]$ gcadmin showddlevent
Event count:0
[gbase@rh6-1 zxq]$ gcadmin showdmlstorageevent
Event count:2
Event ID: 19
ObjectName: testdb.t5
TableID: 521221
Fail Data Copy:
------------------------------------------------------
SegName: n1 NodeIP: 10.0.2.201 FAILURE
Event ID: 20
ObjectName: testdb.t5
TableID: 521221
Fail Data Copy:
------------------------------------------------------
SegName: n2 NodeIP: 10.0.2.201 FAILURE
[gbase@rh6-1 zxq]$ ./getEventByTablename.py testdb t5
check testdb.t5 ...
-----dmlevent---------
eventid=25
tabletype=DISTRIBUTION
nodeipaddr=10.0.2.201
segname=n1
nodeipaddr=10.0.2.201
segname=n2
-----ddlevent---------
-----dmlstorageevent---------
eventid=19
tabletype=DISTRIBUTION
nodeipaddr=10.0.2.201
segname=n1
eventid=20
tabletype=DISTRIBUTION
nodeipaddr=10.0.2.201
segname=n2
[gbase@rh6-1 zxq]$