Hi,
I do have the same setup in a part of my Network, my setup is a master ->
satellite -> client, all with icinga2. In some cases, satellite is not able to
reach the client, so the only way to do a hostalive check is with the 'icinga2
node list' command where you can check the last seen timestamp. formorer posted
a simple perl script in irc a few months ago.
#!/usr/bin/perl
use JSON;
use Data::Dumper;
use File::Slurp;
use Time::HiRes;
use POSIX;
use v5.10;
use Nagios::Plugin;
use strict;
my $np = Nagios::Plugin->new (
usage => "Usage: %s [ -v|--verbose ] [-H <host>] [-t <timeout>] "
. "[ -c|--critical=<threshold> ] [ -w|--warning=<threshold> ]",
);
$np->add_arg(
spec => 'host|H=s',
help => q(nodename),
required => 1,
);
$np->add_arg(
spec => 'critical|c=i',
help => q(Exit with CRITICAL status if node wasn't seen for INTEGER
seconds),
required => 0,
default => 120,
);
$np->add_arg(
spec => 'warning|w=i',
help => q(Exit with WARNING status if node wasn't seen for INTEGER
seconds),
required => 0,
default => 60,
);
$np->getopts;
my $host = $np->opts->host;
open (my $fh, '-|', 'icinga2 node list --batch');
my $text = read_file( $fh );
my $data = decode_json($text);
if (defined($data->{$host})) {
my $diff = time() - ceil($data->{$host}->{seen});
$np->nagios_exit(
return_code => $np->check_threshold($diff),
message => " host $host was last seen $diff seconds ago."
);
} else {
$np->nagios_exit(3, "Host $host not found");
}
Maybe you can use that too.
Regards
Reto
-----Ursprüngliche Nachricht-----
Von: icinga-users [mailto:[email protected]] Im Auftrag von
Per-Henrik Lundblom
Gesendet: Dienstag, 1. Dezember 2015 10:40
An: [email protected]
Betreff: Re: [icinga-users] Using cluster-zone check for host state
* Markus Joosten <[email protected]<mailto:[email protected]>>
[151130 17:48]:
> Checks are always executed from an endpoint in the respective zone the
> host and service objects are defined in.
Haden't realized this, thanks for the clarification.
> Therefore you would have to create additional host objects for your
> clients in your *master* zone. (This also applies to checks via ping,
> since you need to execute the checks from your master, and not from
> the client!)
>
> These additional hosts in your master zone could then use
> "cluster-zone" as their check-command.
I think I am still not getting it. There cannot be multiple declarations for
the same hosts. If I name the hosts in the master zone differently, I will end
up with two entries for each satellite/client in icinga2web.
I put the additional host objects for the clients in the master/ subdir in
zones.d while keeping the original host objects in each client zone subdir
(client[12]/).
Regards,
PH
--
Per-Henrik Lundblom email: [email protected]<mailto:[email protected]>
phone: +46 707 647050 webpage: www.whatever.nu<http://www.whatever.nu>
_______________________________________________
icinga-users mailing list
[email protected]<mailto:[email protected]>
https://lists.icinga.org/mailman/listinfo/icinga-users
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users