parent
4dedf3dc30
commit
1c2c4e8377
|
@ -1,3 +1,7 @@
|
|||
UserParameter=samba_dc.discovery[*],sudo /var/lib/zabbix/bin/disco_samba_dc_sudo --what='$1'
|
||||
# Create a text item with key samba_dc.info[300] and a check interval of 300
|
||||
# Then use dependent item to get individual counters
|
||||
UserParameter=samba_dc.info[*],sudo /var/lib/zabbix/bin/check_samba_dc_sudo --since=$1
|
||||
UserParameter=samba_dc.info[*],sudo /var/lib/zabbix/bin/check_samba_dc_sudo --since='$1'
|
||||
# Create a text item with key samba_dc.ou[{#SAMBA_OU}], then use dependant items with JSONPath to get individual info
|
||||
UserParameter=samba_dc.ou[*],sudo /var/lib/zabbix/bin/check_samba_dc_sudo --ou='$1'
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ my $pdbedit = which('pdbedit');
|
|||
# Number of seconds in the past to count authentications
|
||||
my $since = 300;
|
||||
my $pretty = 0;
|
||||
my $general = 1;
|
||||
my $ou = undef;
|
||||
|
||||
# This log is expected to be in JSON format. For example, in smb.conf :
|
||||
# log level = 1 auth_audit:3 auth_json_audit:4@/var/log/samba/audit_auth.log
|
||||
my $audit_auth_log = '/var/log/samba/audit_auth.log';
|
||||
|
@ -25,14 +28,31 @@ if (not defined $samba_tool or not defined $pdbedit){
|
|||
GetOptions(
|
||||
'pretty' => \$pretty,
|
||||
'since=i' => \$since,
|
||||
'audit-auth-log=s' => \$audit_auth_log
|
||||
'audit-auth-log=s' => \$audit_auth_log,
|
||||
'general' => \$general,
|
||||
'ou=s' => \$ou
|
||||
);
|
||||
|
||||
if ($since !~ m/^\d+$/){
|
||||
die "Invalid value for since\n";
|
||||
}
|
||||
|
||||
my $json = {
|
||||
my $json = {};
|
||||
|
||||
if (defined $ou){
|
||||
$json = {
|
||||
objects => 0
|
||||
};
|
||||
if ($ou !~ m/^(?<RDN>(?<Key>(?:\\[0-9A-Fa-f]{2}|\\\[^=\,\\]|[^=\,\\]+)+)\=(?<Value>(?:\\[0-9A-Fa-f]{2}|\\\[^=\,\\]|[^=\,\\]+)+))(?:\s*\,\s*(?<RDN>(?<Key>(?:\\[0-9A-Fa-f]{2}|\\\[^=\,\\]|[^=\,\\]+)+)\=(?<Value>(?:\\[0-9A-Fa-f]{2}|\\\[^=\,\\]|[^=\,\\]+)+)))*$/){
|
||||
die "Invalid OU\n";
|
||||
}
|
||||
foreach (qx($samba_tool ou listobjects '$ou')){
|
||||
die "Error while counting objects of OU $ou\n" if ($? != 0);
|
||||
chomp;
|
||||
$json->{objects}++;
|
||||
}
|
||||
} elsif ($general){
|
||||
$json = {
|
||||
accounts => {
|
||||
users => 0,
|
||||
inactive_users => 0,
|
||||
|
@ -152,5 +172,6 @@ if (-e $audit_auth_log){
|
|||
}
|
||||
close $auth_log;
|
||||
}
|
||||
}
|
||||
|
||||
print to_json($json, { pretty => $pretty });
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use JSON;
|
||||
use Getopt::Long;
|
||||
use File::Which;
|
||||
|
||||
my $what = 'ou';
|
||||
my $pretty = 0;
|
||||
my $json = [];
|
||||
|
||||
my $samba_tool = which('samba-tool');
|
||||
|
||||
if (not defined $samba_tool){
|
||||
print $json;
|
||||
exit 0;
|
||||
}
|
||||
|
||||
GetOptions(
|
||||
'what=s' => \$what,
|
||||
'pretty' => \$pretty
|
||||
);
|
||||
|
||||
if ($what eq 'ou'){
|
||||
foreach (qx($samba_tool ou list)){
|
||||
chomp;
|
||||
push @{$json}, {
|
||||
'{#SAMBA_OU}' => $_
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print to_json($json, { pretty => $pretty });
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<zabbix_export>
|
||||
<version>5.0</version>
|
||||
<date>2021-01-11T08:38:19Z</date>
|
||||
<date>2021-01-11T15:08:31Z</date>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Templates</name>
|
||||
|
@ -644,6 +644,51 @@
|
|||
</triggers>
|
||||
</item>
|
||||
</items>
|
||||
<discovery_rules>
|
||||
<discovery_rule>
|
||||
<name>Samba:OU discovery</name>
|
||||
<key>samba_dc.discovery[ou]</key>
|
||||
<delay>1h</delay>
|
||||
<item_prototypes>
|
||||
<item_prototype>
|
||||
<name>Samba: Number of objects in {#SAMBA_OU}</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>samba_dc.ou[{#SAMBA_OU},objects]</key>
|
||||
<delay>0</delay>
|
||||
<history>60d</history>
|
||||
<trends>1825d</trends>
|
||||
<units>!objects</units>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Samba</name>
|
||||
</application>
|
||||
</applications>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<params>$.objects</params>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<master_item>
|
||||
<key>samba_dc.ou[{#SAMBA_OU}]</key>
|
||||
</master_item>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<name>Samba: Info for {#SAMBA_OU}</name>
|
||||
<key>samba_dc.ou[{#SAMBA_OU}]</key>
|
||||
<delay>5m</delay>
|
||||
<history>0</history>
|
||||
<trends>0</trends>
|
||||
<value_type>TEXT</value_type>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Samba</name>
|
||||
</application>
|
||||
</applications>
|
||||
</item_prototype>
|
||||
</item_prototypes>
|
||||
</discovery_rule>
|
||||
</discovery_rules>
|
||||
</template>
|
||||
<template>
|
||||
<template>Template_App_Samba_DC_Aggregate</template>
|
||||
|
|
Loading…
Reference in New Issue