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.')){ break } $lines += ($rr.oid + ' = ' + $rr.val) $cur = $rr.oid } }catch{ $lines += ('walk-exc ' + $_.Exception.Message) } try{ $u.Close() }catch{} return $lines } $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.228';c='cxtreme-1234'}, @{h='192.168.18.234';c='private'} ) AO ('W0 start ' + (Get-Date -Format 'HH:mm:ss') + ' targets=' + $hosts.Count) foreach($t in $hosts){ $h=$t.h; $c=$t.c AO ("== $h ==") Walk $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.2.1.1.6' 30 | ForEach-Object { AO (" U6 $_") } Walk $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.2.1.1.2' 20 | ForEach-Object { AO (" P2 $_") } Walk $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.2.1.1.1' 20 | ForEach-Object { AO (" N1 $_") } $r4=GetP $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.1.4.0' (Get-Random -Min 100 -Max 999) $r5=GetP $h $c '1.3.6.1.4.1.37950.1.1.5.10.12.19.1.5.0' (Get-Random -Min 100 -Max 999) AO (" SC lvl=$r4 app=$r5") Flush } AO ('W1 done ' + (Get-Date -Format 'HH:mm:ss')) AO 'REALEND-D589' Flush