function ParseOneG([byte[]]$rx){ $seq=ReadTLV $rx 0; $i=$seq.s; $ver=ReadTLV $rx $i; $i=$ver.next; $cm=ReadTLV $rx $i; $i=$cm.next; $pdu=ReadTLV $rx $i if($pdu.tag -ne 0xA2){ return $null } $j=$pdu.s; $rq=ReadTLV $rx $j; $j=$rq.next; $es=ReadTLV $rx $j; $j=$es.next; $ei=ReadTLV $rx $j; $j=$ei.next $vbl=ReadTLV $rx $j; $k=$vbl.s; $vb=ReadTLV $rx $k; $l=$vb.s $ob=ReadTLV $rx $l; $l2=$ob.next; $vv=ReadTLV $rx $l2 $oidv=TLVBytes $rx $ob $parts=@([int]($oidv[0]/40), [int]($oidv[0]%40)); $v=0 for($m=1;$m -lt $oidv.Length;$m++){ $b=$oidv[$m]; $v=($v -shl 7) -bor ($b -band 0x7F); if(($b -band 0x80) -eq 0){ $parts+=$v; $v=0 } } return @{oid=($parts -join '.'); val=(FmtVal $rx $vv)} } function Walk([string]$h,[string]$c,[string]$oid,[int]$steps){ $u=$null; $lines=@(); $cur=$oid try{ $u=UdpSess $h for($i=0;$i -lt $steps;$i++){ $rx=SnmpReq $u (MkPkt $c $cur (Get-Random -Min 100 -Max 999) 0xA1 $null) if(-not $rx){ $lines += 'walk-norsp'; break } $rr=ParseOneG $rx if(-not $rr){ $lines += 'walk-parsefail'; break } if(-not $rr.oid.StartsWith('1.3.6.1.4.1.37950.1.1.5.10.12.19.2')){ break } $lines += ($rr.oid + ' = ' + $rr.val) $cur = $rr.oid } }catch{ $lines += ('walk-exc ' + $_.Exception.Message) } try{ $u.Close() }catch{} return $lines } function FindSeg($lines){ $hit=@(); foreach($l in $lines){ if($l -match '115\.101\.103\.97\.100\.109'){ $hit += $l } } if($hit.Count -eq 0){ return 'none' } return ($hit -join ' ;; ') } $base='1.3.6.1.4.1.37950.1.1.5.10.12.19.1' $U='segadm'; $P='Seg#x1015' $hosts=@( @{h='192.168.18.17';c='private'}, @{h='192.168.18.68';c='private'}, @{h='192.168.18.69';c='private'}, @{h='192.168.18.108';c='private'}, @{h='192.168.18.234';c='private'} ) AO ('X0 start ' + (Get-Date -Format 'HH:mm:ss') + ' targets=' + $hosts.Count) foreach($t in $hosts){ $h=$t.h; $c=$t.c AO ("== $h ==") $full = Walk $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.2' 60 AO (" TABBASE " + (FindSeg $full)) $full | Select-Object -First 4 | ForEach-Object { AO (" TB $_") } $a=SetI $h $c "$base.4.0" 2 (Get-Random -Min 100 -Max 999) Start-Sleep -Milliseconds 300 $b=SetI $h $c "$base.5.0" 1 (Get-Random -Min 100 -Max 999) Start-Sleep -Milliseconds 1200 $w1 = Walk $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.2' 60 AO (" VA lvl2=$a app1=$b seg=" + (FindSeg $w1)) if((FindSeg $w1) -ne 'none'){ AO ("OK $h variantA"); Flush; continue } $c1=SetI $h $c "$base.5.0" 2 (Get-Random -Min 100 -Max 999) Start-Sleep -Milliseconds 1200 $w2 = Walk $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.2' 60 AO (" VB app2=$c1 seg=" + (FindSeg $w2)) if((FindSeg $w2) -ne 'none'){ AO ("OK $h variantB"); Flush; continue } $clr1=SetS $h $c "$base.1.0" '' (Get-Random -Min 100 -Max 999) $clr2=SetS $h $c "$base.2.0" '' (Get-Random -Min 100 -Max 999) Start-Sleep -Milliseconds 400 $d1=SetS $h $c "$base.3.0" $P (Get-Random -Min 700 -Max 950) $d2=SetS $h $c "$base.1.0" $U (Get-Random -Min 100 -Max 400) $d3=SetS $h $c "$base.2.0" $P (Get-Random -Min 400 -Max 700) $d4=SetS $h $c "$base.3.0" $P (Get-Random -Min 700 -Max 950) Start-Sleep -Milliseconds 400 $d5=SetI $h $c "$base.4.0" 1 (Get-Random -Min 100 -Max 999) Start-Sleep -Milliseconds 400 $d6=SetI $h $c "$base.5.0" 1 (Get-Random -Min 100 -Max 999) Start-Sleep -Milliseconds 1500 $w3 = Walk $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.2' 60 AO (" VC clr=$clr1/$clr2 s3=$d1 s1=$d2 s2=$d3 s3b=$d4 i4=$d5 i5=$d6 seg=" + (FindSeg $w3)) Flush Start-Sleep -Milliseconds 400 } AO ('X1 done ' + (Get-Date -Format 'HH:mm:ss')) AO 'REALEND-D590' Flush