#!/usr/bin/perl use strict; use warnings; my $base = '1.3.6.1.4.1.546.1.1.5.1'; my %keep = ( '1' => 'ndx', '2' => 'user', '3' => 'pts', '4' => 'huh?', '5' => 'time', '6' => 'host', ); my %kept; while ( <DATA> ) { my ( $oid, $ndx, $val ) = /^ 13 \s $base \. (\d) \. (\d) \s \w+ \s ( +.*) $/x or next; push @{ $kept{$oid} }, $val if ( exists $keep{$oid} ); } while ( shift @{ $kept{1} } ) { my ( @info ) = map { shift @{ $kept{$_} } } 2 .. 6; print "@info", $/; } __DATA__ 13 1.3.6.1.4.1.546.1.1.5.1.1.1 INTEGER 1 13 1.3.6.1.4.1.546.1.1.5.1.1.2 INTEGER 2 13 1.3.6.1.4.1.546.1.1.5.1.1.3 INTEGER 3 13 1.3.6.1.4.1.546.1.1.5.1.1.4 INTEGER 4 13 1.3.6.1.4.1.546.1.1.5.1.2.1 OctetString user 13 1.3.6.1.4.1.546.1.1.5.1.2.2 OctetString user 13 1.3.6.1.4.1.546.1.1.5.1.2.3 OctetString user 13 1.3.6.1.4.1.546.1.1.5.1.2.4 OctetString user 13 1.3.6.1.4.1.546.1.1.5.1.3.1 OctetString pts/2 13 1.3.6.1.4.1.546.1.1.5.1.3.2 OctetString pts/3 13 1.3.6.1.4.1.546.1.1.5.1.3.3 OctetString pts/4 13 1.3.6.1.4.1.546.1.1.5.1.3.4 OctetString pts/5 13 1.3.6.1.4.1.546.1.1.5.1.4.1 INTEGER 10096 13 1.3.6.1.4.1.546.1.1.5.1.4.2 INTEGER 11928 13 1.3.6.1.4.1.546.1.1.5.1.4.3 INTEGER 4 13 1.3.6.1.4.1.546.1.1.5.1.4.4 INTEGER 21612 13 1.3.6.1.4.1.546.1.1.5.1.5.1 TimeTicks 11d 07:39:59 13 1.3.6.1.4.1.546.1.1.5.1.5.2 TimeTicks 9d 05:47:57 13 1.3.6.1.4.1.546.1.1.5.1.5.3 TimeTicks 14d 03:29:03 13 1.3.6.1.4.1.546.1.1.5.1.5.4 TimeTicks 0d 00:29:52 13 1.3.6.1.4.1.546.1.1.5.1.6.1 OctetString machine.domain.com 13 1.3.6.1.4.1.546.1.1.5.1.6.2 OctetString machine.domain.com 13 1.3.6.1.4.1.546.1.1.5.1.6.3 OctetString machine.domain.com 13 1.3.6.1.4.1.546.1.1.5.1.6.4 OctetString machine.domain.com 12 1.3.6.1.4.1.546.1.1.6.1.0 OctetString 00

user pts/2 10096 11d 07:39:59 machine.domain.com user pts/3 11928 9d 05:47:57 machine.domain.com user pts/4 4 14d 03:29:03 machine.domain.com user pts/5 21612 0d 00:29:52 machine.domain.com

In reply to Re: Parsing SNMP output by Anonymous Monk
in thread Parsing SNMP output by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.