Announcement

Collapse
No announcement yet.

Ajout RRD à un plug in : un peu d'aide s'il vous plait

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ajout RRD à un plug in : un peu d'aide s'il vous plait

    Voila j'ai un plugin en shell script qui permet de trouver le nombre d'utilisateurs connectes sur une base WIFI cisco
    Je souhaitais savoir comment afficher cela sur un graphique pour oreon

    merci beaucoup de votre aide...(j'ai déjà lu RRD et leur utilisation mais je ne cerne pas vraiment la chose)

    Code:
    #Variable d'environnement pour exécuter un shellscript
    #!/bin/sh
    
    #Définition des variables
    nb_client=`(snmpwalk -c public -v 1 $1  mib-2.17.4.3.1.1 | grep -c =)`
    nb_client=`(expr $nb_client - 1)`
    
    #Test
    if [ "$nb_client" -lt 0 ]
    then
            nb_client=0;
    fi
    echo "Il y a $nb_client sur la base $1";
    exit 0;
    DEBIAN SARGE 3.1 + OREON 1.3.1 + NAGIOS 2.5

  • #2
    Un truc comme ca : :idea:

    check_graph_snmp -H blabla -o mib-2.17.4.3.1.1
    Intel(R) Xeon(TM) CPU 3.4GHz - MemTotal : 1034476 kB
    Centreon 2.4.1 - Nagios 3.2.1 - Nagios Plugins 1.4.15 - Manubulon Plugins tuné
    Fedora Core 5 - 2.6.20-1.2320

    Comment


    • #3
      non lol car la mib de la base wifi de contient pas la donnée précise du nb de connectés ..il faut calculer avant
      DEBIAN SARGE 3.1 + OREON 1.3.1 + NAGIOS 2.5

      Comment


      • #4
        ba edite le script check_graph_snmp et place ton oid au lieu d'en demander un.

        Et apres la requete ajoute ton calcul et c fini :wink:
        Intel(R) Xeon(TM) CPU 3.4GHz - MemTotal : 1034476 kB
        Centreon 2.4.1 - Nagios 3.2.1 - Nagios Plugins 1.4.15 - Manubulon Plugins tuné
        Fedora Core 5 - 2.6.20-1.2320

        Comment


        • #5
          y a pas D'OID unique lol..je dois faire la somme du nombre d'OID avec un client pour trouver le nb de clients connectés
          DEBIAN SARGE 3.1 + OREON 1.3.1 + NAGIOS 2.5

          Comment


          • #6
            Ah ba la faut faire ton propre plugin à partir d'un existant
            Si tu sais scripter shell, tu t'en sortiras en perl.
            Intel(R) Xeon(TM) CPU 3.4GHz - MemTotal : 1034476 kB
            Centreon 2.4.1 - Nagios 3.2.1 - Nagios Plugins 1.4.15 - Manubulon Plugins tuné
            Fedora Core 5 - 2.6.20-1.2320

            Comment


            • #7
              réponse

              si tu a une solution ca m interresse !
              en effet mois je fais un check sur le nombre de session ouverte sur windows et souhaite avoir un graph

              exemple ci-dessous
              check_snmp
              Check_command_arguments : !.1.3.6.1.4.1.77.1.2.19.0!4!public

              on m a parlé d un check snmp value qui doit faire des graph mais l echelle n est pas bonne !
              merci

              Si non il faut que quelqu un nous aide a mofifier le check suivant

              #! /usr/bin/perl -w
              #
              # $Id: check_graph_uptime.pl,v 1.3 2005/08/11 11:38:41 wistof Exp $
              #
              # This plugin is developped under GPL Licence:
              # http://www.fsf.org/licenses/gpl.txt

              # Developped by Linagora SA: http://www.linagora.com

              # The Software is provided to you AS IS and WITH ALL FAULTS.
              # LINAGORA makes no representation and gives no warranty whatsoever,
              # whether express or implied, and without limitation, with regard to the quality,
              # safety, contents, performance, merchantability, non-infringement or suitability for
              # any particular or intended purpose of the Software found on the LINAGORA web site.
              # In no event will LINAGORA be liable for any direct, indirect, punitive, special,
              # incidental or consequential damages however they may arise and even if LINAGORA has
              # been previously advised of the possibility of such damages.

              # based on "graph plugins" developped by Oreon Team. See http://www.oreon.org.
              ##
              ## Plugin init
              ##
              use strict;
              use Net::SNMP qw(nmp);
              use FindBin qw($Bin);
              use lib "$Bin";
              use oreon;
              use vars qw($VERSION %oreon);
              use vars qw(%oreon);
              BEGIN
              {
              %oreon=oreon::get_parameters;
              }

              use lib $oreon{NAGIOS_LIBEXEC} ;
              my $pathtorrdbase = $oreon{DIR_OREON}."rrd/";

              use utils qw($TIMEOUT %ERRORS &print_revision &support);
              use vars qw($PROGNAME);
              use Getopt::Long;
              use vars qw($opt_h $opt_V $opt_g $opt_D $opt_S $opt_H $opt_C $opt_v $opt_d $day);


              $PROGNAME = $0;
              sub print_help ();
              sub print_usage ();

              Getopt::Long::Configure('bundling');
              GetOptions
              ("h" => \$opt_h, "help" => \$opt_h,
              "V" => \$opt_V, "version" => \$opt_V,
              "g" => \$opt_g, "rrdgraph" => \$opt_g,
              "D=s" => \$opt_D, "directory=s" => \$opt_D,
              "v=s" => \$opt_v, "snmp=s" => \$opt_v,
              "C=s" => \$opt_C, "community=s" => \$opt_C,
              "S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
              "d" => \$opt_d, "day" => \$opt_d,
              "H=s" => \$opt_H, "hostname=s" => \$opt_H);

              if ($opt_V) {
              print_revision($PROGNAME,'$Revision: 1.3 $');
              exit $ERRORS{'OK'};
              }

              if ($opt_h) {
              print_help();
              exit $ERRORS{'OK'};
              }

              $opt_H = shift unless ($opt_H);
              (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);


              ($opt_v) || ($opt_v = shift) || ($opt_v = "1");
              my $snmp = $1 if ($opt_v =~ /(\d)/);

              ($opt_S) || ($opt_S = shift) || ($opt_S = 1);
              my $ServiceId;
              if ($opt_S =~ /([0-9]+)/){
              $ServiceId = $1;
              }
              else{
              print "Unknown -S Service ID expected... or it doesn't exist, try another id - number\n";
              exit $ERRORS{'UNKNOWN'};
              }

              ($opt_C) || ($opt_C = shift) || ($opt_C = "public");

              ($opt_D) || ($opt_D = shift) || ($opt_D = $pathtorrdbase);
              $pathtorrdbase = $1 if ($opt_D =~ /([-.\/\_\ A-Za-z0-9]+)/);

              use lib qw(/usr/local/rrdtool/lib/perl ../lib/perl);
              my $rrd = $pathtorrdbase.$ServiceId.".rrd";

              use RRDs;
              my $start=time;
              my $name = $0;
              $name =~ s/\.pl.*//g;
              my $ERROR = RRDs::error;
              my $day = 0;

              ##
              ## RRDTools create rrd
              ##
              if ($opt_g) {
              if (-e $rrd) {;}
              else
              {
              RRDs::create ($rrd, "--start",$start-1, "--step",300,
              "DS:a:GAUGE:600:U:U",
              "RRA:AVERAGE:0.5:1:8440",
              "RRA:MIN:0.5:12:8440",
              "RRA:MAX:0.5:12:8440",
              );
              $ERROR = RRDs::error;
              if ($ERROR) {
              print " unable to create `$rrd': $ERROR\n";
              exit $ERRORS{'UNKNOWN'};
              }
              }
              }

              ##
              ## Plugin snmp requests
              ##

              my $OID_OBJECTID =".1.3.6.1.2.1.1.1.0";
              my $OID_UPTIME_WINDOWS =".1.3.6.1.2.1.1.3.0";
              my $OID_UPTIME_OTHER =".1.3.6.1.2.1.25.1.1.0";

              # create a SNMP session
              my ( $session, $error ) = Net::SNMP->session(-hostname => $opt_H,-community => $opt_C, -version => $snmp);
              if ( !defined($session) ) {
              print("CRITICAL: $error");
              exit $ERRORS{'CRITICAL'};
              }

              my $result = $session->get_request(
              -varbindlist => [$OID_OBJECTID]
              );
              if (!defined($result)) {
              printf("UNKNOWN: %s.\n", $session->error);
              $session->close;
              exit $ERRORS{'UNKNOWN'};
              }

              my $return_result = $result->{$OID_OBJECTID};
              my $OID = "";
              if ($return_result =~ /.*Windows.*/i ) {
              $OID = $OID_UPTIME_WINDOWS;
              } else {
              $OID = $OID_UPTIME_OTHER;
              }

              $result = $session->get_request(

              -varbindlist => [$OID]
              );
              if (!defined($result)) {
              printf("UNKNOWN: %s.\n", $session->error);
              $session->close;
              exit $ERRORS{'UNKNOWN'};
              }

              my $un = 0;

              $return_result = $result->{$OID};
              if ( $return_result =~ m/(\d*) day[s]?,\s*(\d*)\d*)\d*).(\d*)/ ) {
              $un = $5 + $4 * 100 + $3 * 100 * 60 + $2 * 100 * 60 * 60 + $1 * 100 * 60 * 60 * 24;
              $day = $1;
              }

              if ( $return_result =~ m/(\d*) hour.*(\d*)\d*).(\d*)/ ) {
              $un = $4 + $3 * 100 + $3 * 100 * 60 + $1 * 100 * 60 * 60 ;
              }

              if ($opt_d) {
              $un = $day;
              }

              #print "un : $un\n";

              ##
              ## RRDtools update
              ##
              if ($opt_g) {
              $start=time;
              RRDs::update $rrd, "$start:".$un;
              $ERROR = RRDs::error;
              if ($ERROR) {
              print " unable to update `$rrd': $ERROR\n";
              exit $ERRORS{'UNKNOWN'};
              }
              }

              ##
              ## Plugin return code
              ##

              if ($un || ( $un == 0) ){
              if ($opt_d) {
              print "OK - Uptime (in day): $un\n";
              } else {
              print "OK - Uptime (in hundredths of a second): $un\n";
              }
              exit $ERRORS{'OK'};
              }
              else{
              print "CRITICAL Host unavailable\n";
              exit $ERRORS{'CRITICAL'};
              }


              sub print_usage () {
              print "\nUsage:\n";
              print "$PROGNAME\n";
              print " -H (--hostname) Hostname to query - (required)\n";
              print " -C (--community) SNMP read community (defaults to public,\n";
              print " used with SNMP v1 and v2c\n";
              print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
              print " 2 for SNMP v2c\n";
              print " -g (--rrdgraph) create a rrd base and add datas into this one\n";
              print " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
              print " by default: ".$pathtorrdbase."\n";
              print " (The path is valid with spaces '/my\ path/...')\n";
              print " -S (--ServiceId) Oreon Service Id\n";
              print " -d (--day) Uptime in day\n";
              print " -V (--version) Plugin version\n";
              print " -h (--help) usage help\n";

              }

              sub print_help () {
              print "Copyright (c) 2005 Linagora\n";
              print "Bugs to http://www.linagora.com/\n";
              print "\n";
              print_usage();
              print "\n";
              }

              Comment

              Working...
              X