0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From 7cd7e91ab3de5aa75dc963cb08b0618c1885cf0d Mon Sep 17 00:00:00 2001
  2. From: NeilBrown <neilb@suse.com>
  3. Date: Wed, 5 Dec 2018 16:35:00 +1100
  4. Subject: [PATCH 05/11] Monitor: add system timer to run --oneshot periodically
  5. "mdadm --monitor --oneshot" can be used to get a warning
  6. if there are any degraded arrays. It can be helpful to get
  7. this warning periodically while the condition persists.
  8. This patch add a systemd service and timer which can
  9. be enabled with
  10. systemctl enable mdmonitor-oneshot.service
  11. and will then provide daily warnings.
  12. Signed-off-by: NeilBrown <neilb@suse.com>
  13. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
  14. ---
  15. Makefile | 1 +
  16. systemd/mdmonitor-oneshot.service | 15 +++++++++++++++
  17. systemd/mdmonitor-oneshot.timer | 15 +++++++++++++++
  18. 3 files changed, 31 insertions(+)
  19. create mode 100644 systemd/mdmonitor-oneshot.service
  20. create mode 100644 systemd/mdmonitor-oneshot.timer
  21. diff --git a/Makefile b/Makefile
  22. index afb62cc6..dfe00b0a 100644
  23. --- a/Makefile
  24. +++ b/Makefile
  25. @@ -279,6 +279,7 @@ install-systemd: systemd/mdmon@.service
  26. mdadm-last-resort@.service mdadm-grow-continue@.service \
  27. mdcheck_start.timer mdcheck_start.service \
  28. mdcheck_continue.timer mdcheck_continue.service \
  29. + mdmonitor-oneshot.timer mdmonitor-oneshot.service \
  30. ; \
  31. do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp.2 && \
  32. $(ECHO) $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
  33. diff --git a/systemd/mdmonitor-oneshot.service b/systemd/mdmonitor-oneshot.service
  34. new file mode 100644
  35. index 00000000..fd469b12
  36. --- /dev/null
  37. +++ b/systemd/mdmonitor-oneshot.service
  38. @@ -0,0 +1,15 @@
  39. +# This file is part of mdadm.
  40. +#
  41. +# mdadm is free software; you can redistribute it and/or modify it
  42. +# under the terms of the GNU General Public License as published by
  43. +# the Free Software Foundation; either version 2 of the License, or
  44. +# (at your option) any later version.
  45. +
  46. +[Unit]
  47. +Description=Reminder for degraded MD arrays
  48. +
  49. +[Service]
  50. +Environment= MDADM_MONITOR_ARGS=--scan
  51. +EnvironmentFile=-/run/sysconfig/mdadm
  52. +ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
  53. +ExecStart=BINDIR/mdadm --monitor --oneshot $MDADM_MONITOR_ARGS
  54. diff --git a/systemd/mdmonitor-oneshot.timer b/systemd/mdmonitor-oneshot.timer
  55. new file mode 100644
  56. index 00000000..cb54bdaa
  57. --- /dev/null
  58. +++ b/systemd/mdmonitor-oneshot.timer
  59. @@ -0,0 +1,15 @@
  60. +# This file is part of mdadm.
  61. +#
  62. +# mdadm is free software; you can redistribute it and/or modify it
  63. +# under the terms of the GNU General Public License as published by
  64. +# the Free Software Foundation; either version 2 of the License, or
  65. +# (at your option) any later version.
  66. +
  67. +[Unit]
  68. +Description=Reminder for degraded MD arrays
  69. +
  70. +[Timer]
  71. +OnCalendar= 2:00:00
  72. +
  73. +[Install]
  74. +WantedBy= mdmonitor.service
  75. --
  76. 2.19.1