Add very basic script for PMG monitoring

tags/zabbix-agent-addons-0.2.52-0.beta1
Daniel Berteaud 6 years ago
parent 10498eee04
commit a806da0b58
  1. 9
      zabbix_conf/pmg.conf
  2. 31
      zabbix_scripts/check_pmg_sudo
  3. 35
      zabbix_scripts/disco_pmg_sudo

@ -0,0 +1,9 @@
# Discover PMG items
# $1 can be domains
UserParameter=pmg.discovery[*],/usr/bin/sudo /var/lib/zabbix/bin/disco_pmg_sudo --what $1
# Type: Agent or Agent (active)
# pmg.check.all[type,id]
# Where type is what to monitor (domain)
# id is the id of the item to monitor. Eg, the domain name
UserParameter=pmg.check.all[*],/usr/bin/sudo /var/lib/zabbix/bin/check_pmg_sudo --$1 $2

@ -0,0 +1,31 @@
#!/usr/bin/perl -w
use strict;
use warnings;
use JSON;
use Getopt::Long;
use File::Which;
use Data::Dumper;
my $pmgsh = which('pmgsh');
my $json = {};
my $pretty = 0;
my ($domain) = undef;
GetOptions(
'domain=s' => \$domain,
'pretty' => \$pretty
);
if ($domain){
my $stats = from_json(qx($pmgsh get /statistics/domains 2>/dev/null));
foreach my $dom (@{$stats}){
next unless ($dom->{domain} eq $domain);
$json->{$_} = $dom->{$_} foreach (qw/bytes_in bytes_out count_in count_out spamcount_in spamcount_out viruscount_in viruscount_out/);
}
} else{
print 'ZBX_UNSUPORTED';
exit 0;
}
print to_json($json, { pretty => $pretty }) . "\n";

@ -0,0 +1,35 @@
#!/usr/bin/perl -w
use strict;
use warnings;
use JSON;
use Getopt::Long;
use File::Which;
my $what = 'nodes';
my $pretty = 0;
GetOptions(
'what=s' => \$what,
'pretty' => \$pretty
);
my $pmgsh = which('pmgsh');
my $json = {};
@{$json->{data}} = ();
unless($pmgsh){
print to_json($json) . "\n";
exit 0;
}
if ($what eq 'domains'){
my $domains = from_json(qx($pmgsh get /config/domains 2>/dev/null));
foreach my $item (@{$domains}){
push @{$json->{data}}, {
'{#PMG_RELAY_DOMAIN}' => $item->{domain},
};
}
}
print to_json($json, { pretty => $pretty }) . "\n";
Loading…
Cancel
Save