proc TakeSnapShot { copyToLocalPathAndFileName {view "Flow Statistics"} {getEgress 0} } { # This API will create a "Results" folder on the IxNetwork Tcl Server # C: drive if it doesn't exist. # Important note: # Users must verify if traffic started successfully. If not, don't call # TakeSnapShot. Or else you will get the previous stats left behind on the GUI. # # If traffic started successfully and taking a snapshot failed, this API # will return 0. # If snapshot is ok, it will return the $$copyToLocalPathAndFileName. # $copyToLocalPathAndFileName # # If using the HLT command to take snapshot: # TakeSnapShot will put the csv result file to the path of your # current destination. For example: # # If you executed TaksSnapShot from /home/hgee, and you stated the destination # as /home/hgee/results, then the csv snapshot result file will be in: # /home/hgee/home/hgee/results/snapshot.csv. # # If using low level command to take snapshot: # Then the csv snapshot result file will be in: # /home/hgee/snapshot.csv. # # $view # This parameter defaults to get statistics from Flow Statistics. # Users could also select which statistics they want to collect. # In the case of getting egress tracking stats, the GetEgressStats # API creates a "EgressStats" statistic view. # Users would need to call this API and pass in EgressStats. set csvWindowsPath "C:\\Results" # You can also add to the list "Traffic Item Statistics" #set listOfTrafficStats [list "Flow Statistics"] set listOfTrafficStats [list $view] set csvFileName "[string map {" " "_"} [lindex $listOfTrafficStats 0]]" set root [ixNet getRoot] set stats $root/statistics # This is csv logging ixNet setAttr $stats -enableCsvLogging "true" ixNet setAttr $stats -csvFilePath $csvWindowsPath #"C:\Users\hgee\AppData\Local\Ixia\IxNetwork\data\logs" ixNet setAttr $stats -pollInterval 1 ixNet commit puts "TakeSnapshot: listOfTrafficStats: $listOfTrafficStats ---" set opts [::ixTclNet::GetDefaultSnapshotSettings] #puts "\n$opts\n" lset opts [lsearch $opts *Location*] [subst {Snapshot.View.Csv.Location: $csvWindowsPath}] #lset opts [lsearch $opts *GeneratingMode*] {Snapshot.View.Csv.GeneratingMode: kAppendCSVFile} lset opts [lsearch $opts *GeneratingMode*] {Snapshot.View.Csv.GeneratingMode: "kOverwriteCSVFile"} lset opts [lsearch $opts *Settings.Name*] [subst {Snapshot.Settings.Name: $csvFileName}] #lset opts [lsearch $opts *Contents*] {Snapshot.View.Contents: "currentPage"} lset opts [lsearch $opts *Contents*] {Snapshot.View.Contents: "allPages"} lset opts [lsearch $opts *StringQuotes*] {Snapshot.View.Csv.StringQuotes: "False"} lappend opts [subst {Snapshot.View.Csv.Name: $csvFileName}] # opts: {Snapshot.View.Contents: "allPages"} {Snapshot.View.Csv.Location: C:\Results} {Snapshot.View.Csv.GeneratingMode: "kOverwriteCSVFile"} {Snapshot.View.Csv.StringQuotes: "False"} {Snapshot.View.Csv.SupportsCSVSorting: "False"} {Snapshot.View.Csv.FormatTimestamp: "True"} {Snapshot.View.Csv.DumpTxPortLabelMap: "False"} {Snapshot.View.Csv.DecimalPrecision: "3"} {Snapshot.Settings.Name: Flow_Statistics} {Snapshot.View.Csv.Name: Flow_Statistics} catch {ixTclNet::TakeViewCSVSnapshot $listOfTrafficStats $opts} errMsg ixNet setAttr $stats -enableCsvLogging "false" ixNet commit # HLT # set resultStatus [::ixia::copy_csv_fileName "$csvWindowsPath\\$csvFileName.csv" $copyToLocalPathAndFileName] # Original low level #catch {ixNet exec copyFile [ixNet readFrom "$csvWindowsPath\\tmp.[file tail [info script]]...Flow_Statistics.csv" -ixNetRelative] [ixNet writeTo $copyToLocalPathAndFileName -overwrite]} errMsg catch {ixNet exec copyFile [ixNet readFrom "$csvWindowsPath\\$csvFileName.csv" -ixNetRelative] [ixNet writeTo $copyToLocalPathAndFileName -overwrite]} errMsg puts "\nTakeSnapshot result: $errMsg\n" if {$errMsg != "::ixNet::OK"} { return 0 } else { return $copyToLocalPathAndFileName } }