+ Répondre à la discussion
Page 2 sur 2 PremièrePremière 12
Affichage des résultats 21 à 28 sur 28
  1. #21
    Futur Membre du Club
    Inscrit en
    juillet 2009
    Messages
    182
    Détails du profil
    Informations forums :
    Inscription : juillet 2009
    Messages : 182
    Points : 18
    Points
    18

    Par défaut

    Je viens de faire les modifications, voici les erreurs :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    Use of uninitialized value in anonymous hash ({}) at ./test.pl line 49.
    Use of uninitialized value in anonymous hash ({}) at ./test.pl line 49.
    Use of uninitialized value in anonymous hash ({}) at ./test.pl line 49.
    Use of uninitialized value in anonymous hash ({}) at ./test.pl line 49.
    Use of uninitialized value in say at ./test.pl line 54.
    Ligne : 49 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $var{$key} = { pairwise { $a => $b } @col_names, @col_values } if defined $key;

  2. #22
    Expert Confirmé Sénior

    Inscrit en
    avril 2009
    Messages
    3 226
    Détails du profil
    Informations personnelles :
    Âge : 49

    Informations forums :
    Inscription : avril 2009
    Messages : 3 226
    Points : 4 178
    Points
    4 178

    Par défaut

    Mmmm, désolé, je n'ai plus le temps ce soir, et demain, ce sera très chaud... peut-être à lundi.
    Plus j'apprends, et plus je mesure mon ignorance (philou67430)
    Toute technologie suffisamment avancée est indiscernable d'un script Perl (Llama book)
    Partagez vos problèmes pour que l'on partage ensemble nos solutions : je ne réponds pas aux questions techniques par message privé
    Using strict and warnings is good for you.

  3. #23
    Futur Membre du Club
    Inscrit en
    juillet 2009
    Messages
    182
    Détails du profil
    Informations forums :
    Inscription : juillet 2009
    Messages : 182
    Points : 18
    Points
    18

    Par défaut

    Bonjour,

    Je n'arrive pas vraiement à comprendre l'erreur "uninitialized value in anonymous hash" ou à trouver une explication qui me permettrait d'avancer...

    En général quel est ce type d'erreur ?

  4. #24
    Expert Confirmé Sénior

    Inscrit en
    avril 2009
    Messages
    3 226
    Détails du profil
    Informations personnelles :
    Âge : 49

    Informations forums :
    Inscription : avril 2009
    Messages : 3 226
    Points : 4 178
    Points
    4 178

    Par défaut

    Désolé, je t'ai oublié.
    Cette erreur vient du fait qu'une valeur non définie est utilisée comme clé d'une table de hashage.
    Plus j'apprends, et plus je mesure mon ignorance (philou67430)
    Toute technologie suffisamment avancée est indiscernable d'un script Perl (Llama book)
    Partagez vos problèmes pour que l'on partage ensemble nos solutions : je ne réponds pas aux questions techniques par message privé
    Using strict and warnings is good for you.

  5. #25
    Expert Confirmé Sénior

    Inscrit en
    avril 2009
    Messages
    3 226
    Détails du profil
    Informations personnelles :
    Âge : 49

    Informations forums :
    Inscription : avril 2009
    Messages : 3 226
    Points : 4 178
    Points
    4 178

    Par défaut

    Après my $key $shift @col_values, ajoutes les lignes suivantes :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    say "Line: $line";
    say "Key: $key";
    say join ", ", pairwise { $a." => ".$b } @col_names, @col_values;
    et montre moi ce que ça retourne.

    Sinon, essaye de modifier cette ligne :
    en
    Plus j'apprends, et plus je mesure mon ignorance (philou67430)
    Toute technologie suffisamment avancée est indiscernable d'un script Perl (Llama book)
    Partagez vos problèmes pour que l'on partage ensemble nos solutions : je ne réponds pas aux questions techniques par message privé
    Using strict and warnings is good for you.

  6. #26
    Futur Membre du Club
    Inscrit en
    juillet 2009
    Messages
    182
    Détails du profil
    Informations forums :
    Inscription : juillet 2009
    Messages : 182
    Points : 18
    Points
    18

    Par défaut

    Bonjour Philou67430,

    Entre temps j'ai récrit mon script PERL pour ne plus passer par un serveur SSH mais directement me connecter sur le switch. La numération à changer mais cela reste la même chose.

    Voici le retour du script modifié :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
     
    ./switch2.pl
    Line: switch>terminal length 0
    Key: switch>terminal
    Use of uninitialized value $a in concatenation (.) or string at ./switch2.pl line 51.
    Use of uninitialized value $a in concatenation (.) or string at ./switch2.pl line 51.
     => length,  => 0
    Use of uninitialized value in anonymous hash ({}) at ./switch2.pl line 52.
    Use of uninitialized value in anonymous hash ({}) at ./switch2.pl line 52.
    Line: switch>enable
    Key: switch>enable
     
    Line: Password:
    Key: Password:
     
    Line: switch#sh interfaces counters
    Key: switch#sh
    Use of uninitialized value $a in concatenation (.) or string at ./switch2.pl line 51.
    Use of uninitialized value $a in concatenation (.) or string at ./switch2.pl line 51.
     => interfaces,  => counters
    Use of uninitialized value in anonymous hash ({}) at ./switch2.pl line 52.
    Use of uninitialized value in anonymous hash ({}) at ./switch2.pl line 52.
    Line: Fa0/1           38683093          91864         152865           6137
    Key: Fa0/1
    InOctets => 38683093, InUcastPkts => 91864, InMcastPkts => 152865, InBcastPkts => 6137
    Line: Fa0/2        19349094427       19275757         235285          66839
    Key: Fa0/2
    InOctets => 19349094427, InUcastPkts => 19275757, InMcastPkts => 235285, InBcastPkts => 66839
    Line: Fa0/3          636508501        3307229             67           8944
    Key: Fa0/3
    InOctets => 636508501, InUcastPkts => 3307229, InMcastPkts => 67, InBcastPkts => 8944
    Line: Fa0/4         3778785876        8844952            292           4012
    Key: Fa0/4
    InOctets => 3778785876, InUcastPkts => 8844952, InMcastPkts => 292, InBcastPkts => 4012
    Line: Fa0/5          889123917        6233404            124            857
    Key: Fa0/5
    InOctets => 889123917, InUcastPkts => 6233404, InMcastPkts => 124, InBcastPkts => 857
    Line: Fa0/6          792678644        5306598             29           3666
    Key: Fa0/6
    InOctets => 792678644, InUcastPkts => 5306598, InMcastPkts => 29, InBcastPkts => 3666
    Line: Fa0/7         7912521757       28529770          74625          57785
    Key: Fa0/7
    InOctets => 7912521757, InUcastPkts => 28529770, InMcastPkts => 74625, InBcastPkts => 57785
    Line: Fa0/8         2161229303        9237154         214530         336804
    Key: Fa0/8
    InOctets => 2161229303, InUcastPkts => 9237154, InMcastPkts => 214530, InBcastPkts => 336804
    Line: Fa0/9         2054801982       17757552          30502         127784
    Key: Fa0/9
    InOctets => 2054801982, InUcastPkts => 17757552, InMcastPkts => 30502, InBcastPkts => 127784
    Line: Fa0/10           7788574          51143              6            191
    Key: Fa0/10
    InOctets => 7788574, InUcastPkts => 51143, InMcastPkts => 6, InBcastPkts => 191
    Line: Fa0/11        7999930907       13376152           5671         391905
    Key: Fa0/11
    InOctets => 7999930907, InUcastPkts => 13376152, InMcastPkts => 5671, InBcastPkts => 391905
    Line: Fa0/12                 0              0              0              0
    Key: Fa0/12
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/13                 0              0              0              0
    Key: Fa0/13
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/14        1124993080         856145             74              3
    Key: Fa0/14
    InOctets => 1124993080, InUcastPkts => 856145, InMcastPkts => 74, InBcastPkts => 3
    Line: Fa0/15                 0              0              0              0
    Key: Fa0/15
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/16                 0              0              0              0
    Key: Fa0/16
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/17                 0              0              0              0
    Key: Fa0/17
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/18                 0              0              0              0
    Key: Fa0/18
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/19         126086300         493401              6            141
    Key: Fa0/19
    InOctets => 126086300, InUcastPkts => 493401, InMcastPkts => 6, InBcastPkts => 141
    Line: Fa0/20                 0              0              0              0
    Key: Fa0/20
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/21                 0              0              0              0
    Key: Fa0/21
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/22                 0              0              0              0
    Key: Fa0/22
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/23                 0              0              0              0
    Key: Fa0/23
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/24                 0              0              0              0
    Key: Fa0/24
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Gi0/1            9465722          67282              5            210
    Key: Gi0/1
    InOctets => 9465722, InUcastPkts => 67282, InMcastPkts => 5, InBcastPkts => 210
    Line: Gi0/2        25413575516       96929463        5836128       11377822
    Key: Gi0/2
    InOctets => 25413575516, InUcastPkts => 96929463, InMcastPkts => 5836128, InBcastPkts => 11377822
    Line: Fa0/1         1458140965         230370        6368343       12371626
    Key: Fa0/1
    OutOctets => 1458140965, OutUcastPkts => 230370, OutMcastPkts => 6368343, OutBcastPkts => 12371626
    Line: Fa0/2         3258652246       12368250        6279249       12309912
    Key: Fa0/2
    OutOctets => 3258652246, OutUcastPkts => 12368250, OutMcastPkts => 6279249, OutBcastPkts => 12309912
    Line: Fa0/3         1644557042        3392515        6514860       12368963
    Key: Fa0/3
    OutOctets => 1644557042, OutUcastPkts => 3392515, OutMcastPkts => 6514860, OutBcastPkts => 12368963
    Line: Fa0/4         4288858135        8454272        6514501       12372366
    Key: Fa0/4
    OutOctets => 4288858135, OutUcastPkts => 8454272, OutMcastPkts => 6514501, OutBcastPkts => 12372366
    Line: Fa0/5         2254126399        6465721        5680621       10622283
    Key: Fa0/5
    OutOctets => 2254126399, OutUcastPkts => 6465721, OutMcastPkts => 5680621, OutBcastPkts => 10622283
    Line: Fa0/6         1745476072        5441876        5680745       10620503
    Key: Fa0/6
    OutOctets => 1745476072, OutUcastPkts => 5441876, OutMcastPkts => 5680745, OutBcastPkts => 10620503
    Line: Fa0/7         7904951370       28392537        5612167       10565818
    Key: Fa0/7
    OutOctets => 7904951370, OutUcastPkts => 28392537, OutMcastPkts => 5612167, OutBcastPkts => 10565818
    Line: Fa0/8         2641998698        8702145        5471416       10285973
    Key: Fa0/8
    OutOctets => 2641998698, OutUcastPkts => 8702145, OutMcastPkts => 5471416, OutBcastPkts => 10285973
    Line: Fa0/9         3952314256       19347636        6481328       12242537
    Key: Fa0/9
    OutOctets => 3952314256, OutUcastPkts => 19347636, OutMcastPkts => 6481328, OutBcastPkts => 12242537
    Line: Fa0/10        1181139227         124630        5680712       10623745
    Key: Fa0/10
    OutOctets => 1181139227, OutUcastPkts => 124630, OutMcastPkts => 5680712, OutBcastPkts => 10623745
    Line: Fa0/11        9578845385       12897956        6509549       11985906
    Key: Fa0/11
    OutOctets => 9578845385, OutUcastPkts => 12897956, OutMcastPkts => 6509549, OutBcastPkts => 11985906
    Line: Fa0/12        1174696812          75971        5676507       10611782
    Key: Fa0/12
    OutOctets => 1174696812, OutUcastPkts => 75971, OutMcastPkts => 5676507, OutBcastPkts => 10611782
    Line: Fa0/13                 0              0              0              0
    Key: Fa0/13
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/14         367894640         498134            734           1629
    Key: Fa0/14
    OutOctets => 367894640, OutUcastPkts => 498134, OutMcastPkts => 734, OutBcastPkts => 1629
    Line: Fa0/15                 0              0              0              0
    Key: Fa0/15
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/16                 0              0              0              0
    Key: Fa0/16
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/17                 0              0              0              0
    Key: Fa0/17
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/18                 0              0              0              0
    Key: Fa0/18
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/19         215398333         460039         829752        1739535
    Key: Fa0/19
    OutOctets => 215398333, OutUcastPkts => 460039, OutMcastPkts => 829752, OutBcastPkts => 1739535
    Line: Fa0/20                 0              0              0              0
    Key: Fa0/20
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/21                 0              0              0              0
    Key: Fa0/21
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/22                 0              0              0              0
    Key: Fa0/22
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/23                 0              0              0              0
    Key: Fa0/23
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/24                 0              0              0              0
    Key: Fa0/24
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Gi0/1         1181692893         135979        5680760       10623459
    Key: Gi0/1
    OutOctets => 1181692893, OutUcastPkts => 135979, OutMcastPkts => 5680760, OutBcastPkts => 10623459
    Line: Gi0/2        44754859684      104633485        1262595         999979
    Key: Gi0/2
    OutOctets => 44754859684, OutUcastPkts => 104633485, OutMcastPkts => 1262595, OutBcastPkts => 999979
    Line: switch#
    Key: switch#
    Use of uninitialized value in concatenation (.) or string at ./switch2.pl line 51.
    Use of uninitialized value in concatenation (.) or string at ./switch2.pl line 51.
    Use of uninitialized value in concatenation (.) or string at ./switch2.pl line 51.
    Use of uninitialized value in concatenation (.) or string at ./switch2.pl line 51.
    OutOctets => , OutUcastPkts => , OutMcastPkts => , OutBcastPkts =>
    Use of uninitialized value in say at ./switch2.pl line 57.
    Key Gi0/2, InOctets:

  7. #27
    Expert Confirmé Sénior

    Inscrit en
    avril 2009
    Messages
    3 226
    Détails du profil
    Informations personnelles :
    Âge : 49

    Informations forums :
    Inscription : avril 2009
    Messages : 3 226
    Points : 4 178
    Points
    4 178

    Par défaut

    OK, ça me semble être le traitement des lignes parasites qui pose problème, celles qui débutent le fichier.
    Par quel moyen est-il possible de les identifier, sachant que je ne connais pas vraiment ce qu'elles peuvent contenir.

    Une idée : on les ignore jusqu'à trouver une ligne qui commence par N.

    Dans ce cas, remplace la ligne
    par
    Et poste à nouveau le script complet, histoire d'être synchro.
    Plus j'apprends, et plus je mesure mon ignorance (philou67430)
    Toute technologie suffisamment avancée est indiscernable d'un script Perl (Llama book)
    Partagez vos problèmes pour que l'on partage ensemble nos solutions : je ne réponds pas aux questions techniques par message privé
    Using strict and warnings is good for you.

  8. #28
    Futur Membre du Club
    Inscrit en
    juillet 2009
    Messages
    182
    Détails du profil
    Informations forums :
    Inscription : juillet 2009
    Messages : 182
    Points : 18
    Points
    18

    Par défaut

    Execution du script :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
     
    ./switch2.pl
    Line: Fa0/1           38695873          91876         152942           6137
    Key: Fa0/1
    InOctets => 38695873, InUcastPkts => 91876, InMcastPkts => 152942, InBcastPkts =                                                                                                                                                             > 6137
    Line: Fa0/2        19384924724       19304663         235476          66881
    Key: Fa0/2
    InOctets => 19384924724, InUcastPkts => 19304663, InMcastPkts => 235476, InBcast                                                                                                                                                             Pkts => 66881
    Line: Fa0/3          636844003        3308907             67           8949
    Key: Fa0/3
    InOctets => 636844003, InUcastPkts => 3308907, InMcastPkts => 67, InBcastPkts =>                                                                                                                                                              8949
    Line: Fa0/4         3783986114        8861258            297           4015
    Key: Fa0/4
    InOctets => 3783986114, InUcastPkts => 8861258, InMcastPkts => 297, InBcastPkts                                                                                                                                                              => 4015
    Line: Fa0/5          892573774        6244408            124            857
    Key: Fa0/5
    InOctets => 892573774, InUcastPkts => 6244408, InMcastPkts => 124, InBcastPkts =                                                                                                                                                             > 857
    Line: Fa0/6          800430849        5320104             29           3668
    Key: Fa0/6
    InOctets => 800430849, InUcastPkts => 5320104, InMcastPkts => 29, InBcastPkts =>                                                                                                                                                              3668
    Line: Fa0/7         7931011824       28576116          74661          57858
    Key: Fa0/7
    InOctets => 7931011824, InUcastPkts => 28576116, InMcastPkts => 74661, InBcastPk                                                                                                                                                             ts => 57858
    Line: Fa0/8         2162054573        9243378         214674         337000
    Key: Fa0/8
    InOctets => 2162054573, InUcastPkts => 9243378, InMcastPkts => 214674, InBcastPk                                                                                                                                                             ts => 337000
    Line: Fa0/9         2055782574       17766429          30517         127786
    Key: Fa0/9
    InOctets => 2055782574, InUcastPkts => 17766429, InMcastPkts => 30517, InBcastPk                                                                                                                                                             ts => 127786
    Line: Fa0/10           7789342          51155              6            191
    Key: Fa0/10
    InOctets => 7789342, InUcastPkts => 51155, InMcastPkts => 6, InBcastPkts => 191
    Line: Fa0/11        8000053201       13376624           5677         392154
    Key: Fa0/11
    InOctets => 8000053201, InUcastPkts => 13376624, InMcastPkts => 5677, InBcastPkt                                                                                                                                                             s => 392154
    Line: Fa0/12                 0              0              0              0
    Key: Fa0/12
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/13                 0              0              0              0
    Key: Fa0/13
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/14        1124993080         856145             74              3
    Key: Fa0/14
    InOctets => 1124993080, InUcastPkts => 856145, InMcastPkts => 74, InBcastPkts =>                                                                                                                                                              3
    Line: Fa0/15                 0              0              0              0
    Key: Fa0/15
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/16                 0              0              0              0
    Key: Fa0/16
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/17                 0              0              0              0
    Key: Fa0/17
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/18                 0              0              0              0
    Key: Fa0/18
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/19         126086300         493401              6            141
    Key: Fa0/19
    InOctets => 126086300, InUcastPkts => 493401, InMcastPkts => 6, InBcastPkts => 1                                                                                                                                                             41
    Line: Fa0/20                 0              0              0              0
    Key: Fa0/20
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/21                 0              0              0              0
    Key: Fa0/21
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/22                 0              0              0              0
    Key: Fa0/22
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/23                 0              0              0              0
    Key: Fa0/23
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Fa0/24                 0              0              0              0
    Key: Fa0/24
    InOctets => 0, InUcastPkts => 0, InMcastPkts => 0, InBcastPkts => 0
    Line: Gi0/1            9466298          67291              5            210
    Key: Gi0/1
    InOctets => 9466298, InUcastPkts => 67291, InMcastPkts => 5, InBcastPkts => 210
    Line: Gi0/2        25429914231       97018105        5838991       11386973
    Key: Gi0/2
    InOctets => 25429914231, InUcastPkts => 97018105, InMcastPkts => 5838991, InBcas                                                                                                                                                             tPkts => 11386973
    Line: Fa0/1         1459038451         230409        6371603       12381349
    Key: Fa0/1
    OutOctets => 1459038451, OutUcastPkts => 230409, OutMcastPkts => 6371603, OutBca                                                                                                                                                             stPkts => 12381349
    Line: Fa0/2         3261247398       12380652        6282395       12319593
    Key: Fa0/2
    OutOctets => 3261247398, OutUcastPkts => 12380652, OutMcastPkts => 6282395, OutB                                                                                                                                                             castPkts => 12319593
    Line: Fa0/3         1645605776        3394244        6518197       12378681
    Key: Fa0/3
    OutOctets => 1645605776, OutUcastPkts => 3394244, OutMcastPkts => 6518197, OutBc                                                                                                                                                             astPkts => 12378681
    Line: Fa0/4         4298422955        8471173        6517833       12382086
    Key: Fa0/4
    OutOctets => 4298422955, OutUcastPkts => 8471173, OutMcastPkts => 6517833, OutBc                                                                                                                                                             astPkts => 12382086
    Line: Fa0/5         2258055585        6478777        5683958       10632006
    Key: Fa0/5
    OutOctets => 2258055585, OutUcastPkts => 6478777, OutMcastPkts => 5683958, OutBc                                                                                                                                                             astPkts => 10632006
    Line: Fa0/6         1749204419        5454623        5684082       10630224
    Key: Fa0/6
    OutOctets => 1749204419, OutUcastPkts => 5454623, OutMcastPkts => 5684082, OutBc                                                                                                                                                             astPkts => 10630224
    Line: Fa0/7         7913711230       28434954        5615468       10575468
    Key: Fa0/7
    OutOctets => 7913711230, OutUcastPkts => 28434954, OutMcastPkts => 5615468, OutB                                                                                                                                                             castPkts => 10575468
    Line: Fa0/8         2643618765        8708292        5474609       10295500
    Key: Fa0/8
    OutOctets => 2643618765, OutUcastPkts => 8708292, OutMcastPkts => 5474609, OutBc                                                                                                                                                             astPkts => 10295500
    Line: Fa0/9         3955358970       19359160        6484650       12252258
    Key: Fa0/9
    OutOctets => 3955358970, OutUcastPkts => 19359160, OutMcastPkts => 6484650, OutB                                                                                                                                                             castPkts => 12252258
    Line: Fa0/10        1182048311         124663        5684049       10633468
    Key: Fa0/10
    OutOctets => 1182048311, OutUcastPkts => 124663, OutMcastPkts => 5684049, OutBca                                                                                                                                                             stPkts => 10633468
    Line: Fa0/11        9579816568       12898440        6512880       11995380
    Key: Fa0/11
    OutOctets => 9579816568, OutUcastPkts => 12898440, OutMcastPkts => 6512880, OutB                                                                                                                                                             castPkts => 11995380
    Line: Fa0/12        1175604976          75990        5679844       10621505
    Key: Fa0/12
    OutOctets => 1175604976, OutUcastPkts => 75990, OutMcastPkts => 5679844, OutBcas                                                                                                                                                             tPkts => 10621505
    Line: Fa0/13                 0              0              0              0
    Key: Fa0/13
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/14         367894640         498134            734           1629
    Key: Fa0/14
    OutOctets => 367894640, OutUcastPkts => 498134, OutMcastPkts => 734, OutBcastPkt                                                                                                                                                             s => 1629
    Line: Fa0/15                 0              0              0              0
    Key: Fa0/15
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/16                 0              0              0              0
    Key: Fa0/16
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/17                 0              0              0              0
    Key: Fa0/17
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/18                 0              0              0              0
    Key: Fa0/18
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/19         215398333         460039         829752        1739535
    Key: Fa0/19
    OutOctets => 215398333, OutUcastPkts => 460039, OutMcastPkts => 829752, OutBcast                                                                                                                                                             Pkts => 1739535
    Line: Fa0/20                 0              0              0              0
    Key: Fa0/20
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/21                 0              0              0              0
    Key: Fa0/21
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/22                 0              0              0              0
    Key: Fa0/22
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/23                 0              0              0              0
    Key: Fa0/23
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Fa0/24                 0              0              0              0
    Key: Fa0/24
    OutOctets => 0, OutUcastPkts => 0, OutMcastPkts => 0, OutBcastPkts => 0
    Line: Gi0/1         1182601643         136007        5684097       10633182
    Key: Gi0/1
    OutOctets => 1182601643, OutUcastPkts => 136007, OutMcastPkts => 5684097, OutBca                                                                                                                                                             stPkts => 10633182
    Line: Gi0/2        44816246512      104738219        1263365        1000551
    Key: Gi0/2
    OutOctets => 44816246512, OutUcastPkts => 104738219, OutMcastPkts => 1263365, Ou                                                                                                                                                             tBcastPkts => 1000551
    Line: switch#
    Key: switch#
    Use of uninitialized value in concatenation (.) or string at ./switch2.pl line 51                                                                                                                                                             .
    Use of uninitialized value in concatenation (.) or string at ./switch2.pl line 51                                                                                                                                                             .
    Use of uninitialized value in concatenation (.) or string at ./switch2.pl line 51                                                                                                                                                             .
    Use of uninitialized value in concatenation (.) or string at ./switch2.pl line 51                                                                                                                                                             .
    OutOctets => , OutUcastPkts => , OutMcastPkts => , OutBcastPkts =>
    Use of uninitialized value in say at ./switch2.pl line 57.
    Key Gi0/2, InOctets:
    Script PERL :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
     
    #!/usr/bin/perl
    #
     
    use Net::SSH2;
    use strict;
    use warnings;
     
    use feature qw(:5.10);
    use List::MoreUtils qw(pairwise);
     
    my $ip="192.168.10.10";
    my $password="password";
    my $user="admin";
    my $enable=$password;
     
    my $ssh2 = Net::SSH2->new();
    $ssh2->connect("$ip") or die;
    if ($ssh2->auth_password("$user","$password")) {
    my $chan2 = $ssh2->channel();
    $chan2->shell();
    $chan2->blocking(0);
    print $chan2 "terminal length 0\n";
    print $chan2 "enable\n";
    print $chan2 "$enable\n";
    print $chan2 "sh interfaces counters\n";
     
    my %var;
    our ($a, $b);
     
    my @col_names;
    while (defined( my $line = <$chan2>)) {
      chomp $line;
      if ($line =~ /^Port/) {
        @col_names = split /\s+/, $line;
        shift @col_names;
      }
      elsif (@col_names) {
        if (my @col_values = split /\s+/, $line) {
          my $key = shift @col_values;
    say "Line: $line";
    say "Key: $key";
    say join ", ", pairwise { $a." => ".$b } @col_names, @col_values;
          $var{$key} = { pairwise { $a => $b } @col_names, @col_values } if defined $key;
        }
      }
    }
     
    say "Key Gi0/2, InOctets: ", $var{"Gi0/2"}->{"InOctets"};
     
    $chan2->close();
     
    } else {
    warn "auth error.\n";
    }

Liens sociaux

Règles de messages

  • Vous ne pouvez pas créer de nouvelles discussions
  • Vous ne pouvez pas envoyer des réponses
  • Vous ne pouvez pas envoyer des pièces jointes
  • Vous ne pouvez pas modifier vos messages
  •