URL: https://linuxfr.org/forums/programmation-shell/posts/fusion-de-tableau-de-requette-snmp Title: fusion de tableau de requette snmp Authors: kowalsky Date: 2005年07月06日T12:11:54+02:00 Tags: Score: 0 Bonjour tout le monde Je cherche a faire un petit script qui me donnerais les voisins de mes equipements cisco, en interogeant la MIB snmp relatif au voisin CDP. voici les commandes tapé snmpwalk `equihost 100` cisco.ciscoMgmt.ciscoCdpMIB. ciscoCdpMIBObjects.cdpCache. cdpCacheTable.cdpCacheEntry. cdpCacheDeviceId | awk -F "." '{print 9ドル " "10ドル}' | awk '{print 1ドル " " 2ドル " " 7ドル}' Recupère les voisins avec le numero de l'interface en snmp 9 1 shoot-land-2924-472 14 1 shoot-land-3640-943 134 1 shoot-land-rsm-220 149 1 shoot-land-2924-104 150 1 shoot-land-2924-105 151 1 shoot-land-2924-106 152 1 shoot-land-2924-107 153 1 shoot-land-2924-108 154 1 shoot-land-2924-109 158 1 shoot-land-3640-943 160 1 shoot-land-3524-1021 161 1 shoot-land-2924-493 162 1 shoot-land-2924-494 163 1 shoot-land-2924-495 164 2 shoot-land-3548-1929 165 1 shoot-land-2950-2443 167 1 shoot-land-2924-2073 168 1 shoot-land-2950-2428 170 1 shoot-land-2950-2441 171 1 shoot-land-2950-2452 246 2 shoot-land-3550-3457 248 2 shoot-aube-4006-1932 248 3 shoot-land-2950-3270 248 4 shoot-land-2651-3606 248 5 shoot-land-2621-1232 249 1 shoot-land-3548-1473 snmpwalk `equihost 100` cisco.ciscoMgmt.ciscoCdpMIB. ciscoCdpMIBObjects. cdpCache.cdpCacheTable. cdpCacheEntry.cdpCacheDevicePort | awk -F "." '{print 9ドル " "10ドル}' | awk '{print 1ドル " " 2ドル " " 7ドル}' pareil, mais pour l'interface "distante" 9 1 Ethernet0 14 1 Ethernet0/0 134 1 Vlan1 149 1 FastEthernet0/1 150 1 FastEthernet0/1 151 1 FastEthernet0/1 152 1 FastEthernet0/1 153 1 FastEthernet0/1 154 1 FastEthernet0/1 158 1 Ethernet2/3 160 1 FastEthernet0/23 161 1 FastEthernet0/1 162 1 FastEthernet0/1 163 1 FastEthernet0/1 164 2 FastEthernet0/1 165 1 FastEthernet0/1 167 1 FastEthernet0/1 168 1 FastEthernet0/1 170 1 FastEthernet0/1 171 1 FastEthernet0/1 246 2 FastEthernet0/1 248 2 2/5 248 3 FastEthernet0/24 248 4 FastEthernet0/1 248 5 FastEthernet0/1 249 1 GigabitEthernet0/1 snmpwalk `equihost 100` ifName | awk -F "." '{print 6ドル" "7ドル}' | awk '{print 1ドル" "6ドル}' Et cette commande me recupère la liste avec correspondance entre numero snmp et numero plus "humain"...! 1 sc0 2 sl0 3 VLAN-1 4 VLAN-1002 5 VLAN-1004 6 VLAN-1005 7 VLAN-1003 8 4/1 9 4/2 10 4/3 11 4/4 12 4/5 13 4/6 14 4/7 15 4/8 16 4/9 17 4/10 18 4/11 19 4/12 20 4/13 21 4/14 22 4/15 23 4/16 24 4/17 25 4/18 26 4/19 27 4/20 28 4/21 29 4/22 30 4/23 etc, ça liste donc les ports, même ceux qui ne m'interesse pas...! Le but serait donc d'arriver à un truc du genre: 4/2 9 1 shoot-land-4700-472 Ethernet0 4/7 14 1 shoot-land-3640-943 Ethernet0/0 3/1 134 1 shoot-land-rsm-101 Vlan1 3/2 149 1 shoot-land-2924-104 FastEthernet0/1 3/3 150 1 shoot-land-2924-105 FastEthernet0/1 3/4 151 1 shoot-land-2924-106 FastEthernet0/1 3/5 152 1 shoot-land-2924-107 FastEthernet0/1 3/6 153 1 shoot-land-2924-108 FastEthernet0/1 3/7 154 1 shoot-land-2924-109 FastEthernet0/1 3/8 158 1 shoot-land-3640-943 Ethernet2/3 3/9 160 1 shoot-land-3524-1021 FastEthernet0/23 3/10 161 1 shoot-land-2924-493 FastEthernet0/1 3/11 162 1 shoot-land-2924-494 FastEthernet0/1 3/14 163 1 shoot-land-2924-495 FastEthernet0/1 3/15 164 2 shoot-land-3548-1929 FastEthernet0/1 3/16 165 1 shoot-land-2950-2443 FastEthernet0/1 3/17 167 1 shoot-land-2924-2073 FastEthernet0/1 3/18 168 1 shoot-land-2950-2428 FastEthernet0/1 3/19 170 1 shoot-land-2950-2441 FastEthernet0/1 3/20 171 1 shoot-land-2950-2452 FastEthernet0/1 3/21 246 2 shoot-land-3550-3457 FastEthernet0/1 3/22 248 2 shoot-aube-4006-1932 2/5 3/23 248 3 shoot-land-2950-3270 FastEthernet0/24 5/6 248 4 shoot-land-2651-3606 FastEthernet0/1 5/7 248 5 shoot-land-2621-1232 FastEthernet0/1 5/8 249 1 shoot-land-3548-1473 GigabitEthernet0/1 je ne vous demande bien sur pas de me le faire hein...! mais si vous pouviez me mettre sur la voie au moins, sachant que ça doit etre fait en shell, bash si possible...!! Merci d'avance...!