Forum Discussion
13 Replies
- JRahmAdmin
possible, but would require some scripting work in tmsh, bash, perl, or python.
- uni_87886Cirrostratus
You can get stats in a reasonably usable for using the field-fmt option of the show commands. For example
tmsh show ltm virtual field-fmt raw
It's not csv, but not too hard to parse either
- nkingcade_12003Nimbostratushow do I parse it?
- uniAltostratus
You can get stats in a reasonably usable for using the field-fmt option of the show commands. For example
tmsh show ltm virtual field-fmt raw
It's not csv, but not too hard to parse either
- nkingcade_12003Nimbostratushow do I parse it?
- JRahmAdmin
I'm working on a script to look at real time interface statistics, and I'm parsing with TMSH using lindex and splitting on line numbers.
proc script::run {} { tmsh::clear_screen if { $tmsh::argc == 1 } { set int [getFeedback "Please enter the interface number (ie, 1.1): "] } else { set int [lindex $tmsh::argv 1] } set l1 [] set l2 [] set interval [getFeedback "Please enter refresh rate for the stats (in seconds): "] set delay [expr $interval * 1000] lappend l1 [lindex [lindex [split [tmsh::show net interface $int raw field-fmt] "\n"] 1] 1] lappend l1 [lindex [lindex [split [tmsh::show net interface $int raw field-fmt] "\n"] 2] 1] while { true } { after $delay lappend l2 [lindex [lindex [split [tmsh::show net interface $int raw field-fmt] "\n"] 1] 1] lappend l2 [lindex [lindex [split [tmsh::show net interface $int raw field-fmt] "\n"] 2] 1] tmsh::clear_screen set s1 $l1 set s2 $l2 set statsIn [expr ([lindex $s2 0] - [lindex $s1 0]) / $interval] set statsOut [expr ([lindex $s2 1] - [lindex $s1 1]) / $interval] puts "Interface\t\tInbound (bps)\t\tOutbound (bps)" puts "$int\t\t\t$statsIn\t\t\t$statsOut" set l1 $l2 unset l2 } }
I would suggest instead of using a while loop, you can just use puts and commas for each field.
- JRahmAdmin
FYI, the getFeedback is a proc in the same TMSH script:
proc getFeedback { question } { puts -nonewline $question flush stdout return [gets stdin] }
- uni_87886Cirrostratus
Jason's method above is great if it is long term. For a quick-and-dirty solution, this perl will convert your output for you. Put it in a file, such as field-to-csv, and run it like this:
tmsh show ltm virtual field-fmt raw | field-to-csv
!/usr/bin/perl while ($line = <>) { chomp($line); if ($line =~ /{/) { $out = ""} elsif ($line =~ /}/) { print "$out\n" } else { $out .= "," if (length($out) != 0); ($field,$value) = split(" ",$line,2); if ($value =~ /,/) { $out .= "\"$value\"" } else { $out .= $value } } }
- uni_87886Cirrostratusfinally got the formatting right
- gratlmichael_22NimbostratusHas anyone the script ready for the export the performance data to csv? mem usage, packets, ssl transactions, http,.. Thanks!
- uniAltostratus
Jason's method above is great if it is long term. For a quick-and-dirty solution, this perl will convert your output for you. Put it in a file, such as field-to-csv, and run it like this:
tmsh show ltm virtual field-fmt raw | field-to-csv
!/usr/bin/perl while ($line = <>) { chomp($line); if ($line =~ /{/) { $out = ""} elsif ($line =~ /}/) { print "$out\n" } else { $out .= "," if (length($out) != 0); ($field,$value) = split(" ",$line,2); if ($value =~ /,/) { $out .= "\"$value\"" } else { $out .= $value } } }
- uniAltostratusfinally got the formatting right
- gratlmichael_22NimbostratusHas anyone the script ready for the export the performance data to csv? mem usage, packets, ssl transactions, http,.. Thanks!