Cisco# show the processes
CPU utilization for five seconds, 2%/1%; One minute: 5%; Five minutes: 5%
PID QTy PC Runtime (ms) Invoked uSecs sports a TTY Process
1 41617 Cwe e30 0 0 0 5472/6000 50 Chunk Manager
2 Csp 4297 c14c 59116 2528/3000 25877476 2 0 Load Meter
Cisco# show mem
Free Head Total (b) 2 (b) (b) the Lowest Largest (b) (b)
Processor e7d0 4671 898471984 137597416 760874568 759095384 742587636
I want to extract notepad in certain fields, such as five minutes: 5% and 2 (b) 137597416 written to excel, A column is A set of fixed content, I automatically fill in column b is to program, excel spreadsheet type is:
A column B column
5% CPU utilization
The memory usage of 137597416
Consult the VB a great god, and how to write the script? Thank you very much!
CodePudding user response:
Option Explicit
Private Sub Command1_Click ()
Dim strtest As String
Strtest=strtest & amp; "Cisco# show the processes & amp;" VbCrLf
Strtest=strtest & amp; "The CPU utilization for five seconds, 2%/1%; One minute: 5%; Five minutes: 5% "& amp; VbCrLf
Strtest=strtest & amp; "PID QTy PC Runtime (ms) Invoked uSecs sports a TTY Process" & amp; VbCrLf
Strtest=strtest & amp; "1 e30 Cwe 41617 0 0 0 5472/6000 50 Chunk Manager" & amp; VbCrLf
Strtest=strtest & amp; "2 Csp c14c 4297 2528/3000 59116 25877476 2 0 Load Meter" & amp; VbCrLf
Strtest=strtest & amp; VbCrLf
Strtest=strtest & amp; VbCrLf
Strtest=strtest & amp; "Cisco# show mem" & amp; VbCrLf
Strtest=strtest & amp; "Head Total (b) 2 (b) (b) Free Lowest Largest (b) (b)" & amp; VbCrLf
Strtest=strtest & amp; "Processor e7d0 4671 898471984 137597416 760874568 759095384 742587636" & amp; VbCrLf
The Debug. Print strtest
The Debug. Print "CPU usage:" & amp; GetStrBtween2Key (strtest, "five minutes", vbCrLf) 'leading characteristics of the word in full only CPU utilization, and directly find
Dim lngTmp As Long
Strtest lngTmp=InStr (1, "the Largest (b)") 'access to memory data characteristics of leading position
LngTmp=InStr (strtest lngTmp + 1, "")
LngTmp=InStr (strtest lngTmp + 1, "")
Strtest lngTmp=InStr (lngTmp + 1, "") 'access to memory data row third space the starting position of the
The Debug. Print "footprint," & amp; GetStrBtween2Key (strtest, ""," ", lngTmp) 'starting position to start a space for a start, a space for the end, in the middle of the string
End Sub
'take the input string strin since lngStartFrom position leading character string for strBefore suffix character string for strAfter string
Private Function getStrBtween2Key (strIn As String, strBefore As String, strAfter As String, Optional lngStartFrom As Long=1) As String
Dim lngStart As Long
Dim lngEnd As Long
LngStart=InStr (lngStartFrom strIn, strBefore) + Len (strBefore)
LngEnd=InStr (lngStart strIn, strAfter)
GetStrBtween2Key=Mid (strIn lngStart, lngEnd - lngStart)
End the Function
CodePudding user response:
Thank humbly great god help!