[rancid] HP procurve backup extra commands

Hagen, Skye (skyeh@uidaho.edu) skyeh at uidaho.edu
Tue Nov 1 15:37:13 UTC 2022


Alex,

Not sure if attachments are allowed in this e-mail forum, so I'm pasting the code below. This is the code I wrote for LLDP neighbors for Procurve switches.

sub ShowLLDPDetail {
    print STDERR "    In ShowLLDPDetail: $_" if ($debug);

    my($deviceID, $sysname, $platform, $interface, $address, $capabilities);
    my($portID, $portdesc);
    my $telephone = 0;
    while (<INPUT>) {
        tr/\015//d;
        last if (/^$prompt/);
        next if (/^(\s*|\s*$cmd\s*)$/);
        return(1) if (/Line has invalid autocommand /);
        return(1) if (/(Invalid (input|command) detected|Type help or )/i);
        # the pager can not be disabled per-session on the PIX
        if (/^(<-+ More -+>)/) {
            my($len) = length($1);
            s/^$1\s{$len}//;
        }

        if (/ChassisId\s+: (.*)/) {
            $deviceID = $1;
            next;
        }

        if (/SysName\s+: (\S+)/) {
            $sysname = $1;
            next;
        }
            
        if (/System Descr : (.*)/) {
            $platform = $1;
            next;
        }
            
        if (/System Capabilities Supported\s+:(.*)/) {
            $capabilities = $1;
            next;
        }
            
        if (/Local Port   : (\S+)/) {
            $interface = $1;
            next;
        }

        if (/PortId       : (\S+)/) {
            $portID = $1;
            next;
        }

        if (/PortDescr    : (\S+)/) {
            $portdesc = $1;
            next;
        }
            
        if (/Address : (\S+)/) {
            $address = $1;
            if ($capabilities =~ /telephone/) {
                $telephone++;
            } else {
                if ($sysname) {
                    $deviceID = $sysname;
                } elsif ($deviceID =~ /.. .. .. .. .. ../) {
                    $deviceID = $address;
                }
                if (!$portID) { $portID = $portdesc; }
                ProcessHistory("LLDP","keysort","$deviceID $interface",
                               ";LLDP: Device: $deviceID Platform: $platform Local_Int: $interface Remote_Int: $portID\n");
            }
            $deviceID     = "";
            $sysname      = "";
            $platform     = "";
            $interface    = "";
            $address      = "";
            $capabilities = "";
            $portID       = "";
            $portdesc     = "";
            next;
        }

    }
    if ($telephone) {
        ProcessHistory("PHONES", "keysort", "phone",
                       ";PHONES: $telephone Telephone(s) detected\n");
    }

    ProcessHistory("","","",";\n");
    return(0);

}




-----Original Message-----
From: Rancid-discuss <rancid-discuss-bounces at www.shrubbery.net> On Behalf Of heasley
Sent: Tuesday, November 1, 2022 7:18 AM
To: Eckersley, Alex <alex.eckersley at espria.nl>
Cc: rancid-discuss at www.shrubbery.net
Subject: Re: [rancid] HP procurve backup extra commands

Tue, Nov 01, 2022 at 10:26:02AM +0000, Eckersley, Alex:
> Hi,
> 
> I want to get some extra information from HP procurves that we use, like "show lldp info remote-device" or "show cdp neighbors".
> The backup works well but I have no clue where to add these extra commands... can someone please point this out to me?

hey.  The best way is to copy the device definition from rancid.types.base to rancid.types.conf, rename the definition, then add whatever commands you want and update the group's router.db to use the new definition.

Also see section 4 of the FAQ.

_______________________________________________
Rancid-discuss mailing list
Rancid-discuss at www.shrubbery.net
https://urldefense.com/v3/__https://www.shrubbery.net/mailman/listinfo/rancid-discuss__;!!JYXjzlvb!mbZIUTbO8dCRXo5hNln8E5pRlvjBjrGmZWee6BgfXBij6Ily5IpB_RH83HbbXPLAiAxD8bNyCeRXaic$ 



More information about the Rancid-discuss mailing list