If your end goal is just to have and view the metrics, a tool like cacti, munin, mrtg could help you with less detail needed than asked for in your question.
That said, Cisco supports the standard MIBs to interfaces.
Each interface will be assigned an index. All of the information for the interfaces will be stored in tables. Each table is referenced by a specific OID, and the information for the specific interface in that table will be referenced by attaching the interface's index to the table's OID.
As an example, here's a script that looks up the ifIndex, ifDescr, ifAdminStatus, and ifOperStatus for every interface on a device. This example shows the oids used and the act of looking up table values based on their index. (I pulled this example out of a much larger piece of code to simplify it, so there are likely some minor bugs):
#!/usr/bin/perl
use Net::SNMP;
my %oids = (
'ifDescr' => '1.3.6.1.2.1.2.2.1.2',
'ifType' => '1.3.6.1.2.1.2.2.1.3',
'ifAdminStatus' => '1.3.6.1.2.1.2.2.1.7',
'ifOperStatus' => '1.3.6.1.2.1.2.2.1.8',
);
my $device = shift || die "Need device to poll";
my $community = shift || 'public';
my($snmp,$snmp_error) = Net::SNMP->session(-hostname => $device,
-community => $community);
my $info;
if (!$snmp) {
printf STDERR ("Couldn't create snmp object for $d: $snmp_error\n");
} else {
$info = $snmp->get_entries(-columns => [ $oids{ifDescr}, $oids{ifAdminStatus},
$oids{ifOperStatus}, $oids{ifType} ]);
if (!$info) {
printf STDERR ("Couldn't poll $d: %s\n", $snmp->error());
}
}
foreach my $oid (grep /^$oids{ifDescr}\./, keys(%$info)) {
my($index) = $oid =~ m|\.(\d+)$|;
print join(',', $device,
$index,
$info->{"$oids{ifDescr}.$index"},
$info->{"$oids{ifType}.$index"},
$info->{"$oids{ifAdminStatus}.$index"},
$info->{"$oids{ifOperStatus}.$index"}), "\n";
}
All the interesting stuff is under 1.3.6.1.2.1.2.2.1
, the ifEntry OID. Here's a link that explains some of the members of it, including the ones I used above and other you might be interested in, like Octet, Packets, Errors, etc
The Cisco CDP mib OIDs here includes cdpInterfaceIfIndex which should map to the local physical interface. (ifmib)
Establishing "Uplink" can be tricky, but you can sometimes infer from relative traffic ratios and sometimes from spanning tree what devices are 'upstream' of others.
Also consider this an opportunity to standardize the naming convention to make it more obvious where in your hierarchy a device sits. ("Access", "Distribution", "Core" to use cisco speak -- your hierarchy may slightly differ)
Best Answer
To answer my own question, it doesn't look like Cisco provides high granularity configuration via SNMP (e.g., port configuration), but it does provide a method for initiating a FTP/TFTP/SCP config copy to the switch. This copy can be performed to the running configuration which allows merging. This means a configuration snippet could be written to a text file, then TFTP'd to the switch which will merge with the running config, rather than replacing it. If copying to the start configuration, a merge operation is not done, so it replaces the entire config. An important distinction ;)
Details here: http://www.cisco.com/en/US/tech/tk648/tk362/technologies_configuration_example09186a0080094aa6.shtml