From f026b0e562172e05fd2753caad2ae41e390cad90 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Mon, 7 Jan 2019 13:24:52 +0100 Subject: [PATCH] pmlogger_daily_report: add systemd timers as cron alternative The timer and service files are installed by default with ENABLE_SYSTEMD. Signed-off-by: David Disseldorp --- src/pmlogger/GNUmakefile | 23 +++++++++++++++++++++- src/pmlogger/pmlogger_daily_report.service.in | 8 ++++++++ src/pmlogger/pmlogger_daily_report.timer | 8 ++++++++ src/pmlogger/pmlogger_daily_report_poll.service.in | 8 ++++++++ src/pmlogger/pmlogger_daily_report_poll.timer | 8 ++++++++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/pmlogger/pmlogger_daily_report.service.in create mode 100644 src/pmlogger/pmlogger_daily_report.timer create mode 100644 src/pmlogger/pmlogger_daily_report_poll.service.in create mode 100644 src/pmlogger/pmlogger_daily_report_poll.timer Index: pcp/src/pmlogger/GNUmakefile =================================================================== --- pcp.orig/src/pmlogger/GNUmakefile +++ pcp/src/pmlogger/GNUmakefile @@ -22,7 +22,8 @@ OTHERS = pmnewlog.sh control rc_pmlogger pmlogger_daily_report.sh pmlogger_rewrite.sh LDIRT = crontab crontab.docker crontab.daily_report pmlogger.service \ pmlogger_daily.service pmlogger_daily_poll.service \ - pmlogger_daily_check.service + pmlogger_daily_check.service pmlogger_daily_report.service \ + pmlogger_daily_report_poll.service ifeq ($(TARGET_OS),linux) CRONTAB_USER = $(PCP_USER) @@ -65,6 +66,10 @@ ifeq ($(ENABLE_SYSTEMD),true) $(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 + $(INSTALL) -m 644 pmlogger_daily_report.timer $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily_report.timer + $(INSTALL) -m 644 pmlogger_daily_report.service $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily_report.service + $(INSTALL) -m 644 pmlogger_daily_report_poll.timer $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily_report_poll.timer + $(INSTALL) -m 644 pmlogger_daily_report_poll.service $(PCP_SYSTEMDUNIT_DIR)/pmlogger_daily_report_poll.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 @@ -81,7 +86,9 @@ ifneq ($(ENABLE_SYSTEMD),true) 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) +ifneq ($(ENABLE_SYSTEMD),true) $(INSTALL) -m 644 crontab.daily_report $(CRONTAB_DAILY_REPORT_PATH) +endif $(INSTALL) -m 775 -o $(PCP_USER) -g $(PCP_GROUP) -d $(PCP_SA_DIR) include $(BUILDRULES) @@ -114,6 +121,20 @@ pmlogger_daily_check.service : pmlogger_ -e 's;@PCP_USER@;'$(PCP_USER)';' \ # END +pmlogger_daily_report.service : pmlogger_daily_report.service.in + $(SED) <$< >$@ \ + -e 's;@PCP_BINADM_DIR@;'$(PCP_BINADM_DIR)';' \ + -e 's;@PCP_USER@;'$(PCP_USER)';' \ + -e 's;@PCP_SA_DIR@;'$(PCP_SA_DIR)';' \ + # END + +pmlogger_daily_report_poll.service : pmlogger_daily_report_poll.service.in + $(SED) <$< >$@ \ + -e 's;@PCP_BINADM_DIR@;'$(PCP_BINADM_DIR)';' \ + -e 's;@PCP_USER@;'$(PCP_USER)';' \ + -e 's;@PCP_SA_DIR@;'$(PCP_SA_DIR)';' \ + # END + crontab : crontab.in $(SED) -e 's;@user@;'$(CRONTAB_USER)';' -e 's;@path@;'$(PCP_BINADM_DIR)';' $< > $@ Index: pcp/src/pmlogger/pmlogger_daily_report.service.in =================================================================== --- /dev/null +++ pcp/src/pmlogger/pmlogger_daily_report.service.in @@ -0,0 +1,8 @@ +[Unit] +Description=Generate system activity reports +Documentation=man:pmlogger(1) + +[Service] +Type=oneshot +ExecStart=@PCP_BINADM_DIR@/pmlogger_daily_report -o @PCP_SA_DIR@ +User=@PCP_USER@ Index: pcp/src/pmlogger/pmlogger_daily_report.timer =================================================================== --- /dev/null +++ pcp/src/pmlogger/pmlogger_daily_report.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Daily generation of system activity reports + +[Timer] +OnCalendar=*-*-* 02:00:00 + +[Install] +WantedBy=timers.target Index: pcp/src/pmlogger/pmlogger_daily_report_poll.service.in =================================================================== --- /dev/null +++ pcp/src/pmlogger/pmlogger_daily_report_poll.service.in @@ -0,0 +1,8 @@ +[Unit] +Description=Poll system activity report generation +Documentation=man:pmlogger(1) + +[Service] +Type=oneshot +ExecStart=@PCP_BINADM_DIR@/pmlogger_daily_report -o @PCP_SA_DIR@ -p +User=@PCP_USER@ Index: pcp/src/pmlogger/pmlogger_daily_report_poll.timer =================================================================== --- /dev/null +++ pcp/src/pmlogger/pmlogger_daily_report_poll.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Hourly polling of system activity report generation + +[Timer] +OnCalendar=*-*-* *:30:00 + +[Install] +WantedBy=timers.target