From ebce8bc85f6d777bd50dbf72b4b016af94549491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Fri, 22 Jun 2018 16:04:32 +0200 Subject: [PATCH] Add a ZFS plugin (both config file and script) In order to check ZFS pool health. --- CHANGELOG.md | 1 + README.md | 6 + defaults/main.yml | 10 +- tasks/main.yml | 21 +++ templates/etc/xymon/clientlaunch.d/zfs.cfg.j2 | 6 + templates/usr/lib/xymon/client/ext/zfs.j2 | 123 ++++++++++++++++++ 6 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 templates/etc/xymon/clientlaunch.d/zfs.cfg.j2 create mode 100755 templates/usr/lib/xymon/client/ext/zfs.j2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0366744..8a0e723 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Ensure to apply the config only if wanted. * Some yamllint fix. * Add a all hosts variable for the plugin "list" whitelist. +* Add a ZFS plugin (both config file and script). ## v1.1 diff --git a/README.md b/README.md index 7296df6..6f27b4e 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ Manage Xymon (client) installation and configuration. * **xymon_plug_libs_whitelist** : All hosts whitelist of processes that should not be monitored with `libs` plugin. * **xymon_plug_libs_group_whitelist** : Group whitelist of processes that should not be monitored with `libs` plugin. * **xymon_plug_libs_host_whitelist** : Host whitelist of processes that should not be monitored with `libs` plugin. +* **xymon_cli__plug_zfs_state** : The state of plugin `zfs` [default : `false`]. +* **xymon_cli__plug_zfs_script_path** : Path to the ZFS script [default : `/usr/lib/xymon/client/ext/zfs`]. +* **xymon_cli__plug_zfs_script_tpl** : Template used to generate the previous script [default : `usr/lib/xymon/client/ext/zfs.j2`]. +* **xymon_cli__plug_zfs_path** : Configuration file for the `zfs` plugin [default : `/etc/xymon/clientlaunch.d/zfs.cfg`]. +* **xymon_cli__plug_zfs_tpl** : Template used to generate the previous config file [default : `etc/xymon/clientlaunch.d/zfs.cfg.j2`]. ### OS Specific Variables @@ -73,6 +78,7 @@ Some plugins and options can be managed with this role : * apt : Check state of packages and repositories. * libs : Check for running processes with upgraded libraries. * mq : Check mail queue. +* zfs : Check ZFS pools status. ## Development diff --git a/defaults/main.yml b/defaults/main.yml index de0156d..2e75f22 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -46,7 +46,6 @@ xymon_srv_list: "monitoring.{{ ansible_domain }}" # Plugins management [[[ # ---------------------- -# plugins [[[ xymon_plug_manage: true ## Plugin apt [[[ @@ -80,7 +79,14 @@ xymon_plug_libs_whitelist: {} xymon_plug_libs_group_whitelist: {} xymon_plug_libs_host_whitelist: {} -## ]]] + # ]]] +## Plugin zfs [[[ +xymon_cli__plug_zfs_state: false +xymon_cli__plug_zfs_script_path: '/usr/lib/xymon/client/ext/zfs' +xymon_cli__plug_zfs_script_tpl: 'usr/lib/xymon/client/ext/zfs.j2' +xymon_cli__plug_zfs_path: '/etc/xymon/clientlaunch.d/zfs.cfg' +xymon_cli__plug_zfs_tpl: 'etc/xymon/clientlaunch.d/zfs.cfg.j2' + # ]]] # ]]] diff --git a/tasks/main.yml b/tasks/main.yml index d6ce260..adf58c5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -125,3 +125,24 @@ xymon_plug_manage|bool) notify: restart xymon-client service +# Manage zfs plugin [[[1 +- name: PLUGIN zfs config file + template: + src: '{{ xymon_cli__plug_zfs_tpl }}' + dest: '{{ xymon_cli__plug_zfs_path }}' + owner: root + group: root + mode: 0644 + when: (xymon_cli_manage|bool and + xymon_plug_manage|bool) + notify: restart xymon-client service + +- name: PLUGIN zfs script file + template: + src: '{{ xymon_cli__plug_zfs_script_tpl }}' + dest: '{{ xymon_cli__plug_zfs_script_path }}' + owner: root + group: xymon + mode: 0755 + when: (xymon_cli_manage|bool and + xymon_plug_manage|bool) diff --git a/templates/etc/xymon/clientlaunch.d/zfs.cfg.j2 b/templates/etc/xymon/clientlaunch.d/zfs.cfg.j2 new file mode 100644 index 0000000..c4e5e29 --- /dev/null +++ b/templates/etc/xymon/clientlaunch.d/zfs.cfg.j2 @@ -0,0 +1,6 @@ +[zfs] + {{ '#DISABLED' if xymon_cli__plug_zfs_state else 'DISABLED' }} + ENVFILE /etc/xymon/xymonclient.cfg + CMD /usr/bin/sudo -E -u root $XYMONCLIENTHOME/ext/zfs + LOGFILE /var/log/xymon/zfs.log + INTERVAL 5m diff --git a/templates/usr/lib/xymon/client/ext/zfs.j2 b/templates/usr/lib/xymon/client/ext/zfs.j2 new file mode 100755 index 0000000..308fc28 --- /dev/null +++ b/templates/usr/lib/xymon/client/ext/zfs.j2 @@ -0,0 +1,123 @@ +#!/bin/ksh +# Revision History: +# 1. Mike Rowell , original +# 2. Uwe Kirbach +# 3. T.J. Yang: add in some comments. +# 4. Vernon Everett /tmp/xymon_zfs +$XYMON $XYMONSRV $XYMONSERVERS "data $MACHINE.$TEST $DISPCOLOR $(echo; echo "$DATA" ;echo;echo)" +