initial commit of file from CVS for smeserver-zabbix-agent on Sat Sep 7 21:17:46 AEST 2024

This commit is contained in:
Trevor Batley 2024-09-07 21:17:46 +10:00
parent c771a7111d
commit 127b1311fe
51 changed files with 1771 additions and 2 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.rpm
*.log
*spec-20*
*.tar.gz

21
Makefile Normal file
View File

@ -0,0 +1,21 @@
# Makefile for source rpm: smeserver-zabbix-agent
# $Id: Makefile,v 1.1 2020/12/04 18:33:52 brianr Exp $
NAME := smeserver-zabbix-agent
SPECFILE = $(firstword $(wildcard *.spec))
define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
endef
MAKEFILE_COMMON := $(shell $(find-makefile-common))
ifeq ($(MAKEFILE_COMMON),)
# attept a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif
include $(MAKEFILE_COMMON)

View File

@ -1,3 +1,16 @@
# smeserver-zabbix-agent # <img src="https://www.koozali.org/images/koozali/Logo/Png/Koozali_logo_2016.png" width="25%" vertical="auto" style="vertical-align:bottom"> smeserver-zabbix-agent
SMEServer Koozali developed git repo for smeserver-zabbix-agent smecontribs SMEServer Koozali developed git repo for smeserver-zabbix-agent smecontribs
## Wiki
<br />https://wiki.koozali.org/Zabbix-agent
<br />https://wiki.koozali.org/Zabbix-agent/fr
## Bugzilla
Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=smeserver-zabbix-agent&product=SME%20Contribs&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED)
## Description
<br />*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.*
*Once it has been checked, then this comment will be deleted*
<br />

View File

@ -0,0 +1,338 @@
Summary: sme server integration of zabbix agent
Name: smeserver-zabbix-agent
Version: 0.4.8
Release: 1%{?dist}
License: GNU GPL version 2
URL: http://www.zabbix.com/
Group: SMEserver/addon
Source: %{name}-%{version}.tar.gz
BuildArchitectures: noarch
BuildRequires: e-smith-devtools
BuildRoot: /var/tmp/%{name}-%{version}
Requires: e-smith-release >= 7.0
Requires: zabbix-agent => 2.0.0
Requires: zabbix-agent-addons => 0.1.15
Requires: smeserver-remoteuseraccess
Requires: qmqtool
Requires: perl(IO::Socket)
Requires: perl(Net::SSLeay)
Requires: perl(Date::Parse)
Requires: perl(Crypt::OpenSSL::X509)
AutoReqProv: no
%description
smserver integration of zabbix agent.
Zabbix is an entreprise-class open source distributed monitoring
solution
%changelog
* Fri May 29 2020 Daniel Berteaud <daniel@firewall-services.com> 0.4.8-1
- Adapt regex to match queued emails when spam filtering is disabled
(daniel@firewall-services.com)
* Thu Feb 27 2020 Daniel Berteaud <daniel@firewall-services.com> 0.4.7-1
- Rewrite util_send_status_mail to go through the SMTP server (daniel@firewall-
services.com)
- Remove useless var in spec file (daniel@firewall-services.com)
* Wed Nov 27 2019 Daniel Berteaud <daniel@firewall-services.com> 0.4.6-1
- Remove the git CHANGELOG as it's not generated anymore (daniel@firewall-
services.com)
* Wed Nov 27 2019 Daniel Berteaud <daniel@firewall-services.com> 0.4.5-1
- Adapt spec file for tito (daniel@firewall-services.com)
- Detect if running >= 4.4, and remove vfs.dev.discovery UserParameter in this
case (daniel@firewall-services.com)
* Wed Nov 27 2019 Daniel Berteaud <daniel@firewall-services.com>
- Detect if running >= 4.4, and remove vfs.dev.discovery UserParameter in this
case (daniel@firewall-services.com)
* Tue Nov 26 2019 Daniel Berteaud <daniel@firewall-services.com> 0.4.3-1
- new package built with tito
* Tue May 3 2016 Daniel Berteaud <daniel@firewall-services.com> - 0.4.3-1.sme
- Add dmarc regex in util_parse_mail_in and add support for spf_deny plugin
* Wed Apr 27 2016 Daniel Berteaud <daniel@firewall-services.com> - 0.4.2-1.sme
- Adapt qpsmtpd parser regex to match naughty rejects against the original
plugin
* Tue Apr 19 2016 Daniel Berteaud <daniel@firewall-services.com> - 0.4.1-1.sme
- Adapt util_parse_mail_in and util_count_mail_in to work with qpsmtpd 0.96
- Define %clean before %files so epel-macros don't try to add a default
buggy %clean on el5
* Mon Mar 21 2016 Daniel Berteaud <daniel@firewall-services.com> - 0.4.0-1.sme
- Add support for new encryption features of zabbix 3.0
* Wed Jun 10 2015 Daniel B. <daniel@firewall-services.com> - 0.3.8-1.sme
- Add a random delay before sending the status email
* Mon Jan 5 2015 Daniel B. <daniel@firewall-services.com> - 0.3.7-1.sme
- Requires qmqtool to monitor qmail queue
* Wed Jun 25 2014 Daniel B. <daniel@firewall-services.com> - 0.3.6-1.sme
- Fix a warning in util_send_mail.pl script on EL6
* Wed Jun 11 2014 Daniel B. <daniel@firewall-services.com> - 0.3.5-1.sme
- Fix exec perm on certs check scripts
* Tue May 6 2014 Daniel B. <daniel@firewall-services.com> - 0.3.4-1.sme
- Add support for nmb lookup script
* Wed Feb 19 2014 Daniel B. <daniel@firewall-services.com> - 0.3.3-1.sme
- Fix a typo in dependency
* Wed Feb 19 2014 Daniel B. <daniel@firewall-services.com> - 0.3.2-1.sme
- Add script to monitor PHPki certificates
* Tue Feb 18 2014 Daniel B. <daniel@firewall-services.com> - 0.3.1-1.sme
- Fix a syntaxe error in check_asterisk
* Tue Apr 16 2013 Daniel B. <daniel@firewall-services.com> - 0.3.0-1.sme
- Huge cleanup
- Requires zabbix-agent-addons
* Thu Apr 11 2013 Daniel B. <daniel@firewall-services.com> - 0.2.1-1.sme
- Improvement in mdstat-parser.pl
* Thu Jun 14 2012 Daniel B. <daniel@firewall-services.com> - 0.2.0-1.sme
- Import to GIT
- Remove certificate expiration script
- Make it 2.0 compatible
* Thu Jun 7 2012 Daniel B. <daniel@firewall-services.com> - 0.1-52.sme
- Add missing perl module in dependency
* Thu Jun 7 2012 Daniel B. <daniel@firewall-services.com> - 0.1-51.sme
- Add certificate expiration script
* Fri Oct 28 2011 Daniel B. <daniel@firewall-services.com> - 0.1-50.sme
- Fix a closing bracket in templates
* Wed Oct 26 2011 Daniel B. <daniel@firewall-services.com> - 0.1-49.sme
- Add better asterisk monitoring capabilities
* Fri Jul 08 2011 Daniel B. <daniel@firewall-services.com> - 0.1-48.sme
- Configure timeout from the DB (prop TimeOut)
* Wed May 04 2011 Daniel B. <daniel@firewall-services.com> 0.1-47
- Send status mail with some logs and active connexions (StatusMail prop)
* Thu Sep 02 2010 Daniel B. <daniel@firewall-services.com> 0.1-46
- Add /usr/sbin in path for check_lvm and check_asterisk
* Thu Sep 02 2010 Daniel B. <daniel@firewall-services.com> 0.1-45
- Add basic asterisk monitoring support
- Add basic LVM monitoring support
* Wed Aug 04 2010 Daniel B. <daniel@firewall-services.com> 0.1-44
- Support up to 8 disks for I/O monitoring. Report valid 0 value
for non existing ones to prevent errors in server's log
* Wed Jun 23 2010 Daniel B. <daniel@firewall-services.com> 0.1-43
- Possibility to set Hostname from the DB [SME: 6083]
* Mon May 03 2010 Daniel B. <daniel@firewall-services.com> 0.1-42
- disable MegaCli log (which can break monitoring if log file reaches 2GB)
- report CRITICAL if both CRITICAL and WARNING are found
- add Squid UserParameters (hit ratio, cache size, req per minute)
* Wed Mar 17 2010 Daniel B. <daniel@firewall-services.com> 0.1-41
- read megaraid options from the DB (number of spares, number of
error to ignore)
* Fri Mar 12 2010 Daniel B. <daniel@firewall-services.com> 0.1-40
- update regex for incomming mail stats for newer qpsmtpd
* Wed Feb 17 2010 Daniel B. <daniel@firewall-services.com> 0.1-39
- update megaraid-parser.pl script with options to ignore some errors
* Mon Jan 4 2010 Daniel B. <daniel@firewall-services.com> 0.1-38
- Change UPS UserParameters to use wildcard, so you can monitor several UPS
easily (require changes in the templates on the server side)
* Sun Dec 6 2009 Daniel B. <daniel@firewall-services.com> 0.1-37
- Call megaraid-parser.pl scripts with sudo in zabbix_agentd.conf
* Wed Dec 2 2009 Daniel B. <daniel@firewall-services.com> 0.1-36
- Run megaraid-parser.pl as root (with sudo) instead of granting
zabbix user unrestricted access to MegaCli
* Fri Sep 25 2009 Daniel B. <daniel@firewall-services.com> 0.1-35
- Support up to 8 disks for smart monitoring. Report valid 0 value
for non existing ones to prevent errors in server's log
* Tue Sep 01 2009 Daniel B. <daniel@firewall-services.com> 0.1-34
- Add missing return after smart parameters (if several disks are monitored)
* Mon Aug 31 2009 Daniel B. <daniel@firewall-services.com> 0.1-33
- Add system.smart UserParameter (monitor smart values for configured hard drives)
* Wed Jul 08 2009 Daniel B. <daniel@firewall-services.com> 0.1-32
- Fix megaraid-parser script to support RAID-10 arrays
* Mon Jun 08 2009 Daniel B. <daniel@firewall-services.com> 0.1-31
- Add cpu.number UserParameter (return the number of CPU on the host)
* Wed May 06 2009 Daniel B. <daniel@firewall-services.com> 0.1-30
- Create missing tmp directory
* Mon Apr 27 2009 Daniel B. <daniel@firewall-services.com> 0.1-29
- megaraid-parser.pl is now compatible with newer versions
of MegaCli
- Fix permission on megaraid-parser.pl script
* Thu Apr 23 2009 Daniel B. <daniel@firewall-services.com> 0.1-28
- improvements in sensors script
- Add megaraid-parser.pl script to get more accurate MegaRaid
conrolers informations
- use a cronjob to parse mail logs so multiple zabbix server
can be used. Also, it won't repport false value if your host
has been unreachable for some time
- change output of mdstat-parser.pl to report everything in one
line (looks like megaraid-parser)
* Mon Apr 20 2009 Daniel B. <daniel@firewall-services.com> 0.1-27
- Add updates.available to retrieve the number of updates available
with yum
- Added sensors[*] key to retrieve sensors informations. The value are retrieved
with the script /var/lib/zabbix/bin/sensors which can be customized.
* Fri Mar 27 2009 Daniel B. <daniel@firewall-services.com> 0.1-26
- Add raid.mega.status UserParameters to monitor status of MegaRaid based
raid array
* Tue Mar 24 2009 Daniel B. <daniel@firewall-services.com> 0.1-25
- Add comments for each UserParameter for configuration on the server side
(Type of information, unit, etc...)
* Tue Mar 24 2009 Daniel B. <daniel@firewall-services.com> 0.1-24
- Add raid.sw.status userparameter to report software raid array status
- Remove tabs from spec
- Permission cleanup on scripts
* Wed Mar 18 2009 Daniel B. <daniel@firewall-services.com> 0.1-23
- Correct mysql.size parameter (sudo -u mysql)
* Mon Mar 09 2009 Daniel B. <daniel@firewall-services.com> 0.1-22
- Fix typo in sudoers template (ZABBIX_AGENT_MYSQL)
* Mon Mar 02 2009 Daniel B. <daniel@firewall-services.com> 0.1-21
- Add smeserver-remoteuseraccess as a dependencie (sudoer templates issue)
* Mon Mar 02 2009 Daniel B. <daniel@firewall-services.com> 0.1-20
- Adjust masq service on zabbix-agent-update event
- Add description of Timout directive
- Add BufferSend and BufferSize directive to optimize
agent <-> server communication
* Sun Mar 01 2009 Daniel B. <daniel@firewall-services.com> 0.1-19
- Add size of mysql data (mysql.size)
* Fri Feb 20 2009 Daniel B. <daniel@firewall-services.com> 0.1-18
- Add stats for InternalInterface and ExternalInterface
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-17
- Ignore local delivery from outgoing mail stats
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-16
- Fix a typo in mail.out.failure UserParameters
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-15
- Add UserParameters for outhoing mails statistics
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-14
- add missing other_denied UserParameters for mailStats
- Fix expand-template for /etc/sudoers during zabbix-agent-update event
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-13
- Add incoming mails statistics
- Rename signal-event to zabbix-agent-update (to prevent a conflict on
sudoers files which needs to be expanded for server and agent)
* Wed Feb 11 2009 Daniel B. <daniel@firewall-services.com> 0.1-12
- Remove Useless buffers and cache mem
- Add vm.memory.size.pused (used memory in %)
- Add ups.battery.charge for ups
- Added "passive" db parameter
- default access is private
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-11
- Fix permissions on mysqladmin_status script
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-10
- Change used swap key
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-9
- Added userparameters for used swap space used in bytes
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-8
- Correct a type in memory statistics (for cached memory)
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-7
- Report also free, buffers and cached mem so stats are more accurate
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-6
- substract cache/buffer from used mem
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-5
- Change key name for used memory
- Report Used mem instead of total
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-4
- Escape brackets in template
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-3
- Add UserParameters to repport amount of used memory
* Mon Feb 9 2009 Daniel B. <daniel@firewall-services.com> 0.1-2
- Add UserParameters to monitor real external IP, UPS status,
mysql stats
* Fri Feb 6 2009 Daniel B. <daniel@firewall-services.com> 0.1-1
- add Hostname directive in zabbix_agentd.conf
* Wed Feb 04 2009 Daniel B. <daniel@firewall-services.com> 0.1-0
- initial release
%prep
%setup
%build
%{__mkdir_p} root/var/lib/zabbix/tmp
perl ./createlinks
%install
rm -rf $RPM_BUILD_ROOT
(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT)
rm -f %{name}-%{version}-filelist
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \
--file /var/lib/zabbix/bin/check_mysqladmin_status_sudo 'attr(0750,root,zabbix)' \
--file /var/lib/zabbix/bin/util_logtail 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/util_count_mail_in 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/util_count_mail_out 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/util_parse_mail_in 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/util_parse_mail_out 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/check_asterisk 'attr(0750,root,zabbix)' \
--file /var/lib/zabbix/bin/util_send_status_mail 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/disco_certs_sudo 'attr(0750,root,zabbix)' \
--file /var/lib/zabbix/bin/check_certs_sudo 'attr(0750,root,zabbix)' \
--dir /var/lib/zabbix/tmp 'attr(0750,zabbix,zabbix)' \
> %{name}-%{version}-filelist
%clean
rm -rf $RPM_BUILD_ROOT
%files -f %{name}-%{version}-filelist
%defattr(-,root,root)
%postun
#uninstall
if [ $1 = 0 ] ; then
/etc/init.d/zabbix-agent stop
fi
true

1
contriborbase Normal file
View File

@ -0,0 +1 @@
contribs10

32
createlinks Normal file
View File

@ -0,0 +1,32 @@
#!/usr/bin/perl -w
use esmith::Build::CreateLinks qw(:all);
# Templates to expand
foreach my $conf (qw!zabbix_agentd.conf zabbix_agentd.conf.d/asterisk.conf
zabbix_agentd.conf.d/deprecated_cpunum.conf zabbix_agentd.conf.d/deprecated_memory.conf
zabbix_agentd.conf.d/deprecated_netstat.conf zabbix_agentd.conf.d/deprecated_swap.conf
zabbix_agentd.conf.d/extip.conf zabbix_agentd.conf.d/mail.conf zabbix_agentd.conf.d/mysql.conf
zabbix_agentd.conf.d/phpki_certs.conf zabbix_agentd.conf.d/samba.conf zabbix_agentd.conf.d/block_devices.conf!){
templates2events("/etc/zabbix/$conf", qw(zabbix-agent-update bootstrap-console-save smeserver-zabbix-agent-update));
}
templates2events("/etc/sudoers", "zabbix-agent-update");
templates2events("/etc/rc.d/init.d/masq", "zabbix-agent-update");
templates2events("/etc/crontab", "zabbix-agent-update");
# Services to restart
safe_symlink("restart", "root/etc/e-smith/events/zabbix-agent-update/services2adjust/zabbix-agent");
safe_symlink("adjust", "root/etc/e-smith/events/zabbix-agent-update/services2adjust/masq");
$event="smeserver-zabbix-agent-update";
templates2events("/etc/sudoers", $event);
templates2events("/etc/rc.d/init.d/masq", $event);
templates2events("/etc/crontab", $event);
templates2events("/etc/backup-data.d/smeserver-zabbix-agent.include", $event);
# Services to restart
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/zabbix-agent");
safe_symlink("adjust", "root/etc/e-smith/events/$event/services2adjust/masq");
# systemd-specific action mandatory for this package-update event
event_link("systemd-reload", $event, "89");
event_link("systemd-default", $event, "88");

View File

@ -0,0 +1 @@
disabled

View File

@ -0,0 +1 @@
127.0.0.1

View File

@ -0,0 +1 @@
10050

View File

@ -0,0 +1 @@
private

View File

@ -0,0 +1 @@
enabled

View File

@ -0,0 +1 @@
service

View File

@ -0,0 +1,21 @@
#Only non rpm owned files are backupe there
{
use RPM2;
my $rpm_db = RPM2->open_rpm_db();
my @dirs = qw(
/etc/zabbix
/etc/zabbix/zabbix_agentd.conf.d/
/var/lib/zabbix/bin/
);
foreach my $some_dir (@dirs) {
next unless ( -e $some_dir );
opendir(my $dh, $some_dir) || die "Can't open $some_dir: $!";
while ( (my $file = readdir $dh) ) {
next if $file =~ /^\.{1,2}$/;
$OUT .= "$some_dir/$file\n" unless $rpm_db->find_by_file("$some_dir/$file");
}
closedir $dh;
}
}

View File

@ -0,0 +1,20 @@
{
if ((${'zabbix-agent'}{'status'} || 'disabled') eq 'enabled'){
$OUT .=<<"HERE";
# Parse mail logs and write stats in zabbix tmp directory
*/10 * * * * root /var/lib/zabbix/bin/util_count_mail_in
*/10 * * * * root /var/lib/zabbix/bin/util_count_mail_out
HERE
if ((${'zabbix-agent'}{'StatusMail'} || 'disabled' ) eq 'enabled'){
$OUT .=<<'HERE';
# Send a status mail
*/15 * * * * root sleep $[ $RANDOM \% 120 ]; /var/lib/zabbix/bin/util_send_status_mail
HERE
}
}
}

View File

@ -0,0 +1,2 @@
Cmnd_Alias ZABBIX_AGENT = /var/lib/zabbix/bin/*_sudo

View File

@ -0,0 +1,2 @@
zabbix ALL=(root) NOPASSWD: ZABBIX_AGENT

View File

@ -0,0 +1,28 @@
{
if ( -x '/usr/sbin/asterisk' ){
my $login = "";
my $user = ${'zabbix-agent'}{'AsteriskManagerLogin'} || '';
my $pass = ${'zabbix-agent'}{'AsteriskManagerPassword'} || '';
if ($user ne ''){
$login .= "--user=$user";
}
if ($pass ne ''){
$login .= " --secret=$pass";
}
$OUT.=<<"HERE"
# Type: Agent or Agent (active)
# Key: asterisk[key] where key can be max_latency, sip_peers, channels, internal_calls,
# outgoing_calls, incoming_calls, external_calls, duration_internal or duration_external
# Type of information: Numeric (integer 64bit)
# Units: depends on the key
# Custom multiplier: Do not use
# Store Value: As is
UserParameter=asterisk[*],/var/lib/zabbix/bin/check_asterisk $login --what=\$1
HERE
}
}

View File

@ -0,0 +1,13 @@
{
$OUT = '';
qx(zabbix_agentd -t vfs.dev.discovery -c /dev/null | grep -q ZBX_NOTSUPPORTED);
if ($? != 0){
$OUT .= '# vfs.dev.discovery is natively supported, not UserParameter needed';
} else{
$OUT .=<<'_EOF';
# Discover block devices
UserParameter=vfs.dev.discovery,/var/lib/zabbix/bin/disco_block_devices
_EOF
}
}

View File

@ -0,0 +1,14 @@
# Number of CPU
# Description: Number of CPU
# Type: Agent or Agent (active)
# Key: cpu.number
# Type of information: Numeric (integer 64bit)
# Units: cpu
# Use multiplier: do not use
# Update interval: 86400 (once a day)
# Store Value: As is
# Show Value: As is
UserParameter=cpu.number,cat /proc/cpuinfo | grep processor | wc -l

View File

@ -0,0 +1,24 @@
# Amount of used memory (the agent lacks this stats)
# Description: Used Memory
# Type: Agent or Agent (active)
# Key: vm.memory.size.used
# Type of information: Numeric (integer 64bit)
# Units: B
# Use multiplier: do not use
# Store Value: As is
# Show Value: As is
UserParameter=vm.memory.size.used,free -b | grep 'buffers/cache' | awk '\{print $3\}'
# Amount of used memory in % (the agent lacks this stats)
# Description: Used Memory in %
# Type: Agent or Agent (active)
# Key: vm.memory.size.pused
# Type of information: Numeric (integer 64bit)
# Units: %
# Use multiplier: do not use
# Store Value: As is
# Show Value: As is
UserParameter=vm.memory.size.pused,echo $(($(free -b | grep 'buffers/cache' | awk '\{print $3\}')*100/$(free -b | grep 'Mem' | awk '\{print $2\}')))

View File

@ -0,0 +1,62 @@
# Some networks statistics
# zabbix agent support natively interface stats, but, it's hard to create templates for a lot of
# SME Servers which can use different interface name (External can be eth0, eth1, ppp0 etc...)
# This way, net.if.in.internal, net.if.in.external, net.if.out.internal and net.if.out.external
# will always refers to the correct interface.
{
my $internal = $InternalInterface{'Name'} || 'eth0';
my $external = $ExternalInterface{'Name'} || 'eth1';
# Do we use the bridge contrib ?
# If yes, we reports only the traffic on the real ethernet interface.
if ( (($bridge{'status'} || 'disabled') eq 'enabled') && (defined $bridge{'ethernetInterface'}) ){
$internal = $bridge{'ethernetInterface'};
}
$OUT .=<<"HERE";
# Description: In Internal
# Type: Agent or Agent (active)
# Key: net.if.in.internal
# Type of information: Numeric (float)
# Units: b/s
# Custom multiplier: 8 (if you want the value in bits/s instead of Bytes/s)
# Store Value: Delta (speed per second)
UserParameter=net.if.in.internal,cat /proc/net/dev | grep $internal | cut -d":" -f2 | awk '{print \$1}'
# Description: Out Internal
# Type: Agent or Agent (active)
# Key: net.if.out.internal
# Type of information: Numeric (float)
# Units: b/s
# Custom multiplier: 8 (if you want the value in bits/s instead of Bytes/s)
# Store Value: Delta (speed per second)
UserParameter=net.if.out.internal,cat /proc/net/dev | grep $internal | cut -d":" -f2 | awk '{print \$9}'
HERE
if (($SystemMode || 'serveronly') ne 'serveronly'){
$OUT .=<<"HERE";
# Description: In External
# Type: Agent or Agent (active)
# Key: net.if.in.external
# Type of information: Numeric (float)
# Units: b/s
# Custom multiplier: 8 (if you want the value in bits/s instead of Bytes/s)
# Store Value: Delta (speed per second)
UserParameter=net.if.in.external,cat /proc/net/dev | grep $external | cut -d":" -f2 | awk '{print \$1}'
# Description: Out External
# Type: Agent or Agent (active)
# Key: net.if.out.external
# Type of information: Numeric (float)
# Units: b/s
# Custom multiplier: 8 (if you want the value in bits/s instead of Bytes/s)
# Store Value: Delta (speed per second)
UserParameter=net.if.out.external,cat /proc/net/dev | grep $external | cut -d":" -f2 | awk '{print \$9}'
HERE
}
}

View File

@ -0,0 +1,12 @@
# Amount of used swap in bytes
# Description: Used swap space
# Type: Agent or Agent (active)
# Key: system.swap.size.used
# Type of information: Numeric (integer 64bit)
# Units: B
# Multiplier: do not use
# Store Value: As is
# Show Value: As is
UserParameter=system.swap.size.used,free -b | grep Swap | awk '\{print $3\}'

View File

@ -0,0 +1,9 @@
# Retrieve real external IP
# Description: Ext IP
# Type: Agent or Agent (active)
# Key: ip.external
# Type of information: Character
# Show Value: As is
UserParameter=ip.external,/usr/bin/curl --connect-timeout 5 -s -o - -k "http://www.wimip.fr/?t="

View File

@ -0,0 +1,15 @@
# Incomming mails statistics
# Description: Incoming Mail <key>
# Type: Agent or Agent (active)
# Key: mail.in[<key>] (for example mail.in[dnsbl])
# Type of information: Numeric (integer 64bit)
# Units: mails/h
# Use multiplier: Custom multiplier
# Custom multiplier: 6
# Update interval: 600
# Store Value: As is
# Show Value: As is
UserParameter=mail.in[*],cat /var/lib/zabbix/tmp/mail.in.$1

View File

@ -0,0 +1,16 @@
# Outgoing mails statistics
# Description: Incoming Mail <key>
# Type: Agent or Agent (active)
# Key: mail.out.[<key>] (for example mail.out[total])
# Type of information: Numeric (integer 64bit)
# Units: mails/h
# Use multiplier: Custom multiplier
# Custom multiplier: 6
# Update interval: 600
# Store Value: As is
# Show Value: As is
UserParameter=mail.out[*],cat /var/lib/zabbix/tmp/mail.out.$1

View File

@ -0,0 +1,15 @@
# Some stats about MySQL
# Description: MySQL <key>
# Type: Agent or Agent (active)
# Type of information: Numeric (float)
# Unit: <depend on the key> (for example, qps)
# Use multiplier: do not use
# Store Value: As is
UserParameter=mysql.uptime,/usr/bin/sudo /var/lib/zabbix/bin/check_mysqladmin_status_sudo | cut -d" " -f2
UserParameter=mysql.threads,/usr/bin/sudo /var/lib/zabbix/bin/check_mysqladmin_status_sudo | cut -d" " -f5
UserParameter=mysql.questions,/usr/bin/sudo /var/lib/zabbix/bin/check_mysqladmin_status_sudo | cut -d" " -f8
UserParameter=mysql.slowqueries,/usr/bin/sudo /var/lib/zabbix/bin/check_mysqladmin_status_sudo | cut -d" " -f12
UserParameter=mysql.qps,/usr/bin/sudo /var/lib/zabbix/bin/check_mysqladmin_status_sudo | cut -d" " -f29

View File

@ -0,0 +1,23 @@
{
if (-e '/opt/phpki/phpki-store/CA/index.txt'){
$OUT .=<<'EOF';
# Discovery of certificates and their status
# Key: pki.certs.discovery
# Macro:
# - {#CRTCN} : contains the common name
# - {#CRTSERIAL} : the serial number
# - {#CRTSTATUS} : the status, as a string (valid, revoked, expired)
# Available arguments:
# --index : path to the index file
# --path : directory where certificatres are stored, certificates should be named $serial.pem (in PEM format)
UserParameter=pki.certs.discovery,/usr/bin/sudo /var/lib/zabbix/bin/disco_certs_sudo --index=/opt/phpki/phpki-store/CA/index.txt --path=/opt/phpki/phpki-store/CA/newcerts/
UserParameter=pki.certs[*],/usr/bin/sudo /var/lib/zabbix/bin/check_certs_sudo --what=$1 --cert=$2
EOF
}
$OUT .= '';
}

View File

@ -0,0 +1,2 @@
# Check if nmbd is available and working
UserParameter=samba.nmbd.status,/var/lib/zabbix/bin/check_nmblookup --server=127.0.0.1 --host={$smb{ServerName};}

View File

@ -0,0 +1,2 @@
Server={ (${'zabbix-agent'}{'Servers'} || '127.0.0.1'); }

View File

@ -0,0 +1,6 @@
{
my $host = (${'zabbix-agent'}{'Hostname'} || $SystemName.".".$DomainName);
$OUT = "Hostname=$host\n";
}

View File

@ -0,0 +1,11 @@
ListenPort={ (${'zabbix-agent'}{'TCPPort'} || '10050'); }
{
my $access = ${'zabbix-agent'}{'access'} || 'private';
my $listen = '127.0.0.1';
$listen = $LocalIP if ($access eq 'private');
$listen = '' if ($access eq 'public');
$OUT .= "ListenIP=$listen\n" if ($listen ne '');
}

View File

@ -0,0 +1 @@
StartAgents=5

View File

@ -0,0 +1,2 @@
BufferSend=30
BufferSize=100

View File

@ -0,0 +1,5 @@
{
if ((${'zabbix-agent'}{'ServerActive'} || '') ne ''){
$OUT .= "ServerActive=${'zabbix-agent'}{'ServerActive'}\n";
}
}

View File

@ -0,0 +1 @@
EnableRemoteCommands={ (${'zabbix-agent'}{'RemoteCommands'} || 'disabled') eq 'enabled' ? '1':'0'; }

View File

@ -0,0 +1,5 @@
DebugLevel=3
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=10

View File

@ -0,0 +1 @@
Include=/etc/zabbix/zabbix_agentd.conf.d/

View File

@ -0,0 +1,5 @@
# Spend no more than Timeout seconds on processing
# Must be between 1 and 30
Timeout={${'zabbix-agent'}{'TimeOut'} || '3'}

View File

@ -0,0 +1,33 @@
{
my @encryptions = ();
my $psk_file = ${'zabbix-agent'}{'TLSPSKFile'} || '/etc/zabbix/zabbix_agentd.psk';
my $psk_id = ${'zabbix-agent'}{'TLSPSKIdentity'} || $SystemName . '.' . $DomainName . '-agent';
if (-s $psk_file){
push @encryptions, 'psk';
$OUT .=<<_EOF;
TLSPSKFile=$psk_file
TLSPSKIdentity=$psk_id
_EOF
}
my $cert = ${'zabbix-agent'}{'TLSCertFile'} || '/etc/zabbix/zabbix_agentd.crt';
my $key = ${'zabbix-agent'}{'TLSKeyFile'} || '/etc/zabbix/zabbix_agentd.key';
my $ca = ${'zabbix-agent'}{'TLSCAFile'} || '/etc/zabbix/zabbix_agentd.ca';
if (-s $cert && -s $key && -s $ca){
push @encryptions, 'cert';
$OUT .=<<_EOF;
TLSCertFile=$cert
TLSKeyFile=$key
TLSCAFile=$ca
_EOF
my $issuer = ${'zabbix-agent'}{'TLSServerCertIssuer'} || '';
my $subject = ${'zabbix-agent'}{'TLSServerCertSubject'} || '';
$OUT .= "TLSServerCertIssuer=$issuer\n" if ($issuer ne '');
$OUT .= "TLSServerCertSubject=$subject\n" if ($subject ne '');
}
my $encryptions = (scalar @encryptions > 0) ? join(',', @encryptions) : '';
$OUT .=<<_EOF if ($encryptions ne '');
TLSConnect=$encryptions
TLSAccept=$encryptions
_EOF
}

View File

@ -0,0 +1,2 @@
[Install]
WantedBy=sme-server.target

View File

@ -0,0 +1,210 @@
#!/usr/bin/perl -w
use Asterisk::AMI::Common;
use Getopt::Long;
open STDERR, '>/dev/null';
# Set some default
my $host = '127.0.0.1';
my $port = '5038';
my $user = 'zabbixagent';
my $secret = 'zabbixsecret';
my $what = 'sip_peers';
GetOptions(
"host=s" => \$host,
"port=s" => \$port,
"user=s" => \$user,
"secret=s" => \$secret,
"what=s" => \$what
);
our $ast = Asterisk::AMI::Common->new(
PeerAddr => $host,
PeerPort => $port,
Username => $user,
Secret => $secret
);
die "Unable to connect to asterisk manager" unless ($ast);
sub help{
print<<"EOF";
usage: $0 --host=asterisk.domain.tld --port=5038 --user=manager --secret=azerty --what=sip_peers
--what can take the following argument:
* sip_peers: number of connected sip peers
* max_latency: highest latency of connected sip_peers
* channels: total number of active channels
* internal_calls: number of active internal calls
* outgoing_calls: number of active outgoing calls (external)
* incoming_calls: number of active incoming calls (external)
* external_calls: number of external calls (in + out)
* duration_internal: actual highest duration of internal calls
* duration_external: actual highest duration of external calls
EOF
}
if ($what eq 'sip_peers'){
print get_connected_peers_num('sip');
}
elsif ($what eq 'max_latency'){
print get_max_peer_latency();
}
elsif($what eq 'channels'){
print get_active_channels_num();
}
elsif ($what eq 'internal_calls'){
print get_internal_call_num();
}
elsif ($what eq 'outgoing_calls'){
print get_outgoing_call_num();
}
elsif ($what eq 'incoming_calls'){
print get_incoming_call_num();
}
elsif ($what eq 'external_calls'){
print get_outgoing_call_num() + get_incoming_call_num();
}
elsif ($what eq 'duration_internal'){
print get_max_duration_internal();
}
elsif ($what eq 'duration_external'){
print get_max_duration_external();
}
else{
help();
$ast->disconnect();
exit (1);
}
$ast->disconnect();
exit(0);
# Return the number of connected peers for
# the specified protocol (only SIP supporteed for now)
sub get_connected_peers_num{
my $proto = shift;
my $peers;
if ($proto eq 'sip'){
$peers = get_sip_peers();
}
else{
return 'unsupported protocol';
}
my $num = 0;
foreach my $peer (keys %{$peers}){
my $status = $peers->{$peer}->{'Status'};
$num++ if ($status =~ m/^OK/);
}
return $num;
}
# Return the list of SIP peers (as a hashref)
sub get_sip_peers{
return $ast->sip_peers();
}
# Return the highest latency of all the peers
sub get_max_peer_latency{
my $peers = get_sip_peers();
my $latency = 0;
foreach my $peer (keys %{$peers}){
my $status = $peers->{$peer}->{'Status'};
$status =~ /\((\d+)\sms\)/;
$latency = $1 if ($1 > $latency);
}
return $latency;
}
# Return channels list as a hashref
sub get_channels(){
return $ast->channels();
}
# Return the number of channels
sub get_active_channels_num{
my $channels = get_channels();
my $num = 0;
foreach my $chan (keys %{$channels}){
$num++;
}
return $num;
}
# Return the number of active channels
sub get_up_channels_num{
my $channels = get_channels();
my $num = 0;
foreach my $chan (keys %{$channels}){
my $status = $channels->{$chan}->{'State'};
$num++ if ($status eq 'Up');
}
return $num;
}
# Return the number of outgoing calls
sub get_outgoing_call_num{
my $channels = get_channels();
my $num = 0;
foreach my $chan (keys %{$channels}){
my $context = $channels->{$chan}->{'Context'};
my $status = $channels->{$chan}->{'State'};
$num++ if ($context eq 'macro-dialout-trunk' and $status eq 'Up');
}
return $num;
}
# Return the number of incoming calls
sub get_incoming_call_num{
my $channels = get_channels();
my $num = 0;
foreach my $chan (keys %{$channels}){
my $context = $channels->{$chan}->{'Context'};
my $status = $channels->{$chan}->{'State'};
$num++ if ($context =~ /^from\-(trunk|pstn|zaptel|dahdi)/ and $status eq 'Up');
}
return $num;
}
# Return the number of internal calls
sub get_internal_call_num{
my $channels = get_channels();
my $num = 0;
foreach my $chan (keys %{$channels}){
my $context = $channels->{$chan}->{'Context'};
my $status = $channels->{$chan}->{'State'};
$num++ if (($context eq 'macro-dial' or $context eq 'from-internal') and $status eq 'Up');
}
return $num
}
# Return the max duration of current internal calls
sub get_max_duration_internal{
my $channels = get_channels();
my $max = 0;
foreach my $chan (keys %{$channels}){
my $dur = $channels->{$chan}->{'Seconds'};
my $context = $channels->{$chan}->{'Context'};
$max = $dur if (($context eq 'macro-dial' or $context eq 'from-internal') and $dur > $max);
}
return $max
}
# Return the max duration of current external calls (in or out)
sub get_max_duration_external{
my $channels = get_channels();
my $max = 0;
foreach my $chan (keys %{$channels}){
my $dur = $channels->{$chan}->{'Seconds'};
my $context = $channels->{$chan}->{'Context'};
$max = $dur if (($context eq 'macro-dialout-trunk' or $context =~ /^from\-(trunk|pstn|zaptel|dahdi)/) and $dur > $max);
}
return $max
}

View File

@ -0,0 +1,33 @@
#!/usr/bin/perl -w
# Check a PEM certificate
# --what: what to monitor. Only expire is supported for now, and returns the number of day before expiration
# --cert: the path to the certificate you want to check
use strict;
use warnings;
use Crypt::OpenSSL::X509;
use Date::Parse;
use Getopt::Long;
my $what = 'expire';
my $cert = '';
GetOptions(
"cert=s" => \$cert,
"what=s" => \$what
);
die "Usage: $0 --what=status --cert=/path/to/pem/certificate\n" unless
(-f $cert);
$cert = Crypt::OpenSSL::X509->new_from_file( "$cert" );
my $expire_in = int ((str2time($cert->notAfter())-time())/(3600*24));
if ($what eq 'expire'){
print $expire_in;
}
else{
die "Only expire is supported for now";
}

View File

@ -0,0 +1,5 @@
#!/bin/sh
HOME=/root
exec /usr/bin/mysqladmin status

View File

@ -0,0 +1,49 @@
#!/usr/bin/perl -w
use strict;
use warnings;
use Crypt::OpenSSL::X509;
use Date::Parse;
use Getopt::Long;
use JSON;
my $index = '/opt/phpki/phpki-store/CA/index.txt';
my $path = '/opt/phpki/phpki-store/CA/newcerts';
GetOptions(
"index=s" => \$index,
"path=s" => \$path
);
open INDEX, "$index" or die "Couldn't open $index\n";
my $json;
foreach my $l (<INDEX>){
next unless $l =~ m/^([VR])\t\d+Z\t(\d+Z)?\t(\w+)\tunknown\t.*/;
my $status = $1;
my $serial = $3;
my $cert = Crypt::OpenSSL::X509->new_from_file( "$path/$serial.pem" );
my $expire_in = int ((str2time($cert->notAfter())-time())/(3600*24));
if ($status eq 'V'){
$status = 'valid';
}
elsif ($expire_in lt 0){
$status = 'expired';
}
else{
$status = 'revoked';
}
my $subject = $cert->subject;
$subject =~ m/.*\sCN=(.*),/;
my $cn = $1;
push @{$json->{data}}, {
"{#CRTCN}" => $cn,
"{#CRTSERIAL}" => $serial,
"{#CRTSTATUS}" => $status,
};
}
close INDEX;
print to_json($json);

View File

@ -0,0 +1,13 @@
#!/bin/bash
BINDIR='/var/lib/zabbix/bin'
LOGTAIL=$BINDIR'/util_logtail'
PARSER=$BINDIR'/util_parse_mail_in'
LOGFILE='/var/log/qpsmtpd/current'
TMPDIR='/var/lib/zabbix/tmp/'
for WHAT in $($BINDIR/util_parse_mail_in keys); do
$LOGTAIL $LOGFILE $TMPDIR/mail.in.$WHAT.offset | $PARSER $WHAT > $TMPDIR/mail.in.$WHAT
done

View File

@ -0,0 +1,11 @@
#!/bin/bash
BINDIR='/var/lib/zabbix/bin'
LOGTAIL=$BINDIR'/util_logtail'
PARSER=$BINDIR'/util_parse_mail_out'
LOGFILE='/var/log/qmail/current'
TMPDIR='/var/lib/zabbix/tmp/'
for WHAT in failure deferral success total; do
$LOGTAIL $LOGFILE $TMPDIR/mail.out.$WHAT.offset | $PARSER $WHAT > $TMPDIR/mail.out.$WHAT
done

View File

@ -0,0 +1,95 @@
#!/usr/bin/perl
# Copyright (C) 2009 Daniel Berteaud <daniel@firewall-services.com>
# Copyright (C) 2003 Jonathan Middleton <jjm@ixtab.org.uk
# Copyright (C) 2001 Paul Slootman <paul@debian.org>
# This file is part of Logcheck.
# Modifications for integration with smeserver-zabbix-agent
# Logcheck is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# Logcheck is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Foobar; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
my ($logfile, $offsetfile) = @ARGV;
if (! -f $logfile) {
print "File $logfile cannot be read.\n";
exit 66;
}
unless ($offsetfile) {
# offsetfile not given, use .offset/$logfile in the same directory
$offsetfile = $logfile . '.offset';
}
unless (open(LOGFILE, $logfile)) {
print "File $logfile cannot be read.\n";
exit 66;
}
my ($inode, $offset) = (0, 0);
if (open(OFFSET, $offsetfile)) {
$_ = <OFFSET>;
unless (! defined $_) {
chomp $_;
$inode = $_;
$_ = <OFFSET>;
unless (! defined $_) {
chomp $_;
$offset = $_;
}
}
}
my ($ino, $size);
unless ((undef,$ino,undef,undef,undef,undef,undef,$size) = stat $logfile) {
print "Cannot get $logfile file size.\n", $logfile;
exit 65;
}
if ($inode == $ino) {
exit 0 if $offset == $size; # short cut
if ($offset > $size) {
$offset = 0;
#print "***************\n";
#print "*** WARNING ***: Log file $logfile is smaller than last time checked!\n";
#print "*************** This could indicate tampering.\n";
}
}
if ($inode != $ino || $offset > $size) {
$offset = 0;
}
seek(LOGFILE, $offset, 0);
while (<LOGFILE>) {
print $_;
}
$size = tell LOGFILE;
close LOGFILE;
unless (open(OFFSET, ">$offsetfile")) {
print "File $offsetfile cannot be created. Check your permissions.\n";
exit 73;
}
unless (chmod 0600, $offsetfile) {
print "Cannot set permissions on file $offsetfile\n";
exit 65;
}
print OFFSET "$ino\n$size\n";
close OFFSET;
exit 0;

View File

@ -0,0 +1,129 @@
#!/usr/bin/perl -w
# Copyright (C) 2009-2016 Daniel Berteaud <daniel@firewall-services.com>
# This file is part of smeserver-zabbix-agent package.
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Foobar; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# This script parse qpsmtpd logs (which must be sent to STDIN), and count the number
# of emails rejected by each plugins, and those accepted. You need to logterse plugin enabled
my $what = $ARGV[0] || '';
# This is the list of plugins we can get stats for
# you can set the regex used to identify a line in the logs
my %denied = (
dnsbl => qr{(dnsbl\s+90|naughty\s+90\d\s+\(dnsbl\))},
rhsbl => qr{rhsbl\s+90},
uribl => qr{uribl\s+90},
clamav => qr{virus::clam(av|dscan)\s+90},
check_earlytalker => qr{(check_)?earlytalker\s+90},
check_basicheaders => qr{(check_basic)?headers\s+90},
check_goodrcptto => qr{(check_)?goodrcptto\s+90},
check_spamhelo => qr{((check_spam)?helo\s+90|naughty\s+90\d\s+\(helo\))},
fcrdns => qr{fcrdns\s+90},
karma => qr{(karma\s+90|naughty\s+90\d\s+\(karma\))},
spf => qr{(sender_permitted_from|spf_deny)\s+90},
dmarc => qr{dmarc\s+90},
tls_failed => qr{tls\s+90},
resolvable_fromhost => qr{(require_)?resolvable_fromhost}
);
my @others = qw(total_denied spam_denied other_denied spam_queued queued total);
# If arg is keys, just print the supported keys and exit
if ($what eq "keys"){
print join "\n", (keys %denied, @others);
exit (0)
}
my %cnt;
foreach (keys %denied, @others){
$cnt{$_} = 0;
}
while (<STDIN>) {
my $line = $_;
# We only want logterse lines like
# @400000004994ad092afa867c 18386 logging::logterse plugin:
# The format can slightly change depending on qpsmtpd version
next unless $line =~ m/^\@[0-9a-f]{24} \d+( \((queue|deny)\))? logging::logterse/;
# Lets count all the message which have been denied 'msg denied before queued'
if ($line =~ m/msg denied before queued/){
$cnt{total_denied}++;
# Now try to find the plugin responsible for the deny
foreach (keys %denied){
if ($line =~ m/$denied{$_}/){
$cnt{$_}++;
}
}
next;
}
# Rejected by spamassassin because spam score is too high
elsif ($line =~ m/spam score exceeded threshold/){
$cnt{spam_denied}++;
next;
}
# Tagged as spam, but kept accepted
elsif ($line =~ m/queued\s+<.*>\s+Yes,\s+(score|hits)=/){
$cnt{spam_queued}++;
next;
}
# Queued, not tagged as spam (or spam filtering disabled), those are the clean emails
elsif ($line =~ m/queued\s+<.*>(\s+No,\s+(score|hits)=.+)?/){
$cnt{queued}++;
next;
}
}
# Now lets count other_denied, which is total_denied minus
# all the known plugins denied
$cnt{other_denied} = $cnt{total_denied};
foreach (keys %denied){
$cnt{total} = $cnt{total} + $cnt{$_};
$cnt{other_denied} = $cnt{other_denied} - $cnt{$_};
}
foreach (@others){
$cnt{total} = $cnt{total} + $cnt{$_} if ($_ !~ /total/);
}
# The print argument prints all on stdout
if ($what eq "print"){
foreach (keys %denied,@others){
print "$_: $cnt{$_}\n";
}
}
# If the arg is a known plugin, prints only its value
elsif (defined $cnt{$what}){
print "$cnt{$what}\n";
}
# Else, print an error
else{
print "supported items are: ";
foreach (keys %denied, @others){
print "$_ ";
}
print "\n";
exit 1;
}
exit 0;

View File

@ -0,0 +1,70 @@
#!/usr/bin/perl -w
# Copyright (C) 2009 Daniel Berteaud <daniel@firewall-services.com>
# This file is part of smeserver-zabbix-agent package.
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Foobar; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
my $what = $ARGV[0] || '';
# On initialise nos compteurs a 0
my @results = qw(failure deferral success total);
my %cnt;
foreach (@results){
$cnt{$_} = 0;
}
while (<STDIN>) {
my $line = $_;
# on limites aux lignes concernant l'envoie
# @400000004994ad092afa867c delivery 96906: success etc...
next unless $line =~ m/^\@[0-9a-f]{24} delivery \d+: (success|failure|deferral).*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|CNAME_lookup_failed_temporarily)/;
my $result = $1;
$cnt{$result}++;
}
# Caclul des totaux:
foreach (@results){
$cnt{total} = $cnt{total} + $cnt{$_} if $_ !~ /total/;
}
# Si l'argument est "print" on affiche toutes les stats
if ($what eq "print"){
foreach (@results){
print "$_: $cnt{$_}\n";
}
}
# Si l'argument correspond a un compteur definit
# On affiche uniquemment cette valeur
elsif (defined $cnt{$what}){
print "$cnt{$what}\n";
}
# Sinon, on quitte avec une erreur
else{
print "supported items are: ";
foreach (@results){
print "$_ ";
}
print "\n";
exit 1;
}
exit 0;

View File

@ -0,0 +1,31 @@
#!/usr/bin/perl -w
use esmith::ConfigDB;
use MIME::Lite;
use Net::SMTP;
my $c = esmith::ConfigDB->open_ro();
my $domain = $c->get('DomainName')->value();
my $host = $c->get('SystemName')->value();
my $z = $c->get('zabbix-agent');
my $dest = $z->prop('StatusRecipient') || 'admin@' . $domain;
my $smtp = Net::SMTP->new('localhost');
my $mail = MIME::Lite->new(
From => 'smeserver-status@' . $domain,
To => $dest,
Subject => "[STATUS] $host.$domain",
Data => localtime(time)."\n" .
"\n#>tail /var/log/messages :\n" .
`/usr/bin/tail \$(readlink /var/log/messages)` .
"\n#>netstat --numeric-hosts -tpu :\n" .
`/bin/netstat --numeric-hosts -tpu`
);
$smtp->mail('smeserver-status@' . $domain);
$smtp->recipient($dest);
$smtp->data();
$smtp->datasend($mail->as_string);
$smtp->dataend();
$smtp->quit;

356
smeserver-zabbix-agent.spec Normal file
View File

@ -0,0 +1,356 @@
Summary: sme server integration of zabbix agent
Name: smeserver-zabbix-agent
Version: 0.4.8
Release: 4%{?dist}
License: GNU GPL version 2
URL: http://www.zabbix.com/
Group: SMEserver/addon
Source: %{name}-%{version}.tar.xz
BuildArchitectures: noarch
BuildRequires: e-smith-devtools
BuildRoot: /var/tmp/%{name}-%{version}
Requires: e-smith-release >= 7.0
Requires: zabbix-agent => 2.0.0
Requires: zabbix-agent-addons => 0.1.15
Requires: smeserver-remoteuseraccess
Requires: qmqtool
Requires: perl(IO::Socket)
Requires: perl(Net::SSLeay)
Requires: perl(Date::Parse)
Requires: perl(Crypt::OpenSSL::X509)
AutoReqProv: no
%description
smserver integration of zabbix agent.
Zabbix is an entreprise-class open source distributed monitoring
solution
%changelog
* Sat Sep 07 2024 cvs2git.sh aka Brian Read <brianr@koozali.org> 0.4.8-4.sme
- Roll up patches and move to git repo [SME: 12338]
* Sat Sep 07 2024 BogusDateBot
- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday,
by assuming the date is correct and changing the weekday.
* Mon Aug 01 2022 Jean-Philippe Pialasse <tests@pialasse.com> 0.4.8-3.sme
- add to core backup [SME: 12032]
* Thu Apr 01 2021 Jean-Philippe Pialasse <tests@pialasse.com> 0.4.8-2.sme
- initial SME10 import [SME: 11515]
drop in for systemd service file
update event created for automatic install
remove ownership of /var/lib/zabbix/bin
* Fri May 29 2020 Daniel Berteaud <daniel@firewall-services.com> 0.4.8-1
- Adapt regex to match queued emails when spam filtering is disabled
(daniel@firewall-services.com)
* Thu Feb 27 2020 Daniel Berteaud <daniel@firewall-services.com> 0.4.7-1
- Rewrite util_send_status_mail to go through the SMTP server (daniel@firewall-
services.com)
- Remove useless var in spec file (daniel@firewall-services.com)
* Wed Nov 27 2019 Daniel Berteaud <daniel@firewall-services.com> 0.4.6-1
- Remove the git CHANGELOG as it's not generated anymore (daniel@firewall-
services.com)
* Wed Nov 27 2019 Daniel Berteaud <daniel@firewall-services.com> 0.4.5-1
- Adapt spec file for tito (daniel@firewall-services.com)
- Detect if running >= 4.4, and remove vfs.dev.discovery UserParameter in this
case (daniel@firewall-services.com)
* Wed Nov 27 2019 Daniel Berteaud <daniel@firewall-services.com>
- Detect if running >= 4.4, and remove vfs.dev.discovery UserParameter in this
case (daniel@firewall-services.com)
* Tue Nov 26 2019 Daniel Berteaud <daniel@firewall-services.com> 0.4.3-1
- new package built with tito
* Tue May 3 2016 Daniel Berteaud <daniel@firewall-services.com> - 0.4.3-1.sme
- Add dmarc regex in util_parse_mail_in and add support for spf_deny plugin
* Wed Apr 27 2016 Daniel Berteaud <daniel@firewall-services.com> - 0.4.2-1.sme
- Adapt qpsmtpd parser regex to match naughty rejects against the original
plugin
* Tue Apr 19 2016 Daniel Berteaud <daniel@firewall-services.com> - 0.4.1-1.sme
- Adapt util_parse_mail_in and util_count_mail_in to work with qpsmtpd 0.96
- Define %clean before %files so epel-macros don't try to add a default
buggy %clean on el5
* Mon Mar 21 2016 Daniel Berteaud <daniel@firewall-services.com> - 0.4.0-1.sme
- Add support for new encryption features of zabbix 3.0
* Wed Jun 10 2015 Daniel B. <daniel@firewall-services.com> - 0.3.8-1.sme
- Add a random delay before sending the status email
* Mon Jan 5 2015 Daniel B. <daniel@firewall-services.com> - 0.3.7-1.sme
- Requires qmqtool to monitor qmail queue
* Wed Jun 25 2014 Daniel B. <daniel@firewall-services.com> - 0.3.6-1.sme
- Fix a warning in util_send_mail.pl script on EL6
* Wed Jun 11 2014 Daniel B. <daniel@firewall-services.com> - 0.3.5-1.sme
- Fix exec perm on certs check scripts
* Tue May 6 2014 Daniel B. <daniel@firewall-services.com> - 0.3.4-1.sme
- Add support for nmb lookup script
* Wed Feb 19 2014 Daniel B. <daniel@firewall-services.com> - 0.3.3-1.sme
- Fix a typo in dependency
* Wed Feb 19 2014 Daniel B. <daniel@firewall-services.com> - 0.3.2-1.sme
- Add script to monitor PHPki certificates
* Tue Feb 18 2014 Daniel B. <daniel@firewall-services.com> - 0.3.1-1.sme
- Fix a syntaxe error in check_asterisk
* Tue Apr 16 2013 Daniel B. <daniel@firewall-services.com> - 0.3.0-1.sme
- Huge cleanup
- Requires zabbix-agent-addons
* Thu Apr 11 2013 Daniel B. <daniel@firewall-services.com> - 0.2.1-1.sme
- Improvement in mdstat-parser.pl
* Thu Jun 14 2012 Daniel B. <daniel@firewall-services.com> - 0.2.0-1.sme
- Import to GIT
- Remove certificate expiration script
- Make it 2.0 compatible
* Thu Jun 7 2012 Daniel B. <daniel@firewall-services.com> - 0.1-52.sme
- Add missing perl module in dependency
* Thu Jun 7 2012 Daniel B. <daniel@firewall-services.com> - 0.1-51.sme
- Add certificate expiration script
* Fri Oct 28 2011 Daniel B. <daniel@firewall-services.com> - 0.1-50.sme
- Fix a closing bracket in templates
* Wed Oct 26 2011 Daniel B. <daniel@firewall-services.com> - 0.1-49.sme
- Add better asterisk monitoring capabilities
* Fri Jul 08 2011 Daniel B. <daniel@firewall-services.com> - 0.1-48.sme
- Configure timeout from the DB (prop TimeOut)
* Wed May 04 2011 Daniel B. <daniel@firewall-services.com> 0.1-47
- Send status mail with some logs and active connexions (StatusMail prop)
* Thu Sep 02 2010 Daniel B. <daniel@firewall-services.com> 0.1-46
- Add /usr/sbin in path for check_lvm and check_asterisk
* Thu Sep 02 2010 Daniel B. <daniel@firewall-services.com> 0.1-45
- Add basic asterisk monitoring support
- Add basic LVM monitoring support
* Wed Aug 04 2010 Daniel B. <daniel@firewall-services.com> 0.1-44
- Support up to 8 disks for I/O monitoring. Report valid 0 value
for non existing ones to prevent errors in server's log
* Wed Jun 23 2010 Daniel B. <daniel@firewall-services.com> 0.1-43
- Possibility to set Hostname from the DB [SME: 6083]
* Mon May 03 2010 Daniel B. <daniel@firewall-services.com> 0.1-42
- disable MegaCli log (which can break monitoring if log file reaches 2GB)
- report CRITICAL if both CRITICAL and WARNING are found
- add Squid UserParameters (hit ratio, cache size, req per minute)
* Wed Mar 17 2010 Daniel B. <daniel@firewall-services.com> 0.1-41
- read megaraid options from the DB (number of spares, number of
error to ignore)
* Fri Mar 12 2010 Daniel B. <daniel@firewall-services.com> 0.1-40
- update regex for incomming mail stats for newer qpsmtpd
* Wed Feb 17 2010 Daniel B. <daniel@firewall-services.com> 0.1-39
- update megaraid-parser.pl script with options to ignore some errors
* Mon Jan 4 2010 Daniel B. <daniel@firewall-services.com> 0.1-38
- Change UPS UserParameters to use wildcard, so you can monitor several UPS
easily (require changes in the templates on the server side)
* Sun Dec 6 2009 Daniel B. <daniel@firewall-services.com> 0.1-37
- Call megaraid-parser.pl scripts with sudo in zabbix_agentd.conf
* Wed Dec 2 2009 Daniel B. <daniel@firewall-services.com> 0.1-36
- Run megaraid-parser.pl as root (with sudo) instead of granting
zabbix user unrestricted access to MegaCli
* Fri Sep 25 2009 Daniel B. <daniel@firewall-services.com> 0.1-35
- Support up to 8 disks for smart monitoring. Report valid 0 value
for non existing ones to prevent errors in server's log
* Tue Sep 01 2009 Daniel B. <daniel@firewall-services.com> 0.1-34
- Add missing return after smart parameters (if several disks are monitored)
* Mon Aug 31 2009 Daniel B. <daniel@firewall-services.com> 0.1-33
- Add system.smart UserParameter (monitor smart values for configured hard drives)
* Wed Jul 08 2009 Daniel B. <daniel@firewall-services.com> 0.1-32
- Fix megaraid-parser script to support RAID-10 arrays
* Mon Jun 08 2009 Daniel B. <daniel@firewall-services.com> 0.1-31
- Add cpu.number UserParameter (return the number of CPU on the host)
* Wed May 06 2009 Daniel B. <daniel@firewall-services.com> 0.1-30
- Create missing tmp directory
* Mon Apr 27 2009 Daniel B. <daniel@firewall-services.com> 0.1-29
- megaraid-parser.pl is now compatible with newer versions
of MegaCli
- Fix permission on megaraid-parser.pl script
* Thu Apr 23 2009 Daniel B. <daniel@firewall-services.com> 0.1-28
- improvements in sensors script
- Add megaraid-parser.pl script to get more accurate MegaRaid
conrolers informations
- use a cronjob to parse mail logs so multiple zabbix server
can be used. Also, it won't repport false value if your host
has been unreachable for some time
- change output of mdstat-parser.pl to report everything in one
line (looks like megaraid-parser)
* Mon Apr 20 2009 Daniel B. <daniel@firewall-services.com> 0.1-27
- Add updates.available to retrieve the number of updates available
with yum
- Added sensors[*] key to retrieve sensors informations. The value are retrieved
with the script /var/lib/zabbix/bin/sensors which can be customized.
* Fri Mar 27 2009 Daniel B. <daniel@firewall-services.com> 0.1-26
- Add raid.mega.status UserParameters to monitor status of MegaRaid based
raid array
* Tue Mar 24 2009 Daniel B. <daniel@firewall-services.com> 0.1-25
- Add comments for each UserParameter for configuration on the server side
(Type of information, unit, etc...)
* Tue Mar 24 2009 Daniel B. <daniel@firewall-services.com> 0.1-24
- Add raid.sw.status userparameter to report software raid array status
- Remove tabs from spec
- Permission cleanup on scripts
* Wed Mar 18 2009 Daniel B. <daniel@firewall-services.com> 0.1-23
- Correct mysql.size parameter (sudo -u mysql)
* Mon Mar 09 2009 Daniel B. <daniel@firewall-services.com> 0.1-22
- Fix typo in sudoers template (ZABBIX_AGENT_MYSQL)
* Mon Mar 02 2009 Daniel B. <daniel@firewall-services.com> 0.1-21
- Add smeserver-remoteuseraccess as a dependencie (sudoer templates issue)
* Mon Mar 02 2009 Daniel B. <daniel@firewall-services.com> 0.1-20
- Adjust masq service on zabbix-agent-update event
- Add description of Timout directive
- Add BufferSend and BufferSize directive to optimize
agent <-> server communication
* Sun Mar 01 2009 Daniel B. <daniel@firewall-services.com> 0.1-19
- Add size of mysql data (mysql.size)
* Fri Feb 20 2009 Daniel B. <daniel@firewall-services.com> 0.1-18
- Add stats for InternalInterface and ExternalInterface
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-17
- Ignore local delivery from outgoing mail stats
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-16
- Fix a typo in mail.out.failure UserParameters
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-15
- Add UserParameters for outhoing mails statistics
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-14
- add missing other_denied UserParameters for mailStats
- Fix expand-template for /etc/sudoers during zabbix-agent-update event
* Tue Feb 17 2009 Daniel B. <daniel@firewall-services.com> 0.1-13
- Add incoming mails statistics
- Rename signal-event to zabbix-agent-update (to prevent a conflict on
sudoers files which needs to be expanded for server and agent)
* Wed Feb 11 2009 Daniel B. <daniel@firewall-services.com> 0.1-12
- Remove Useless buffers and cache mem
- Add vm.memory.size.pused (used memory in %)
- Add ups.battery.charge for ups
- Added "passive" db parameter
- default access is private
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-11
- Fix permissions on mysqladmin_status script
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-10
- Change used swap key
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-9
- Added userparameters for used swap space used in bytes
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-8
- Correct a type in memory statistics (for cached memory)
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-7
- Report also free, buffers and cached mem so stats are more accurate
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-6
- substract cache/buffer from used mem
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-5
- Change key name for used memory
- Report Used mem instead of total
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-4
- Escape brackets in template
* Tue Feb 10 2009 Daniel B. <daniel@firewall-services.com> 0.1-3
- Add UserParameters to repport amount of used memory
* Mon Feb 9 2009 Daniel B. <daniel@firewall-services.com> 0.1-2
- Add UserParameters to monitor real external IP, UPS status,
mysql stats
* Fri Feb 6 2009 Daniel B. <daniel@firewall-services.com> 0.1-1
- add Hostname directive in zabbix_agentd.conf
* Wed Feb 04 2009 Daniel B. <daniel@firewall-services.com> 0.1-0
- initial release
%prep
%setup
rm -rf .tito
%build
%{__mkdir_p} root/var/lib/zabbix/tmp
perl ./createlinks
%install
rm -rf $RPM_BUILD_ROOT
(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT)
rm -f %{name}-%{version}-filelist
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \
--file /var/lib/zabbix/bin/check_mysqladmin_status_sudo 'attr(0750,root,zabbix)' \
--file /var/lib/zabbix/bin/util_logtail 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/util_count_mail_in 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/util_count_mail_out 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/util_parse_mail_in 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/util_parse_mail_out 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/check_asterisk 'attr(0750,root,zabbix)' \
--file /var/lib/zabbix/bin/util_send_status_mail 'attr(0755,root,root)' \
--file /var/lib/zabbix/bin/disco_certs_sudo 'attr(0750,root,zabbix)' \
--file /var/lib/zabbix/bin/check_certs_sudo 'attr(0750,root,zabbix)' \
--dir /var/lib/zabbix/tmp 'attr(0750,zabbix,zabbix)' \
| grep -P -v '^%dir %attr\(0755,root,root\) /var/lib' \
> %{name}-%{version}-filelist
cat %{name}-%{version}-filelist
%clean
rm -rf $RPM_BUILD_ROOT
%files -f %{name}-%{version}-filelist
%defattr(-,root,root)
%postun
#uninstall
if [ $1 = 0 ] ; then
/etc/init.d/zabbix-agent stop
fi
true