Skip to content

Commit f123de1

Browse files
committed
add systemd timer units replacing cronjobs
Systemd timer units, while preserving functionality of cronjobs, provide some additional features: - dependency on cron can be dropped - timer units next expiration is clearly visible in "systemctl list-timers" - unit customization rules provide cleaner way for administrator to modify default parameters, enable, disable and override individual timers
1 parent f35239b commit f123de1

9 files changed

+91
-1
lines changed

Makefile.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ install_all: install_base cron/crontab sysstat \
380380
fi
381381
if [ -d "$(DESTDIR)$(SYSTEMD_UNIT_DIR)" ]; then \
382382
$(INSTALL_DATA) sysstat.service $(DESTDIR)$(SYSTEMD_UNIT_DIR); \
383+
$(INSTALL_DATA) cron/sysstat-collect.service $(DESTDIR)$(SYSTEMD_UNIT_DIR); \
384+
$(INSTALL_DATA) cron/sysstat-collect.timer $(DESTDIR)$(SYSTEMD_UNIT_DIR); \
385+
$(INSTALL_DATA) cron/sysstat-summary.service $(DESTDIR)$(SYSTEMD_UNIT_DIR); \
386+
$(INSTALL_DATA) cron/sysstat-summary.timer $(DESTDIR)$(SYSTEMD_UNIT_DIR); \
383387
elif [ -d $(DESTDIR)$(INIT_DIR) ]; then \
384388
$(INSTALL_BIN) sysstat $(DESTDIR)$(INIT_DIR)/sysstat; \
385389
if [ -x $(CHKCONFIG) ]; then \
@@ -492,6 +496,10 @@ ifeq ($(COPY_ONLY),n)
492496
endif
493497
if [ -d "$(DESTDIR)$(SYSTEMD_UNIT_DIR)" ]; then \
494498
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/sysstat.service; \
499+
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/sysstat-collect.service; \
500+
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/sysstat-collect.timer; \
501+
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/sysstat-summary.service; \
502+
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/sysstat-summary.timer; \
495503
fi
496504

497505
ifeq ($(INSTALL_CRON),y)
@@ -519,6 +527,7 @@ clean:
519527
almost-distclean: clean nls/sysstat.pot
520528
rm -f sa1 sa2 sysstat cron/crontab version.h sysconfig.h prealloc.h
521529
rm -f sysstat.sysconfig cron/sysstat.crond cron/sysstat.cron.daily sysstat.service
530+
rm -f cron/sysstat-collect.service cron/sysstat-collect.timer cron/sysstat-summary.service cron/sysstat-summary.timer
522531
rm -f cron/sysstat.cron.hourly cron/sysstat.crond.sample cron/sysstat.crond.sample.in
523532
rm -f contrib/isag/isag
524533
rm -f man/sa1.8 man/sa2.8 man/sadc.8 man/sadf.1 man/sar.1 man/iostat.1 man/sysstat.5

README

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ ${PREFIX}/share/locale/*/LC_MESSAGES/sysstat.mo
8181
${PREFIX}/share/doc/sysstat-x.y.z/*
8282
/var/log/sa
8383
${INIT_DIR}/sysstat
84-
/lib/systemd/system/sysstat.service if OS uses systemd
84+
/lib/systemd/system/sysstat.service if OS uses systemd
85+
/lib/systemd/system/sysstat-collect.service if OS uses systemd
86+
/lib/systemd/system/sysstat-collect.timer if OS uses systemd
87+
/lib/systemd/system/sysstat-summary.service if OS uses systemd
88+
/lib/systemd/system/sysstat-summary.timer if OS uses systemd
8589
/etc/sysconfig/sysstat
8690
/etc/sysconfig/sysstat.ioconf
8791
/etc/cron.d/sysstat

configure

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5416,6 +5416,14 @@ ac_config_files="$ac_config_files sysstat"
54165416
# Permissions must be changed
54175417
ac_config_files="$ac_config_files sysstat.service"
54185418
5419+
ac_config_files="$ac_config_files cron/sysstat-collect.service"
5420+
5421+
ac_config_files="$ac_config_files cron/sysstat-collect.timer"
5422+
5423+
ac_config_files="$ac_config_files cron/sysstat-summary.service"
5424+
5425+
ac_config_files="$ac_config_files cron/sysstat-summary.timer"
5426+
54195427
ac_config_files="$ac_config_files man/sa1.8:man/sa1.in"
54205428
# File must be renamed
54215429
ac_config_files="$ac_config_files man/sa2.8:man/sa2.in"
@@ -6157,6 +6165,10 @@ do
61576165
"cron/sysstat.crond.sample.in") CONFIG_FILES="$CONFIG_FILES cron/sysstat.crond.sample.in:cron/sysstat.crond.in" ;;
61586166
"sysstat") CONFIG_FILES="$CONFIG_FILES sysstat" ;;
61596167
"sysstat.service") CONFIG_FILES="$CONFIG_FILES sysstat.service" ;;
6168+
"cron/sysstat-collect.service") CONFIG_FILES="$CONFIG_FILES cron/sysstat-collect.service" ;;
6169+
"cron/sysstat-collect.timer") CONFIG_FILES="$CONFIG_FILES cron/sysstat-collect.timer" ;;
6170+
"cron/sysstat-summary.service") CONFIG_FILES="$CONFIG_FILES cron/sysstat-summary.service" ;;
6171+
"cron/sysstat-summary.timer") CONFIG_FILES="$CONFIG_FILES cron/sysstat-summary.timer" ;;
61606172
"man/sa1.8") CONFIG_FILES="$CONFIG_FILES man/sa1.8:man/sa1.in" ;;
61616173
"man/sa2.8") CONFIG_FILES="$CONFIG_FILES man/sa2.8:man/sa2.in" ;;
61626174
"man/sadc.8") CONFIG_FILES="$CONFIG_FILES man/sadc.8:man/sadc.in" ;;

configure.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ AC_CONFIG_FILES([cron/sysstat.crond])
600600
AC_CONFIG_FILES([cron/sysstat.crond.sample.in:cron/sysstat.crond.in], [sed s/^/#/ cron/sysstat.crond.sample.in > cron/sysstat.crond.sample])
601601
AC_CONFIG_FILES([sysstat], [chmod +x sysstat]) # Permissions must be changed
602602
AC_CONFIG_FILES([sysstat.service])
603+
AC_CONFIG_FILES([cron/sysstat-collect.service])
604+
AC_CONFIG_FILES([cron/sysstat-collect.timer])
605+
AC_CONFIG_FILES([cron/sysstat-summary.service])
606+
AC_CONFIG_FILES([cron/sysstat-summary.timer])
603607
AC_CONFIG_FILES([man/sa1.8:man/sa1.in]) # File must be renamed
604608
AC_CONFIG_FILES([man/sa2.8:man/sa2.in]) # File must be renamed
605609
AC_CONFIG_FILES([man/sadc.8:man/sadc.in]) # File must be renamed

cron/sysstat-collect.service.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# @SYSTEMD_UNIT_DIR@/sysstat-collect.service
2+
# (C) 2014 Tomasz Torcz <[email protected]>
3+
#
4+
# @PACKAGE_NAME@-@PACKAGE_VERSION@ systemd unit file:
5+
# Collects system activity data
6+
# Activated by sysstat-collect.timer unit
7+
8+
[Unit]
9+
Description=system activity accounting tool
10+
Documentation=man:sa1(8)
11+
12+
[Service]
13+
Type=oneshot
14+
User=@CRON_OWNER@
15+
ExecStart=@SA_LIB_DIR@/sa1 1 1
16+

cron/sysstat-collect.timer.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# @SYSTEMD_UNIT_DIR@/sysstat-collect.timer
2+
# (C) 2014 Tomasz Torcz <[email protected]>
3+
#
4+
# @PACKAGE_NAME@-@PACKAGE_VERSION@ systemd unit file:
5+
# Activates activity collector every @CRON_INTERVAL@ minutes
6+
7+
[Unit]
8+
Description=Run system activity accounting tool every @CRON_INTERVAL@ minutes
9+
10+
[Timer]
11+
OnCalendar=*:00/@CRON_INTERVAL@
12+
13+
[Install]
14+
WantedBy=sysstat.service

cron/sysstat-summary.service.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# @SYSTEMD_UNIT_DIR@/sysstat-summary.service
2+
# (C) 2014 Tomasz Torcz <[email protected]>
3+
#
4+
# @PACKAGE_NAME@-@PACKAGE_VERSION@ systemd unit file:
5+
# Generates daily summary of process accounting
6+
7+
[Unit]
8+
Description=Generate a daily summary of process accounting
9+
Documentation=man:sa2(8)
10+
11+
[Service]
12+
Type=oneshot
13+
User=@CRON_OWNER@
14+
ExecStart=@SA_LIB_DIR@/sa2 -A

cron/sysstat-summary.timer.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# @SYSTEMD_UNIT_DIR@/sysstat-summary.timer
2+
# (C) 2014 Tomasz Torcz <[email protected]>
3+
#
4+
# @PACKAGE_NAME@-@PACKAGE_VERSION@ systemd unit file:
5+
# Triggers daily summary generation.
6+
# Activates sysstat-summary.service
7+
8+
[Unit]
9+
Description=Generate a daily summary of process accounting at 23:53
10+
11+
[Timer]
12+
OnCalendar=23:53:00
13+
14+
[Install]
15+
WantedBy=sysstat.service

sysstat.service.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ ExecStart=@SA_LIB_DIR@/sa1 --boot
1616

1717
[Install]
1818
WantedBy=multi-user.target
19+
Also=sysstat-collect.timer
20+
Also=sysstat-summary.timer
1921

0 commit comments

Comments
 (0)