From 7264f3bee5f1c9bf2fc666ca2a862c25b1173992 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Mon, 7 Jan 2019 01:27:54 +0100 Subject: [PATCH] pmie: add systemd timers as cron alternative The pmie_check and pmie_daily check timer/service files are installed by default with ENABLE_SYSTEMD. crontab.docker is kept as-is. Signed-off-by: David Disseldorp --- src/pmie/GNUmakefile | 22 ++++++++++++++++++++-- src/pmie/pmie_check.service.in | 8 ++++++++ src/pmie/pmie_check.timer | 10 ++++++++++ src/pmie/pmie_daily.service.in | 8 ++++++++ src/pmie/pmie_daily.timer | 8 ++++++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/pmie/pmie_check.service.in create mode 100644 src/pmie/pmie_check.timer create mode 100644 src/pmie/pmie_daily.service.in create mode 100644 src/pmie/pmie_daily.timer diff --git a/src/pmie/GNUmakefile b/src/pmie/GNUmakefile index e27f2968d..11f472c11 100644 --- a/src/pmie/GNUmakefile +++ b/src/pmie/GNUmakefile @@ -18,7 +18,7 @@ include $(TOPDIR)/src/include/builddefs SUBDIRS = src examples OTHERS = control stomp rc_pmie pmie2col.sh pmie_check.sh pmie_daily.sh -LDIRT = crontab crontab.docker pmie.service +LDIRT = crontab crontab.docker pmie.service pmie_daily.service pmie_check.service ifeq ($(TARGET_OS),linux) CRONTAB_USER = $(PCP_USER) @@ -28,7 +28,7 @@ CRONTAB_USER = CRONTAB_PATH = $(PCP_SYSCONF_DIR)/pmie/crontab endif -default:: crontab crontab.docker pmie.service +default:: crontab crontab.docker pmie.service pmie_daily.service pmie_check.service default:: $(SUBDIRS) $(SUBDIRS_MAKERULE) @@ -50,6 +50,10 @@ endif $(INSTALL) -m 755 rc_pmie $(PCP_RC_DIR)/pmie ifeq ($(ENABLE_SYSTEMD),true) $(INSTALL) -m 644 pmie.service $(PCP_SYSTEMDUNIT_DIR)/pmie.service + $(INSTALL) -m 644 pmie_daily.timer $(PCP_SYSTEMDUNIT_DIR)/pmie_daily.timer + $(INSTALL) -m 644 pmie_daily.service $(PCP_SYSTEMDUNIT_DIR)/pmie_daily.service + $(INSTALL) -m 644 pmie_check.timer $(PCP_SYSTEMDUNIT_DIR)/pmie_check.timer + $(INSTALL) -m 644 pmie_check.service $(PCP_SYSTEMDUNIT_DIR)/pmie_check.service endif $(INSTALL) -m 775 -o $(PCP_USER) -g $(PCP_GROUP) -d $(PCP_LOG_DIR)/pmie $(INSTALL) -m 775 -o $(PCP_USER) -g $(PCP_GROUP) -d $(PCP_TMP_DIR)/pmie @@ -61,7 +65,9 @@ ifeq ($(TARGET_OS),linux) $(INSTALL) -m 755 -d $(PCP_LOG_DIR)/pmie $(INSTALL) -m 1777 -d $(PCP_TMP_DIR)/pmie endif +ifneq ($(ENABLE_SYSTEMD),true) $(INSTALL) -m 644 crontab $(CRONTAB_PATH) +endif include $(BUILDRULES) @@ -72,6 +78,18 @@ install_pcp : install pmie.service : pmie.service.in $(SED) -e 's;@path@;'$(PCP_RC_DIR)';' <$< >$@ +pmie_check.service : pmie_check.service.in + $(SED) <$< >$@ \ + -e 's;@PCP_BINADM_DIR@;'$(PCP_BINADM_DIR)';' \ + -e 's;@PCP_USER@;'$(PCP_USER)';' \ + # END + +pmie_daily.service : pmie_daily.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)';g' $< > $@ diff --git a/src/pmie/pmie_check.service.in b/src/pmie/pmie_check.service.in new file mode 100644 index 000000000..f216f7a67 --- /dev/null +++ b/src/pmie/pmie_check.service.in @@ -0,0 +1,8 @@ +[Unit] +Description=Check PMIE instances are running +Documentation=man:pmie(1) + +[Service] +Type=oneshot +ExecStart=@PCP_BINADM_DIR@/pmie_check -C +User=@PCP_USER@ diff --git a/src/pmie/pmie_check.timer b/src/pmie/pmie_check.timer new file mode 100644 index 000000000..ae91a192b --- /dev/null +++ b/src/pmie/pmie_check.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Half-hourly check of PMIE instances + +[Timer] +OnCalendar=*-*-* *:28:00 +OnCalendar=*-*-* *:58:00 + +[Install] +WantedBy=timers.target + diff --git a/src/pmie/pmie_daily.service.in b/src/pmie/pmie_daily.service.in new file mode 100644 index 000000000..ea933da4b --- /dev/null +++ b/src/pmie/pmie_daily.service.in @@ -0,0 +1,8 @@ +[Unit] +Description=Process PMIE logs +Documentation=man:pmie(1) + +[Service] +Type=oneshot +ExecStart=@PCP_BINADM_DIR@/pmie_daily -X xz -x 3 +User=@PCP_USER@ diff --git a/src/pmie/pmie_daily.timer b/src/pmie/pmie_daily.timer new file mode 100644 index 000000000..e36b79990 --- /dev/null +++ b/src/pmie/pmie_daily.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Daily processing of PMIE logs + +[Timer] +OnCalendar=*-*-* 00:08:00 + +[Install] +WantedBy=timers.target -- 2.13.7