IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Programmation et administration système Perl Discussion :

Amélioration d'un Plugin en PERL


Sujet :

Programmation et administration système Perl

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 16
    Points : 5
    Points
    5
    Par défaut Amélioration d'un Plugin en PERL
    Bonjour,

    Je rencontre actuellement de petits problèmes sur ma prod.
    Etant en charge de la supervision (Nagios) des différents équipements de l'infra, je suis amené à surveiller une VM Netscaler 10.0 et particulièrement l'une de ses interfaces réseau.

    Le plugin ci-dessous "Check_int_traffic.pl" fonctionne très bien dessus mais il lui manque 2/3 choses pour être parfait.

    Lien pour télécharger le plugin :
    http://exchange.nagios.org/component...=4006&cf_id=24

    En effet, ce plugin ne sait pas traiter les switch -w (Warning) et -c (Critical)
    ce qui fait qu'il me renvoit bien l'activité du traffic de l'interface en temps réel, mais hélas il ne sait pas renvoyer d'alertes si le traffic atteint par exemple 5Mbps.

    Voilà le probleme d'une part.
    Et d'autre part je ne sais pas développer, n'ayant pas reçu une formation suffisamment solide dans ce domaine.

    Ma question : y'aurait il une âme charitable sur ce forum qui se sentirait de taille pour completer le developpement de ce plugin ?

    Je remercie par avance celui ou celle qui voudra bien s'y coller.

    Merci ^^
    @+

    Anthony

  2. #2
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 16
    Points : 5
    Points
    5
    Par défaut
    N'hésitez pas à poster si vous avez besoin de plus de précisions sur le fonctionnement de ce plugin... lignes de commandes, copies d'écran etc

    Merci !!

    A

  3. #3
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 820
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    Bonjour,

    Je trouve la démarche un peu gonflée de venir poster sur ce forum un programme trouvé sur le net pour demander à ce que l'on le réécrive pour vos besoins. Les personnes ici ne sont pas là pour faire votre boulot et sans que vous n'y mettiez du votre.

    À l'avenir, merci d'éviter de venir faire ce genre de demande ici.

  4. #4
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 16
    Points : 5
    Points
    5
    Par défaut
    Bonjour Djibril


    Il n'y a pas de feinte, j'ai annoncé la couleur dès le départ : je ne suis pas développeur et j'ai besoin d'aide.
    Est-ce un forum d'entraide ou pas?

    Tout ce que je suis capable d'apporter c'est des explications sur le fonctionnement des lignes de commande et des copies d'écran.

    J'ai jeté un oeil à ce script et je pense que pour un developpeur averti, c'est l'histoire d'une dizaine de lignes pas plus.

    Voilà, merci.

    A

  5. #5
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 820
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    De toute façon, à première vu d’œil, le programme est à refaire entièrement car il a été écrit avec d'anciennes méthodes.

    Voici le programme en question :
    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
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    #! /usr/bin/perl -w
     
    # Author: Martin Fuerstenau, Oce Printing Systems
    #         martin.fuerstenau_at_oce.com or Martin.fuerstenau_at_nagiossw.org
    #
    # Date:   23 Jul 2011
    # 
    #
    # Purpose and features of the program:
    #
    # - Get the network usage for Windows, Solaris and Linux servers.
    #
    # History and Changes:
    # 
    # - 23 Jul 2011 Version 1
    #    - First released version
    #
    # - 29 Sep 2011 Version 1.1
    #   - Corrected minor bug (String xxx in output)
    #   - Enhanced for NetApp network interfaces
    #
    # - 9 Oct 2012 Version 1.2
    #   - Corrections for Windows 2012 server.
    #
     
     
    use strict;
    use Getopt::Long;
    use Net::SNMP;
     
    my $ProgName = "check_int_traffic";
    my $help; 
    my $hostname;                                 # hostname 
    my $host;                                     # Valid hostname
    my $snmpport;                                 # SNMP port
    my $snmpport_def = "161";                     # SNMP port default
    my $os;                                       # To store the operating system name
     
     
    my $sysDescr;                                 # Contains the system description. Needed to decide
                                                  # whether it is Solaris, a Linux or Windows
    my $sysObject;                                # $sysObject and $sysObjectID are needed for Linux
    my $sysObjectID;                              # only to determine whether it is an old ucd-snmp or net-snmp
    my $ucdintcnt = 0;                            # Interface counter f. ucd-snmp. ucd-snmp doesn't report
                                                  # eth0, eth1 etc.. It reports only eth. But we need a unique
                                                  # name. So as a workaround this counter is added
     
    my $out;                                      # Contains the output
    my $perfout;                                  # Contains the performance output
     
    my $firstloop = 0;                            # To determine whether it is the first loop run or not
     
    my $IntIdx;                                   # Interface Index
    my $IntDescr;                                 # Contains the interface name (description)
    my $oid2descr;                                # Gets the result of the get_table for description
    my $descr_oid = '1.3.6.1.2.1.2.2.1.2';        # Base OID for description
     
    my $in_octet;                                 # Contains the incoming octets
    my $oid2in_octet;                             # Gets the result of the get_table for incoming octets
    my $in_octet_oid = '1.3.6.1.2.1.2.2.1.10';    # Base OID for description
     
    my $out_octet;                                # Contains the outgoing octets
    my $oid2out_octet;                            # Gets the result of the get_table for outgoing octets
    my $out_octet_oid = '1.3.6.1.2.1.2.2.1.16';   # Base OID for description
     
    my $oper;                                     # Contains the interface operational status
    my $oid2oper;                                 # Gets the result of the get_table for operational status
    my $oper_oid = '1.3.6.1.2.1.2.2.1.8';         # Base OID for description
     
     
    my %InterfaceStat = (
                        "1" => "up",
                        "2" => "down",
                        "3" => "testing",
                        "4" => "unknown",
                        "5" => "dormant",
                        "6" => "notPresent",
                        "7" => "lowerLayerDown"
                        );                        # Get the operational status of the interface Enumerations:
    my ($session,$error);                         # Needed to establish the session
    my $key;                                      # Needed in the loops. Contains various OIDs
    my $snmpversion;                              # SNMP version
    my $snmpversion_def = 1;                      # SNMP version default
    my $community;                                # community 
    my $oid2get;                                  # To store the OIDs
    my $IntDownAlert;                             # Alarm if interface is down. Default is no alarm
    my $IsDown = 0;                               # Used in loop. Switched to 1 if a interface is down
     
     
    $ENV{'PATH'}='';
    $ENV{'BASH_ENV'}=''; 
    $ENV{'ENV'}='';
     
    # Start of the main routine
     
    Getopt::Long::Configure('bundling');
    GetOptions
    	("h"   => \$help,          "help"          => \$help,
    	 "v=s" => \$snmpversion,   "snmpversion=s" => \$snmpversion,
    	 "d" =>   \$IntDownAlert,  "down"          => \$IntDownAlert,
    	 "H=s" => \$hostname,      "hostname=s"    => \$hostname,
    	 "C=s" => \$community,     "community=s"   => \$community,
    	 "p=s" => \$snmpport,      "port=s"        => \$snmpport);
     
    if ($help)
       {
       print_help();
       exit 0;
       }
     
    if (!$hostname)
        {
        print "Host name/address not specified\n\n";
        print_usage();
        exit 3;
        }
     
    if ($hostname =~ /([-.A-Za-z0-9]+)/)
       {
       $host = $1;
       }
     
    if (!$host)
        {
        print "Invalid host: $hostname\n\n";
        print_usage();
        exit 3;
        }
     
    if (!$community)
       {
       $community = "public";
       }
     
    if (!$IntDownAlert)
       {
       # 0 = No alarm
       # 1 = Alarm if an interface is down
       $IntDownAlert = 0;
       }
     
    if (!$snmpversion)
       {
       $snmpversion = $snmpversion_def;
       }
     
    if (!$snmpport)
       {
       $snmpport = $snmpport_def;
       }
     
    if (!($snmpversion eq "1" || $snmpversion eq "2"))
       {
       print "\nError! Only SNMP V1 or 2 supported!\n";
       print "Wrong version submitted.\n";
       print_usage();
       exit 3;
       }
     
    # --------------- Begin main subroutine ----------------------------------------
     
    # We initialize the snmp connection
     
    ($session, $error) = Net::SNMP->session( -hostname  => $hostname,
                                             -version   => $snmpversion,
                                             -community => $community,
                                             -port      => $snmpport,
                                             -retries   => 10,
                                             -timeout   => 10
                                            );
     
     
    # If there is something wrong...exit
     
    if (!defined($session))
       {
       printf("ERROR: %s.\n", $error);
       exit 3;
       }
     
    # Get rid of UTF8 translation in case of accentuated caracters
    $session->translate(Net::SNMP->TRANSLATE_NONE);
     
    # Get the operating system
     
    $oid2get = ".1.3.6.1.2.1.1.1.0";
     
    $sysDescr = $session->get_request( -varbindlist => ["$oid2get"] );
     
    $os = $$sysDescr{$oid2get};
    $os =~ s/^.*Software://;
    $os =~ s/^\s+//;
    $os =~ s/ .*//;
     
     
    # Get all interface tables
     
    $oid2descr = $session->get_table( -baseoid =>  $descr_oid );
    $oid2in_octet = $session->get_table( -baseoid =>  $in_octet_oid );
    $oid2out_octet = $session->get_table( -baseoid =>  $out_octet_oid );
    $oid2oper = $session->get_table( -baseoid =>  $oper_oid );
     
     
    if ( $os eq "NetApp" )
       {
     
       # Because ucd list only eth (or so) without a number (like eth0) we
       # have to determine wether it is ucd (2021) or net-snmp (8072) so we can
       # set up a counter to generate this information
     
       $oid2get = ".1.3.6.1.2.1.1.2.0";
       $sysObject = $session->get_request( -varbindlist => ["$oid2get"] );
       $sysObjectID = $$sysObject{$oid2get};
       $sysObjectID =~ s/^\.1\.3\.6\.1\.4\.1\.//;
       $sysObjectID =~ s/\..*$//;
     
       foreach $key ( keys %$oid2descr)
              {
     
              # Monitoring traffic on a loopback interface doesn't make sense
              if ($$oid2descr{$key} =~ m/lo.*$/isog)
                 {
                 delete $$oid2descr{$key};
                 }
              else
                 {
                 # This is a little bit tricky. If we have deleted the loopback interface
                 # during this run of the loop $key is not set. Therefore the if-statement
                 # will cause an error because $key is not initialized. So we first have to check
                 # it is :-))
     
                 # Kick out any sit interface
                 if ($$oid2descr{$key} =~ m/vh.*$/isog)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
              }
     
       # 0 = No alarm
       # 1 = Alarm if an interface is down
       # $IntDownAlert;                           # Alarm if interface is down. Default is no alarm
       # $IsDown = 0;                             # Used in loop. Switched to 1 if a interface is down
     
       foreach $key ( keys %$oid2descr)
              {
              $IntIdx = $key;
              $IntIdx =~ s/^.*\.//;
     
              if ( $sysObjectID == 2021 )
                 {
                 $$oid2descr{$key} = $$oid2descr{$key}.$ucdintcnt;
                 $ucdintcnt++;
                 }
              # Get the incoming octets
              $oid2get = $in_octet_oid.".".$IntIdx;
              $in_octet = $$oid2in_octet{$oid2get};
     
              # Get the outgoing octets
              $oid2get = $out_octet_oid.".".$IntIdx;
              $out_octet = $$oid2out_octet{$oid2get};
     
              # Get the operational status of the interface
              # Enumerations:
              # 1 - up
              # 2 - down
              # 3 - testing
              # 4 - unknown
              # 5 - dormant
              # 6 - notPresent
              # 7 - lowerLayerDown
     
              $oid2get = $oper_oid.".".$IntIdx;
              $oper = $$oid2oper{$oid2get};
              $IntDescr = $$oid2descr{$key};
     
              if ( $IntDownAlert == 1 )
                 {
                 if ( $oper != 1 )
                    {
                    $IsDown = 1;
                    }
                 }
     
              if ( $firstloop == 0 )
                 {
                 $firstloop = 1;
                 $IntDescr =~ s/\0//isog;
                 $out = $IntDescr . ":" . $InterfaceStat{$oper};
                 $perfout = "'" . $IntDescr . "_in_octet'=" . $in_octet . "c '" . $IntDescr . "_out_octet'=" . $out_octet . "c";
                 }
              else
                 {
                 $IntDescr =~ s/\0//isog;
                 $out .= " " . $IntDescr . ":" . $InterfaceStat{$oper};
                 $perfout .= "  '" . $IntDescr . "_in_octet'=" . $in_octet . "c '" . $IntDescr . "_out_octet'=" . $out_octet . "c";
                 }
              }
     
       if ( $IsDown == 1 )
          {
          print "Critical! $out";
          print " | $perfout";
          exit 2;
          }
       else
          {
          print "OK. $out";
          print " | $perfout";
          exit 0;
          }
     
       }
     
     
    if ( $os eq "Linux" )
       {
     
       # Because ucd list only eth (or so) without a number (like eth0) we
       # have to determine wether it is ucd (2021) or net-snmp (8072) so we can
       # set up a counter to generate this information
     
       $oid2get = ".1.3.6.1.2.1.1.2.0";
       $sysObject = $session->get_request( -varbindlist => ["$oid2get"] );
       $sysObjectID = $$sysObject{$oid2get};
       $sysObjectID =~ s/^\.1\.3\.6\.1\.4\.1\.//;
       $sysObjectID =~ s/\..*$//;
     
       foreach $key ( keys %$oid2descr)
              {
     
              # Monitoring traffic on a loopback interface doesn't make sense
              if ($key =~ m/^.*\.1$/)
                 {
                 delete $$oid2descr{$key};
                 }
              else
                 {
                 # This is a little bit tricky. If we have deleted the loopback interface
                 # during this run of the loop $key is not set. Therefore the if-statement
                 # will cause an error because $key is not initialized. So we first have to check
                 # it is :-))
     
                 # Kick out any sit interface
                 if ($$oid2descr{$key} =~ m/sit.*$/isog)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
              }
     
       # 0 = No alarm
       # 1 = Alarm if an interface is down
       # $IntDownAlert;                           # Alarm if interface is down. Default is no alarm
       # $IsDown = 0;                             # Used in loop. Switched to 1 if a interface is down
     
       foreach $key ( keys %$oid2descr)
              {
              $IntIdx = $key;
              $IntIdx =~ s/^.*\.//;
     
              if ( $sysObjectID == 2021 )
                 {
                 $$oid2descr{$key} = $$oid2descr{$key}.$ucdintcnt;
                 $ucdintcnt++;
                 }
              # Get the incoming octets
              $oid2get = $in_octet_oid.".".$IntIdx;
              $in_octet = $$oid2in_octet{$oid2get};
     
              # Get the outgoing octets
              $oid2get = $out_octet_oid.".".$IntIdx;
              $out_octet = $$oid2out_octet{$oid2get};
     
              # Get the operational status of the interface
              # Enumerations:
              # 1 - up
              # 2 - down
              # 3 - testing
              # 4 - unknown
              # 5 - dormant
              # 6 - notPresent
              # 7 - lowerLayerDown
     
              $oid2get = $oper_oid.".".$IntIdx;
              $oper = $$oid2oper{$oid2get};
              $IntDescr = $$oid2descr{$key};
     
              if ( $IntDownAlert == 1 )
                 {
                 if ( $oper != 1 )
                    {
                    $IsDown = 1;
                    }
                 }
     
              if ( $firstloop == 0 )
                 {
                 $firstloop = 1;
                 $IntDescr =~ s/\0//isog;
                 $out = $IntDescr . ":" . $InterfaceStat{$oper};
                 $perfout = "'" . $IntDescr . "_in_octet'=" . $in_octet . "c '" . $IntDescr . "_out_octet'=" . $out_octet . "c";
                 }
              else
                 {
                 $IntDescr =~ s/\0//isog;
                 $out .= " " . $IntDescr . ":" . $InterfaceStat{$oper};
                 $perfout .= "  '" . $IntDescr . "_in_octet'=" . $in_octet . "c '" . $IntDescr . "_out_octet'=" . $out_octet . "c";
                 }
              }
     
       if ( $IsDown == 1 )
          {
          print "Critical! $out";
          print " | $perfout";
          exit 2;
          }
       else
          {
          print "OK. $out";
          print " | $perfout";
          exit 0;
          }
     
       }
     
     
    if ( $os eq "SunOS" )
       {
       foreach $key ( keys %$oid2descr)
              {
              # Monitoring traffic on a loopback interface doesn't make sense
              if ($key =~ m/^.*\.1$/)
                 {
                 delete $$oid2descr{$key};
                 }
              }
     
       foreach $key ( keys %$oid2descr)
              {
              $IntIdx = $key;
              $IntIdx =~ s/^.*\.//;
     
              # Get the incoming octets
              $oid2get = $in_octet_oid.".".$IntIdx;
              $in_octet = $$oid2in_octet{$oid2get};
     
              # Get the outgoing octets
              $oid2get = $out_octet_oid.".".$IntIdx;
              $out_octet = $$oid2out_octet{$oid2get};
     
              # Get the operational status of the interface
              # Enumerations:
              # 1 - up
              # 2 - down
              # 3 - testing
              # 4 - unknown
              # 5 - dormant
              # 6 - notPresent
              # 7 - lowerLayerDown
     
              $oid2get = $oper_oid.".".$IntIdx;
              $oper = $$oid2oper{$oid2get};
              $IntDescr = $$oid2descr{$key};
     
              if ( $IntDownAlert == 1 )
                 {
                 if ( $oper != 1 )
                    {
                    $IsDown = 1;
                    }
                 }
     
              if ( $firstloop == 0 )
                 {
                 $firstloop = 1;
                 $IntDescr =~ s/\0//isog;
                 $out = $IntDescr . ":" . $InterfaceStat{$oper};
                 $perfout = "'" . $IntDescr . "_in_octet'=" . $in_octet . "c '" . $IntDescr . "_out_octet'=" . $out_octet . "c";
                 }
              else
                 {
                 $IntDescr =~ s/\0//isog;
                 $out .= " " . $IntDescr . ":" . $InterfaceStat{$oper};
                 $perfout .= "  '" . $IntDescr . "_in_octet'=" . $in_octet . "c '" . $IntDescr . "_out_octet'=" . $out_octet . "c";
                 }
              }
     
       if ( $IsDown == 1 )
          {
          print "Critical! $out";
          print " | $perfout";
          exit 2;
          }
       else
          {
          print "OK. $out";
          print " | $perfout";
          exit 0;
          }
     
       }
     
     
    if ( $os eq "Windows" )
       {
       foreach $key ( keys %$oid2descr)
              {
              # Monitoring traffic on a loopback interface doesn't make sense
              if ($key =~ m/^.*\.1$/)
                 {
                 delete $$oid2descr{$key};
                 }
     
              if ($$oid2descr{$key})
                 {
                 if ($$oid2descr{$key} =~ m/^WAN.*$/)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
     
              if ($$oid2descr{$key})
                 {
                 if ($$oid2descr{$key} =~ m/^RAS.*$/)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
     
              if ($$oid2descr{$key})
                 {
                 if ($$oid2descr{$key} =~ m/^.*LightWeight Filter.*$/)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
     
              if ($$oid2descr{$key})
                 {
                 if ($$oid2descr{$key} =~ m/^.*QoS Packet Scheduler.*$/)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
     
              if ($$oid2descr{$key})
                 {
                 if ($$oid2descr{$key} =~ m/^Microsoft ISATAP Adapter.*$/)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
     
              if ($$oid2descr{$key})
                 {
                 if ($$oid2descr{$key} =~ m/^Microsoft Network Adapter.*$/)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
     
              if ($$oid2descr{$key})
                 {
                 if ($$oid2descr{$key} =~ m/^Microsoft Debug Adapter.*$/)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
     
     
              if ($$oid2descr{$key})
                 {
                 if ($$oid2descr{$key} =~ m/^Microsoft Kernel Debug.*$/)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
     
              if ($$oid2descr{$key})
                 {
                 if ($$oid2descr{$key} =~ m/^.*Pseudo-Interface.*$/)
                    {
                    delete $$oid2descr{$key};
                    }
                 }
              }
     
       foreach $key ( keys %$oid2descr)
              {
              $IntIdx = $key;
              $IntIdx =~ s/^.*\.//;
     
              # Get the incoming octets
              $oid2get = $in_octet_oid.".".$IntIdx;
              $in_octet = $$oid2in_octet{$oid2get};
     
              # Get the outgoing octets
              $oid2get = $out_octet_oid.".".$IntIdx;
              $out_octet = $$oid2out_octet{$oid2get};
     
              # Get the operational status of the interface
              # Enumerations:
              # 1 - up
              # 2 - down
              # 3 - testing
              # 4 - unknown
              # 5 - dormant
              # 6 - notPresent
              # 7 - lowerLayerDown
     
              $oid2get = $oper_oid.".".$IntIdx;
              $oper = $$oid2oper{$oid2get};
              $IntDescr = $$oid2descr{$key};
     
              if ( $IntDownAlert == 1 )
                 {
                 if ( $oper != 1 )
                    {
                    $IsDown = 1;
                    }
                 }
     
              if ( $firstloop == 0 )
                 {
                 $firstloop = 1;
                 $IntDescr =~ s/\0//isog;
                 $out = $IntDescr . ":" . $InterfaceStat{$oper};
                 $perfout = "'" . $IntDescr . "_in_octet'=" . $in_octet . "c '" . $IntDescr . "_out_octet'=" . $out_octet . "c";
                 }
              else
                 {
                 $IntDescr =~ s/\0//isog;
                 $out .= " " . $IntDescr . ":" . $InterfaceStat{$oper};
                 $perfout .= "  '" . $IntDescr . "_in_octet'=" . $in_octet . "c '" . $IntDescr . "_out_octet'=" . $out_octet . "c";
                 }
              }
     
       if ( $IsDown == 1 )
          {
          print "Critical! $out";
          print " | $perfout";
          exit 2;
          }
       else
          {
          print "OK. $out";
          print " | $perfout";
          exit 0;
          }
     
       }
     
    # Not kicked out yet? So it seems to unknown
    exit 3;
     
    # --------------- Begin subroutines ----------------------------------------
     
    sub print_usage
        {
        print "\nUsage: $ProgName -H <host> [-C community] [-d]\n\n";
        print "or\n";
        print "\nUsage: $ProgName -h for help.\n\n";
        }
     
    sub print_help
        {
        print "$ProgName,Version 1.0\n";
        print "Copyright (c) 2011 Martin Fuerstenau - Oce Printing Systems\n";
        print_usage();
        print "    -H, --hostname=HOST            Name or IP address of host to check\n";
        print "    -C, --community=community      SNMP community (default public)\n\n";
        print "    -v, --snmpversion=snmpversion  Version of the SNMP protocol. At present version 1 or 2c\n\n";
        print "    -p, --portsnmpversion=snmpversion  Version of the SNMP protocol. At present version 1 or 2c\n\n";
        print "    -d, --down                     Alarm if any of the interfaces is down\n\n";
        print "    -h, --help Short help message\n\n";
        print "\n";
        }

  6. #6
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 820
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    Pour ton information si cela peut t'aider : http://djibril.developpez.com/tutori...services/#LV-K

  7. #7
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 16
    Points : 5
    Points
    5
    Par défaut
    Citation Envoyé par djibril Voir le message
    Pour ton information si cela peut t'aider : http://djibril.developpez.com/tutori...services/#LV-K
    Merci Djibril, je vais regarder ça de plus près aujour'hui.

    Thanks.

    A

  8. #8
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 16
    Points : 5
    Points
    5
    Par défaut
    J'ai contacté le programmeur qui m'a aimablement répondu dans la foulée.
    Il m'a expliqué combien un tel mécanisme était difficile à mettre en place.

    Toutefois, il a aussi ajouté ceci:
    An easier way to have an alarm is to set up a ICMP check with approriate settings for latency and packet loss because a network interface with too much traffic won't answer to it or have a higher latency or will dro packets
    En gros, dès que le traffic commence à augmenter sur l'interface, les pings commencent à ne plus répondre correctement donc = packets loss.

    Un check_icmp ou check_ping peut etre mis en place avec les switch -w / -c ... disant que au bout de tant de pings sans réponse, il envoit un warning ou un critical.

    Merci pour vos éventuels commentaire sur cette option.

  9. #9
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 820
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    Citation Envoyé par Anthony_D Voir le message
    J'ai contacté le programmeur qui m'a aimablement répondu dans la foulée.
    Il m'a expliqué combien un tel mécanisme était difficile à mettre en place.
    Et toi qui écrivait ceci :
    J'ai jeté un oeil à ce script et je pense que pour un developpeur averti, c'est l'histoire d'une dizaine de lignes pas plus.


  10. #10
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 16
    Points : 5
    Points
    5
    Par défaut
    bah... oui je me suis gourré

  11. #11
    Rédacteur/Modérateur

    Avatar de Lolo78
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2012
    Messages
    3 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mai 2012
    Messages : 3 612
    Points : 12 469
    Points
    12 469
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par Anthony_D Voir le message
    Ma question : y'aurait il une âme charitable sur ce forum qui se sentirait de taille pour completer le developpement de ce plugin ?
    Ceci est un forum d'entraide, par un service gratuit d'écriture de code.

    Si tu essaies de le faire toi même et rencontre des difficultés, on t'aidera. Si tu ne veux pas essayer, alors embauche les services d'un développeur.

  12. #12
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 16
    Points : 5
    Points
    5
    Par défaut
    Les Mib de ma VM netscaler renvoient la valeur 0 aussi bien en IfInOctets qu'en IfOutOctets ...lol, ceci explique peut-etre cela.
    Par ailleurs, le plug in "check_snmp_int.pl" fonctionne à merveille sur le switch cisco de mon agence, ainsi que sur une VM windows 7 de test ... il est donc logique qu'il affiche une bande passante de 0 si les MIB de la netscaler affichent 0.
    Voilà, encore un mystère à élucider, mais ce n'est certainement pas du coté du PERL qu'il faut chercher.

  13. #13
    Modérateur
    Avatar de ggnore
    Profil pro
    Inscrit en
    Juillet 2004
    Messages
    2 472
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France

    Informations forums :
    Inscription : Juillet 2004
    Messages : 2 472
    Points : 4 029
    Points
    4 029
    Par défaut
    Tu recevrais 56984004648 tu serais pas mieux. Il faut que tu sois capable de comparer 2 valeurs successives sachant que le temps entre 2 sondages a son importance. Il faut stocker la donnée pour faire le différentiel avec la précédente ou la suivante divisé par le nombre de secondes entre 2 sondages.
    Toutes les vertus des hommes se perdent dans l’intérêt comme les fleuves se perdent dans la mer.
    N'oubliez pas de consulter les FAQ Linux et les cours et tutoriels Linux

  14. #14
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 16
    Points : 5
    Points
    5
    Par défaut
    Oui le fameux switch "-d" pour Delta. C'est vrai je ne serais pas plus avancé, mais bon, admets qu'une interface réseau te renvoit 0 alors que tu sais pertinament qu'il y a plusieurs dizaines d'utilisateurs qui bossent, c'est quand meme très suspect ^^

  15. #15
    Modérateur
    Avatar de ggnore
    Profil pro
    Inscrit en
    Juillet 2004
    Messages
    2 472
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France

    Informations forums :
    Inscription : Juillet 2004
    Messages : 2 472
    Points : 4 029
    Points
    4 029
    Par défaut
    Tu as raison, ça ne peut pas marche. ça veut dire que ton OID est incorrecte : tu ne cibles pas la bonne interface.
    Toutes les vertus des hommes se perdent dans l’intérêt comme les fleuves se perdent dans la mer.
    N'oubliez pas de consulter les FAQ Linux et les cours et tutoriels Linux

  16. #16
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 16
    Points : 5
    Points
    5
    Par défaut
    Citation Envoyé par ggnore Voir le message
    Tu as raison, ça ne peut pas marche. ça veut dire que ton OID est incorrecte : tu ne cibles pas la bonne interface.
    C'est précisémment là où je ne sais pas, et je bloque.
    Que veux tu faire de plus lorsque snmpwalk te renvoit ceci:

    IF-MIB::ifInOctets.1 = Counter32: 0
    IF-MIB::ifOutOctets.1 = Counter32: 0


    Les données fournies par le systeme (netscaler) sont fausses à la base, donc tu aurras beau interroger tes mibs, elles te donneront 0.

    J'ai ouvert un Case auprès de Citrix pour y voir plus clair dans cette affaire, ce n'est pas normal qu'il renvoit 0. J'ai fait la meme manip snmpwalk sur un switch Cisco et regarde :

    IF-MIB::ifInOctets.1 = Counter32: 1361409154
    IF-MIB::ifOutOctets.1 = Counter32: 2388013353

    Tu vois la différence ? c'est qu'il y a bien un "truc"
    j'ai deja perdu pas mal de temps là-dessus, Citrix me doit une réponse.

Discussions similaires

  1. Programme d'amélioration Plugin
    Par bamby44 dans le forum Eclipse Platform
    Réponses: 3
    Dernier message: 15/07/2009, 15h21
  2. Problème Plugin nagios codé en Perl
    Par KraD_74 dans le forum Programmation et administration système
    Réponses: 4
    Dernier message: 03/06/2009, 15h47
  3. [Perforce] Amélioration du plugin pour Eclipse
    Par Yogui dans le forum SCM
    Réponses: 4
    Dernier message: 15/04/2009, 17h34
  4. nagios plugins perl
    Par bibouman dans le forum Programmation et administration système
    Réponses: 2
    Dernier message: 11/04/2007, 12h49
  5. [langage] EPIC Plugin eclipse pour perl
    Par JefDeBourges dans le forum Langage
    Réponses: 2
    Dernier message: 21/12/2004, 18h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo