mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-30 18:27:53 +00:00 
			
		
		
		
	scripts: Fix firemod hash output to be like I wanted.
Fix latency normalization math. Fix tos python script to work better.
This commit is contained in:
		| @@ -171,7 +171,7 @@ sub normalize_latency { | ||||
|     $adjust = -$min1; | ||||
|   } | ||||
|   elsif ($min2 < 0) { | ||||
|     $adjust = -$min2; | ||||
|     $adjust = $min2; | ||||
|   } | ||||
|   return $self->normalize_bucket($lat1, $adjust); | ||||
| } | ||||
| @@ -790,7 +790,7 @@ sub show_as_hash { | ||||
|    my $found_start_x = 0; | ||||
|    foreach my $line (@lines) { | ||||
|       foreach my $start (@LANforge::Utils::starting_exceptions) { | ||||
|          # we purposes are not wasting time trimming whitespace | ||||
|          # we purposefully are not wasting time trimming whitespace | ||||
|          my $i = index($line, $start); | ||||
|          if ($i >= 0) { | ||||
|             push(@special, $line); | ||||
| @@ -886,6 +886,51 @@ sub show_as_hash { | ||||
|       $key = undef; | ||||
|       $value = undef; | ||||
|    } | ||||
|  | ||||
|    # Add some common short-hand actions that we supported in the past. | ||||
|    my $val; | ||||
|  | ||||
|    $val = $rh_pairs->{"Rx-Pkts-Per-Sec"}; | ||||
|    if (defined($val)) { | ||||
|      $rh_pairs->{"rx_pps"} = $val; | ||||
|    } | ||||
|    $val = $rh_pairs->{"Tx-Pkts-Per-Sec"}; | ||||
|    if (defined($val)) { | ||||
|      $rh_pairs->{"tx_pps"} = $val; | ||||
|    } | ||||
|    $val = $rh_pairs->{"Rx-Pkts-Total"}; | ||||
|    if (defined($val)) { | ||||
|      $rh_pairs->{"rx_pkts"} = $val; | ||||
|      $rh_pairs->{"Rx Pkts"} = $val; | ||||
|      $rh_pairs->{"Rx-Pkts"} = $val; | ||||
|    } | ||||
|    $val = $rh_pairs->{"Tx-Pkts-Total"}; | ||||
|    if (defined($val)) { | ||||
|      $rh_pairs->{"tx_pkts"} = $val; | ||||
|      $rh_pairs->{"Tx Pkts"} = $val; | ||||
|      $rh_pairs->{"Tx-Pkts"} = $val; | ||||
|    } | ||||
|    $val = $rh_pairs->{"Rx-Bytes-bps"}; | ||||
|    if (defined($val)) { | ||||
|      $rh_pairs->{"rx_bps"} = $val; | ||||
|    } | ||||
|    $val = $rh_pairs->{"Tx-Bytes-bps"}; | ||||
|    if (defined($val)) { | ||||
|      $rh_pairs->{"tx_bps"} = $val; | ||||
|    } | ||||
|  | ||||
|    $val = $rh_pairs->{"Rx-Bytes-Total"}; | ||||
|    if (defined($val)) { | ||||
|      $rh_pairs->{"Rx-Bytes"} = $val; | ||||
|      $rh_pairs->{"Rx Bytes"} = $val; | ||||
|    } | ||||
|  | ||||
|    $val = $rh_pairs->{"Tx-Bytes-Total"}; | ||||
|    if (defined($val)) { | ||||
|      $rh_pairs->{"Tx-Bytes"} = $val; | ||||
|      $rh_pairs->{"Tx Bytes"} = $val; | ||||
|    } | ||||
|  | ||||
|    #foreach $key (sort keys %$rh_pairs) { | ||||
|    #   print "{$key} => $rh_pairs->{$key}\n"; | ||||
|    #} | ||||
|   | ||||
							
								
								
									
										143
									
								
								lf_firemod.pl
									
									
									
									
									
								
							
							
						
						
									
										143
									
								
								lf_firemod.pl
									
									
									
									
									
								
							| @@ -353,6 +353,9 @@ if (grep {$_ eq $::action} split(',', "show_endp,set_endp,create_endp,create_arm | ||||
|          for $option (split(',', $::endp_vals)) { | ||||
|             #print "OPTION[$option]\n"; | ||||
|             #next if ($option =~ /\s/); | ||||
| 	    my $oopt = $option; | ||||
| 	    $option_map{ $option } = ''; | ||||
|  | ||||
|             if ($option =~ /rx[_-]pps/    ) { $option = "Rx-Pkts-Per-Sec"; } | ||||
|             if ($option =~ /tx[_-]pps/    ) { $option = "Tx-Pkts-Per-Sec"; } | ||||
|             if ($option =~ /rx[_-]pkts/   ) { $option = "Rx-Pkts-Total"; } | ||||
| @@ -370,19 +373,21 @@ if (grep {$_ eq $::action} split(',', "show_endp,set_endp,create_endp,create_arm | ||||
|                $option_map{ "Tx-Bytes-Total" } = ''; | ||||
|                $option = "Bytes Transmitted"; | ||||
|             } | ||||
|             if ($option =~ /rx_b(ps|ytes)/  ) { | ||||
|             elsif ($option =~ /rx_b(ps|ytes)/  ) { | ||||
|                $option_map{ "Rx-Bytes-Total" } = ''; | ||||
|                $option = "Bytes Rcvd"; | ||||
|             } | ||||
|             if ($option =~ /tx_packets/) { | ||||
|             elsif ($option =~ /tx_packets/) { | ||||
|                $option_map{ "Tx-Pkts-Total" } = ''; | ||||
|                $option = "Packets Transmitted"; | ||||
|             } | ||||
|             if ($option =~ /rx_packets/) { | ||||
|             elsif ($option =~ /rx_packets/) { | ||||
|                $option_map{ "Rx-Pkts-Total" } = ''; | ||||
|                $option = "Packets Rcvd"; | ||||
|             } | ||||
|             $option_map{ $option } = ''; | ||||
| 	    if ($oopt ne $option) { | ||||
| 	      $option_map{ $option } = ''; | ||||
| 	    } | ||||
|          } | ||||
|          # options are reformatted | ||||
|  | ||||
| @@ -423,135 +428,9 @@ if (grep {$_ eq $::action} split(',', "show_endp,set_endp,create_endp,create_arm | ||||
|             } | ||||
|             $option_map{ $option } = $val; | ||||
|          } | ||||
| # | ||||
| #            my $endval_done = 0; | ||||
| #            for $match (@matches) { | ||||
| #               last if ($endval_done); | ||||
| #               print "\nMatch-line: $end_val> $match\n"; | ||||
| # | ||||
| #               # no value between colon separated tags can be very | ||||
| #               # confusing to parse, let's force a dumb value in if we find that | ||||
| #               #if ($match =~ /[^ ]+:\s+[^ ]+:/) { | ||||
| #               #   $match =~ s/([^ ]+:)\s+([^ ]+:\s+)/$1 ""  $2/g; | ||||
| #               #   #print "\n M> $match\n"; | ||||
| #               #} | ||||
| # | ||||
| # | ||||
| #               ## ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | ||||
| #               ##    special cases                                                  # | ||||
| #               ## ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | ||||
| # | ||||
| #               elsif ($end_val =~ /Cx Detected/) { | ||||
| #                  my $value = 0; | ||||
| #                  #print "# case 2\n"; | ||||
| #                  ($option) = ($match =~ /(Cx Detected)/); | ||||
| #                  if (defined $option_map{ $option } ) { | ||||
| #                     $value = 0 + ($match =~ /:\s+(\d+)/)[0]; | ||||
| #                     $option_map{ $option } = $value; | ||||
| #                     $endval_done++; | ||||
| #                     last; | ||||
| #                  } | ||||
| #               } | ||||
| #               elsif (($match =~ /Tx (Bytes|Pkts)/ && (($end_val =~ /tx_(bps|pps)/) || ($end_val =~ /Tx (Bytes|Pkts)/) || ($end_val =~ /(Pkts|Bytes) Sent/))) || | ||||
| #                     ($match =~ /Rx (Bytes|Pkts)/ && (($end_val =~ /rx_(bps|pps)/) || ($end_val =~ /Rx (Bytes|Pkts)/)|| ($end_val =~ /(Pkts|Bytes) Rcvd/)))) { | ||||
| #                  my $value = 0; | ||||
| #                  ($option) = ($match =~ /([TR]x (Bytes|Pkts))/); | ||||
| #                  #print "# case 3, Option: $option" . NL; | ||||
| #                  @parts      = ($match =~ m{ Total: (\d+) +Time: \d+s\s+ Cur: (\d+) +(\d+)\/s \#$}); | ||||
| #                  #print "\n TX: ".join(",",@parts)."\n"; | ||||
| #                  if (defined $option_map{ $option } ) { | ||||
| #                     if (($end_val =~ /tx_(bps|pps)/ ) || | ||||
| #                         ($end_val =~ /rx_(bps|pps)/ )) { | ||||
| #                        $value = 0 + $parts[2]; | ||||
| #                        if ($end_val =~ /bps/) { | ||||
| #                          $value *= 8; | ||||
| #                        } | ||||
| #                     } | ||||
| #                     else { | ||||
| #                        $value = 0 + $parts[0]; | ||||
| #                     } | ||||
| #                     print "\n    B end_val[$end_val] option[$option] now ".$value."\n"; | ||||
| #                     $option_map{ $end_val } = $value; | ||||
| # | ||||
| #                     # For backwards compat with older logic | ||||
| #                     if (defined($option_map{"Bytes Rcvd"})) { | ||||
| #                       if ($end_val eq "Rx Bytes") { | ||||
| #                         $option_map{"Bytes Rcvd"} = $value; | ||||
| #                       } | ||||
| #                     } | ||||
| #                     $endval_done++; | ||||
| #                     last; | ||||
| #                  } | ||||
| #               } | ||||
| #               elsif ($match =~ / [TR][Xx] (((OOO|Duplicate|Failed) (Bytes|Pkts))|Wrong Dev|CRC Failed|Bit Errors|Dropped)/ | ||||
| #                     || $match =~ /Conn (Established|Timeouts)|TCP Retransmits/) { | ||||
| #                  my $value = 0; | ||||
| #                  ($option) = ($match =~ /([TR][Xx] (((OOO|Duplicate|Failed) (Bytes|Pkts))|Wrong Dev|CRC Failed|Bit Errors|Dropped)|Conn (Established|Timeouts)|TCP Retransmits)/); | ||||
| #                  @parts      = $match =~ m{ Total: (\d+) +Time: \d+s\s+ Cur: (\d+) +(\d+)\/s \#$}; | ||||
| #                  #print "\n# case 4 TX: ".join(",",@parts)."\n"; | ||||
| #                  if (defined $option_map{ $option } ) { | ||||
| #                     #print "$match\n"; | ||||
| #                     $match =~ s/""/ /g; | ||||
| #                     ($option_map{ $option }) = $match =~/.*?:\s+(.*?)\s+\#$/; | ||||
| #                     $endval_done++; | ||||
| #                     last; | ||||
| #                  } | ||||
| #               } | ||||
| #               elsif ($match =~ /(Bytes|Packets) (Rcvd|Transmitted)/ ) { | ||||
| #                  ($option) = ($match =~ /((Bytes|Packets) (Rcvd|Transmitted))/); | ||||
| #                  @parts      = ($match =~ m{ Total: (\d+) +Time: \d+s\s+ Cur: (\d+) +(\d+)\/s \#$}); | ||||
| #                  #print "\n# case 5 TX: ".join(",",@parts)."\n"; | ||||
| #                  my $value = 0; | ||||
| #                  if (defined $option_map{ $option } ) { | ||||
| #                     if ($end_val =~ /rx_(bps|pps)/ ) { | ||||
| #                        $value = 0 + $parts[2]; | ||||
| #                     } | ||||
| #                     elsif ($end_val =~ /rx_(byte|pkt|packet)s/ ) { | ||||
| #                        $value = 0 + $parts[0]; | ||||
| #                     } | ||||
| #                     if ($option eq "Bytes Rcvd") { | ||||
| #                        if ($end_val =~ /rx_bps/ ) { | ||||
| #                           $value   *= 8; | ||||
| #                        } | ||||
| #                     } | ||||
| #                     $option_map{ $option } = $value; | ||||
| #                     $endval_done++; | ||||
| #                     last; | ||||
| #                  } | ||||
| #               } | ||||
| #               else { | ||||
| #                  $match =~ s/Shelf: (\d+), /Shelf: $1  / | ||||
| #                     if ($match =~ /^\s*Shelf:/ ); | ||||
| # | ||||
| #                  $match =~ s/(Endpoint|PktsToSend): (\d+) /$1: $2  / | ||||
| #                     if ($match =~ /\s*(Endpoint|PktsToSend):/ ); | ||||
| # | ||||
| #                  if ($match =~ /((Src|Dst)Mac): /) { | ||||
| #                     my ($name1, $mac1) = ( $match =~ /(...Mac): (.*?)  /); | ||||
| #                     $mac1 =~ s/ /-/g; | ||||
| #                     $match =~ s/(...Mac): (.. .. .. .. .. ..) /$1: $mac1 /; | ||||
| #                  } | ||||
| #                  if ($match =~ /FileName: .*? SendBadCrc: /) { | ||||
| #                     my $filename1 = ''; | ||||
| #                     ($filename1) =~ /FileName: (.*?) SendBadCrc.*$/; | ||||
| #                     $filename1 = '""' if ($filename1 =~ /^ *$/); | ||||
| #                     $match =~ s/(FileName): (.*?) (SendBadCrc.*)$/$1: $filename1  $3/; | ||||
| #                  } | ||||
| #                  $match =~ s/CWND: (\d+) /CWND: $1  / | ||||
| #                     if ($match =~/CWND: (\d+) /); | ||||
| #                  # ~specials | ||||
| # | ||||
| #                  #print "  match: $match\n"; | ||||
| #                  if ($match =~ /.*$end_val:\s+(\S+)/) { | ||||
| #                    my $value = $1; | ||||
| #                    #print " Found value: $value for key: $end_val\n"; | ||||
| #                    $option_map{ $end_val } = $value; | ||||
| #                    $endval_done++; | ||||
| #                  } | ||||
| #               } | ||||
| #            } # ~matches | ||||
| #         } # ~endp_vals | ||||
|  | ||||
|          for $option ( sort keys %option_map ) { | ||||
| 	    #print("Checking option: $option\n"); | ||||
|             print $option.": ".$option_map{ $option }."\n"; | ||||
|          } | ||||
|       } | ||||
|   | ||||
| @@ -481,10 +481,12 @@ def main(): | ||||
|                        worksheet.write(row, col, "", center_blue); col += 1 | ||||
|                        worksheet.write(row, col, "", center_blue); col += 1 | ||||
|  | ||||
|                    worksheet.write(row, col, float(results[2]) / 1000000, center_blue); col += 1 | ||||
|                    worksheet.write(row, col, float(results[3]) / 1000000, center_tan); col += 1 | ||||
|                    worksheet.write(row, col, "%s"%((float(resultsA[2]) + float(resultsB[2])) / 1000000), center_blue); col += 1 | ||||
|                    worksheet.write(row, col, "%s"%((float(resultsA[3]) + float(resultsB[3])) / 1000000), center_tan); col += 1 | ||||
|                    print("results[2]:%s  3: %s"%(results[2], results[3])) | ||||
|  | ||||
|                    worksheet.write(row, col, "%.2f"%(float(results[2]) / 1000000), center_blue); col += 1 | ||||
|                    worksheet.write(row, col, "%.2f"%(float(results[3]) / 1000000), center_tan); col += 1 | ||||
|                    worksheet.write(row, col, "%.2f"%((float(resultsA[2]) + float(resultsB[2])) / 1000000), center_blue); col += 1 | ||||
|                    worksheet.write(row, col, "%.2f"%((float(resultsA[3]) + float(resultsB[3])) / 1000000), center_tan); col += 1 | ||||
|                    worksheet.write(row, col, lat_cols[2], center_tan); col += 1 | ||||
|                    worksheet.write(row, col, lat_cols[0], center_tan); col += 1 | ||||
|                    worksheet.write(row, col, lat_cols[1], center_tan); col += 1 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ben Greear
					Ben Greear