pcp/0008-pmlogger_daily-add-systemd-timers-as-cron-alternativ.patch
David Disseldorp e303564cab Accepting request 663403 from home:dmdiss:fate326864_pcp_42
- Use systemd timers instead of crontab; (bsc#1115413).
  + 0007-pmie-add-systemd-timers-as-cron-alternative.patch
  + 0008-pmlogger_daily-add-systemd-timers-as-cron-alternativ.patch
  + 0009-pmlogger_daily_report-add-systemd-timers-as-cron-alt.patch

- Upgrade to 4.2.0 (fate#326865)
- python package dependency changes
  + add setuptools and python-requests
  + fix python-jsonpointer
  + disable pcp-pmda-postgresql due to missing psycopg2 dependency

OBS-URL: https://build.opensuse.org/request/show/663403
OBS-URL: https://build.opensuse.org/package/show/Base:System/pcp?expand=0&rev=65
2019-01-08 10:31:11 +00:00

186 lines
6.4 KiB
Diff

From 4482bde0673fe1e548060a5c7ef6f58cf43209c3 Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Mon, 7 Jan 2019 02:07:01 +0100
Subject: [PATCH] pmlogger_daily: add systemd timers as cron alternative
The timer and service files are installed by default with
ENABLE_SYSTEMD. crontab.docker is kept as-is.
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
src/pmlogger/GNUmakefile | 32 ++++++++++++++++++++++++++--
src/pmlogger/pmlogger_daily.service.in | 8 +++++++
src/pmlogger/pmlogger_daily.timer | 8 +++++++
src/pmlogger/pmlogger_daily_check.service.in | 8 +++++++
src/pmlogger/pmlogger_daily_check.timer | 9 ++++++++
src/pmlogger/pmlogger_daily_poll.service.in | 8 +++++++
src/pmlogger/pmlogger_daily_poll.timer | 8 +++++++
7 files changed, 79 insertions(+), 2 deletions(-)
create mode 100644 src/pmlogger/pmlogger_daily.service.in
create mode 100644 src/pmlogger/pmlogger_daily.timer
create mode 100644 src/pmlogger/pmlogger_daily_check.service.in
create mode 100644 src/pmlogger/pmlogger_daily_check.timer
create mode 100644 src/pmlogger/pmlogger_daily_poll.service.in
create mode 100644 src/pmlogger/pmlogger_daily_poll.timer
diff --git a/src/pmlogger/GNUmakefile b/src/pmlogger/GNUmakefile
index 75af514d5..942458e1f 100644
--- a/src/pmlogger/GNUmakefile
+++ b/src/pmlogger/GNUmakefile
@@ -20,7 +20,9 @@ SUBDIRS = src
OTHERS = pmnewlog.sh control rc_pmlogger \
pmlogger_daily.sh pmlogger_check.sh pmlogger_merge.sh pmlogmv.sh \
pmlogger_daily_report.sh pmlogger_rewrite.sh
-LDIRT = crontab crontab.docker crontab.daily_report pmlogger.service
+LDIRT = crontab crontab.docker crontab.daily_report pmlogger.service \
+ pmlogger_daily.service pmlogger_daily_poll.service \
+ pmlogger_daily_check.service
ifeq ($(TARGET_OS),linux)
CRONTAB_USER = $(PCP_USER)
@@ -31,7 +33,7 @@ CRONTAB_PATH = $(PCP_SYSCONF_DIR)/pmlogger/crontab
endif
CRONTAB_DAILY_REPORT_PATH = $(CRONTAB_PATH)-daily-report
-default:: crontab crontab.docker pmlogger.service crontab.daily_report
+default:: $(LDIRT)
default:: $(SUBDIRS)
$(SUBDIRS_MAKERULE)
@@ -57,6 +59,12 @@ endif
$(INSTALL) -m 755 rc_pmlogger $(PCP_RC_DIR)/pmlogger
ifeq ($(ENABLE_SYSTEMD),true)
$(INSTALL) -m 644 pmlogger.service $(PCP_SYSTEMDUNIT_DIR)/pmlogger.service
+ $(INSTALL) -m 644 pmlogger_daily.timer $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily.timer
+ $(INSTALL) -m 644 pmlogger_daily.service $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily.service
+ $(INSTALL) -m 644 pmlogger_daily_poll.timer $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily_poll.timer
+ $(INSTALL) -m 644 pmlogger_daily_poll.service $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily_poll.service
+ $(INSTALL) -m 644 pmlogger_daily_check.timer $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily_check.timer
+ $(INSTALL) -m 644 pmlogger_daily_check.service $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily_check.service
endif
$(INSTALL) -m 775 -o $(PCP_USER) -g $(PCP_GROUP) -d $(PCP_LOG_DIR)/pmlogger
$(INSTALL) -m 775 -o $(PCP_USER) -g $(PCP_GROUP) -d $(PCP_TMP_DIR)/pmlogger
@@ -68,7 +76,9 @@ ifeq ($(TARGET_OS),linux)
$(INSTALL) -m 755 -d $(PCP_LOG_DIR)/pmlogger
$(INSTALL) -m 1777 -d $(PCP_TMP_DIR)/pmlogger
endif
+ifneq ($(ENABLE_SYSTEMD),true)
$(INSTALL) -m 644 crontab $(CRONTAB_PATH)
+endif
$(INSTALL) -m 644 utilproc.sh $(PCP_SHARE_DIR)/lib/utilproc.sh
$(INSTALL) -m 755 pmlogger_daily_report.sh $(PCP_BINADM_DIR)/pmlogger_daily_report$(SHELLSUFFIX)
$(INSTALL) -m 644 crontab.daily_report $(CRONTAB_DAILY_REPORT_PATH)
@@ -83,6 +93,24 @@ install_pcp : install
pmlogger.service : pmlogger.service.in
$(SED) -e 's;@path@;'$(PCP_RC_DIR)';' <$< >$@
+pmlogger_daily.service : pmlogger_daily.service.in
+ $(SED) <$< >$@ \
+ -e 's;@PCP_BINADM_DIR@;'$(PCP_BINADM_DIR)';' \
+ -e 's;@PCP_USER@;'$(PCP_USER)';' \
+ # END
+
+pmlogger_daily_poll.service : pmlogger_daily_poll.service.in
+ $(SED) <$< >$@ \
+ -e 's;@PCP_BINADM_DIR@;'$(PCP_BINADM_DIR)';' \
+ -e 's;@PCP_USER@;'$(PCP_USER)';' \
+ # END
+
+pmlogger_daily_check.service : pmlogger_daily_check.service.in
+ $(SED) <$< >$@ \
+ -e 's;@PCP_BINADM_DIR@;'$(PCP_BINADM_DIR)';' \
+ -e 's;@PCP_USER@;'$(PCP_USER)';' \
+ # END
+
crontab : crontab.in
$(SED) -e 's;@user@;'$(CRONTAB_USER)';' -e 's;@path@;'$(PCP_BINADM_DIR)';' $< > $@
diff --git a/src/pmlogger/pmlogger_daily.service.in b/src/pmlogger/pmlogger_daily.service.in
new file mode 100644
index 000000000..d08438370
--- /dev/null
+++ b/src/pmlogger/pmlogger_daily.service.in
@@ -0,0 +1,8 @@
+[Unit]
+Description=Process archive logs
+Documentation=man:pmlogger(1)
+
+[Service]
+Type=oneshot
+ExecStart=@PCP_BINADM_DIR@/pmlogger_daily
+User=@PCP_USER@
diff --git a/src/pmlogger/pmlogger_daily.timer b/src/pmlogger/pmlogger_daily.timer
new file mode 100644
index 000000000..92bc398cf
--- /dev/null
+++ b/src/pmlogger/pmlogger_daily.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=Daily processing of archive logs
+
+[Timer]
+OnCalendar=*-*-* 00:10:00
+
+[Install]
+WantedBy=timers.target
diff --git a/src/pmlogger/pmlogger_daily_check.service.in b/src/pmlogger/pmlogger_daily_check.service.in
new file mode 100644
index 000000000..56fd47c55
--- /dev/null
+++ b/src/pmlogger/pmlogger_daily_check.service.in
@@ -0,0 +1,8 @@
+[Unit]
+Description=Check pmlogger instances are running
+Documentation=man:pmlogger(1)
+
+[Service]
+Type=oneshot
+ExecStart=@PCP_BINADM_DIR@/pmlogger_daily -C
+User=@PCP_USER@
diff --git a/src/pmlogger/pmlogger_daily_check.timer b/src/pmlogger/pmlogger_daily_check.timer
new file mode 100644
index 000000000..381b2c5ab
--- /dev/null
+++ b/src/pmlogger/pmlogger_daily_check.timer
@@ -0,0 +1,9 @@
+[Unit]
+Description=Half-hourly check of pmlogger instances
+
+[Timer]
+OnCalendar=*-*-* *:25:00
+OnCalendar=*-*-* *:55:00
+
+[Install]
+WantedBy=timers.target
diff --git a/src/pmlogger/pmlogger_daily_poll.service.in b/src/pmlogger/pmlogger_daily_poll.service.in
new file mode 100644
index 000000000..da5859d8b
--- /dev/null
+++ b/src/pmlogger/pmlogger_daily_poll.service.in
@@ -0,0 +1,8 @@
+[Unit]
+Description=Poll log processing
+Documentation=man:pmlogger(1)
+
+[Service]
+Type=oneshot
+ExecStart=@PCP_BINADM_DIR@/pmlogger_daily -p
+User=@PCP_USER@
diff --git a/src/pmlogger/pmlogger_daily_poll.timer b/src/pmlogger/pmlogger_daily_poll.timer
new file mode 100644
index 000000000..0b4650b37
--- /dev/null
+++ b/src/pmlogger/pmlogger_daily_poll.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=Hourly polling of log processing
+
+[Timer]
+OnCalendar=*-*-* *:30:00
+
+[Install]
+WantedBy=timers.target
--
2.13.7