dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch

c025cf
From 7cd7e91ab3de5aa75dc963cb08b0618c1885cf0d Mon Sep 17 00:00:00 2001
c025cf
From: NeilBrown <neilb@suse.com>
c025cf
Date: Wed, 5 Dec 2018 16:35:00 +1100
c025cf
Subject: [RHEL7.7 PATCH 05/21] Monitor: add system timer to run --oneshot
c025cf
 periodically
c025cf
c025cf
"mdadm --monitor --oneshot" can be used to get a warning
c025cf
if there are any degraded arrays.  It can be helpful to get
c025cf
this warning periodically while the condition persists.
c025cf
c025cf
This patch add a systemd service and timer which can
c025cf
be enabled with
c025cf
   systemctl enable mdmonitor-oneshot.service
c025cf
c025cf
and will then provide daily warnings.
c025cf
c025cf
Signed-off-by: NeilBrown <neilb@suse.com>
c025cf
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
c025cf
---
c025cf
 Makefile                          |  1 +
c025cf
 systemd/mdmonitor-oneshot.service | 15 +++++++++++++++
c025cf
 systemd/mdmonitor-oneshot.timer   | 15 +++++++++++++++
c025cf
 3 files changed, 31 insertions(+)
c025cf
 create mode 100644 systemd/mdmonitor-oneshot.service
c025cf
 create mode 100644 systemd/mdmonitor-oneshot.timer
c025cf
c025cf
diff --git a/Makefile b/Makefile
c025cf
index afb62cc..dfe00b0 100644
c025cf
--- a/Makefile
c025cf
+++ b/Makefile
c025cf
@@ -279,6 +279,7 @@ install-systemd: systemd/mdmon@.service
c025cf
 		mdadm-last-resort@.service mdadm-grow-continue@.service \
c025cf
 		mdcheck_start.timer mdcheck_start.service \
c025cf
 		mdcheck_continue.timer mdcheck_continue.service \
c025cf
+		mdmonitor-oneshot.timer mdmonitor-oneshot.service \
c025cf
 		; \
c025cf
 	do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp.2 && \
c025cf
 	   $(ECHO) $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
c025cf
diff --git a/systemd/mdmonitor-oneshot.service b/systemd/mdmonitor-oneshot.service
c025cf
new file mode 100644
c025cf
index 0000000..fd469b1
c025cf
--- /dev/null
c025cf
+++ b/systemd/mdmonitor-oneshot.service
c025cf
@@ -0,0 +1,15 @@
c025cf
+#  This file is part of mdadm.
c025cf
+#
c025cf
+#  mdadm is free software; you can redistribute it and/or modify it
c025cf
+#  under the terms of the GNU General Public License as published by
c025cf
+#  the Free Software Foundation; either version 2 of the License, or
c025cf
+#  (at your option) any later version.
c025cf
+
c025cf
+[Unit]
c025cf
+Description=Reminder for degraded MD arrays
c025cf
+
c025cf
+[Service]
c025cf
+Environment=  MDADM_MONITOR_ARGS=--scan
c025cf
+EnvironmentFile=-/run/sysconfig/mdadm
c025cf
+ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
c025cf
+ExecStart=BINDIR/mdadm --monitor --oneshot $MDADM_MONITOR_ARGS
c025cf
diff --git a/systemd/mdmonitor-oneshot.timer b/systemd/mdmonitor-oneshot.timer
c025cf
new file mode 100644
c025cf
index 0000000..cb54bda
c025cf
--- /dev/null
c025cf
+++ b/systemd/mdmonitor-oneshot.timer
c025cf
@@ -0,0 +1,15 @@
c025cf
+#  This file is part of mdadm.
c025cf
+#
c025cf
+#  mdadm is free software; you can redistribute it and/or modify it
c025cf
+#  under the terms of the GNU General Public License as published by
c025cf
+#  the Free Software Foundation; either version 2 of the License, or
c025cf
+#  (at your option) any later version.
c025cf
+
c025cf
+[Unit]
c025cf
+Description=Reminder for degraded MD arrays
c025cf
+
c025cf
+[Timer]
c025cf
+OnCalendar= 2:00:00
c025cf
+
c025cf
+[Install]
c025cf
+WantedBy= mdmonitor.service
c025cf
-- 
c025cf
2.7.5
c025cf