⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 np_act.py

📁 该软件根据网络数据生成NetFlow记录。NetFlow可用于网络规划、负载均衡、安全监控等
💻 PY
📖 第 1 页 / 共 3 页
字号:
##                 #print pc##                 max_times_tcp_inseq_susage = max([max_times_tcp_inseq_susage, pc])##                 times_tcp_inseq_susage.append([ts, pc])##                 # TCP_CATCHUP##                 v = ull2l(wr.get_tcp_catchup_usrtm())##                 #print v##                 pc = (float(v)*100)/per##                 #print pc##                 max_times_tcp_catchup_uusage = max([max_times_tcp_catchup_uusage, pc])##                 times_tcp_catchup_uusage.append([ts, pc])                ##                 v = ull2l(wr.get_tcp_catchup_systm())##                 #print v##                 pc = (float(v)*100)/per##                 #print pc##                 max_times_tcp_catchup_susage = max([max_times_tcp_catchup_susage, pc])##                 times_tcp_catchup_susage.append([ts, pc])##                 # TCP_SERV##                 v = ull2l(wr.get_tcp_serv_usrtm())##                 #print v##                 pc = (float(v)*100)/per##                 #print pc##                 max_times_tcp_serv_uusage = max([max_times_tcp_serv_uusage, pc])##                 times_tcp_serv_uusage.append([ts, pc])                ##                 v = ull2l(wr.get_tcp_serv_systm())##                 #print v##                 pc = (float(v)*100)/per##                 #print pc##                 max_times_tcp_serv_susage = max([max_times_tcp_serv_susage, pc])##                 times_tcp_serv_susage.append([ts, pc])##                 # HTTP##                 v = ull2l(wr.get_http_usrtm())##                 #print v##                 pc = (float(v)*100)/per##                 #print pc##                 max_times_http_uusage = max([max_times_http_uusage, pc])##                 times_http_uusage.append([ts, pc])                ##                 v = ull2l(wr.get_http_systm())##                 #print v##                 pc = (float(v)*100)/per##                 #print pc##                 max_times_http_susage = max([max_times_http_susage, pc])##                 times_http_susage.append([ts, pc])##                 # HTML##                 v = ull2l(wr.get_html_usrtm())##                 #print v##                 pc = (float(v)*100)/per##                 #print pc##                 max_times_html_uusage = max([max_times_html_uusage, pc])##                 times_html_uusage.append([ts, pc])                ##                 v = ull2l(wr.get_html_systm())##                 #print v##                 pc = (float(v)*100)/per##                 #print pc##                 max_times_html_susage = max([max_times_html_susage, pc])##                 times_html_susage.append([ts, pc])        elif rectype == REC_PROCSTAT:            # these are all recorded per period            pcr.read(file)            ts = float(tv2l(pcr.get_ts()) - first_ts)/1000000            per_jiff = pcr.get_s_tcpu()/ncpus            per_s = float(per_jiff)/hz            utm = ul2l(pcr.get_p_utm())            pc = (float(utm)*100)/per_jiff            max_proc_utm = max([max_proc_utm, pc])            proc_utm.append([ts, pc])            stm = ul2l(pcr.get_p_stm())            pc = (float(stm)*100)/per_jiff            max_proc_stm = max([max_proc_stm, pc])            proc_stm.append([ts, pc])            ttm = utm + stm            pc = (float(ttm)*100)/per_jiff            max_proc_ttm = max([max_proc_ttm, pc])            proc_ttm.append([ts, pc])            majflt = ul2l(pcr.get_p_majflt())            v = majflt/per_s            max_proc_majflt = max([max_proc_majflt, v])            proc_majflt.append([ts, v])            nswap = ul2l(pcr.get_p_nswap())            v = nswap/per_s            max_proc_nswap = max([max_proc_nswap, v])            proc_nswap.append([ts, v])            itot = ul2l(pcr.get_s_itot())            v = itot/per_s            max_proc_itot = max([max_proc_itot, v])            proc_itot.append([ts, v])            csw = ul2l(pcr.get_s_csw())            v = csw/per_s            max_proc_csw = max([max_proc_csw, v])            proc_csw.append([ts, v])                            else:            file.advance()        # end while        file_closes.append(float(tv2l(file.close()) - first_ts)/1000000)# end for file in filessets = [    [trusage, 50.0, 1.0, '%CPU', '', 1],    [urusage, 50.0, 1.0, '%CPU - user', '', 1],    [srusage, 50.0, 1.0, '%CPU - system', '', 1],##     [maxrss, max_maxrss, 1.0, 'Max RSS MB', ''],##     [majflt, max_majflt, 1.0, 'Major page faults', ''],##     [nswap, max_nswap, 1.0, 'Swaps', ''],##     [blkio, max_blkio, 1.0, 'In/out blocks', ''],##     [cswitches, max_cswitches, 1.0, 'Context switches', ''],##     [times_ip_uusage, max_times_ip_uusage, 1.0, 'IP call usr %CPU', ''],##     [times_ip_susage, max_times_ip_susage, 1.0, 'IP call sys %CPU', ''],##     [times_udp_uusage, max_times_udp_uusage, 1.0, 'UDP call usr %CPU', ''],##     [times_udp_susage, max_times_udp_susage, 1.0, 'UDP call sys %CPU', ''],##     [times_tcp_uusage, max_times_tcp_uusage, 1.0, 'TCP call usr %CPU', ''],##     [times_tcp_susage, max_times_tcp_susage, 1.0, 'TCP call sys %CPU', ''],##     [times_tcp_inseq_uusage, max_times_tcp_inseq_uusage, 1.0, 'TCP_INSEQ call usr %CPU', ''],##     [times_tcp_inseq_susage, max_times_tcp_inseq_susage, 1.0, 'TCP_INSEQ call sys %CPU', ''],##     [times_tcp_catchup_uusage, max_times_tcp_catchup_uusage, 1.0, 'TCP_CATCHUP call usr %CPU', ''],##     [times_tcp_catchup_susage, max_times_tcp_catchup_susage, 1.0, 'TCP_CATCHUP call sys %CPU', ''],##     [times_tcp_serv_uusage, max_times_tcp_serv_uusage, 1.0, 'TCP_SERV call usr %CPU', ''],##     [times_tcp_serv_susage, max_times_tcp_serv_susage, 1.0, 'TCP_SERV call sys %CPU', ''],##     [times_http_uusage, max_times_http_uusage, 1.0, 'HTTP call usr %CPU', ''],##     [times_http_susage, max_times_http_susage, 1.0, 'HTTP call sys %CPU', ''],##     [times_html_uusage, max_times_html_uusage, 1.0, 'HTML call usr %CPU', ''],##     [times_html_susage, max_times_html_susage, 1.0, 'HTML call sys %CPU', ''],        [wire_bw, max_wmbs, 1.0, 'Wire Mbs', '', 2],    [tcp_bw, max_tmbs, 1.0, 'TCP Mbs', '', 3],    [udp_bw, max_umbs, 1.0, 'UDP Mbs', '', 3],    [http_bw, max_hmbs, 1.0,  'HTTP Mbs', '', 4],    [html_parse, max_hparsed, 1.0, 'HTML Octets parsed MBs', '', 5],        [wire_pkts, max_wpps, 1.0, 'Wire Pkts', '', 2],    [tcp_pkts, max_tpps, 1.0, 'TCP Pkts', '', 3],    [udp_pkts, max_upps, 1.0, 'UDP Pkts', '', 3],    [http_pkts, max_hpps, 1.0,  'HTTP Pkts', '', 4],        [w_wire_bw, w_max_wmbs, 1.0, 'Wire (wire driven) Mbs', '', 2],    [w_tcp_bw, w_max_tmbs, 1.0, 'TCP (wire driven) Mbs', '', 3],    [w_udp_bw, w_max_umbs, 1.0, 'UDP (wire driven) Mbs', '', 3],    [w_http_bw, w_max_hmbs, 1.0,  'HTTP (wire driven) Mbs', '', 4],    [w_html_parse, w_max_hparsed, 1.0, 'HTML Octets parsed (wire driven) MBs ', '', 5],        [w_wire_pkts, w_max_wpps, 1.0, 'Wire (wire driven) Pkts', '', 2],    [w_tcp_pkts, w_max_tpps, 1.0, 'TCP (wire driven) Pkts', '', 3],    [w_udp_pkts, w_max_upps, 1.0, 'UDP (wire driven) Pkts', '', 3],    [w_http_pkts, w_max_hpps, 1.0,  'HTTP (wire driven) Pkts', '', 4],        [rwritten, max_repwritten, 1.0,  'Log bytes written KB', '', 4],    [dwritten, max_dumpwritten, 1.0,  'Error bytes written KB', '', 4],    [twritten, max_twritten, 1.0,  'Total bytes written KB', '', 4],        [rdumped, max_repdumped, 1.0,  'Log bytes dumped KB', '', 4],    [ddumped, max_dumpdumped, 1.0,  'Error bytes dumped KB', '', 4],    [tdumped, max_tdumped, 1.0,  'Total bytes dumped KB', '', 4],        [max_fetch_int, max_mfi, 1.0, 'Max fetch interval ms', '', 6],    [bheld, max_bheld, 1.0, 'Maximum buffers held', '', 8],    [fails, max_fails, 1.0, 'Buffer alloc fails', '', 0],    [tcp_to, max_tcp_to, 1.0, 'TCP flows timed out', ''],    [udp_to, max_udp_to, 1.0, 'UDP flows timed out', ''],    [tcp_seq_to, max_tcp_seq_to, 1.0, 'TCP pkts timed out', ''],        [IP_ulen, max_IP_ulen, 1.0, 'Pkts < IP min len p//s', ''],        [tous_in, max_tous_in, 1.0, 'tous_in buffers//s', ''],    [tous_out, max_tous_in, 1.0, 'tous_out buffers//s', ''],    [frus_in, max_frus_in, 1.0, 'frus_in buffers//s', ''],    [frus_out, max_frus_in, 1.0, 'frus_out buffers//s', ''],        [proc_utm, 50.0, 1.0, '%CPU - usr (proc)', ''],    [proc_stm, 50.0, 1.0, '%CPU - sys (proc)', ''],    [proc_ttm, 50.0, 1.0, '%CPU - total (proc)', ''],    [proc_majflt, max_proc_majflt, 1.0, 'Major page faults//s (proc)', ''],    [proc_nswap, max_proc_nswap, 1.0, 'Page swaps//s (proc)', ''],    [proc_itot, max_proc_itot, 1.0, 'Interrupts//s (proc)', ''],    [proc_csw, max_proc_csw, 1.0, 'Context switches//s (proc)', '']    ]datasets = []shows = []## scale e'm all to range 0-100#i = 0for data in sets:    #print '%s %f' % (data[3], data[1])    if data[1] == 0:        continue        while data[1] > 100.0:        #print 'down'        data[2] /= 10        data[1] /= 10            while data[1] < 10.0:        #print 'up'        data[2] *= 10        data[1] *= 10    #print data[1], data[2]        if data[2] != 1.0:        for dep in data[0]:            #print dep[1]            dep[1] *= data[2]            #print dep[1]        fmt = ' X%%.%df' % (places(data[2]))        data[4] = fmt % (data[2])    datasets.append(DataSet(data[0], DATA_TS, '%s%s' % (data[3], data[4]),                            i+1, None))    shows.append(data[3])    print '%s %f %f' % (data[3], data[1], data[2])    i += 1## select what shown on first plot#showlist = []wantlist = [    '%CPU',    '%CPU - user',    # '%CPU - system',##     #'Max RSS MB',##     #'Major page faults',##     #'Swaps',##     #'In/out blocks',##     #'Context switches',##    # 'IP call %CPU',##    # 'IP call sys %CPU',##    # 'UDP call %CPU',##    # 'UDP call sys %CPU',##     #'TCP call %CPU',##    # 'TCP call sys %CPU',##     #'TCP_INSEQ call %CPU',##    # 'TCP_INSEQ call sys %CPU',##    # 'TCP_CATCHUP call %CPU',##    # 'TCP_CATCHUP call sys %CPU',##     #'TCP_SERV call %CPU',##     #'TCP_SERV call sys %CPU',##     #'HTTP call %CPU',##     #'HTTP call sys %CPU',##     #'HTML call %CPU',##    # 'HTML call sys %CPU',        #'Wire Mbs',    #'TCP Mbs',    #'UDP Mbs',    #'HTTP Mbs',    #'HTML Octets parsed MBs',    #'Wire Pkts',    #'TCP Pkts',    #'UDP Pkts',    #'HTTP Pkts',        #'Wire (wire driven) Mbs',    #'TCP (wire driven) Mbs',    #'UDP (wire driven) Mbs',    #'HTTP (wire driven) Mbs',    #'HTML (wire driven) Octets parsed MBs',        #'Wire (wire driven) Pkts',    #'TCP (wire driven) Pkts',    #'UDP (wire driven) Pkts',    #'HTTP (wire driven) Pkts',        # 'Log bytes written KB',    # 'Error bytes written KB',    # 'Total bytes written KB',        # 'Log bytes dumped KB',    # 'Error bytes dumped KB',    # 'Total bytes dumped KB',        # 'Max fetch interval ms',     # 'Maximum buffers held',     # 'Buffer alloc fails',        'Pkts < IP min len p//s',        'tous_in buffers//s',    'tous_out buffers//s',    'frus_in buffers//s',    'frus_out buffers//s',    'TCP flows timed out',    'UDP flows timed out',    'TCP pkts timed out',    '%CPU - usr (proc)',    '%CPU - sys (proc)',    '%CPU - total (proc)',    'Major page faults//s (proc)',    'Page swaps//s (proc)',    'Interrupts//s (proc)',    'Context switches//s (proc)'    ]for s in shows:    if wantlist.count(s):        showlist.append(shows.index(s))   try:    plot = np_Plot(datasets, basepath, standalone='yes',           title='Nprobe activity', xlab='Running time %s', ylab='',           raw_data=0, top=0, showlist=showlist, width=1500, height=1000,           decorations=[Plot_Decoration(XLINE, file_closes)])except EmptyDataSetError, p:    print '%s - empty data set' % (p)    sys.exit(1)#decs = plot.add_Decoration([Plot_Decoration(XLINE, xlines)])#plot.activate()        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -