From 127b1311fe8dc8c314010b4118975df0a1b5096f Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Sat, 7 Sep 2024 21:17:46 +1000 Subject: [PATCH] initial commit of file from CVS for smeserver-zabbix-agent on Sat Sep 7 21:17:46 AEST 2024 --- .gitignore | 4 + Makefile | 21 ++ README.md | 17 +- additional/smeserver-zabbix-agent.spec | 338 +++++++++++++++++ contriborbase | 1 + createlinks | 32 ++ .../defaults/zabbix-agent/RemoteCommands | 1 + .../defaults/zabbix-agent/Servers | 1 + .../defaults/zabbix-agent/TCPPort | 1 + .../defaults/zabbix-agent/access | 1 + .../defaults/zabbix-agent/status | 1 + .../configuration/defaults/zabbix-agent/type | 1 + .../template-begin | 21 ++ .../templates/etc/crontab/zabbix_mail_stats | 20 + .../templates/etc/sudoers/00zabbixAgentAlias | 2 + .../templates/etc/sudoers/30zabbixAgent | 2 + .../zabbix_agentd.conf.d/asterisk.conf/10All | 28 ++ .../block_devices.conf/10All | 13 + .../deprecated_cpunum.conf/10All | 14 + .../deprecated_memory.conf/10All | 24 ++ .../deprecated_netstat.conf/10All | 62 +++ .../deprecated_swap.conf/10All | 12 + .../zabbix_agentd.conf.d/extip.conf/10All | 9 + .../zabbix_agentd.conf.d/mail.conf/10In | 15 + .../zabbix_agentd.conf.d/mail.conf/20Out | 16 + .../zabbix_agentd.conf.d/mysql.conf/10All | 15 + .../phpki_certs.conf/10All | 23 ++ .../samba.conf/10nmblookup | 2 + .../zabbix/zabbix_agentd.conf/10zabbixServers | 2 + .../etc/zabbix/zabbix_agentd.conf/15hostname | 6 + .../etc/zabbix/zabbix_agentd.conf/20listen | 11 + .../etc/zabbix/zabbix_agentd.conf/30fork | 1 + .../zabbix/zabbix_agentd.conf/40ActiveBuffers | 2 + .../zabbix/zabbix_agentd.conf/50ActiveServer | 5 + .../zabbix_agentd.conf/60remoteCommands | 1 + .../etc/zabbix/zabbix_agentd.conf/70logs | 5 + .../etc/zabbix/zabbix_agentd.conf/75Include | 1 + .../etc/zabbix/zabbix_agentd.conf/80timeout | 5 + .../etc/zabbix/zabbix_agentd.conf/85TLS | 33 ++ .../zabbix-agent.service.d/51-koozali.conf | 2 + root/var/lib/zabbix/bin/check_asterisk | 210 +++++++++++ root/var/lib/zabbix/bin/check_certs_sudo | 33 ++ .../zabbix/bin/check_mysqladmin_status_sudo | 5 + root/var/lib/zabbix/bin/disco_certs_sudo | 49 +++ root/var/lib/zabbix/bin/util_count_mail_in | 13 + root/var/lib/zabbix/bin/util_count_mail_out | 11 + root/var/lib/zabbix/bin/util_logtail | 95 +++++ root/var/lib/zabbix/bin/util_parse_mail_in | 129 +++++++ root/var/lib/zabbix/bin/util_parse_mail_out | 70 ++++ root/var/lib/zabbix/bin/util_send_status_mail | 31 ++ smeserver-zabbix-agent.spec | 356 ++++++++++++++++++ 51 files changed, 1771 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 additional/smeserver-zabbix-agent.spec create mode 100644 contriborbase create mode 100644 createlinks create mode 100644 root/etc/e-smith/db/configuration/defaults/zabbix-agent/RemoteCommands create mode 100644 root/etc/e-smith/db/configuration/defaults/zabbix-agent/Servers create mode 100644 root/etc/e-smith/db/configuration/defaults/zabbix-agent/TCPPort create mode 100644 root/etc/e-smith/db/configuration/defaults/zabbix-agent/access create mode 100644 root/etc/e-smith/db/configuration/defaults/zabbix-agent/status create mode 100644 root/etc/e-smith/db/configuration/defaults/zabbix-agent/type create mode 100644 root/etc/e-smith/templates/etc/backup-data.d/smeserver-zabbix-agent.include/template-begin create mode 100644 root/etc/e-smith/templates/etc/crontab/zabbix_mail_stats create mode 100644 root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias create mode 100644 root/etc/e-smith/templates/etc/sudoers/30zabbixAgent create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/asterisk.conf/10All create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/block_devices.conf/10All create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_cpunum.conf/10All create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_memory.conf/10All create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_netstat.conf/10All create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_swap.conf/10All create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/extip.conf/10All create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mail.conf/10In create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mail.conf/20Out create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mysql.conf/10All create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/phpki_certs.conf/10All create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/samba.conf/10nmblookup create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/10zabbixServers create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/15hostname create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/20listen create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/30fork create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/40ActiveBuffers create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/50ActiveServer create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/60remoteCommands create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/70logs create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/75Include create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/80timeout create mode 100644 root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/85TLS create mode 100644 root/usr/lib/systemd/system/zabbix-agent.service.d/51-koozali.conf create mode 100644 root/var/lib/zabbix/bin/check_asterisk create mode 100644 root/var/lib/zabbix/bin/check_certs_sudo create mode 100644 root/var/lib/zabbix/bin/check_mysqladmin_status_sudo create mode 100644 root/var/lib/zabbix/bin/disco_certs_sudo create mode 100644 root/var/lib/zabbix/bin/util_count_mail_in create mode 100644 root/var/lib/zabbix/bin/util_count_mail_out create mode 100644 root/var/lib/zabbix/bin/util_logtail create mode 100644 root/var/lib/zabbix/bin/util_parse_mail_in create mode 100644 root/var/lib/zabbix/bin/util_parse_mail_out create mode 100644 root/var/lib/zabbix/bin/util_send_status_mail create mode 100644 smeserver-zabbix-agent.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbb3a13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.rpm +*.log +*spec-20* +*.tar.gz diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..13cd13d --- /dev/null +++ b/Makefile @@ -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) diff --git a/README.md b/README.md index 5572284..0cdefcf 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ -# smeserver-zabbix-agent +# smeserver-zabbix-agent -SMEServer Koozali developed git repo for smeserver-zabbix-agent smecontribs \ No newline at end of file +SMEServer Koozali developed git repo for smeserver-zabbix-agent smecontribs + +## Wiki +
https://wiki.koozali.org/Zabbix-agent +
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 + +
*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* +
diff --git a/additional/smeserver-zabbix-agent.spec b/additional/smeserver-zabbix-agent.spec new file mode 100644 index 0000000..07c775f --- /dev/null +++ b/additional/smeserver-zabbix-agent.spec @@ -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 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 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 0.4.6-1 +- Remove the git CHANGELOG as it's not generated anymore (daniel@firewall- + services.com) + +* Wed Nov 27 2019 Daniel Berteaud 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 +- Detect if running >= 4.4, and remove vfs.dev.discovery UserParameter in this + case (daniel@firewall-services.com) + +* Tue Nov 26 2019 Daniel Berteaud 0.4.3-1 +- new package built with tito + +* Tue May 3 2016 Daniel Berteaud - 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 - 0.4.2-1.sme +- Adapt qpsmtpd parser regex to match naughty rejects against the original + plugin + +* Tue Apr 19 2016 Daniel Berteaud - 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 - 0.4.0-1.sme +- Add support for new encryption features of zabbix 3.0 + +* Wed Jun 10 2015 Daniel B. - 0.3.8-1.sme +- Add a random delay before sending the status email + +* Mon Jan 5 2015 Daniel B. - 0.3.7-1.sme +- Requires qmqtool to monitor qmail queue + +* Wed Jun 25 2014 Daniel B. - 0.3.6-1.sme +- Fix a warning in util_send_mail.pl script on EL6 + +* Wed Jun 11 2014 Daniel B. - 0.3.5-1.sme +- Fix exec perm on certs check scripts + +* Tue May 6 2014 Daniel B. - 0.3.4-1.sme +- Add support for nmb lookup script + +* Wed Feb 19 2014 Daniel B. - 0.3.3-1.sme +- Fix a typo in dependency + +* Wed Feb 19 2014 Daniel B. - 0.3.2-1.sme +- Add script to monitor PHPki certificates + +* Tue Feb 18 2014 Daniel B. - 0.3.1-1.sme +- Fix a syntaxe error in check_asterisk + +* Tue Apr 16 2013 Daniel B. - 0.3.0-1.sme +- Huge cleanup +- Requires zabbix-agent-addons + +* Thu Apr 11 2013 Daniel B. - 0.2.1-1.sme +- Improvement in mdstat-parser.pl + +* Thu Jun 14 2012 Daniel B. - 0.2.0-1.sme +- Import to GIT +- Remove certificate expiration script +- Make it 2.0 compatible + +* Thu Jun 7 2012 Daniel B. - 0.1-52.sme +- Add missing perl module in dependency + +* Thu Jun 7 2012 Daniel B. - 0.1-51.sme +- Add certificate expiration script + +* Fri Oct 28 2011 Daniel B. - 0.1-50.sme +- Fix a closing bracket in templates + +* Wed Oct 26 2011 Daniel B. - 0.1-49.sme +- Add better asterisk monitoring capabilities + +* Fri Jul 08 2011 Daniel B. - 0.1-48.sme +- Configure timeout from the DB (prop TimeOut) + +* Wed May 04 2011 Daniel B. 0.1-47 +- Send status mail with some logs and active connexions (StatusMail prop) + +* Thu Sep 02 2010 Daniel B. 0.1-46 +- Add /usr/sbin in path for check_lvm and check_asterisk + +* Thu Sep 02 2010 Daniel B. 0.1-45 +- Add basic asterisk monitoring support +- Add basic LVM monitoring support + +* Wed Aug 04 2010 Daniel B. 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. 0.1-43 +- Possibility to set Hostname from the DB [SME: 6083] + +* Mon May 03 2010 Daniel B. 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. 0.1-41 +- read megaraid options from the DB (number of spares, number of + error to ignore) + +* Fri Mar 12 2010 Daniel B. 0.1-40 +- update regex for incomming mail stats for newer qpsmtpd + +* Wed Feb 17 2010 Daniel B. 0.1-39 +- update megaraid-parser.pl script with options to ignore some errors + +* Mon Jan 4 2010 Daniel B. 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. 0.1-37 +- Call megaraid-parser.pl scripts with sudo in zabbix_agentd.conf + +* Wed Dec 2 2009 Daniel B. 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. 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. 0.1-34 +- Add missing return after smart parameters (if several disks are monitored) + +* Mon Aug 31 2009 Daniel B. 0.1-33 +- Add system.smart UserParameter (monitor smart values for configured hard drives) + +* Wed Jul 08 2009 Daniel B. 0.1-32 +- Fix megaraid-parser script to support RAID-10 arrays + +* Mon Jun 08 2009 Daniel B. 0.1-31 +- Add cpu.number UserParameter (return the number of CPU on the host) + +* Wed May 06 2009 Daniel B. 0.1-30 +- Create missing tmp directory + +* Mon Apr 27 2009 Daniel B. 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. 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. 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. 0.1-26 +- Add raid.mega.status UserParameters to monitor status of MegaRaid based + raid array + +* Tue Mar 24 2009 Daniel B. 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. 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. 0.1-23 +- Correct mysql.size parameter (sudo -u mysql) + +* Mon Mar 09 2009 Daniel B. 0.1-22 +- Fix typo in sudoers template (ZABBIX_AGENT_MYSQL) + +* Mon Mar 02 2009 Daniel B. 0.1-21 +- Add smeserver-remoteuseraccess as a dependencie (sudoer templates issue) + +* Mon Mar 02 2009 Daniel B. 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. 0.1-19 +- Add size of mysql data (mysql.size) + +* Fri Feb 20 2009 Daniel B. 0.1-18 +- Add stats for InternalInterface and ExternalInterface + +* Tue Feb 17 2009 Daniel B. 0.1-17 +- Ignore local delivery from outgoing mail stats + +* Tue Feb 17 2009 Daniel B. 0.1-16 +- Fix a typo in mail.out.failure UserParameters + +* Tue Feb 17 2009 Daniel B. 0.1-15 +- Add UserParameters for outhoing mails statistics + +* Tue Feb 17 2009 Daniel B. 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. 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. 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. 0.1-11 +- Fix permissions on mysqladmin_status script + +* Tue Feb 10 2009 Daniel B. 0.1-10 +- Change used swap key + +* Tue Feb 10 2009 Daniel B. 0.1-9 +- Added userparameters for used swap space used in bytes + +* Tue Feb 10 2009 Daniel B. 0.1-8 +- Correct a type in memory statistics (for cached memory) + +* Tue Feb 10 2009 Daniel B. 0.1-7 +- Report also free, buffers and cached mem so stats are more accurate + +* Tue Feb 10 2009 Daniel B. 0.1-6 +- substract cache/buffer from used mem + +* Tue Feb 10 2009 Daniel B. 0.1-5 +- Change key name for used memory +- Report Used mem instead of total + +* Tue Feb 10 2009 Daniel B. 0.1-4 +- Escape brackets in template + +* Tue Feb 10 2009 Daniel B. 0.1-3 +- Add UserParameters to repport amount of used memory + +* Mon Feb 9 2009 Daniel B. 0.1-2 +- Add UserParameters to monitor real external IP, UPS status, + mysql stats + +* Fri Feb 6 2009 Daniel B. 0.1-1 +- add Hostname directive in zabbix_agentd.conf + +* Wed Feb 04 2009 Daniel B. 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 diff --git a/contriborbase b/contriborbase new file mode 100644 index 0000000..9b7fd51 --- /dev/null +++ b/contriborbase @@ -0,0 +1 @@ +contribs10 diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..f40f338 --- /dev/null +++ b/createlinks @@ -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"); diff --git a/root/etc/e-smith/db/configuration/defaults/zabbix-agent/RemoteCommands b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/RemoteCommands new file mode 100644 index 0000000..7a68b11 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/RemoteCommands @@ -0,0 +1 @@ +disabled diff --git a/root/etc/e-smith/db/configuration/defaults/zabbix-agent/Servers b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/Servers new file mode 100644 index 0000000..7b9ad53 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/Servers @@ -0,0 +1 @@ +127.0.0.1 diff --git a/root/etc/e-smith/db/configuration/defaults/zabbix-agent/TCPPort b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/TCPPort new file mode 100644 index 0000000..f8d7468 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/TCPPort @@ -0,0 +1 @@ +10050 diff --git a/root/etc/e-smith/db/configuration/defaults/zabbix-agent/access b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/access new file mode 100644 index 0000000..3e18ebf --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/access @@ -0,0 +1 @@ +private diff --git a/root/etc/e-smith/db/configuration/defaults/zabbix-agent/status b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/zabbix-agent/type b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/type new file mode 100644 index 0000000..24e1098 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/zabbix-agent/type @@ -0,0 +1 @@ +service diff --git a/root/etc/e-smith/templates/etc/backup-data.d/smeserver-zabbix-agent.include/template-begin b/root/etc/e-smith/templates/etc/backup-data.d/smeserver-zabbix-agent.include/template-begin new file mode 100644 index 0000000..f74560e --- /dev/null +++ b/root/etc/e-smith/templates/etc/backup-data.d/smeserver-zabbix-agent.include/template-begin @@ -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; +} +} diff --git a/root/etc/e-smith/templates/etc/crontab/zabbix_mail_stats b/root/etc/e-smith/templates/etc/crontab/zabbix_mail_stats new file mode 100644 index 0000000..94f7c54 --- /dev/null +++ b/root/etc/e-smith/templates/etc/crontab/zabbix_mail_stats @@ -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 + } +} +} diff --git a/root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias b/root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias new file mode 100644 index 0000000..16fa86d --- /dev/null +++ b/root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias @@ -0,0 +1,2 @@ +Cmnd_Alias ZABBIX_AGENT = /var/lib/zabbix/bin/*_sudo + diff --git a/root/etc/e-smith/templates/etc/sudoers/30zabbixAgent b/root/etc/e-smith/templates/etc/sudoers/30zabbixAgent new file mode 100644 index 0000000..64aaf52 --- /dev/null +++ b/root/etc/e-smith/templates/etc/sudoers/30zabbixAgent @@ -0,0 +1,2 @@ +zabbix ALL=(root) NOPASSWD: ZABBIX_AGENT + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/asterisk.conf/10All b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/asterisk.conf/10All new file mode 100644 index 0000000..272cdb9 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/asterisk.conf/10All @@ -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 +} + +} + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/block_devices.conf/10All b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/block_devices.conf/10All new file mode 100644 index 0000000..634166c --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/block_devices.conf/10All @@ -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 + } +} + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_cpunum.conf/10All b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_cpunum.conf/10All new file mode 100644 index 0000000..457b4fa --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_cpunum.conf/10All @@ -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 + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_memory.conf/10All b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_memory.conf/10All new file mode 100644 index 0000000..2a294dd --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_memory.conf/10All @@ -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\}'))) + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_netstat.conf/10All b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_netstat.conf/10All new file mode 100644 index 0000000..a959195 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_netstat.conf/10All @@ -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 +} +} + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_swap.conf/10All b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_swap.conf/10All new file mode 100644 index 0000000..00e457e --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/deprecated_swap.conf/10All @@ -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\}' + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/extip.conf/10All b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/extip.conf/10All new file mode 100644 index 0000000..7bdd04b --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/extip.conf/10All @@ -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=" + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mail.conf/10In b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mail.conf/10In new file mode 100644 index 0000000..e56cb74 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mail.conf/10In @@ -0,0 +1,15 @@ +# Incomming mails statistics + +# Description: Incoming Mail +# Type: Agent or Agent (active) +# Key: mail.in[] (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 + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mail.conf/20Out b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mail.conf/20Out new file mode 100644 index 0000000..feac236 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mail.conf/20Out @@ -0,0 +1,16 @@ +# Outgoing mails statistics + +# Description: Incoming Mail +# Type: Agent or Agent (active) +# Key: mail.out.[] (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 + + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mysql.conf/10All b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mysql.conf/10All new file mode 100644 index 0000000..d9162d6 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/mysql.conf/10All @@ -0,0 +1,15 @@ + +# Some stats about MySQL + +# Description: MySQL +# Type: Agent or Agent (active) +# Type of information: Numeric (float) +# Unit: (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 + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/phpki_certs.conf/10All b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/phpki_certs.conf/10All new file mode 100644 index 0000000..4e8954b --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/phpki_certs.conf/10All @@ -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 .= ''; + +} diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/samba.conf/10nmblookup b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/samba.conf/10nmblookup new file mode 100644 index 0000000..db22bee --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf.d/samba.conf/10nmblookup @@ -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};} diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/10zabbixServers b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/10zabbixServers new file mode 100644 index 0000000..d4463fe --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/10zabbixServers @@ -0,0 +1,2 @@ +Server={ (${'zabbix-agent'}{'Servers'} || '127.0.0.1'); } + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/15hostname b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/15hostname new file mode 100644 index 0000000..c9b06e2 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/15hostname @@ -0,0 +1,6 @@ +{ + +my $host = (${'zabbix-agent'}{'Hostname'} || $SystemName.".".$DomainName); +$OUT = "Hostname=$host\n"; + +} diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/20listen b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/20listen new file mode 100644 index 0000000..9b4f07e --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/20listen @@ -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 ''); + +} diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/30fork b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/30fork new file mode 100644 index 0000000..39c503e --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/30fork @@ -0,0 +1 @@ +StartAgents=5 diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/40ActiveBuffers b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/40ActiveBuffers new file mode 100644 index 0000000..2fefc76 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/40ActiveBuffers @@ -0,0 +1,2 @@ +BufferSend=30 +BufferSize=100 diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/50ActiveServer b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/50ActiveServer new file mode 100644 index 0000000..c8d174e --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/50ActiveServer @@ -0,0 +1,5 @@ +{ +if ((${'zabbix-agent'}{'ServerActive'} || '') ne ''){ + $OUT .= "ServerActive=${'zabbix-agent'}{'ServerActive'}\n"; +} +} diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/60remoteCommands b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/60remoteCommands new file mode 100644 index 0000000..218d353 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/60remoteCommands @@ -0,0 +1 @@ +EnableRemoteCommands={ (${'zabbix-agent'}{'RemoteCommands'} || 'disabled') eq 'enabled' ? '1':'0'; } diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/70logs b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/70logs new file mode 100644 index 0000000..d483ea0 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/70logs @@ -0,0 +1,5 @@ +DebugLevel=3 +PidFile=/var/run/zabbix/zabbix_agentd.pid +LogFile=/var/log/zabbix/zabbix_agentd.log +LogFileSize=10 + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/75Include b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/75Include new file mode 100644 index 0000000..3288229 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/75Include @@ -0,0 +1 @@ +Include=/etc/zabbix/zabbix_agentd.conf.d/ diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/80timeout b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/80timeout new file mode 100644 index 0000000..3e3bbd1 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/80timeout @@ -0,0 +1,5 @@ +# Spend no more than Timeout seconds on processing +# Must be between 1 and 30 + +Timeout={${'zabbix-agent'}{'TimeOut'} || '3'} + diff --git a/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/85TLS b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/85TLS new file mode 100644 index 0000000..0ef3b84 --- /dev/null +++ b/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/85TLS @@ -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 +} diff --git a/root/usr/lib/systemd/system/zabbix-agent.service.d/51-koozali.conf b/root/usr/lib/systemd/system/zabbix-agent.service.d/51-koozali.conf new file mode 100644 index 0000000..aa4f147 --- /dev/null +++ b/root/usr/lib/systemd/system/zabbix-agent.service.d/51-koozali.conf @@ -0,0 +1,2 @@ +[Install] +WantedBy=sme-server.target diff --git a/root/var/lib/zabbix/bin/check_asterisk b/root/var/lib/zabbix/bin/check_asterisk new file mode 100644 index 0000000..d61682b --- /dev/null +++ b/root/var/lib/zabbix/bin/check_asterisk @@ -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 +} + diff --git a/root/var/lib/zabbix/bin/check_certs_sudo b/root/var/lib/zabbix/bin/check_certs_sudo new file mode 100644 index 0000000..5ae3641 --- /dev/null +++ b/root/var/lib/zabbix/bin/check_certs_sudo @@ -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"; +} + diff --git a/root/var/lib/zabbix/bin/check_mysqladmin_status_sudo b/root/var/lib/zabbix/bin/check_mysqladmin_status_sudo new file mode 100644 index 0000000..1c1bbbb --- /dev/null +++ b/root/var/lib/zabbix/bin/check_mysqladmin_status_sudo @@ -0,0 +1,5 @@ +#!/bin/sh +HOME=/root + +exec /usr/bin/mysqladmin status + diff --git a/root/var/lib/zabbix/bin/disco_certs_sudo b/root/var/lib/zabbix/bin/disco_certs_sudo new file mode 100644 index 0000000..88c1ecf --- /dev/null +++ b/root/var/lib/zabbix/bin/disco_certs_sudo @@ -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 (){ + 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); diff --git a/root/var/lib/zabbix/bin/util_count_mail_in b/root/var/lib/zabbix/bin/util_count_mail_in new file mode 100644 index 0000000..e6aa1d0 --- /dev/null +++ b/root/var/lib/zabbix/bin/util_count_mail_in @@ -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 + + diff --git a/root/var/lib/zabbix/bin/util_count_mail_out b/root/var/lib/zabbix/bin/util_count_mail_out new file mode 100644 index 0000000..8bab864 --- /dev/null +++ b/root/var/lib/zabbix/bin/util_count_mail_out @@ -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 + diff --git a/root/var/lib/zabbix/bin/util_logtail b/root/var/lib/zabbix/bin/util_logtail new file mode 100644 index 0000000..e44d15d --- /dev/null +++ b/root/var/lib/zabbix/bin/util_logtail @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# Copyright (C) 2009 Daniel Berteaud +# Copyright (C) 2003 Jonathan Middleton + +# 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)) { + $_ = ; + unless (! defined $_) { + chomp $_; + $inode = $_; + $_ = ; + 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 () { + 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; + diff --git a/root/var/lib/zabbix/bin/util_parse_mail_in b/root/var/lib/zabbix/bin/util_parse_mail_in new file mode 100644 index 0000000..598d366 --- /dev/null +++ b/root/var/lib/zabbix/bin/util_parse_mail_in @@ -0,0 +1,129 @@ +#!/usr/bin/perl -w + +# Copyright (C) 2009-2016 Daniel Berteaud + +# 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 () { + 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; diff --git a/root/var/lib/zabbix/bin/util_parse_mail_out b/root/var/lib/zabbix/bin/util_parse_mail_out new file mode 100644 index 0000000..58de9ff --- /dev/null +++ b/root/var/lib/zabbix/bin/util_parse_mail_out @@ -0,0 +1,70 @@ +#!/usr/bin/perl -w + +# Copyright (C) 2009 Daniel Berteaud + +# 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 () { + 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; + diff --git a/root/var/lib/zabbix/bin/util_send_status_mail b/root/var/lib/zabbix/bin/util_send_status_mail new file mode 100644 index 0000000..57481a5 --- /dev/null +++ b/root/var/lib/zabbix/bin/util_send_status_mail @@ -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; + diff --git a/smeserver-zabbix-agent.spec b/smeserver-zabbix-agent.spec new file mode 100644 index 0000000..4b6aaf9 --- /dev/null +++ b/smeserver-zabbix-agent.spec @@ -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 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 0.4.8-3.sme +- add to core backup [SME: 12032] + +* Thu Apr 01 2021 Jean-Philippe Pialasse 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 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 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 0.4.6-1 +- Remove the git CHANGELOG as it's not generated anymore (daniel@firewall- + services.com) + +* Wed Nov 27 2019 Daniel Berteaud 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 +- Detect if running >= 4.4, and remove vfs.dev.discovery UserParameter in this + case (daniel@firewall-services.com) + +* Tue Nov 26 2019 Daniel Berteaud 0.4.3-1 +- new package built with tito + +* Tue May 3 2016 Daniel Berteaud - 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 - 0.4.2-1.sme +- Adapt qpsmtpd parser regex to match naughty rejects against the original + plugin + +* Tue Apr 19 2016 Daniel Berteaud - 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 - 0.4.0-1.sme +- Add support for new encryption features of zabbix 3.0 + +* Wed Jun 10 2015 Daniel B. - 0.3.8-1.sme +- Add a random delay before sending the status email + +* Mon Jan 5 2015 Daniel B. - 0.3.7-1.sme +- Requires qmqtool to monitor qmail queue + +* Wed Jun 25 2014 Daniel B. - 0.3.6-1.sme +- Fix a warning in util_send_mail.pl script on EL6 + +* Wed Jun 11 2014 Daniel B. - 0.3.5-1.sme +- Fix exec perm on certs check scripts + +* Tue May 6 2014 Daniel B. - 0.3.4-1.sme +- Add support for nmb lookup script + +* Wed Feb 19 2014 Daniel B. - 0.3.3-1.sme +- Fix a typo in dependency + +* Wed Feb 19 2014 Daniel B. - 0.3.2-1.sme +- Add script to monitor PHPki certificates + +* Tue Feb 18 2014 Daniel B. - 0.3.1-1.sme +- Fix a syntaxe error in check_asterisk + +* Tue Apr 16 2013 Daniel B. - 0.3.0-1.sme +- Huge cleanup +- Requires zabbix-agent-addons + +* Thu Apr 11 2013 Daniel B. - 0.2.1-1.sme +- Improvement in mdstat-parser.pl + +* Thu Jun 14 2012 Daniel B. - 0.2.0-1.sme +- Import to GIT +- Remove certificate expiration script +- Make it 2.0 compatible + +* Thu Jun 7 2012 Daniel B. - 0.1-52.sme +- Add missing perl module in dependency + +* Thu Jun 7 2012 Daniel B. - 0.1-51.sme +- Add certificate expiration script + +* Fri Oct 28 2011 Daniel B. - 0.1-50.sme +- Fix a closing bracket in templates + +* Wed Oct 26 2011 Daniel B. - 0.1-49.sme +- Add better asterisk monitoring capabilities + +* Fri Jul 08 2011 Daniel B. - 0.1-48.sme +- Configure timeout from the DB (prop TimeOut) + +* Wed May 04 2011 Daniel B. 0.1-47 +- Send status mail with some logs and active connexions (StatusMail prop) + +* Thu Sep 02 2010 Daniel B. 0.1-46 +- Add /usr/sbin in path for check_lvm and check_asterisk + +* Thu Sep 02 2010 Daniel B. 0.1-45 +- Add basic asterisk monitoring support +- Add basic LVM monitoring support + +* Wed Aug 04 2010 Daniel B. 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. 0.1-43 +- Possibility to set Hostname from the DB [SME: 6083] + +* Mon May 03 2010 Daniel B. 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. 0.1-41 +- read megaraid options from the DB (number of spares, number of + error to ignore) + +* Fri Mar 12 2010 Daniel B. 0.1-40 +- update regex for incomming mail stats for newer qpsmtpd + +* Wed Feb 17 2010 Daniel B. 0.1-39 +- update megaraid-parser.pl script with options to ignore some errors + +* Mon Jan 4 2010 Daniel B. 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. 0.1-37 +- Call megaraid-parser.pl scripts with sudo in zabbix_agentd.conf + +* Wed Dec 2 2009 Daniel B. 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. 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. 0.1-34 +- Add missing return after smart parameters (if several disks are monitored) + +* Mon Aug 31 2009 Daniel B. 0.1-33 +- Add system.smart UserParameter (monitor smart values for configured hard drives) + +* Wed Jul 08 2009 Daniel B. 0.1-32 +- Fix megaraid-parser script to support RAID-10 arrays + +* Mon Jun 08 2009 Daniel B. 0.1-31 +- Add cpu.number UserParameter (return the number of CPU on the host) + +* Wed May 06 2009 Daniel B. 0.1-30 +- Create missing tmp directory + +* Mon Apr 27 2009 Daniel B. 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. 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. 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. 0.1-26 +- Add raid.mega.status UserParameters to monitor status of MegaRaid based + raid array + +* Tue Mar 24 2009 Daniel B. 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. 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. 0.1-23 +- Correct mysql.size parameter (sudo -u mysql) + +* Mon Mar 09 2009 Daniel B. 0.1-22 +- Fix typo in sudoers template (ZABBIX_AGENT_MYSQL) + +* Mon Mar 02 2009 Daniel B. 0.1-21 +- Add smeserver-remoteuseraccess as a dependencie (sudoer templates issue) + +* Mon Mar 02 2009 Daniel B. 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. 0.1-19 +- Add size of mysql data (mysql.size) + +* Fri Feb 20 2009 Daniel B. 0.1-18 +- Add stats for InternalInterface and ExternalInterface + +* Tue Feb 17 2009 Daniel B. 0.1-17 +- Ignore local delivery from outgoing mail stats + +* Tue Feb 17 2009 Daniel B. 0.1-16 +- Fix a typo in mail.out.failure UserParameters + +* Tue Feb 17 2009 Daniel B. 0.1-15 +- Add UserParameters for outhoing mails statistics + +* Tue Feb 17 2009 Daniel B. 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. 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. 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. 0.1-11 +- Fix permissions on mysqladmin_status script + +* Tue Feb 10 2009 Daniel B. 0.1-10 +- Change used swap key + +* Tue Feb 10 2009 Daniel B. 0.1-9 +- Added userparameters for used swap space used in bytes + +* Tue Feb 10 2009 Daniel B. 0.1-8 +- Correct a type in memory statistics (for cached memory) + +* Tue Feb 10 2009 Daniel B. 0.1-7 +- Report also free, buffers and cached mem so stats are more accurate + +* Tue Feb 10 2009 Daniel B. 0.1-6 +- substract cache/buffer from used mem + +* Tue Feb 10 2009 Daniel B. 0.1-5 +- Change key name for used memory +- Report Used mem instead of total + +* Tue Feb 10 2009 Daniel B. 0.1-4 +- Escape brackets in template + +* Tue Feb 10 2009 Daniel B. 0.1-3 +- Add UserParameters to repport amount of used memory + +* Mon Feb 9 2009 Daniel B. 0.1-2 +- Add UserParameters to monitor real external IP, UPS status, + mysql stats + +* Fri Feb 6 2009 Daniel B. 0.1-1 +- add Hostname directive in zabbix_agentd.conf + +* Wed Feb 04 2009 Daniel B. 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