Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Print Max Hash

by Marshall (Canon)
on Jan 30, 2018 at 10:40 UTC ( [id://1208113]=note: print w/replies, xml ) Need Help??


in reply to Print Max Hash

Can you show a few lines of example <INPUT> data?

Replies are listed 'Best First'.
Re^2: Print Max Hash
by bartrad (Beadle) on Jan 30, 2018 at 10:51 UTC

    Yes of course.

    Few lines from <INPUT>

    143599203|No|NACK|ENA||Major|20180129054027||ARM|NSA|PRM|0|DCN|Insuffi +cient SNMP security settings|HN408-CP-1E-I|3176 && ne|||||||No|| 143599356|No|NACK|ENA|ip|Major|20180129054037||CLR|NSA|PRM|0|DCN|CLEAR +ED: Network element does not respond to SNMP requests|HN4000e|3176 && + ne|||||||No|| 143599357|No|NACK|ENA|ip|Major|20180129054039||CLR|NSA|PRM|0|DCN|CLEAR +ED: Insufficient SNMP security settings|HN4000e|3176 && ne|||||||No|| 143599999|No|NACK|ENA|ip|Major|20180129054529||ARM|NSA|PRM|0|DCN|Netwo +rk element does not respond to SNMP requests|HN4000e|3176 && ne|||||| +|No||

    I've redacted the IP address and replaced with ip and also entered ne in place of a 6-9 digit number as it's sensitive, but hopefully this gives an idea of the format. Here's a sample of the output the script currently produces. 1st and 2nd column are $node_ip and $ne (both redacted) and third column is then $total{$ne}++ that seems to increment just fine and the final column is what I'm trying to call as the max but it increments regardless of what $ne is.

    ip1 5 | Network element does not respond to SNMP requests | + 212 | ip2 213 | Network element does not respond to SNMP requests | + 213 | ip2 214 | Network element does not respond to SNMP requests | + 214 | ip3 4 | Network element does not respond to SNMP requests | + 214 | ip2 215 | Network element does not respond to SNMP requests | + 215 | ip2 216 | Network element does not respond to SNMP requests | + 216 | ip4 1 | Network element does not respond to SNMP requests | + 216 | ip2 | 217 | Network element does not respond to SNMP requests +| 217 | ip2 218 | Network element does not respond to SNMP requests | + 218 | ip2 219 | Network element does not respond to SNMP requests | + 219 |
      What output do you expect?

      The last column doesn't increment "regardless of what $ne is", you can see that 214 is repeated twice, and so is 216. That's because $ne was different for the first of them and the program incremented a different value in the hash, but it wasn't incremented enough to change the max, so the max stayed the same.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      Can you put this data into <code>...</code> blocks?

        Yep, done, sorry.

      "...Few lines from <INPUT>..."

      May i ask where this "few lines" come from? Some Log? External Program? Probably something from the SNMP toolchain? Or some wrapper around one of these? I guess you know what i mean.

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1208113]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2024-04-26 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found