From 136225c97ab27fa11812c77a640894860c52d868 Mon Sep 17 00:00:00 2001 From: Viktor Ganin Date: Fri, 18 Oct 2019 09:19:10 +0200 Subject: [PATCH 1/4] Add rpkg spec file for epel 7/8 --- .gitignore | 1 + libzbxpgsql.spec.rpkg | 68 +++++++++++++++++++++++++++++++++++++++++++ rpkg.macros | 14 +++++++++ 3 files changed, 83 insertions(+) create mode 100644 libzbxpgsql.spec.rpkg create mode 100755 rpkg.macros diff --git a/.gitignore b/.gitignore index fe6f478..65ed090 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ src/**/Makefile stamp-h1 zabbix-*/ zabbix_agent_bench +.idea/ \ No newline at end of file diff --git a/libzbxpgsql.spec.rpkg b/libzbxpgsql.spec.rpkg new file mode 100644 index 0000000..54a2e4e --- /dev/null +++ b/libzbxpgsql.spec.rpkg @@ -0,0 +1,68 @@ +%define main_version 4.0 +%define minor_version 12 +%define module_dir src/modules + +Name: {{{ git_dir_name }}} +Version: {{{ git_tag_last }}} +Release: {{{ git_commits_since_last_tag_add1 }}}%{?dist} +Summary: PostgreSQL monitoring module for Zabbix + +Group: Applications/Internet +License: GPLv2 +URL: https://github.com/cavaliercoder/libzbxpgsql +VCS: {{{ git_dir_vcs }}} + +Source: {{{ git_dir_pack }}} + +Requires: zabbix-agent >= 4.0.0, zabbix-agent < 4.1.0 +# minimum libpq version based on latest patch of RHEL 5 +Requires : postgresql-libs >= 8.1.23 + +BuildRequires: systemd, gcc, libtool, libconfig-devel, postgresql-devel +Requires(post): systemd +Requires(preun): systemd + +%description +libzbxpgsql is a comprehensive PostgreSQL discovery and monitoring module for the Zabbix monitoring agent written in C. + +%global debug_package %{nil} + +%prep +{{{ git_dir_setup_macro }}} +curl -o /tmp/zbx.rpm https://repo.zabbix.com/zabbix/%{main_version}/rhel/%{?rhel}/SRPMS/zabbix-%{main_version}.%{minor_version}-1.el%{?rhel}.src.rpm +rpm -i /tmp/zbx.rpm +%setup -qTcn zabbix-%{main_version}.%{minor_version} +tar --strip-components=1 -xf %{_topdir}/SOURCES/zabbix-%{main_version}.%{minor_version}.tar.gz +echo 'LoadModule=%{name}.so' > %{_topdir}/SOURCES/%{name}.conf +cp -r %{_topdir}/BUILD/%{name}- %{_topdir}/BUILD/zabbix-%{main_version}.%{minor_version}/src/modules + +%build +cd src/modules/%{name}- +./autogen.sh +%configure --with-zabbix=%{_topdir}/BUILD/zabbix-%{main_version}.%{minor_version} +make + +%install +install --directory %{buildroot}%{_libdir}/zabbix/modules/ +install --directory %{buildroot}/etc/zabbix/zabbix_agentd.d/ + +install -m 0755 %{_topdir}/BUILD/zabbix-%{main_version}.%{minor_version}/%{module_dir}/%{name}-/src/.libs/%{name}.so %{buildroot}%{_libdir}/zabbix/modules/ +install -m 0644 %{_topdir}/BUILD/zabbix-%{main_version}.%{minor_version}/src/modules/%{name}-/conf/%{name}.conf %{buildroot}/etc/zabbix/ +install -m 0644 %{_topdir}/SOURCES/%{name}.conf %{buildroot}/etc/zabbix/zabbix_agentd.d/ + +%clean +rm -rf %{buildroot} + +%files +/%{_libdir}/zabbix/modules/ +/etc/zabbix/%{name}.conf +/etc/zabbix/zabbix_agentd.d/%{name}.conf + +%post +/usr/bin/systemctl try-restart zabbix-agent.service >/dev/null 2>&1 || : + +%postun +/usr/bin/systemctl try-restart zabbix-agent.service >/dev/null 2>&1 || : + +%changelog +{{{ git_changelog }}} diff --git a/rpkg.macros b/rpkg.macros new file mode 100755 index 0000000..27b6abb --- /dev/null +++ b/rpkg.macros @@ -0,0 +1,14 @@ +function git_commits_no { + total_commits="$(git rev-list --all --count)" + echo -n "$total_commits" + } + +function git_tag_last { + tag_last="$(git describe --abbrev=0 | tr -d v)" + echo -n "$tag_last" + } + +function git_commits_since_last_tag_add1 { + commits_since_since_last_tag="$(expr $(git rev-list `git rev-list --tags --no-walk --max-count=1`..HEAD --count) \+ \1)" + echo -n $commits_since_since_last_tag + } \ No newline at end of file From 6861a9a6e0aa43c47d0a09682c4c942c9d29c22f Mon Sep 17 00:00:00 2001 From: Viktor Ganin <12952853+v1k-t0r@users.noreply.github.com> Date: Mon, 28 Oct 2019 16:44:42 +0100 Subject: [PATCH 2/4] Update libzbxpgsql.spec.rpkg --- libzbxpgsql.spec.rpkg | 1 + 1 file changed, 1 insertion(+) diff --git a/libzbxpgsql.spec.rpkg b/libzbxpgsql.spec.rpkg index 54a2e4e..02196a8 100644 --- a/libzbxpgsql.spec.rpkg +++ b/libzbxpgsql.spec.rpkg @@ -37,6 +37,7 @@ echo 'LoadModule=%{name}.so' > %{_topdir}/SOURCES/%{name}.conf cp -r %{_topdir}/BUILD/%{name}- %{_topdir}/BUILD/zabbix-%{main_version}.%{minor_version}/src/modules %build +./configure cd src/modules/%{name}- ./autogen.sh %configure --with-zabbix=%{_topdir}/BUILD/zabbix-%{main_version}.%{minor_version} From 820f8c7def76befc31ae824f4cacf7923e9154ed Mon Sep 17 00:00:00 2001 From: Viktor Ganin <12952853+v1k-t0r@users.noreply.github.com> Date: Wed, 30 Oct 2019 11:46:44 +0100 Subject: [PATCH 3/4] Update rpkg.macros --- rpkg.macros | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpkg.macros b/rpkg.macros index 27b6abb..750fa0d 100755 --- a/rpkg.macros +++ b/rpkg.macros @@ -11,4 +11,4 @@ function git_tag_last { function git_commits_since_last_tag_add1 { commits_since_since_last_tag="$(expr $(git rev-list `git rev-list --tags --no-walk --max-count=1`..HEAD --count) \+ \1)" echo -n $commits_since_since_last_tag - } \ No newline at end of file + } From d0529f1d08dcab1d4534c0753be77df0a72ce2fd Mon Sep 17 00:00:00 2001 From: Viktor Ganin <12952853+v1k-t0r@users.noreply.github.com> Date: Wed, 30 Oct 2019 11:47:50 +0100 Subject: [PATCH 4/4] Update .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 65ed090..8cdcff9 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,4 @@ src/**/Makefile stamp-h1 zabbix-*/ zabbix_agent_bench -.idea/ \ No newline at end of file +.idea/