1.获取DB2:db2 -d testdb -tab信息
Database Member 0 -- Database SOURCEDB -- Active -- Up 0 days 00:00:15 -- Date 2022-02-10-20.05.48.065532
Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg RSE Name
0x00002AAB116AC540 0 DMS Regular 8192 4 Yes 4 1 1 Def 1 0 3 Yes SYSCATSPACE
0x00002AAB116B9900 1 SMS SysTmp 8192 32 Yes 32 1 1 On 1 0 31 No TEMPSPACE1
0x00002AAB116C6CC0 2 DMS Large 8192 32 Yes 32 1 1 Def 1 0 31 Yes USERSPACE1
0x00002AAB116D4080 3 DMS Large 8192 4 Yes 4 1 1 Def 1 0 3 Yes SYSTOOLSPACE
0x00002AAB116E1440 4 SMS UsrTmp 8192 32 Yes 32 1 1 On 1 0 31 No ASNADMINIFSPACE
0x00002AAB31BE0080 5 DMS Large 8192 32 Yes 32 1 1 Def 1 0 31 Yes QCASN
Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped TrackmodState
0x00002AAB116AC540 0 20480 20476 16512 0 3964 16512 16512 0x00000000 0 0 No Dirty
0x00002AAB116B9900 1 1 1 1 0 0 - - 0x00000000 0 0 No Dirty
0x00002AAB116C6CC0 2 4096 4064 160 0 3904 160 160 0x00000000 1633519810 0 No Dirty
0x00002AAB116D4080 3 4096 4092 108 0 3984 108 108 0x00000000 1633519398 0 No Dirty
0x00002AAB116E1440 4 1 1 1 0 0 - - 0x00000000 1633519566 0 No Clean
0x00002AAB31BE0080 5 4096 4064 2400 0 1664 2400 2400 0x00000000 1633519573 0 No Dirty
Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002AAB116AC540 0 Yes Yes 33554432 -1 No None None No
0x00002AAB116B9900 1 Yes No 0 0 No 0 None No
0x00002AAB116C6CC0 2 Yes Yes 33554432 -1 No None None No
0x00002AAB116D4080 3 Yes Yes 33554432 -1 No None None No
0x00002AAB116E1440 4 Yes No 0 0 No 0 None No
0x00002AAB31BE0080 5 Yes Yes 33554432 -1 No None None No
Tablespace Storage Statistics:
Address Id DataTag Rebalance SGID SourceSGID
0x00002AAB116AC540 0 0 No 0 -
0x00002AAB116B9900 1 0 No 0 -
0x00002AAB116C6CC0 2 -1 No 0 -
0x00002AAB116D4080 3 -1 No 0 -
0x00002AAB116E1440 4 0 No 0 -
0x00002AAB31BE0080 5 -1 No 0 -
Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002AAB116A58C0 0 0 File 20480 20476 0 0 /db2data/db2inst1/NODE0000/SOURCEDB/T0000000/C0000000.CAT
0x00002AAB1163DB60 1 0 Path 1 1 0 0 /db2data/db2inst1/NODE0000/SOURCEDB/T0000001/C0000000.TMP
0x00002AAB11633B40 2 0 File 4096 4064 0 0 /db2data/db2inst1/NODE0000/SOURCEDB/T0000002/C0000000.LRG
0x00002AAB1163E360 3 0 File 4096 4092 0 0 /db2data/db2inst1/NODE0000/SOURCEDB/T0000003/C0000000.LRG
0x00002AAB1163EA40 4 0 Path 1 1 0 0 /db2data/db2inst1/NODE0000/SOURCEDB/T0000004/C0000000.UTM
0x00002AAB11622240 5 0 File 4096 4064 0 0 /db2data/db2inst1/NODE0000/SOURCEDB/T0000005/C0000000.LRG
2.使用Python获取某字符串位置
str_start = "Tablespace Statistics:"
str_end = "Tablespace Autoresize Statistics:"
def fileTest(strVal):
lineNum = 0
msg = "There is no result"
with open(r"G:/python/db2pd_sourcedb_tab.txt", 'r') as file:
for line in file.readlines():
lineNum = lineNum + 1
if strVal in line.strip():
msg = "'%s' string in line %d" % (strVal, lineNum)
break
print(msg)
def main():
fileTest(str_start)
fileTest(str_end)
if __name__ == "__main__":
main()
3.执行效果
版权声明:本文为博主原创文章,未经博主允许不得转载。
Python