Compare commits

...

2 Commits

Author SHA1 Message Date
Daniel Berteaud 6dc46b819f Automatic commit of package [zabbix-agent-addons] release [0.2.151-1]. 3 years ago
Daniel Berteaud 74b3ba5928 Add Elasticsearch monitoring scripts 3 years ago
  1. 2
      .tito/packages/zabbix-agent-addons
  2. 6
      zabbix-agent-addons.spec
  3. 2
      zabbix_conf/elasticsearch.conf
  4. 86
      zabbix_scripts/check_elasticsearch
  5. 91
      zabbix_scripts/disco_elasticsearch

@ -1 +1 @@
0.2.150-1 ./
0.2.151-1 ./

@ -4,7 +4,7 @@
Summary: Scripts for Zabbix monitoring
Name: zabbix-agent-addons
Version: 0.2.150
Version: 0.2.151
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
@ -106,6 +106,10 @@ fi
%endif
%changelog
* Mon Oct 18 2021 Daniel Berteaud <daniel@firewall-services.com> 0.2.151-1
- Add Elasticsearch monitoring scripts (daniel@firewall-services.com)
- Updates and fixes in Zabbix templates (daniel@firewall-services.com)
* Fri Jul 16 2021 Daniel Berteaud <daniel@firewall-services.com> 0.2.150-1
- Do not count Unconfigured(good) drives as an error (daniel@firewall-
services.com)

@ -0,0 +1,2 @@
UserParameter=elasticsearch.discovery[*],/var/lib/zabbix/bin/disco_elasticsearch --url=$1 --user=$2 --pass=$3 --$4
UserParameter=elasticsearch.check[*],/var/lib/zabbix/bin/check_elasticsearch --url=$1 --user=$2 --pass=$3 --$4 $5

@ -0,0 +1,86 @@
#!/usr/bin/perl
use warnings;
use strict;
use JSON;
use Getopt::Long;
use LWP::UserAgent;
use HTTP::Request::Common;
use URI;
use Data::Dumper;
my $user = undef;
my $pass = undef;
my $url = 'http://localhost:9200';
my $certcheck = 1;
my $cluster = 0;
my $node = undef;
my $index = undef;
my $pretty = 0;
my $json = {};
GetOptions (
'user=s' => \$user,
'password|p=s' => \$pass,
'url=s' => \$url,
'cert-check!' => \$certcheck,
'cluster' => \$cluster,
'node=s' => \$node,
'index=s' => \$index,
'pretty' => \$pretty
);
# If no option is given, default to fetch the cluster status
if (not defined $cluster and not defined $node and not defined $index){
$cluster = 1;
}
my $uri = URI->new($url);
if (not defined $uri){
die "COuldn't parse $url as a valid url\n";
}
# If connecting over http or is host is localhost
# there's no need to check certificate
if ($uri->scheme eq 'http' or $uri->host =~ m/^localhost|127\.0\.0/){
$certcheck = 0;
}
my $resp;
my $sslopts = {};
if (not $certcheck){
$sslopts = {
verify_hostname => 0,
SSL_verify_mode => 0
}
}
my $ua = LWP::UserAgent->new(
ssl_opts => $sslopts
);
if ($cluster){
$json = make_request('/_cluster/stats');
} elsif (defined $node){
$json = make_request('/_nodes/' . $node);
} elsif (defined $index){
$json = make_request('/_cluster/health/' . $index . '?level=indices')->{'indices'}->{$index};
}
print to_json($json, { pretty => $pretty });
sub make_request {
my $path = shift;
my $req_url = $url . $path;
my $req = GET $req_url;
if (defined $user and defined $pass){
$req->authorization_basic($user, $pass);
}
my $resp = $ua->request($req);
die "Request to $req_url failed : " . $resp->message . "\n" if $resp->is_error;
return from_json($resp->decoded_content);
}

@ -0,0 +1,91 @@
#!/usr/bin/perl
use warnings;
use strict;
use JSON;
use Getopt::Long;
use LWP::UserAgent;
use HTTP::Request::Common;
use URI;
use Data::Dumper;
my $user = undef;
my $pass = undef;
my $url = 'http://localhost:9200';
my $certcheck = 1;
my $nodes = 0;
my $indices = 0;
my $pretty = 0;
my $json = [];
GetOptions (
'user=s' => \$user,
'password|p=s' => \$pass,
'url=s' => \$url,
'cert-check!' => \$certcheck,
'nodes' => \$nodes,
'indices' => \$indices,
'pretty' => \$pretty
);
if ($nodes and $indices){
die "--nodes and --indices are mutually exclusive\n";
}
my $uri = URI->new($url);
if (not defined $uri){
die "$url is not a valid URL\n";
}
# If connecting over http or is host is localhost
# there's no need to check certificate
if ($uri->scheme eq 'http' or $uri->host =~ m/^localhost|127\.0\.0/){
$certcheck = 0;
}
my $sslopts = {};
if (not $certcheck){
$sslopts = {
verify_hostname => 0,
SSL_verify_mode => 0
}
}
my $ua = LWP::UserAgent->new(
ssl_opts => $sslopts
);
if ($nodes){
foreach (@{make_request('/_cat/nodes?format=json')}){
push @{$json}, {
'{#ES_NODE_NAME}' => $_->{name},
'{#ES_NODE_ROLE}' => $_->{'node.role'}
};
}
} elsif ($indices){
foreach (@{make_request('/_cat/indices?format=json')}){
push @{$json}, {
'{#ES_INDICE_NAME}' => $_->{index},
'{#ES_INDICE_STATUS}' => $_->{status},
'{#ES_INDICE_UUID}' => $_->{uuid}
};
}
}
print to_json($json, { pretty => $pretty });
sub make_request {
my $path = shift;
my $req_url = $url . $path;
my $req = GET $req_url;
if (defined $user and defined $pass){
$req->authorization_basic($user, $pass);
}
my $resp = $ua->request($req);
die "Request to $req_url failed : " . $resp->message . "\n" if $resp->is_error;
return from_json($resp->decoded_content);
}
Loading…
Cancel
Save