Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: define Business Rules - if 2 of 3 IP down then warning, if 3/3 down critical

  1. #1
    Junior Member
    Join Date
    May 2015
    Posts
    21

    Resolved -define Business Rules, if 2 of 3 IP down then warning, if 3/3 down critical

    Hello,

    this is my second post cause i'm running out of time ...

    I have 2 DMVPN connections & one mpls
    ip 192.168.30.31 vpn 1
    ip 192.168.30.32 vpn 2
    ip 192.168.30.33 mpls

    How should i do for
    if 3 of 3 ip are Down send mail Critical alert (LAN cutted out)
    if 1 or 2 of 3 ip are down send mail Warning alert

    i saw bp_rule!(h1,dmvpn1 & h2,dmvpn2) & h3,mpls but i'm missing something, i don't realy understand how does it works....



    In your doc for "Consolidated services" you talk about 2 hosts wew, 1 host meta ? ans a service Web cluster ...
    I don't understand the dependancis of those four ... OK 2 hosts web, then a service who will create the agregate check_command bp_rule!g:web,g:HTTPS? but why host meta ?

    define host {
    use http
    host_name web-01
    hostgroups web
    ...
    }

    define host {
    use http
    host_name web-02
    hostgroups web
    ...
    }

    define host {
    host_name meta
    ...
    }

    define service {
    host_name meta
    service_description Web cluster
    check_command bp_rule!g:web,g:HTTPS?
    business_rule_service_notification_options n
    ...
    }

    Thank's a lot
    Last edited by tome; 07-07-2015 at 09:52 PM. Reason: Resolved

  2. #2
    Junior Member
    Join Date
    May 2015
    Posts
    21
    Would this work ?

    the hosts DMVPN1 , DMVPN2 and MPLS are declared as a normal hosts. (whats the role of "host_name servicedelivery" here ?

    define service{
    use standard-service
    host_name servicedelivery
    service_description DMVPN
    check_command bp_rule!(h1,DMVPN1 | h2,DMVPN2) & h3,MPLS
    }

  3. #3
    Junior Member
    Join Date
    May 2015
    Posts
    21
    Anybody ? im getting crasy ...

  4. #4
    Junior Member
    Join Date
    May 2012
    Posts
    25
    Hello,

    the role of "host_name servicedelivery" is to create a virtual host which has DMVPN business service attached.

    I don't see how you can achieve what you want to do because you don't have any warning alerts.

  5. #5
    Junior Member
    Join Date
    May 2015
    Posts
    21
    Hi,

    Thanks for your reply so much, i needed one.
    Maybe I'm not expressing my self correctly...

    to do simple
    In some agency i'have 1 VPN and 1 MPLS (LAN > Main Switch > VPN or MPLS)

    1. How should i do to get un alerte
    - Warning notification only if one of those two (VPN & MPLS) goes down
    - Critical notification if both goes down.
    - Nothing or OK for both up

    - I'm thinking to create a virtual host who will manage this (i don't know if it s possible) and naturaly that virtual host will be parent of the main Switch.
    - if no virtual host can manage this in what other way i can check those two IP (ping only will be great) and get some summary result as described above ?

    found something here but can't manage to get what i want
    http://shinken.readthedocs.org/en/la...egraded-status

    I'm reading the doc but as i m running out of time ...

    thank you for any help

    PS: check-host-alive or check_ping can't be "DMVPN business service" ?

  6. #6
    Junior Member
    Join Date
    May 2015
    Posts
    21
    can this work ?

    define service{
    use standard-service ##what's this
    host_name servicedelivery ### this host must exist before as a define_host or this define service will create it ?
    service_description ERP ### Agregate_connection in my case
    #check_command bp_rule!(h1,database1 | h2,database2) & (h3,Http1 | h4,Http4) & (h5,IPVS1 | h6,IPVS2)
    check_commande bp_rule!(h1,check_ping192.168.0.1 | h2,check_ping192.168.0.2) this doesn't work
    }

    where i'm missing something ?

    thanks a lot

  7. #7
    Junior Member
    Join Date
    May 2012
    Posts
    25
    bp_rule is not the right method, you need check_cluster to do that.

    http://blog.botha.us/sarel/using-nag...-for-services/

    If you want to return a specific state (here Warning) your checks have to return that state but it's not what you have.

    Hope it helps.

  8. #8
    Junior Member
    Join Date
    May 2015
    Posts
    21
    OK thank you, i look forward to this solution and give feedback in few days.

  9. #9
    Junior Member
    Join Date
    May 2015
    Posts
    21
    Hello,

    I tried whole day... got something, doesn't do what i wnat to, but getting close.

    check_service_cluster commande doesn't existe in shinken... i should create a commande & i'm not quite familiar with linux...
    I have until next friday to finish it, i'll try more and also wait for some solution here.
    Hope sombedy will respond, i'm not the first who's tring to do this.

    thank you for your help, it putted me on the right track ! But this needs some more linux-scripting knowledge that what i have.

    shinken is a great tool, don't wanna passe by...

    nice evening all of u

  10. #10
    Junior Member
    Join Date
    Jun 2015
    Posts
    15

    Smile

    Hi Tome,

    I've write a little Perl script that should do what you want.
    Just copy and past the following in a file name check_cluster.pl for exemple and make it executable:
    Code:
    #!/usr/bin/perl
    ############################
    # Description:
    # ------------
    # This script check multyple IPs and give a Warnning or Critical message if more than the threshold number of IPs are down.
    ############################
    
    ############################
    # Revision History:
    # -----------------
    # 26/06/2015 => Gael Langlais   : Creation
    ############################
    
    
    ########################################################
    #                    SYSTEM REQUIRMENT                 #
    # Copy and past the following if you have some trouble #
    # cpan Net::Ping::External Switch Net::Ping            #
    ########################################################
    
    
    use strict;
    use warnings;
    
    use Switch;
    use Getopt::Std;
    use Net::Ping::External qw(ping);
    
    
    
    # Get command line arguments
    # -H "ARRAY of IP"  : ex: -H "192.168.1.1, 192.168.1.2"
    # -w WARNING        : ex: -w 1
    # -c CRITICAL       : ex: -c 2
    getopts("H:l:L:w:c:");
    our ($opt_H,$opt_w,$opt_c,$opt_L);
    
    
    
    # In normal state this should be set to 0
    # 0 = Debug Off, 1 = Debug Level 1
    my $debug       = 0;
    my @host_array  = "";
    my $fail_count  = 0;
    my $warning     = 1; # set warning default value
    my $critical    = 2; # set critical default value
    my $label       = "$0";
    my @host_down   = "";
    
    my $help ="Syntax: $0 -H [list of IPs to check] -w [VALUE]-c [VALUE]
    
    Options:
        -H \"ARRAY of IP\"      : ex: -H \"192.168.1.1, 192.168.1.2\"
        -L \"LABEL\"            : ex: -L \"VPN Cluster\"
        -w WARNING              : ex: -w 1
        -c CRITICAL             : ex: -c 2
    
    Example:
        $0 -H \"192.168.1.1, 192.168.1.2\" -L \"VPN Cluster\" -w 1 -c 2
     Will return:
        VPN Cluster OK - 2/2 hosts are up | host=2
    ";
    
            ############
            ##  MAIN  ##
            ############
    
            
    die "ERROR: Nothing to check. (option \"-H\")\n\n"                  .$help if ( ! defined $opt_H );
    # Uncomment the line below to make warning and critical threshold mandatory
    #die "ERROR: No threshold specify. (options \"-w and -c\")\n\n"     .$help if ( ! defined $opt_w or ! defined $opt_c );
    die "ERROR: Critical value lower or equal to Warning value. (check your options -w and -c)\n\n" .$help if ( $opt_w >= $opt_c );
    
    $warning    = $opt_w if defined $opt_w;
    $critical   = $opt_c if defined $opt_c;
    $label      = $opt_L if defined $opt_L;
    
    #print "* Using ICMP ping.\n" if ( $debug >= 1 );
    #$p = Net::Ping->new("icmp");
    #print "* Option \"-l\" = $local_add\n" if ( $debug >= 1 );
    #$p->bind($local_add); # We will use this interface for the ping
    
    print "* Hosts to check = $opt_H.\n" if ( $debug >= 1 );
    # Grab the list of hosts and put them in an array
    @host_array     = split /, ?/, $opt_H if defined $opt_H;
    
    
    
    $fail_count = &check_hosts();
    print &return_status();
    
    
    
    
    
    
    
    
    
    
    
    #######
    # SUB #
    #######
    
    sub check_hosts
    {
        my $fail_increment = 0;
        my $host;
        foreach $host (@host_array)
        {
            print "Checking host: $host | \$fail_count before: $fail_count => \$fail_count after: " if ( $debug >= 1 );
            if ( ! ping(hostname => $host, timeout => 5) )
            {
                $fail_increment++;
                push @host_down, "$host";
            }
            print "$fail_count after:\n" if ( $debug >= 1 );
            
        }
        return $fail_increment;
    }
    
    
    sub return_status
    {
        my $host_total      = @host_array;
        my $host_ok         = ($host_total - $fail_count);
        my $show_host_down  = "";
        if ($#host_down > 0)
        {
            $show_host_down = join(', ',@host_down);
            $show_host_down =~ s/^..(.*)$/$1/;
            if ($#host_down == 1)
            {
                $show_host_down = "Host down is: ".$show_host_down;
            }else
            {
                $show_host_down = "Hosts down are: ".$show_host_down;
            }
        }
        
        print "* Evaluatings \$fail_count: $fail_count\n" if ( $debug >= 1 );
        if ( $fail_count < $warning)
        {
            return "$label OK - $host_ok/$host_total host are up. $show_host_down| host_up=$host_ok\n";
        }elsif ( $fail_count < $critical)
        {
            return "$label WARNING - $host_ok/$host_total host are up. $show_host_down| host_up=$host_ok\n";
        }elsif ( $fail_count >= $critical)
        {
            return "$label CRITICAL - $host_ok/$host_total host are up. $show_host_down| host_up=$host_ok\n";
        }else{
            return "$label UNKNOW - $host_ok/$host_total host are up. $show_host_down| host_up=$host_ok\n";
        }
    }

    Then just run the script:
    Code:
    $ ./check_cluster.pl -H "192.168.1.2,192.168.1.3,192.168.1.4"  -L "VPN Cluster" -w 1 -c 2
    When Ok it will give you this:
    VPN Cluster OK - 3/3 host are up. | host_up=3

    When Warning it will give you this:
    VPN Cluster WARNING - 2/3 host are up. Host down is: 192.168.100.2| host_up=2

    And Critical:
    VPN Cluster CRITICAL - 0/3 host are up. Hosts down are: 192.168.1.2,192.168.1.3,192.168.1.4| host_up=0

    Please tell me if you find this script usefull. If so I'll publish it on Nagios Exchange

    Best regards,
    Last edited by langlais115; 06-29-2015 at 05:08 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •