From 89705037fd29536a0b21d4830d77b061b6d8d7f7 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Thu, 1 Aug 2024 14:28:52 -0700 Subject: [PATCH 01/35] try to build with debuild --- .gitignore | 1 + README.md | 5 +++++ .../installed-by-dh_installdocs | 0 debian/changelog | 5 +++++ debian/compat | 1 + control => debian/control | 11 ++++++---- debian/debhelper-build-stamp | 1 + debian/files | 2 ++ debian/nagios-plugins-ets.substvars | 2 ++ postinst => debian/postinst | 0 debian/rules | 22 +++++++++++++++++++ 11 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 debian/.debhelper/generated/nagios-plugins-ets/installed-by-dh_installdocs create mode 100644 debian/changelog create mode 100644 debian/compat rename control => debian/control (71%) create mode 100644 debian/debhelper-build-stamp create mode 100644 debian/files create mode 100644 debian/nagios-plugins-ets.substvars rename postinst => debian/postinst (100%) create mode 100755 debian/rules diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bb7af6b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +debian/nagios-plugins-ets diff --git a/README.md b/README.md index f0246bf..91f2b0d 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,8 @@ ls -l /tmp/rpms/x86_64 ``` https://github.com/docker-rpm-builder/docker-rpm-builder + + +# Building + +https://blog.packagecloud.io/buildling-debian-packages-with-debuild/ diff --git a/debian/.debhelper/generated/nagios-plugins-ets/installed-by-dh_installdocs b/debian/.debhelper/generated/nagios-plugins-ets/installed-by-dh_installdocs new file mode 100644 index 0000000..e69de29 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..cf0d272 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +nagios-plugins-ets (1.4) unstable; urgency=low + + * first release + + -- UCSD Sun, 17 Apr 2011 17:37:44 -0700 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 diff --git a/control b/debian/control similarity index 71% rename from control rename to debian/control index 0a7e0e0..0eb2cf3 100644 --- a/control +++ b/debian/control @@ -1,9 +1,12 @@ -Package: nagios-plugins-ets -Version: 1.4 +Source: nagios-plugins-ets Section: utils Priority: optional -Architecture: all -Depends: python3-psutil, smartmontools Maintainer: Your Name +Rules-Requires-Root: no + +Package: nagios-plugins-ets +Version: 1.4 +Architecture: amd64 +#Depends: python3-psutil, smartmontools Description: Nagios plugins for system monitoring Collection of Nagios plugins for system monitoring, including memory check, smartmon, zpools, and service checks. diff --git a/debian/debhelper-build-stamp b/debian/debhelper-build-stamp new file mode 100644 index 0000000..7b3f047 --- /dev/null +++ b/debian/debhelper-build-stamp @@ -0,0 +1 @@ +nagios-plugins-ets diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..8ac4db8 --- /dev/null +++ b/debian/files @@ -0,0 +1,2 @@ +nagios-plugins-ets_1.4_amd64.buildinfo utils optional +nagios-plugins-ets_1.4_amd64.deb utils optional diff --git a/debian/nagios-plugins-ets.substvars b/debian/nagios-plugins-ets.substvars new file mode 100644 index 0000000..978fc8b --- /dev/null +++ b/debian/nagios-plugins-ets.substvars @@ -0,0 +1,2 @@ +misc:Depends= +misc:Pre-Depends= diff --git a/postinst b/debian/postinst similarity index 100% rename from postinst rename to debian/postinst diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..bc6eb03 --- /dev/null +++ b/debian/rules @@ -0,0 +1,22 @@ +#!/usr/bin/make -f +export DH_VERBOSE = 1 +%: + dh $@ + +override_dh_auto_install: + echo hello + pwd + install -d debian/nagios-plugins-ets/usr/lib64/nagios/plugins + #install -d debian/nagios-plugins-ets/usr/lib64/nagios/nagios-plugins-ets + echo x > debian/check_memory + # mkdir -p debian/nagios-plugins-ets/usr/lib64/nagios/plugins + # echo x > debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory + install -p -m0755 debian/check_memory debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory + + +#!/usr/bin/make -f +# You must remove unused comment lines for the released package. +#export DH_VERBOSE = 1 + +# %: +# /debian/nagios-plugins-ets/usr From 8d0f765e9cba51a1f7551af677502f48846a1a24 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Mon, 5 Aug 2024 13:37:04 -0700 Subject: [PATCH 02/35] ignore src --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bb7af6b..fcd93f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ debian/nagios-plugins-ets +debian/src From 55209553e74d791912e57e17fb875af1824fce21 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Mon, 5 Aug 2024 13:37:18 -0700 Subject: [PATCH 03/35] install to usr --- debian/rules | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/rules b/debian/rules index bc6eb03..467aecf 100755 --- a/debian/rules +++ b/debian/rules @@ -8,10 +8,11 @@ override_dh_auto_install: pwd install -d debian/nagios-plugins-ets/usr/lib64/nagios/plugins #install -d debian/nagios-plugins-ets/usr/lib64/nagios/nagios-plugins-ets - echo x > debian/check_memory + mkdir -p debian/src + echo x > debian/src/check_memory # mkdir -p debian/nagios-plugins-ets/usr/lib64/nagios/plugins # echo x > debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory - install -p -m0755 debian/check_memory debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory + install -p -m0755 debian/src/check_memory debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory #!/usr/bin/make -f From bed1c4799db264f690799653b34f67c4f8d7080f Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 14:43:49 -0700 Subject: [PATCH 04/35] moved debian folder --- .github/workflows/build-deb.yml | 39 ++++++----- .gitignore | 2 + README.md | 20 ++++++ .../installed-by-dh_installdocs | 0 debian/compat | 1 - debian/debhelper-build-stamp | 1 - debian/files | 2 - debian/nagios-plugins-ets.substvars | 2 - debian/rules | 23 ------ src/README.md | 70 +++++++++++++++++++ {debian => src/debian}/changelog | 0 src/debian/compat | 1 + {debian => src/debian}/control | 3 +- {debian => src/debian}/postinst | 0 src/debian/rules | 30 ++++++++ src/debian/source/format | 1 + 16 files changed, 147 insertions(+), 48 deletions(-) delete mode 100644 debian/.debhelper/generated/nagios-plugins-ets/installed-by-dh_installdocs delete mode 100644 debian/compat delete mode 100644 debian/debhelper-build-stamp delete mode 100644 debian/files delete mode 100644 debian/nagios-plugins-ets.substvars delete mode 100755 debian/rules create mode 100644 src/README.md rename {debian => src/debian}/changelog (100%) create mode 100644 src/debian/compat rename {debian => src/debian}/control (91%) rename {debian => src/debian}/postinst (100%) create mode 100755 src/debian/rules create mode 100644 src/debian/source/format diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 7e0771f..df4745b 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout source code uses: actions/checkout@v2 - + - name: Install dependencies run: sudo apt-get update && sudo apt-get install -y dpkg-dev @@ -21,25 +21,25 @@ jobs: pwd ls - - name: Create directories for DEB packaging - run: | - mkdir -p nagios-plugins-ets-1.4/usr/lib64/nagios/plugins - mkdir -p nagios-plugins-ets-1.4/DEBIAN + # - name: Create directories for DEB packaging + # run: | + # mkdir -p nagios-plugins-ets-1.4/usr/lib64/nagios/plugins + # mkdir -p nagios-plugins-ets-1.4/DEBIAN - name: Print folder structure run: | ls -R nagios-plugins-ets-1.4 - - name: Download plugin files - run: | + # - name: Download plugin files + # run: | # Download each file using wget - wget -O nagios-plugins-ets-1.4/check_mem.c https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_mem.c - wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_service https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_service - wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartctl https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartctl - wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartmon2.py https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartmon2.py - wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartmon.py https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartmon.py - wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_zpools.sh https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_zpools.sh - chmod 755 nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/* + # wget -O nagios-plugins-ets-1.4/check_mem.c https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_mem.c + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_service https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_service + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartctl https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartctl + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartmon2.py https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartmon2.py + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartmon.py https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartmon.py + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_zpools.sh https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_zpools.sh + # chmod 755 nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/* - name: Print folder structure run: | @@ -47,11 +47,14 @@ jobs: - name: Copy plugin files run: | - cp control nagios-plugins-ets-1.4/DEBIAN/ - cp postinst nagios-plugins-ets-1.4/DEBIAN/ + # cp control nagios-plugins-ets-1.4/DEBIAN/ + # cp postinst nagios-plugins-ets-1.4/DEBIAN/ + # - name: Build DEB package + # run: dpkg-deb --build nagios-plugins-ets-1.4 - name: Build DEB package - run: dpkg-deb --build nagios-plugins-ets-1.4 + run: | + debuild -us -uc - name: Extract tag name id: extract_tag @@ -74,4 +77,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: ./nagios-plugins-ets-1.4.deb - content_type: application/vnd.debian.binary-package \ No newline at end of file + content_type: application/vnd.debian.binary-package diff --git a/.gitignore b/.gitignore index fcd93f5..9b1bd25 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ debian/nagios-plugins-ets debian/src +# src +/nagios-plugins-ets_* diff --git a/README.md b/README.md index 91f2b0d..b3743ad 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,23 @@ https://github.com/docker-rpm-builder/docker-rpm-builder # Building https://blog.packagecloud.io/buildling-debian-packages-with-debuild/ +https://metebalci.com/blog/a-minimum-complete-example-of-debian-packaging-and-launchpad-ppa-hellodeb/ + + +1. Download the tar ball + wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz + + + + + + +debuild -us -uc +dpkg -c ../nagios-plugins-ets_1.4_amd64.deb + + +# Installation + +dpkg -i nagios-plugins-ets-1.4.deb diff --git a/debian/.debhelper/generated/nagios-plugins-ets/installed-by-dh_installdocs b/debian/.debhelper/generated/nagios-plugins-ets/installed-by-dh_installdocs deleted file mode 100644 index e69de29..0000000 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index f599e28..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/debian/debhelper-build-stamp b/debian/debhelper-build-stamp deleted file mode 100644 index 7b3f047..0000000 --- a/debian/debhelper-build-stamp +++ /dev/null @@ -1 +0,0 @@ -nagios-plugins-ets diff --git a/debian/files b/debian/files deleted file mode 100644 index 8ac4db8..0000000 --- a/debian/files +++ /dev/null @@ -1,2 +0,0 @@ -nagios-plugins-ets_1.4_amd64.buildinfo utils optional -nagios-plugins-ets_1.4_amd64.deb utils optional diff --git a/debian/nagios-plugins-ets.substvars b/debian/nagios-plugins-ets.substvars deleted file mode 100644 index 978fc8b..0000000 --- a/debian/nagios-plugins-ets.substvars +++ /dev/null @@ -1,2 +0,0 @@ -misc:Depends= -misc:Pre-Depends= diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 467aecf..0000000 --- a/debian/rules +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/make -f -export DH_VERBOSE = 1 -%: - dh $@ - -override_dh_auto_install: - echo hello - pwd - install -d debian/nagios-plugins-ets/usr/lib64/nagios/plugins - #install -d debian/nagios-plugins-ets/usr/lib64/nagios/nagios-plugins-ets - mkdir -p debian/src - echo x > debian/src/check_memory - # mkdir -p debian/nagios-plugins-ets/usr/lib64/nagios/plugins - # echo x > debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory - install -p -m0755 debian/src/check_memory debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory - - -#!/usr/bin/make -f -# You must remove unused comment lines for the released package. -#export DH_VERBOSE = 1 - -# %: -# /debian/nagios-plugins-ets/usr diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..8f01236 --- /dev/null +++ b/src/README.md @@ -0,0 +1,70 @@ +# Checks + +## check_smartmon + +``` +check_smartmon --all +``` + +NOTE: Will fail if there's no SMART devices, e.g. on VMWare + +* https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_smartmon/details +* https://github.com/nihlaeth/Nagios_check_smartmon + +## check_zpools + +``` +check_zpools -a +``` + +* https://exchange.nagios.org/directory/Plugins/Operating-Systems/Solaris/check_zpools-2Esh/details +* https://www.claudiokuenzler.com/nagios-plugins/check_zpools.sh + +## check_mem + +``` +check_mem -w 90 -c 95 + +-w +-c +``` + +* https://github.com/liberodark/nrpe-installer +* https://raw.githubusercontent.com/liberodark/nrpe-installer/master/src/check_mem.c + +# Compilation + +``` +cat << EOF > /etc/yum.repos.d/docker-rpm-builder-v1.repo +[docker-rpm-builder-v1] +name=docker-rpm-builder-v1 +baseurl=https://dl.bintray.com/alanfranz/drb-v1-centos-7 +repo_gpgcheck=1 +gpgcheck=1 +enabled=1 +gpgkey=https://www.franzoni.eu/keys/D1270819.txt + https://www.franzoni.eu/keys/D401AB61.txt +EOF +yum install docker-rpm-builder +docker-rpm-builder dir --download-sources alanfranz/docker-rpm-builder-configurations:centos-7 . /tmp/rpms +ls -l /tmp/rpms/x86_64 +``` + +https://github.com/docker-rpm-builder/docker-rpm-builder + + +# Building + +https://blog.packagecloud.io/buildling-debian-packages-with-debuild/ +https://metebalci.com/blog/a-minimum-complete-example-of-debian-packaging-and-launchpad-ppa-hellodeb/ + + +wget -O nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz + +debuild -us -uc +dpkg -c ../nagios-plugins-ets_1.4_amd64.deb + + +# Installation + +dpkg -i nagios-plugins-ets-1.4.deb diff --git a/debian/changelog b/src/debian/changelog similarity index 100% rename from debian/changelog rename to src/debian/changelog diff --git a/src/debian/compat b/src/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/src/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/src/debian/control similarity index 91% rename from debian/control rename to src/debian/control index 0eb2cf3..9c245e2 100644 --- a/debian/control +++ b/src/debian/control @@ -3,9 +3,10 @@ Section: utils Priority: optional Maintainer: Your Name Rules-Requires-Root: no +Standards-Version: 1.2 Package: nagios-plugins-ets -Version: 1.4 +# Version: 1.4 Architecture: amd64 #Depends: python3-psutil, smartmontools Description: Nagios plugins for system monitoring diff --git a/debian/postinst b/src/debian/postinst similarity index 100% rename from debian/postinst rename to src/debian/postinst diff --git a/src/debian/rules b/src/debian/rules new file mode 100755 index 0000000..b5789e3 --- /dev/null +++ b/src/debian/rules @@ -0,0 +1,30 @@ +#!/usr/bin/make -f +export DH_VERBOSE = 1 +%: +# rm -rf src +# git clone https://github.com/ucsd-ets/nagios-plugins-ets.git src +# # cp src/* . +# cd src +# ls -al + dh $@ + +override_dh_auto_install: + echo hello + pwd + # install -d debian/src/usr/lib64/nagios/plugins + #install -d debian/nagios-plugins-ets/usr/lib64/nagios/nagios-plugins-ets + # mkdir -p debian/src + # echo x > debian/src/check_memory + mkdir -p debian/nagios-plugins-ets/usr/lib64/nagios/plugins + # echo x > debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory + ls -al + ls -al output + install -p -m0755 output/check_mem debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_mem + + +#!/usr/bin/make -f +# You must remove unused comment lines for the released package. +#export DH_VERBOSE = 1 + +# %: +# /debian/nagios-plugins-ets/usr diff --git a/src/debian/source/format b/src/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/src/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) From 269f776f0f2eb72f697368e9a51412fcea3e83ae Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 14:52:35 -0700 Subject: [PATCH 05/35] removed readme from source --- src/README.md | 70 --------------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 src/README.md diff --git a/src/README.md b/src/README.md deleted file mode 100644 index 8f01236..0000000 --- a/src/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# Checks - -## check_smartmon - -``` -check_smartmon --all -``` - -NOTE: Will fail if there's no SMART devices, e.g. on VMWare - -* https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_smartmon/details -* https://github.com/nihlaeth/Nagios_check_smartmon - -## check_zpools - -``` -check_zpools -a -``` - -* https://exchange.nagios.org/directory/Plugins/Operating-Systems/Solaris/check_zpools-2Esh/details -* https://www.claudiokuenzler.com/nagios-plugins/check_zpools.sh - -## check_mem - -``` -check_mem -w 90 -c 95 - --w --c -``` - -* https://github.com/liberodark/nrpe-installer -* https://raw.githubusercontent.com/liberodark/nrpe-installer/master/src/check_mem.c - -# Compilation - -``` -cat << EOF > /etc/yum.repos.d/docker-rpm-builder-v1.repo -[docker-rpm-builder-v1] -name=docker-rpm-builder-v1 -baseurl=https://dl.bintray.com/alanfranz/drb-v1-centos-7 -repo_gpgcheck=1 -gpgcheck=1 -enabled=1 -gpgkey=https://www.franzoni.eu/keys/D1270819.txt - https://www.franzoni.eu/keys/D401AB61.txt -EOF -yum install docker-rpm-builder -docker-rpm-builder dir --download-sources alanfranz/docker-rpm-builder-configurations:centos-7 . /tmp/rpms -ls -l /tmp/rpms/x86_64 -``` - -https://github.com/docker-rpm-builder/docker-rpm-builder - - -# Building - -https://blog.packagecloud.io/buildling-debian-packages-with-debuild/ -https://metebalci.com/blog/a-minimum-complete-example-of-debian-packaging-and-launchpad-ppa-hellodeb/ - - -wget -O nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz - -debuild -us -uc -dpkg -c ../nagios-plugins-ets_1.4_amd64.deb - - -# Installation - -dpkg -i nagios-plugins-ets-1.4.deb From 2fb9277d1b35b6f3170e9f5ffb2f38ce4a0bdbbc Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 16:43:17 -0700 Subject: [PATCH 06/35] install check_mem --- .gitignore | 10 ++++++++++ src/debian/rules | 26 +++++++++++++++++--------- src/debian/source/format | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 9b1bd25..01fc6db 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,13 @@ debian/nagios-plugins-ets debian/src # src /nagios-plugins-ets_* +/src/debian/.debhelper +/src/debian/nagios-plugins-ets +/src/*.c +/src/.gitignore +/src/check_service +/src/check_smartctl +/src/check_smartctl.1 +/src/*.py* +/src/*.sh +/src/Makefile diff --git a/src/debian/rules b/src/debian/rules index b5789e3..a4e98c4 100755 --- a/src/debian/rules +++ b/src/debian/rules @@ -1,27 +1,35 @@ #!/usr/bin/make -f export DH_VERBOSE = 1 %: + dh $@ # rm -rf src # git clone https://github.com/ucsd-ets/nagios-plugins-ets.git src # # cp src/* . # cd src # ls -al - dh $@ override_dh_auto_install: - echo hello pwd - # install -d debian/src/usr/lib64/nagios/plugins - #install -d debian/nagios-plugins-ets/usr/lib64/nagios/nagios-plugins-ets - # mkdir -p debian/src - # echo x > debian/src/check_memory - mkdir -p debian/nagios-plugins-ets/usr/lib64/nagios/plugins - # echo x > debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory ls -al - ls -al output + make + ls -al +# echo hello +# pwd +# # install -d debian/src/usr/lib64/nagios/plugins +# #install -d debian/nagios-plugins-ets/usr/lib64/nagios/nagios-plugins-ets +# # mkdir -p debian/src +# # echo x > debian/src/check_memory + mkdir -p debian/nagios-plugins-ets/usr/lib64/nagios/plugins +# # echo x > debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_memory +# ls -al +# ls -al output install -p -m0755 output/check_mem debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_mem +override_dh_auto_configure: + echo hello +# pwd +# ls -al debian #!/usr/bin/make -f # You must remove unused comment lines for the released package. #export DH_VERBOSE = 1 diff --git a/src/debian/source/format b/src/debian/source/format index 163aaf8..89ae9db 100644 --- a/src/debian/source/format +++ b/src/debian/source/format @@ -1 +1 @@ -3.0 (quilt) +3.0 (native) From a4dc175682ce61bac8b775ad241a38811b7e8407 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 16:45:21 -0700 Subject: [PATCH 07/35] move files back to debian folder --- .gitignore | 8 ++++---- {src/debian => debian}/changelog | 0 {src/debian => debian}/compat | 0 {src/debian => debian}/control | 0 {src/debian => debian}/postinst | 0 {src/debian => debian}/rules | 0 {src/debian => debian}/source/format | 0 7 files changed, 4 insertions(+), 4 deletions(-) rename {src/debian => debian}/changelog (100%) rename {src/debian => debian}/compat (100%) rename {src/debian => debian}/control (100%) rename {src/debian => debian}/postinst (100%) rename {src/debian => debian}/rules (100%) rename {src/debian => debian}/source/format (100%) diff --git a/.gitignore b/.gitignore index 01fc6db..4c79867 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ -debian/nagios-plugins-ets -debian/src +/debian/nagios-plugins-ets +/debian/src # src /nagios-plugins-ets_* -/src/debian/.debhelper -/src/debian/nagios-plugins-ets +/debian/.debhelper +/debian/nagios-plugins-ets /src/*.c /src/.gitignore /src/check_service diff --git a/src/debian/changelog b/debian/changelog similarity index 100% rename from src/debian/changelog rename to debian/changelog diff --git a/src/debian/compat b/debian/compat similarity index 100% rename from src/debian/compat rename to debian/compat diff --git a/src/debian/control b/debian/control similarity index 100% rename from src/debian/control rename to debian/control diff --git a/src/debian/postinst b/debian/postinst similarity index 100% rename from src/debian/postinst rename to debian/postinst diff --git a/src/debian/rules b/debian/rules similarity index 100% rename from src/debian/rules rename to debian/rules diff --git a/src/debian/source/format b/debian/source/format similarity index 100% rename from src/debian/source/format rename to debian/source/format From 6563b1b800572cbdd741da0878947949405f7633 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 16:47:59 -0700 Subject: [PATCH 08/35] download source --- .github/workflows/build-deb.yml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index df4745b..880b4c7 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -26,9 +26,9 @@ jobs: # mkdir -p nagios-plugins-ets-1.4/usr/lib64/nagios/plugins # mkdir -p nagios-plugins-ets-1.4/DEBIAN - - name: Print folder structure - run: | - ls -R nagios-plugins-ets-1.4 + # - name: Print folder structure + # run: | + # ls -R nagios-plugins-ets-1.4 # - name: Download plugin files # run: | @@ -41,19 +41,21 @@ jobs: # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_zpools.sh https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_zpools.sh # chmod 755 nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/* - - name: Print folder structure - run: | - ls -R nagios-plugins-ets-1.4 + # - name: Print folder structure + # run: | + # ls -R nagios-plugins-ets-1.4 - - name: Copy plugin files - run: | - # cp control nagios-plugins-ets-1.4/DEBIAN/ - # cp postinst nagios-plugins-ets-1.4/DEBIAN/ + # - name: Copy plugin files + # run: | + # # cp control nagios-plugins-ets-1.4/DEBIAN/ + # # cp postinst nagios-plugins-ets-1.4/DEBIAN/ # - name: Build DEB package # run: dpkg-deb --build nagios-plugins-ets-1.4 - name: Build DEB package run: | + wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz + tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 debuild -us -uc - name: Extract tag name @@ -76,5 +78,5 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - files: ./nagios-plugins-ets-1.4.deb + files: ../nagios-plugins-ets-1.4.deb content_type: application/vnd.debian.binary-package From 5c5bf1481bc2166b980f6bf8091e95c2fa3e67dd Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 16:51:31 -0700 Subject: [PATCH 09/35] build the deb --- .github/workflows/build-deb.yml | 26 ++-------- .github/workflows/release-deb.yml | 82 +++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/release-deb.yml diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 880b4c7..361b8d9 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -58,25 +58,9 @@ jobs: tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 debuild -us -uc - - name: Extract tag name - id: extract_tag - run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}" - - - name: Create Release - id: create_release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.extract_tag.outputs.tag }} - name: Release ${{ steps.extract_tag.outputs.tag }} - draft: false - prerelease: false - - - name: Upload DEB package to Release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Archive production artifacts + uses: actions/upload-artifact@v4 with: - files: ../nagios-plugins-ets-1.4.deb - content_type: application/vnd.debian.binary-package + name: nagios-plugins-ets_amd64.deb + path: | + nagios-plugins-ets_1.4_amd64.deb diff --git a/.github/workflows/release-deb.yml b/.github/workflows/release-deb.yml new file mode 100644 index 0000000..880b4c7 --- /dev/null +++ b/.github/workflows/release-deb.yml @@ -0,0 +1,82 @@ +name: Build and Release DEB Package + +on: + push: + tags: + - '*' + +jobs: + rpm-release: + name: Create DEB release + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v2 + + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y dpkg-dev + + - name: Check Directory + run: | + pwd + ls + + # - name: Create directories for DEB packaging + # run: | + # mkdir -p nagios-plugins-ets-1.4/usr/lib64/nagios/plugins + # mkdir -p nagios-plugins-ets-1.4/DEBIAN + + # - name: Print folder structure + # run: | + # ls -R nagios-plugins-ets-1.4 + + # - name: Download plugin files + # run: | + # Download each file using wget + # wget -O nagios-plugins-ets-1.4/check_mem.c https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_mem.c + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_service https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_service + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartctl https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartctl + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartmon2.py https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartmon2.py + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartmon.py https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartmon.py + # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_zpools.sh https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_zpools.sh + # chmod 755 nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/* + + # - name: Print folder structure + # run: | + # ls -R nagios-plugins-ets-1.4 + + # - name: Copy plugin files + # run: | + # # cp control nagios-plugins-ets-1.4/DEBIAN/ + # # cp postinst nagios-plugins-ets-1.4/DEBIAN/ + + # - name: Build DEB package + # run: dpkg-deb --build nagios-plugins-ets-1.4 + - name: Build DEB package + run: | + wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz + tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 + debuild -us -uc + + - name: Extract tag name + id: extract_tag + run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}" + + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.extract_tag.outputs.tag }} + name: Release ${{ steps.extract_tag.outputs.tag }} + draft: false + prerelease: false + + - name: Upload DEB package to Release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: ../nagios-plugins-ets-1.4.deb + content_type: application/vnd.debian.binary-package From 86d1193286d7552ed406d7c95fab05a642cbe44f Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 16:52:16 -0700 Subject: [PATCH 10/35] build every time --- .github/workflows/build-deb.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 361b8d9..1fd01cf 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -2,8 +2,6 @@ name: Build and Release DEB Package on: push: - tags: - - '*' jobs: rpm-release: From a10e6ca4cebf4062e1172b0a90c62f27add9e39e Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 16:54:08 -0700 Subject: [PATCH 11/35] install dependencies --- .github/workflows/build-deb.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 1fd01cf..9b36c36 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -12,7 +12,13 @@ jobs: uses: actions/checkout@v2 - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y dpkg-dev + run: | + sudo apt-get update + sudo apt-get install -y \ + dpkg-dev \ + devscripts \ + build-essential \ + lintian - name: Check Directory run: | From c3967b7e591c08ae73bb8e4b29817338679ae033 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 16:59:02 -0700 Subject: [PATCH 12/35] install debhelper --- .github/workflows/build-deb.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 9b36c36..4bca314 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -18,7 +18,8 @@ jobs: dpkg-dev \ devscripts \ build-essential \ - lintian + lintian \ + debhelper - name: Check Directory run: | From b0ca6a0d919e55ff69b1067dae78802d98cca942 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 16:59:59 -0700 Subject: [PATCH 13/35] remove non debian files --- .github/workflows/build-deb.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 4bca314..1d1e6d2 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -61,6 +61,8 @@ jobs: run: | wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 + rm README.md + rm -rf .github debuild -us -uc - name: Archive production artifacts From f64b67cf09cff74bff92de926162bcec1be45e8e Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 17:03:00 -0700 Subject: [PATCH 14/35] upload the artifact --- .github/workflows/build-deb.yml | 45 ++++----------------------------- 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 1d1e6d2..ec0b1c3 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -11,7 +11,7 @@ jobs: - name: Checkout source code uses: actions/checkout@v2 - - name: Install dependencies + - name: Install debuild run: | sudo apt-get update sudo apt-get install -y \ @@ -21,48 +21,13 @@ jobs: lintian \ debhelper - - name: Check Directory + - name: Download the source tarball run: | - pwd - ls - - # - name: Create directories for DEB packaging - # run: | - # mkdir -p nagios-plugins-ets-1.4/usr/lib64/nagios/plugins - # mkdir -p nagios-plugins-ets-1.4/DEBIAN - - # - name: Print folder structure - # run: | - # ls -R nagios-plugins-ets-1.4 - - # - name: Download plugin files - # run: | - # Download each file using wget - # wget -O nagios-plugins-ets-1.4/check_mem.c https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_mem.c - # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_service https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_service - # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartctl https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartctl - # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartmon2.py https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartmon2.py - # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_smartmon.py https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_smartmon.py - # wget -O nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/check_zpools.sh https://github.com/ucsd-ets/nagios-plugins-ets/blob/master/check_zpools.sh - # chmod 755 nagios-plugins-ets-1.4/usr/lib64/nagios/plugins/* - - # - name: Print folder structure - # run: | - # ls -R nagios-plugins-ets-1.4 - - # - name: Copy plugin files - # run: | - # # cp control nagios-plugins-ets-1.4/DEBIAN/ - # # cp postinst nagios-plugins-ets-1.4/DEBIAN/ + wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz + tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 - # - name: Build DEB package - # run: dpkg-deb --build nagios-plugins-ets-1.4 - name: Build DEB package run: | - wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz - tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 - rm README.md - rm -rf .github debuild -us -uc - name: Archive production artifacts @@ -70,4 +35,4 @@ jobs: with: name: nagios-plugins-ets_amd64.deb path: | - nagios-plugins-ets_1.4_amd64.deb + ../nagios-plugins-ets_1.4_amd64.deb From a380ad21823857163fe0c1844979554a130ef453 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 17:05:43 -0700 Subject: [PATCH 15/35] copy output deb --- .github/workflows/build-deb.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index ec0b1c3..c612498 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -29,10 +29,11 @@ jobs: - name: Build DEB package run: | debuild -us -uc + cp ../nagios-plugins-ets_1.4_amd64.deb nagios-plugins-ets_amd64.deb - name: Archive production artifacts uses: actions/upload-artifact@v4 with: name: nagios-plugins-ets_amd64.deb path: | - ../nagios-plugins-ets_1.4_amd64.deb + nagios-plugins-ets_amd64.deb From 844f267a02102ae281a9cddf66617f42336ca373 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 6 Aug 2024 17:11:49 -0700 Subject: [PATCH 16/35] updated gitignore --- .gitignore | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 4c79867..a9c5877 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,15 @@ /debian/nagios-plugins-ets -/debian/src -# src /nagios-plugins-ets_* /debian/.debhelper /debian/nagios-plugins-ets -/src/*.c -/src/.gitignore -/src/check_service -/src/check_smartctl -/src/check_smartctl.1 -/src/*.py* -/src/*.sh -/src/Makefile +/*.c +/.gitignore +/check_service +/check_smartctl +/check_smartctl.1 +/*.py* +/*.sh +/Makefile +/output +/debian/files +/debian/nagios-plugins-ets.* From 134d13392c4774543db9b62018c0cc642daba302 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Thu, 8 Aug 2024 12:27:45 -0700 Subject: [PATCH 17/35] updated readme --- README.md | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b3743ad..cf07707 100644 --- a/README.md +++ b/README.md @@ -55,24 +55,32 @@ https://github.com/docker-rpm-builder/docker-rpm-builder # Building -https://blog.packagecloud.io/buildling-debian-packages-with-debuild/ -https://metebalci.com/blog/a-minimum-complete-example-of-debian-packaging-and-launchpad-ppa-hellodeb/ - - 1. Download the tar ball wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz +2. Extract source + tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 +3. Run debuild + debuild -us -uc +4. Check the output + dpkg -c ../nagios-plugins-ets_1.4_amd64.deb + +See: +* https://blog.packagecloud.io/buildling-debian-packages-with-debuild/ +* https://metebalci.com/blog/a-minimum-complete-example-of-debian-packaging-and-launchpad-ppa-hellodeb/ +* https://www.debian.org/doc/manuals/debmake-doc/ch04.en.html +# Installation +dpkg -i nagios-plugins-ets-1.4.deb - +notes: -debuild -us -uc -dpkg -c ../nagios-plugins-ets_1.4_amd64.deb +debuild calls dh build which calls dh_auto_build which calls make -j1 which selects the 1st goal which is install. -# Installation +When I've added -dpkg -i nagios-plugins-ets-1.4.deb +all: +before install to makefile, the problem was solved. From 2913918b35f1bcb2316933c01265c0c6fc9befff Mon Sep 17 00:00:00 2001 From: David Andersen Date: Thu, 8 Aug 2024 12:35:04 -0700 Subject: [PATCH 18/35] updated docs --- README.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cf07707..a5535fa 100644 --- a/README.md +++ b/README.md @@ -55,13 +55,27 @@ https://github.com/docker-rpm-builder/docker-rpm-builder # Building -1. Download the tar ball +1. Install debuild + sudo apt-get install -y \ + dpkg-dev \ + devscripts \ + build-essential \ + lintian \ + debhelper + +2. Clone the debian package repo + git clone https://github.com/ucsd-ets/nagios-plugins-ets-deb.git + +3. Download the source tarball wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz -2. Extract source + +4. Extract source tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 -3. Run debuild + +5. Run debuild debuild -us -uc -4. Check the output + +6. Check the output dpkg -c ../nagios-plugins-ets_1.4_amd64.deb See: From d92d609d54d8e89612a5db991b1d4a1e1537c601 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Thu, 8 Aug 2024 12:41:51 -0700 Subject: [PATCH 19/35] updated readme --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a5535fa..337de25 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,10 @@ ls -l /tmp/rpms/x86_64 https://github.com/docker-rpm-builder/docker-rpm-builder -# Building +# How to build the deb 1. Install debuild + sudo apt-get install -y \ dpkg-dev \ devscripts \ @@ -64,19 +65,23 @@ https://github.com/docker-rpm-builder/docker-rpm-builder debhelper 2. Clone the debian package repo - git clone https://github.com/ucsd-ets/nagios-plugins-ets-deb.git + + git clone https://github.com/ucsd-ets/nagios-plugins-ets-deb.git 3. Download the source tarball - wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz + + wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz 4. Extract source - tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 + + tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 5. Run debuild - debuild -us -uc + + debuild -us -uc 6. Check the output - dpkg -c ../nagios-plugins-ets_1.4_amd64.deb + dpkg -c ../nagios-plugins-ets_1.4_amd64.deb See: * https://blog.packagecloud.io/buildling-debian-packages-with-debuild/ @@ -85,12 +90,11 @@ See: # Installation -dpkg -i nagios-plugins-ets-1.4.deb - + dpkg -i nagios-plugins-ets-1.4.deb -notes: +# notes debuild calls dh build which calls dh_auto_build which calls make -j1 which selects the 1st goal which is install. From 428eb14b994853fc1b67135aad9479a3a435247c Mon Sep 17 00:00:00 2001 From: David Andersen Date: Thu, 8 Aug 2024 12:47:52 -0700 Subject: [PATCH 20/35] updated docs --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 337de25..e351e8a 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ https://github.com/docker-rpm-builder/docker-rpm-builder # How to build the deb +Refer to the [tutorial](https://www.debian.org/doc/manuals/debmake-doc/ch04.en.html) for the directory structure. + + 1. Install debuild sudo apt-get install -y \ From f003b04401f439e26cefeb047170b34ca5e56bcc Mon Sep 17 00:00:00 2001 From: David Andersen Date: Thu, 8 Aug 2024 12:50:42 -0700 Subject: [PATCH 21/35] updated docs --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e351e8a..daee242 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,8 @@ Refer to the [tutorial](https://www.debian.org/doc/manuals/debmake-doc/ch04.en.h 3. Download the source tarball - wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz + wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ / + ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz 4. Extract source From 21b133e49c64c80a6b7ac5cb55b82a98f8d37d63 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Thu, 8 Aug 2024 13:30:42 -0700 Subject: [PATCH 22/35] put version into variable --- .github/workflows/release-deb.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-deb.yml b/.github/workflows/release-deb.yml index 880b4c7..910bc45 100644 --- a/.github/workflows/release-deb.yml +++ b/.github/workflows/release-deb.yml @@ -54,8 +54,10 @@ jobs: # run: dpkg-deb --build nagios-plugins-ets-1.4 - name: Build DEB package run: | - wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz - tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 + ## READ VERSION FROM CONTROL FILE + VERSION=1.2 + wget -O ../nagios-plugins-ets_${VERSION}.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz + tar zxvf ../nagios-plugins-ets_${VERSION}.orig.tar.gz --strip-components=1 debuild -us -uc - name: Extract tag name From 7cd48afd22301fdd5397540c1b585325a869f54f Mon Sep 17 00:00:00 2001 From: swapnil110399 Date: Sun, 11 Aug 2024 17:26:26 -0700 Subject: [PATCH 23/35] update the build. --- .github/workflows/build-deb.yml | 14 +- .gitignore | 16 +- Makefile | 6 + README.md | 2 +- check_mem.c | 127 ++++++ check_service | 63 +++ check_smartctl | 302 +++++++++++++ check_smartmon.py | 414 ++++++++++++++++++ check_smartmon2.py | 308 +++++++++++++ check_zpools.sh | 155 +++++++ .../installed-by-dh_installdocs | 0 .../nagios-plugins-ets/dbgsym-build-ids | 1 + .../dbgsym-root/DEBIAN/control | 13 + .../dbgsym-root/DEBIAN/md5sums | 1 + ...12d63821c8fa3b6c945b9cc1334f5021ca13.debug | Bin 0 -> 5032 bytes .../usr/share/doc/nagios-plugins-ets-dbgsym | 1 + debian/control | 2 +- debian/files | 3 + debian/nagios-plugins-ets.debhelper.log | 21 + debian/nagios-plugins-ets.substvars | 3 + debian/nagios-plugins-ets/DEBIAN/control | 9 + debian/nagios-plugins-ets/DEBIAN/md5sums | 7 + debian/nagios-plugins-ets/DEBIAN/postinst | 3 + .../usr/lib64/nagios/plugins/check_mem | Bin 0 -> 14488 bytes .../usr/lib64/nagios/plugins/check_service | 63 +++ .../usr/lib64/nagios/plugins/check_smartctl | 302 +++++++++++++ .../lib64/nagios/plugins/check_smartmon.py | 414 ++++++++++++++++++ .../lib64/nagios/plugins/check_smartmon2.py | 308 +++++++++++++ .../usr/lib64/nagios/plugins/check_zpools.sh | 155 +++++++ .../share/doc/nagios-plugins-ets/changelog.gz | Bin 0 -> 136 bytes debian/rules | 6 + 31 files changed, 2698 insertions(+), 21 deletions(-) create mode 100644 Makefile create mode 100644 check_mem.c create mode 100644 check_service create mode 100644 check_smartctl create mode 100644 check_smartmon.py create mode 100644 check_smartmon2.py create mode 100644 check_zpools.sh create mode 100644 debian/.debhelper/generated/nagios-plugins-ets/installed-by-dh_installdocs create mode 100644 debian/.debhelper/nagios-plugins-ets/dbgsym-build-ids create mode 100644 debian/.debhelper/nagios-plugins-ets/dbgsym-root/DEBIAN/control create mode 100644 debian/.debhelper/nagios-plugins-ets/dbgsym-root/DEBIAN/md5sums create mode 100644 debian/.debhelper/nagios-plugins-ets/dbgsym-root/usr/lib/debug/.build-id/56/9812d63821c8fa3b6c945b9cc1334f5021ca13.debug create mode 120000 debian/.debhelper/nagios-plugins-ets/dbgsym-root/usr/share/doc/nagios-plugins-ets-dbgsym create mode 100644 debian/files create mode 100644 debian/nagios-plugins-ets.debhelper.log create mode 100644 debian/nagios-plugins-ets.substvars create mode 100644 debian/nagios-plugins-ets/DEBIAN/control create mode 100644 debian/nagios-plugins-ets/DEBIAN/md5sums create mode 100755 debian/nagios-plugins-ets/DEBIAN/postinst create mode 100755 debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_mem create mode 100755 debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_service create mode 100755 debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartctl create mode 100755 debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartmon.py create mode 100755 debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartmon2.py create mode 100755 debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_zpools.sh create mode 100644 debian/nagios-plugins-ets/usr/share/doc/nagios-plugins-ets/changelog.gz diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index c612498..5b5cf1a 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -4,13 +4,19 @@ on: push: jobs: - rpm-release: + deb-release: name: Create DEB release runs-on: ubuntu-latest steps: - name: Checkout source code uses: actions/checkout@v2 + - name: Get Version from control file + id: get_version + run: | + VERSION=$(grep -Eo "^Version: .+" debian/control | awk '{print $2}') + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Install debuild run: | sudo apt-get update @@ -23,13 +29,13 @@ jobs: - name: Download the source tarball run: | - wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz - tar zxvf ../nagios-plugins-ets_1.4.orig.tar.gz --strip-components=1 + wget -O ../nagios-plugins-ets_${VERSION}.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/${VERSION}.tar.gz + tar zxvf ../nagios-plugins-ets_${VERSION}.orig.tar.gz --strip-components=1 - name: Build DEB package run: | debuild -us -uc - cp ../nagios-plugins-ets_1.4_amd64.deb nagios-plugins-ets_amd64.deb + cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_amd64.deb - name: Archive production artifacts uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index a9c5877..53752db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1 @@ -/debian/nagios-plugins-ets -/nagios-plugins-ets_* -/debian/.debhelper -/debian/nagios-plugins-ets -/*.c -/.gitignore -/check_service -/check_smartctl -/check_smartctl.1 -/*.py* -/*.sh -/Makefile -/output -/debian/files -/debian/nagios-plugins-ets.* +output diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..04e28b0 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +helloworld: + mkdir -p output + gcc check_mem.c -o output/check_mem + +install: helloworld + install -m 0755 check_mem /usr/lib64/nagios/plugins diff --git a/README.md b/README.md index daee242..04efe3c 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Refer to the [tutorial](https://www.debian.org/doc/manuals/debmake-doc/ch04.en.h 3. Download the source tarball - wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ / + wget -O ../nagios-plugins-ets_1.4.orig.tar.gz https://github.com/ \ ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz 4. Extract source diff --git a/check_mem.c b/check_mem.c new file mode 100644 index 0000000..2ff0b4b --- /dev/null +++ b/check_mem.c @@ -0,0 +1,127 @@ +#include +#include +#include +#include +#include +#include + +#include + +#define INVAL_SIZE UINT64_C(0xFFFFFFFFFFFFFFFF) + +struct mem_stats +{ + uint64_t total_kB; + uint64_t avail_kB; + uint64_t free_kB; + uint64_t buffers_kB; + uint64_t cached_kB; + uint64_t used_kB; +}; + +static void dump_mem_stats(struct mem_stats *mem_stats) +{ + FILE *fp; + char line[1024]; + unsigned int i; + char *nptr; + + fp = fopen("/proc/meminfo", "r"); + + mem_stats->total_kB = INVAL_SIZE; + mem_stats->avail_kB = INVAL_SIZE; + mem_stats->free_kB = INVAL_SIZE; + mem_stats->buffers_kB = INVAL_SIZE; + mem_stats->cached_kB = INVAL_SIZE; + mem_stats->used_kB = INVAL_SIZE; + + while (!feof(fp) && !ferror(fp)) + { + if (!fgets(line, sizeof(line), fp)) + continue; + + if (strncmp(&line[0], "MemTotal:", 9) == 0) + { + mem_stats->total_kB = strtoull(&line[9], &nptr, 10); + continue; + } + + if (strncmp(&line[0], "MemAvailable:", 13) == 0) + { + mem_stats->avail_kB = strtoull(&line[13], &nptr, 10); + continue; + } + + if (strncmp(&line[0], "memFree:", 8) == 0) + { + mem_stats->free_kB = strtoull(&line[8], &nptr, 10); + continue; + } + + if (strncmp(&line[0], "Buffers:", 8) == 0) + { + mem_stats->buffers_kB = strtoull(&line[8], &nptr, 10); + continue; + } + + if (strncmp(&line[0], "Cached:", 7) == 0) + { + mem_stats->cached_kB = strtoull(&line[7], &nptr, 10); + continue; + } + } + + fclose(fp); + + if (mem_stats->avail_kB == INVAL_SIZE) + { + mem_stats->avail_kB = 0; + + if (mem_stats->free_kB != INVAL_SIZE) + mem_stats->avail_kB += mem_stats->free_kB; + + if (mem_stats->buffers_kB != INVAL_SIZE) + mem_stats->avail_kB += mem_stats->buffers_kB; + + if (mem_stats->cached_kB != INVAL_SIZE) + mem_stats->avail_kB += mem_stats->cached_kB; + } + + if (mem_stats->used_kB == INVAL_SIZE) + mem_stats->used_kB = mem_stats->total_kB - mem_stats->avail_kB; +} + +int main(int argc, char **argv) +{ + int result; + float warn_threshold; + float crit_threshold; + struct mem_stats stats; + float mem_pct; + const char *panic_str; + + /* cmd line : $0 -w warn_threshold -c crit_threshold */ + warn_threshold = strtof(argv[2], NULL); + crit_threshold = strtof(argv[4], NULL); + + dump_mem_stats(&stats); + + mem_pct = 10000 * stats.used_kB / stats.total_kB / 100.f; + + panic_str = "OK"; + result = 0; + if (mem_pct >= crit_threshold) + { + panic_str = "Critical"; + result = 2; + } + else if (mem_pct >= warn_threshold) + { + panic_str = "Warning"; + result = 1; + } + + printf("MEMORY %s - Used = %.2f%% | 'Total'=%" PRIu64 "MB 'Used'=%" PRIu64 "MB 'Free'=%" PRIu64 "MB\n", panic_str, mem_pct, stats.total_kB / 1024, stats.used_kB / 1024, stats.avail_kB / 1024); + + return result; +} diff --git a/check_service b/check_service new file mode 100644 index 0000000..f0b9db3 --- /dev/null +++ b/check_service @@ -0,0 +1,63 @@ +#!/bin/bash + +#Author: Tino + +#VARIABLES NAGIOS +OK=0 +WARNING=1 +CRITICAL=2 +UNKNOWN=3 + +PROGNAME=`basename $0 .sh` +VERSION="Version 1.1" + +print_version() { + echo "$VERSION" +} + +print_help() { + print_version $PROGNAME $VERSION + echo "" + echo "$PROGNAME is a Nagios plugin to check a specific service using systemctl." + echo "" + echo "$PROGNAME -s " + exit $UNKNOWN +} + +if test -z "$1" +then + print_help + exit $CRITICAL +fi + +while test -n "$1"; do + case "$1" in + --help|-h) + print_help + exit $UNKNOWN + ;; + --version|-v) + print_version $PROGNAME $VERSION + exit $UNKNOWN + ;; + --service|-s) + SERVICE=$2 + shift + ;; + *) + echo "Unknown argument: $1" + print_help + exit $UNKNOWN + ;; + esac + shift +done + +if systemctl is-active $SERVICE >/dev/null 2>&1 +then + echo -e "OK: Service $SERVICE is running!" + exit $OK +else + echo -e "CRITICAL: Service $SERVICE is not running!" + exit $CRITICAL +fi diff --git a/check_smartctl b/check_smartctl new file mode 100644 index 0000000..dd343bc --- /dev/null +++ b/check_smartctl @@ -0,0 +1,302 @@ +#!/usr/bin/python + +# -*- coding: iso8859-1 -*- +# +# $Id: version.py 133 2006-03-24 10:30:20Z fuller $ +# +# check_smartmon +# Copyright (C) 2006 daemogorgon.net +# Copyright (C) 2010 Orcan Ogetbil (orcan at nbcs.rutgers.edu) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +"""Package versioning +""" + + +import os.path +import subprocess +import sys +import time + +from optparse import OptionParser +from operator import itemgetter, attrgetter + + +__author__ = "fuller " +__version__ = "$Revision$" + + +# path to smartctl +_smartctlPath = "/usr/sbin/smartctl" + +# application wide verbosity (can be adjusted with -v [0-3]) +_verbosity = 0 + +is_array = lambda var: isinstance(var, (list, tuple)) + +def parseCmdLine(args): + """Commandline parsing.""" + + usage = "usage: %prog [options] device" + version = "%%prog %s" % (__version__) + + parser = OptionParser(usage=usage, version=version) + parser.add_option("-d", "--devicetype", action="store", dest="devicetype", default="scsi", metavar="DEVICETYPE", + help="device type (scsi or megaraid,N or ...; defaults to scsi)") + parser.add_option("-v", "--verbosity", action="store", + dest="verbosity", type="int", default=0, + metavar="LEVEL", help="set verbosity level to LEVEL; defaults to 0 (quiet), \ + possible values go up to 3") + parser.add_option("-w", "--warning-threshold", metavar="TEMP", action="store", + type="int", dest="warningThreshold", default=55, + help="set temperature warning threshold to given temperature (defaults to 55)") + parser.add_option("-c", "--critical-threshold", metavar="TEMP", action="store", + type="int", dest="criticalThreshold", default="60", + help="set temperature critical threshold to given temperature (defaults to 60)") + + (options,devices) = parser.parse_args(sys.argv[1:]) + + if len(devices) ==0: + exitWithMessage(3,"UNKNOWN: Error, at least one device must be entered") + + return (options,devices) +# end + + +def checkDevice(path): + """Check if device exists and permissions are ok. + + Returns: + - 0 ok + - 1 no such device + """ + + vprint(3, "Check if %s does exist and can be read" % path) + if not os.access(path, os.F_OK): + return (1, "UNKNOWN: no such device found (%s)" % (path)) + # We can't check the read permissions as unprivileged user - Orcan + #elif not os.access(path, os.R_OK): + # return (2, "UNKNOWN: no read permission given (%s)" % (path)) + else: + return (0, "") + # fi +# end + + +def checkSmartMonTools(path): + """Check if smartctl is available and can be executed. + + Returns: + - 0 ok + - 1 no such file + - 2 cannot execute file + """ + + vprint(3, "Check if %s does exist and can be read" % path) + if not os.access(path, os.F_OK): + return (1, "UNKNOWN: cannot find %s" % path) + elif not os.access(path, os.X_OK): + return (2, "UNKNOWN: cannot execute %s" % path) + else: + return (0, "") + # fi +# end + + +def callSmartMonTools(path, devicetype, device): + # get health status + cmd = "sudo %s -d %s %s -a" % (path, devicetype, device) + vprint(3, "Get device health status: %s" % cmd) + + sp = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + # See if smartctl exits cleanly + # This is a lot hacky since smartctl output is not consistent. It doesn't always + # close output streams stdout, stderr etc. I really don't like the following + # code - Orcan + i = 0 + poll = False + while i < 5: + if sp.poll(): + poll = True + break + i = i+1 + vprint(3, "smartctl did not exit yet. Waiting...") + time.sleep(0.1) + + if poll: # clean + (child_stdin, child_stdout, child_stderr) = (sp.stdin, sp.stdout, sp.stderr) + child_stdout = child_stdout.readlines() + child_stderr = child_stderr.readline() + vprint(3, "smartctl did exit cleanly") + else: # not clean. let's gather what we have + vprint(3, "smartctl did not exit cleanly") + (child_stdout, child_stderr) = sp.communicate() + + if len(child_stderr): + return (3, "UNKNOWN: call exits unexpectedly (%s)" % child_stderr, "", + "") + StatusOutput = "" + faultline = "" + for line in child_stdout: + if line.find("INVALID ARGUMENT TO -d") > 0 or line.find("Unknown device type") > -1: + faultline = line + continue + if faultline != "": + return (3, faultline + line, "") + StatusOutput = StatusOutput + line + # done + return (0 ,"", StatusOutput) +# end + + +def parseOutput(Message): + """Parse smartctl output + + Returns (health status, temperature). + """ + + # parse health status and temperature + healthStatus="" + temperature = None + lines = Message.split("\n") + for line in lines: + if line.find("INQUIRY failed") > -1: + exitWithMessage(1, "UNKNOWN: " + line) + if line.startswith("SMART Health Status:") or line.startswith("SMART overall-health self-assessment"): + healthStatus = line.split()[-1] + if line.startswith("Temperature:"): + try: + temperature = int(line.split()[-2]) + except: + temperature = -100 + break + + vprint(3, "Health status: %s" % healthStatus) + vprint(3, "Temperature: %s" %temperature) + + return (healthStatus, temperature) +# end + + +def createReturnInfo(device, devicetype, healthStatus, temperature, warningThreshold, + criticalThreshold): + """Create return information according to given thresholds.""" + # this is absolutely critical! + if healthStatus != "PASSED" and healthStatus != "OK": + if healthStatus == "": + return (2, "CRITICAL: device %s of type %s did not pass a health status." % (device, devicetype)) + return (2, "CRITICAL: device %s of type %s passed health status: (%s)" % (device, devicetype, healthStatus)) + elif temperature == None and devicetype != "ata": + return (2, "CRITICAL: device %s of type %s does not pass temperature information" % (device, devicetype)) + + elif temperature > criticalThreshold: + return (2, "CRITICAL: device %s of type %s temperature (%d) exceeds critical temperature threshold (%s)" % (device, devicetype, temperature, criticalThreshold)) + elif temperature > warningThreshold: + return (1, "WARNING: device %s of type %s temperature (%d) exceeds warning temperature threshold (%s)" % (device, devicetype, temperature, warningThreshold)) + else: + if temperature == None: + temperature = "N/A" + return (0, "OK: device %s of type %s is functional and stable (temperature: %s C)" % ( device , devicetype, str(temperature))) + + # fi +# end + + +def exitWithMessage(value, message = ""): + """Exit with given value.""" + + if message: + print message + sys.exit(value) +# end + + +def vprint(level, message): + """Verbosity print. + + Decide according to the given verbosity level if the message will be + printed to stdout. + """ + + if level <= verbosity: + print message + # fi +# end + +def allDeviceTypes(devicetype): + dt_array = devicetype.split(",") + if len(dt_array) == 1: + return dt_array + dt_base = dt_array[0] + dt_all = [] + for ext in dt_array[1:]: + dt_all.append(dt_base+","+ext) + return dt_all + +if __name__ == "__main__": + (options, devices) = parseCmdLine(sys.argv) + verbosity = options.verbosity + + vprint(2, "Get device name(s)B") + overallvalue = 0 + devicetypes = allDeviceTypes(options.devicetype) + full_message = [] + + for device in devices: + for devicetype in devicetypes: + vprint(1, "Device: %s" % device) + + # check if we can access 'path' + vprint(2, "Check device") + (value, message) = checkDevice(device) + if value != 0: + exitWithMessage(3, message) + # fi + + # check if we have smartctl available + (value, message) = checkSmartMonTools(_smartctlPath) + if value != 0: + exitWithMessage(3, message) + # fi + vprint(1, "Path to smartctl: %s" % _smartctlPath) + + # call smartctl and parse output + vprint(2, "Call smartctl") + + (value, message, Output) = callSmartMonTools(_smartctlPath, devicetype, device) + if value != 0: + exitWithMessage(3, message) + vprint(2, "Parse smartctl output") + (healthStatus, temperature) = parseOutput(Output) + vprint(2, "Generate return information") + (value, message) = createReturnInfo(device, devicetype, healthStatus, temperature, + options.warningThreshold, options.criticalThreshold) + if value > overallvalue: + overallvalue = value + full_message.append((value,message)) + + full_message = sorted(full_message, key=itemgetter(1)) + message_string = "" + for value,message in full_message: + message_string += message + " " + + + # exit program + exitWithMessage(overallvalue, message_string[:-1]) + +# fi diff --git a/check_smartmon.py b/check_smartmon.py new file mode 100644 index 0000000..1754977 --- /dev/null +++ b/check_smartmon.py @@ -0,0 +1,414 @@ +#!/usr/bin/python +"""Nagios plugin for monitoring S.M.A.R.T. status.""" + +# -*- coding: iso8859-1 -*- +# +# $Id: version.py 133 2006-03-24 10:30:20Z fuller $ +# +# check_smartmon +# Copyright (C) 2006 daemogorgon.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# +# Fork author: nihlaeth +# + +import os.path +import sys +import re +import psutil +import subprocess +from optparse import OptionParser + +__author__ = "fuller " +__version__ = "$Revision$" + + +# path to smartctl +# TODO use which to fetch path +_smartctl_path = "/usr/sbin/smartctl" + +# application wide verbosity (can be adjusted with -v [0-3]) +_verbosity = 0 + + +def parse_cmd_line(arguments): + """Commandline parsing.""" + usage = "usage: %prog [options] device" + version = "%%prog %s" % (__version__) + + parser = OptionParser(usage=usage, version=version) + parser.add_option( + "-d", + "--device", + action="store", + dest="device", + default="", + metavar="DEVICE", + help="device to check") + parser.add_option( + "-a", + "--all-disks", + action="store_true", + dest="alldisks", + default="", + help="Check all disks") + parser.add_option( + "-v", + "--verbosity", + action="store", + dest="verbosity", + type="int", + default=0, + metavar="LEVEL", + help="set verbosity level to LEVEL; defaults to 0 (quiet), \ + possible values go up to 3") + parser.add_option( + "-w", + "--warning-threshold", + metavar="TEMP", + action="store", + type="int", + dest="warning_temp", + default=55, + help=("set temperature warning threshold to given temperature" + " (default:55)")) + parser.add_option( + "-c", + "--critical-threshold", + metavar="TEMP", + action="store", + type="int", + dest="critical_temp", + default="60", + help=("set temperature critical threshold to given temperature" + " (default:60)")) + + return parser.parse_args(arguments) + + +def check_device_permissions(path): + """Check if device exists and permissions are ok. + + Returns: + - 0 ok + - 1 no such device + - 2 no read permission given + """ + vprint(3, "Check if %s does exist and can be read" % path) + if not os.access(path, os.F_OK): + return (3, "UNKNOWN: no such device found") + elif not os.access(path, os.R_OK): + return (3, "UNKNOWN: no read permission given") + else: + return (0, "") + return (0, "") + + +def check_smartmontools(path): + """Check if smartctl is available and can be executed. + + Returns: + - 0 ok + - 1 no such file + - 2 cannot execute file + """ + vprint(3, "Check if %s does exist and can be read" % path) + if not os.access(path, os.F_OK): + print "UNKNOWN: cannot find %s" % path + sys.exit(3) + elif not os.access(path, os.X_OK): + print "UNKNOWN: cannot execute %s" % path + sys.exit(3) + + +def call_smartmontools(path, device): + """Get smartmontool output.""" + cmd = "%s -a %s" % (path, device) + vprint(3, "Get device health status: %s" % cmd) + result = "" + message = "" + code_to_return = 0 + try: + result = subprocess.check_output(cmd, shell=True) + except subprocess.CalledProcessError as error: + # smartctl passes a lot of information via the return code + return_code = error.returncode + if return_code % 2**1 > 0: + # bit 0 is set - command line did not parse + # output is not useful now, simply return + message += "UNKNOWN: smartctl parsing error " + return_code -= 2**0 + code_to_return = 3 + if return_code % 2**2 > 0: + # bit 1 is set - device open failed + # output is not useful now, simply return + message += "UNKNOWN: could not open device " + return_code -= 2**1 + code_to_return = 3 + if return_code % 2**3 > 0: + # bit 2 is set - some smart or ata command failed + # we still want to see what the output says + result = error.output + message += "CRITICAL: some SMART or ATA command to disk " + message += "failed " + return_code -= 2**2 + code_to_return = 2 + if return_code % 2**4 > 0: + # bit 3 is set - smart status returned DISK FAILING + # we still want to see what the output says + result = error.output + message += "CRITICAL: SMART statis is DISK FAILING " + return_code -= 2**3 + code_to_return = 2 + if return_code % 2**5 > 0: + # bit 4 is set - prefail attributes found + result = error.output + message += "CRITICAL: prefail attributes found " + return_code -= 2**4 + code_to_return = 2 + if return_code % 2**6 > 0: + # bit 5 is set - disk ok, but prefail attributes in the past + result = error.output + # this should be a warning, but that's too much hasle + message += "WARNING: some prefail attributes were critical " + message += "in the past " + return_code -= 2**5 + code_to_return = 1 + if return_code % 2**7 > 0: + # bit 6 is set - errors recorded in error log + result = error.output + message += "WARNING: errors recorded in error log " + return_code -= 2**6 + code_to_return = 1 + if return_code % 2**8 > 0: + # bit 7 is set - device self-test log contains errors + result = error.output + message += "CRITICAL: self-test log contains errors " + return_code -= 2**7 + code_to_return = 2 + except OSError as error: + code_to_return = 3 + message = "UNKNOWN: call exits unexpectedly (%s)" % error + + return (code_to_return, result, message) + + +def parse_output(output, warning_temp, critical_temp): + """ + Parse smartctl output. + + Returns status of device. + """ + # parse health status + # + # look for line '=== START OF READ SMART DATA SECTION ===' + status_line = "" + health_status = "" + reallocated_sector_ct = 0 + temperature = 0 + reallocated_event_count = 0 + current_pending_sector = 0 + offline_uncorrectable = 0 + error_count = 0 + + lines = output.split("\n") + for line in lines: + # extract status line + if "overall-health self-assessment test result" in line: + status_line = line + parts = status_line.rstrip().split() + health_status = parts[-1:][0] + vprint(3, "Health status: %s" % health_status) + # extract status line (compatibility with all smartctl versions) + if "Health Status" in line: + status_line = line + parts = status_line.rstrip().split() + health_status = parts[-1:][0] + vprint(3, "Health status: %s" % health_status) + + parts = line.split() + if len(parts) > 0: + # self test spans can also start with 5, so we + # need a tighter check here than elsewhere + if parts[0] == "5" and \ + parts[1] == "Reallocated_Sector_Ct" and \ + reallocated_sector_ct == 0: + # extract reallocated_sector_ct + # 5 is the reallocated_sector_ct id + reallocated_sector_ct = int(parts[9]) + vprint(3, "Reallocated_Sector_Ct: %d" % reallocated_sector_ct) + elif parts[0] == "190" and temperature == 0: + # extract temperature + # 190 can be temperature value id too + temperature = int(parts[9]) + vprint(3, "Temperature: %d" % temperature) + elif parts[0] == "194" and temperature == 0: + # extract temperature + # 194 is the temperature value id + temperature = int(parts[9]) + vprint(3, "Temperature: %d" % temperature) + elif parts[0] == "196" and reallocated_event_count == 0: + # extract reallocated_event_count + # 196 is the reallocated_event_count id + reallocated_event_count = int(parts[9]) + vprint( + 3, + "Reallocated_Event_Count: %d" % reallocated_event_count) + elif parts[0] == "197" and current_pending_sector == 0: + # extract current_pending_sector + # 197 is the current_pending_sector id + current_pending_sector = int(parts[9]) + vprint( + 3, + "Current_Pending_Sector: %d" % current_pending_sector) + elif parts[0] == "198" and offline_uncorrectable == 0: + # extract offline_uncorrectable + # 198 is the offline_uncorrectable id + offline_uncorrectable = int(parts[9]) + vprint( + 3, + "Offline_Uncorrectable: %d" % offline_uncorrectable) + elif "ATA Error Count" in line: + error_count = int(parts[3]) + vprint( + 3, + "ATA error count: %d" % error_count) + elif "No Errors Logged" in line: + error_count = 0 + vprint( + 3, + "ATA error count: 0") + + # now create the return information for this device + return_status = 0 + device_status = "" + + # check if smartmon could read device + if health_status == "": + return (3, "UNKNOWN: could not parse output") + + # check health status + while health_status not in ["PASSED", "OK"]: + return_status = 2 + device_status += "CRITICAL: device does not pass health status " + + # check sectors + if reallocated_sector_ct > 0 or \ + reallocated_event_count > 0 or \ + current_pending_sector > 0 or \ + offline_uncorrectable > 0: + return_status = 2 + device_status += "CRITICAL: there is a problem with bad sectors " + device_status += "on the drive. " + device_status += "Reallocated_Sector_Ct:%d, " % reallocated_sector_ct + device_status += "Reallocated_Event_Count:%d, " % reallocated_event_count + device_status += "Current_Pending_Sector:%d, " % current_pending_sector + device_status += "Offline_Uncorrectable:%d " % offline_uncorrectable + + # check temperature + if temperature > critical_temp: + return_status = 2 + device_status += "CRITICAL: device temperature (%d)" % temperature + device_status += "exceeds critical temperature " + device_status += "threshold (%s) " % critical_temp + elif temperature > warning_temp: + # don't downgrade return status! + if return_status < 2: + return_status = 1 + device_status += "WARNING: device temperature (%d) " % temperature + device_status += "exceeds warning temperature " + device_status += "threshold (%s) " % warning_temp + + # check error count + if error_count > 0: + if return_status < 2: + return_status = 1 + device_status += "WARNING: error count %d " % error_count + + if return_status == 0: + # no warnings or errors, report everything is ok + device_status = "OK: device is functional and stable " + device_status += "(temperature: %d) " % temperature + + return (return_status, device_status) + + +def vprint(level, text): + """Verbosity print. + + Decide according to the given verbosity level if the message will be + printed to stdout. + """ + if level <= verbosity: + print text + + +if __name__ == "__main__": + # pylint: disable=invalid-name + (options, args) = parse_cmd_line(sys.argv) + verbosity = options.verbosity + + check_smartmontools(_smartctl_path) + + vprint(2, "Get device name") + # assemble device list to be monitored + if not options.alldisks: + devices = [options.device] + else: + devices = [] + # Regex for Valid device name + valid_device_name = '/dev/[ahsv]d.*' + for partition in psutil.disk_partitions(): + if re.search(valid_device_name, partition.device): + devices.append(partition.device.strip(partition.device[-1])) + vprint(1, "Devices: %s" % devices) + + return_text = "" + exit_status = 0 + for device in devices: + vprint(1, "Device: %s" % device) + return_text += "%s: " % device + + # check if we can access 'path' + vprint(2, "Check device") + (return_status, message) = check_device_permissions(device) + if return_status != 0: + if exit_status < return_status: + exit_status = return_status + return_text += message + + # call smartctl and parse output + vprint(2, "Call smartctl") + return_status, output, message = call_smartmontools( + _smartctl_path, + device) + if return_status != 0: + if exit_status < return_status: + exit_status = return_status + return_text += message + if output != "": + vprint(2, "Parse smartctl output") + return_status, device_status = parse_output( + output, + options.warning_temp, + options.critical_temp) + if exit_status < return_status: + exit_status = return_status + return_text += device_status + + print return_text + sys.exit(exit_status) diff --git a/check_smartmon2.py b/check_smartmon2.py new file mode 100644 index 0000000..3140ce3 --- /dev/null +++ b/check_smartmon2.py @@ -0,0 +1,308 @@ +#!/usr/bin/python + +# -*- coding: iso8859-1 -*- +# +# $Id: version.py 133 2006-03-24 10:30:20Z fuller $ +# +# check_smartmon +# Copyright (C) 2006 daemogorgon.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# +# MOD by basos (basos= attrSpec[1]: + return (2,)+attrSpec ; # crit (val >= crit) + elif raw >= attrSpec[0]: + return (1,)+attrSpec; # warn (val >= warn) + return (0,)+attrSpec; # ok + #def + + def formatAttr(s_id, s_name, s_failed, s_value, s_thres): + return "Attribute "+str(s_name)+" ("+str(s_id)+") seems to fail ("+(str(s_failed) if s_failed != '-' else \ + str(s_value)+"<="+str(s_thres))+")" + + def pipeStuff(s_name, s_value, s_thres, s_cthres = None, s_min = "0", s_max = "254"): + if (None == s_cthres): s_cthres = s_thres + return "|"+str(s_name)+"="+str(s_value)+";"+str(s_thres)+";"+str(s_cthres)+((";"+s_min+((";"+s_max) if s_max != None else "")) if s_min != None else "") + + # parse health status + # + statusLine = "" + lines = healthMessage.split("\n") + getNext = 0 + healthStatus = '' + temperStuff = (None, "Temperature_not_found", 0 , 0) + in_attrs = 0 + ret = (3, "UNKNNOWN: smartctl encountered an error") + for line in lines: + if healthStatus == '' and re.search(r"^SMART overall-health self-assessment test result", line): + ps = line.split() + healthStatus = ps[-1] + vprint(3, "Health status: %s" % healthStatus) + # this is absolutely critical! + if healthStatus != "PASSED": + ret = (2, "CRITICAL: SMART overall health test failed") + else: + ret = (0, "OK: device is functional and stable") + continue; + # fi + if in_attrs == 1 and (not line or not re.search(r"\d+", line.split()[0])): + vprint(3, "End of Attributes parsing"); + in_attrs = 0 + if in_attrs: + ps = line.split() + s_id, s_name, s_flag, s_value, s_worst, s_thres, s_type, s_updated, s_failed, s_raw = \ + ps[0], ps[1], ps[2], ps[3], ps[4], ps[5], ps[6], ps[7], ps[8], ps[9] + vprint(2, "Checking Attr: %s (%s), v: %s (%s)" % (s_name, s_id, s_value, s_raw)) + if (s_failed != '-' or int(s_value) <= int(s_thres)): + if s_type.lower() == 'pre-fail' : + if s_failed.lower() != 'in_the_past': + ret = (2, "CRITICAL: "+formatAttr(s_id, s_name, s_failed, s_value, s_thres) + \ + pipeStuff(s_name, s_value, s_thres)) + elif ret[0] < 2: + ret = (1, "WARNING: "+formatAttr(s_id, s_name, s_failed, s_value, s_thres) + \ + pipeStuff(s_name, s_value, s_thres)) + elif ret[0] < 2 and s_failed.lower() != 'in_the_past': + ret = (1, "WARNING: "+formatAttr(s_id, s_name, s_failed, s_value, s_thres) + \ + pipeStuff(s_name, s_value, s_thres)) + # fi + tmp = checkAttr(s_id, s_raw, attrSpecs) + if tmp[0] > 0: + if ret[0] < 2: + #ret = (tmp[0], "CRITICAL" if tmp[0] == 2 else "WARNING"+": Attribute raw "+str(s_name)+" ("+str(s_id)+") over "+("critical" if tmp[0] == 2 \ + #else "warning")+"threshold ("+str(s_raw)+">="+str(tmp[2 if tmp[0] == 2 else 1]+")")) + vprint(2, "Attr "+str(s_id)+", "+str(s_raw)+" over thres "+str(tmp)); + ret = (tmp[0], ("CRITICAL" if tmp[0] == 2 else "WARNING")+": " + \ + formatAttr(s_id, s_name, "Raw_limits", s_raw, tmp[2 if tmp[0] == 2 else 1]) + \ + pipeStuff(s_name, s_raw, tmp[1], tmp[2], *(("0", "100") if len(tmp) == 4 and tmp[3] else ()))) + elif tmp[0] == 0 and len(tmp) == 4 and tmp[3]: + # found temperature + temperStuff = (s_name, s_raw) + tmp[1:3] + elif re.search(r"ID.?\s+ATTRIBUTE_NAME\s+FLAG\s+VALUE\s+WORST\s+THRESH\s+TYPE\s+UPDATED\s+WHEN_FAILED\s+RAW_VALUE", line): + vprint(3, "Start of Attributes parsing") + in_attrs = 1 + else: + vprint(3, "Ommiting smartctl row: %s" % line) + # ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE + # done + if ret[0] == 0 and temperStuff[0] != None: + temperStuff = temperStuff + ("0", "100") + ret = (0, ret[1] + pipeStuff(*temperStuff)) + + if ret[0] == 3: + vprint(3, "smartctl error, output: %s" % healthMessage); + return ret + ##(0, "OK: device is functional and stable (temperature: %d)" % temperature) +# end + + +def exitWithMessage(value, message): + """Exit with given value and status message.""" + + print message + sys.exit(value) +# end + + +def vprint(level, message): + """Verbosity print. + + Decide according to the given verbosity level if the message will be + printed to stdout. + """ + + if level <= verbosity: + print message + # fi +# end + + +if __name__ == "__main__": + (options, args) = parseCmdLine(sys.argv) + verbosity = options.verbosity + + vprint(2, "Get device name") + device = options.device + vprint(1, "Device: %s" % device) + + # check if we can access 'path' + vprint(2, "Check device") + (value, message) = checkDevice(device) + if value != 0: + exitWithMessage(3, message) + # fi + + # check if we have smartctl available + #(value, message) = checkSmartMonTools(options.smartctlPath) + #if value != 0: + # exitWithMessage(3, message) + # fi + vprint(1, "Path to smartctl: %s" % options.smartctlPath) + + # call smartctl and parse output + vprint(2, "Call smartctl") + (value, message, healthStatusOutput) = callSmartMonTools(options.smartctlPath, device, options.noCheckStandby, options.smartctlArgs) + if value != 0: + exitWithMessage(value, message) + + vprint(2, "Parse smartctl output and return info") + attrs = {} + if options.rawAttrs: + for at in options.rawAttrs: + attrs[at[0]] = at[1:3] + attrs[options.tempAttrId] = (options.warningThreshold, options.criticalThreshold, True) + (value, message) = createReturnInfo(healthStatusOutput, attrs) + + # exit program + exitWithMessage(value, message) + +# fi diff --git a/check_zpools.sh b/check_zpools.sh new file mode 100644 index 0000000..ad5861e --- /dev/null +++ b/check_zpools.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +######################################################################### +# Script: check_zpools.sh +# Purpose: Nagios plugin to monitor status of zfs pool +# Authors: Aldo Fabi First version (2006-09-01) +# Vitaliy Gladkevitch Forked (2013-02-04) +# Claudio Kuenzler Complete redo, perfdata, etc (2013-2023) +# Per von Zweigbergk Various fixes (2016-10-12) +# @waoki Trap zpool command errors (2022-03-01) +# @mrdsam Improvement (2022-05-24) +# Doc: http://www.claudiokuenzler.com/monitoring-plugins/check_zpools.php +# History: +# 2006-09-01 Original first version +# 2006-10-04 Updated (no change history known) +# 2013-02-04 Forked and released +# 2013-05-08 Make plugin work on different OS, pepp up plugin +# 2013-05-09 Bugfix in exit code handling +# 2013-05-10 Removed old exit vars (not used anymore) +# 2013-05-21 Added performance data (percentage used) +# 2013-07-11 Bugfix in zpool health check +# 2014-02-10 Bugfix in threshold comparison +# 2014-03-11 Allow plugin to run without enforced thresholds +# 2016-10-12 Fixed incorrect shell quoting and typos +# 2022-03-01 Merge PR #10, manually solve conflicts +# 2022-05-24 Removed need for 'awk', using bash-functions instead +# 2023-02-15 Bugfix in single pool CRITICAL output (issue #13) +######################################################################### +### Begin vars +STATE_OK=0 # define the exit code if status is OK +STATE_WARNING=1 # define the exit code if status is Warning +STATE_CRITICAL=2 # define the exit code if status is Critical +STATE_UNKNOWN=3 # define the exit code if status is Unknown +# Set path +PATH=$PATH:/usr/sbin:/sbin +export PATH +### End vars +######################################################################### +help="check_zpools.sh (c) 2006-2023 multiple authors\n +Usage: $0 -p (poolname|ALL) [-w warnpercent] [-c critpercent]\n +Example: $0 -p ALL -w 80 -c 90" +######################################################################### +# Check necessary commands are available +for cmd in zpool [ +do + if ! which "$cmd" 1>/dev/null + then + echo "UNKNOWN: ${cmd} does not exist, please check if command exists and PATH is correct" + exit ${STATE_UNKNOWN} + fi +done +######################################################################### +# Check for people who need help - we are nice ;-) +if [ "${1}" = "--help" ] || [ "${#}" = "0" ]; + then + echo -e "${help}"; + exit ${STATE_UNKNOWN}; +fi +######################################################################### +# Get user-given variables +while getopts "p:w:c:" Input; +do + case ${Input} in + p) pool=${OPTARG};; + w) warn=${OPTARG};; + c) crit=${OPTARG};; + *) echo -e "$help" + exit $STATE_UNKNOWN + ;; + esac +done +######################################################################### +# Did user obey to usage? +if [ -z "$pool" ]; then echo -e "$help"; exit ${STATE_UNKNOWN}; fi +######################################################################### +# Verify threshold sense +if [[ -n $warn ]] && [[ -z $crit ]]; then echo "Both warning and critical thresholds must be set"; exit $STATE_UNKNOWN; fi +if [[ -z $warn ]] && [[ -n $crit ]]; then echo "Both warning and critical thresholds must be set"; exit $STATE_UNKNOWN; fi +if [[ $warn -gt $crit ]]; then echo "Warning threshold cannot be greater than critical"; exit $STATE_UNKNOWN; fi +######################################################################### +# What needs to be checked? +## Check all pools +if [ "$pool" = "ALL" ] +then + POOLS=($(zpool list -Ho name)) + if [ $? -ne 0 ]; then + echo "UNKNOWN zpool query failed"; exit $STATE_UNKNOWN + fi + p=0 + for POOL in ${POOLS[*]} + do + CAPACITY=$(zpool list -Ho capacity "$POOL") + CAPACITY=${CAPACITY%\%} + HEALTH=$(zpool list -Ho health "$POOL") + if [ $? -ne 0 ]; then + echo "UNKNOWN zpool query failed"; exit $STATE_UNKNOWN + fi + # Check with thresholds + if [[ -n $warn ]] && [[ -n $crit ]] + then + if [[ $CAPACITY -ge $crit ]] + then error[${p}]="POOL $POOL usage is CRITICAL (${CAPACITY}%)"; fcrit=1 + elif [[ $CAPACITY -ge $warn && $CAPACITY -lt $crit ]] + then error[$p]="POOL $POOL usage is WARNING (${CAPACITY}%)" + elif [ "$HEALTH" != "ONLINE" ] + then error[${p}]="$POOL health is $HEALTH"; fcrit=1 + fi + # Check without thresholds + else + if [ "$HEALTH" != "ONLINE" ] + then error[${p}]="$POOL health is $HEALTH"; fcrit=1 + fi + fi + perfdata[$p]="$POOL=${CAPACITY}% " + let p++ + done + + if [[ ${#error[*]} -gt 0 ]] + then + if [[ $fcrit -eq 1 ]]; then exit_code=2; else exit_code=1; fi + echo "ZFS POOL ALARM: ${error[*]}|${perfdata[*]}"; exit ${exit_code} + else echo "ALL ZFS POOLS OK (${POOLS[*]})|${perfdata[*]}"; exit 0 + fi + +## Check single pool +else + CAPACITY=$(zpool list -Ho capacity "$pool" 2>&1 ) + CAPACITY=${CAPACITY%\%} + if [[ -n $(echo "${CAPACITY}" | egrep -q 'no such pool$') ]]; then + echo "zpool $pool does not exist"; exit $STATE_CRITICAL + fi + HEALTH=$(zpool list -Ho health "$pool") + if [ $? -ne 0 ]; then + echo "UNKNOWN zpool query failed"; exit $STATE_UNKNOWN + fi + + if [[ -n $warn ]] && [[ -n $crit ]] + then + # Check with thresholds + if [ "$HEALTH" != "ONLINE" ]; then echo "ZFS POOL $pool health is $HEALTH|$pool=${CAPACITY}%"; exit ${STATE_CRITICAL} + elif [[ $CAPACITY -ge $crit ]]; then echo "ZFS POOL $pool usage is CRITICAL (${CAPACITY}%)|$pool=${CAPACITY}%"; exit ${STATE_CRITICAL} + elif [[ $CAPACITY -ge $warn && $CAPACITY -lt $crit ]]; then echo "ZFS POOL $pool usage is WARNING (${CAPACITY}%)|$pool=${CAPACITY}%"; exit ${STATE_WARNING} + else echo "ALL ZFS POOLS OK ($pool)|$pool=${CAPACITY}%"; exit ${STATE_OK} + fi + else + # Check without thresholds + if [ "$HEALTH" != "ONLINE" ] + then echo "ZFS POOL $pool health is $HEALTH|$pool=${CAPACITY}%"; exit ${STATE_CRITICAL} + else echo "ALL ZFS POOLS OK ($pool)|$pool=${CAPACITY}%"; exit ${STATE_OK} + fi + fi + +fi + +echo "UNKNOWN - Should never reach this part" +exit ${STATE_UNKNOWN} diff --git a/debian/.debhelper/generated/nagios-plugins-ets/installed-by-dh_installdocs b/debian/.debhelper/generated/nagios-plugins-ets/installed-by-dh_installdocs new file mode 100644 index 0000000..e69de29 diff --git a/debian/.debhelper/nagios-plugins-ets/dbgsym-build-ids b/debian/.debhelper/nagios-plugins-ets/dbgsym-build-ids new file mode 100644 index 0000000..4d3f414 --- /dev/null +++ b/debian/.debhelper/nagios-plugins-ets/dbgsym-build-ids @@ -0,0 +1 @@ +569812d63821c8fa3b6c945b9cc1334f5021ca13 \ No newline at end of file diff --git a/debian/.debhelper/nagios-plugins-ets/dbgsym-root/DEBIAN/control b/debian/.debhelper/nagios-plugins-ets/dbgsym-root/DEBIAN/control new file mode 100644 index 0000000..0d6e3fb --- /dev/null +++ b/debian/.debhelper/nagios-plugins-ets/dbgsym-root/DEBIAN/control @@ -0,0 +1,13 @@ +Package: nagios-plugins-ets-dbgsym +Package-Type: ddeb +Source: nagios-plugins-ets +Version: 1.4 +Auto-Built-Package: debug-symbols +Architecture: amd64 +Maintainer: Your Name +Installed-Size: 15 +Depends: nagios-plugins-ets (= 1.4) +Section: debug +Priority: optional +Description: debug symbols for nagios-plugins-ets +Build-Ids: 569812d63821c8fa3b6c945b9cc1334f5021ca13 diff --git a/debian/.debhelper/nagios-plugins-ets/dbgsym-root/DEBIAN/md5sums b/debian/.debhelper/nagios-plugins-ets/dbgsym-root/DEBIAN/md5sums new file mode 100644 index 0000000..f403c23 --- /dev/null +++ b/debian/.debhelper/nagios-plugins-ets/dbgsym-root/DEBIAN/md5sums @@ -0,0 +1 @@ +4396913616c442f1b74f14dd49202ba7 usr/lib/debug/.build-id/56/9812d63821c8fa3b6c945b9cc1334f5021ca13.debug diff --git a/debian/.debhelper/nagios-plugins-ets/dbgsym-root/usr/lib/debug/.build-id/56/9812d63821c8fa3b6c945b9cc1334f5021ca13.debug b/debian/.debhelper/nagios-plugins-ets/dbgsym-root/usr/lib/debug/.build-id/56/9812d63821c8fa3b6c945b9cc1334f5021ca13.debug new file mode 100644 index 0000000000000000000000000000000000000000..a683c81a7f999cac2d284558d761c2092029f374 GIT binary patch literal 5032 zcmbVQO^g&p6n;A(0z$I8AS|fRC@~mAXa6)C{G0uSO?KH87JtH_=$Y=B=`b@rcK487 zLvZ!v0TT`;YJv%R(F6{g=*5$$F)>6FE*gv%JdhB>0Zt|+M&IjtZ??Ob34}_fU)A@% z@71fH?ycH)CTFH{U0on$4ZIB0TJF(Eo*g$I;R>2OjKF4m?uK2k4%=%JO#AcNpjVe` zxvX8!_!_jN>!V5=t5JZ*xgr^oC0(a-iQ~;nN8Or9x`)yt#z8FmK6#icDP5*Ni~VA` z`L!gN($U;BHfuuTrL1Kce97}8c~CR0TV|bD(cR|$WSEpA{YH5FrtN2;SW{PFooOdn zCzkr4a`Z;*K1hG_tdsFxvXXEhR<{6N$b!r-&Xb$|Fw^Me;e8J(?2g%KRkZ^yP>)HJy*66hw>&3 zai~x{*&+wW#}8Qhjuo2qxM>Xx*u!@J{()xF95^#LX!j34!*C*P`=Hos;m&`ia{~fh z=sC*+u$Zs~Z9D!h#B-SK3V$b{H?IEM+@OXUczZ*EREBZwd8 zxUQ$4#}TJI%{XPmtu&GA?;`$W8~i-ty}3>LLzMO(Er#)c9e`3!!B??U1_YwGSt{8@ zaJ|qg`%&zLDz2$wHK= z<<;YG2}+?;^OW1H)s|3_YAIyK8EUcO6;G;~SEHnwwFXsH6gx4cGj(Kic2Z3qo=^(Z z#G8jlXQ#&z#!s!9JjC8Z6GuQDoS7RNol$dBQ%5Hk)WYc4%p@vQ)h`q&SQx9CC zXQs!-)u25z3{f1`i?v1z8nmASHN7yaR%d2mcAVyA!6{TdD0yKRgju@hIpsp&a%xPDzVBhLj~J$$G_6mc+`G$;iPZ*}T)hd4E|EHr1b zmohV^RB_Rvz2Q{-w~hIsZ2(|LOSRZ3pvAE#wjwp09xrTwT@PZIjSEe_J)$}hHnhLoI@nhjWRGpFJZqm^sRFqcf{9Rq2rl5TYhA{>?g3;&-zPQ zdTadz{sk-P{olGTvR>|s!Z-W>!_eQfn92H|MaWk6kH9yuLKwfct$T*tD^0$%#ojUW za<92x{lA7@?iHe!{|E4E(V9OV9$Yl^a?cR`IrOKC= 2.34) +misc:Depends= +misc:Pre-Depends= diff --git a/debian/nagios-plugins-ets/DEBIAN/control b/debian/nagios-plugins-ets/DEBIAN/control new file mode 100644 index 0000000..f97fd4f --- /dev/null +++ b/debian/nagios-plugins-ets/DEBIAN/control @@ -0,0 +1,9 @@ +Package: nagios-plugins-ets +Version: 1.4 +Architecture: amd64 +Maintainer: Your Name +Installed-Size: 73 +Section: utils +Priority: optional +Description: Nagios plugins for system monitoring + Collection of Nagios plugins for system monitoring, including memory check, smartmon, zpools, and service checks. diff --git a/debian/nagios-plugins-ets/DEBIAN/md5sums b/debian/nagios-plugins-ets/DEBIAN/md5sums new file mode 100644 index 0000000..c4cd168 --- /dev/null +++ b/debian/nagios-plugins-ets/DEBIAN/md5sums @@ -0,0 +1,7 @@ +10c6362f6044c1436c4037dde8e7d161 usr/lib64/nagios/plugins/check_mem +8e2475317d2e7a9c6645dba25f338011 usr/lib64/nagios/plugins/check_service +989c1cb7943a34f717fc1387ae571714 usr/lib64/nagios/plugins/check_smartctl +7e987e1d6991dff2855768fdd89d09e1 usr/lib64/nagios/plugins/check_smartmon.py +771fe34b732d0e70e971f6974c26c503 usr/lib64/nagios/plugins/check_smartmon2.py +97f7a85b0408f048d1a135eae3f86840 usr/lib64/nagios/plugins/check_zpools.sh +91ea16fd2f132670283a5e8eeaf3d30a usr/share/doc/nagios-plugins-ets/changelog.gz diff --git a/debian/nagios-plugins-ets/DEBIAN/postinst b/debian/nagios-plugins-ets/DEBIAN/postinst new file mode 100755 index 0000000..a31137f --- /dev/null +++ b/debian/nagios-plugins-ets/DEBIAN/postinst @@ -0,0 +1,3 @@ +#!/bin/bash +chmod 755 /usr/lib64/nagios/plugins/* + diff --git a/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_mem b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_mem new file mode 100755 index 0000000000000000000000000000000000000000..cc1724f6fdee45313a1523098f1792abec04d38d GIT binary patch literal 14488 zcmeHOeQXow8GoG+2p_>Ig*JS&Tsu;rRUGoEK%3$Q3`f_DK$8u&wZ^f}iG^dk_L+vR zbU`5=>B3FTC<5s2#LypijQsTpz127{S&Gp*@dnlDP6`Gx97R{eJ+uIC;uaSO$^DnS6aSpzG9{|~Sw zY&!7MbQ#yXIe?b8%LS9MSjY#Z{ogMrifx6n<7*&)pay_JQr$t7_nX>90lj9h3Ah%!*HNF(ah@wtyej<*PP2 z%v(i&`HsVYs6U}7FRKiP+Usj8!-0x$D3a{1=x(U5sIPS;qONK^1!wa8_XMh&;}dEqf-QV zq@A##4X?*uptub2lJZ^`V!n1CDCSL}^yHBr2DvnaeRCdrR~~t59=Vc7UYAFX^_ePv zJYS}ghx5o!fLwyj+E##IsyOFBE?JF%cfj`W6msVE`n!GJU?}1Xhh9=xutQN3AcWJ( z?@g$_xa#flg(55%jVbWoAC4vzmQdqrG{_+t4kHoqcg0vxiN~XH@CHZ!POranr#I*e zg;^{fil{+QgA)eE)3cs!d}dSAI&ZbB)}X3gbp~Bi%ear&J95MzRG0Eqe1H_2z4b8P-R4acLz`2y6eJ5&0b5}G?8_;>Yp&HFy zGI+ev8O;qDJl3seaxUEmI|&D1{1#sx@ zLmCd> z6Zzxu?P)|cOFq^n_coqJQchh}=g8^Cv%q9icQh>&im4V$#l%Vn~P&;+%T=oLQms5RNFqhMP=p~UUoWpYZklsmu-w1T_4!%#3Q|Gb^vH!kIvM6^LjkxwC zo^x`4$p`RoAgA6#yMzDMG%%|Ii(yQ%{}6_e`=6e967Q&Sr&52;{tc|4BYihg1-VV8 zkg&fPGCdLUNglHLu8<|>ko(Ocn~HNc^*H)YoW!95F+CG8Ke?@^d3VfWbIjUFF-voA z-5v85JP(Lne}l)YyerR1F^9p**!8BeYb{hu9N&=S?=~9D&y<2I@ZUq#~Gais1<3ms_ z%HFx9X&25IL$&vMEVbvboJtN@$7$L#Aopem<;D-;PvS+mmB8dZJaHAp?R3%)kt=b<$W^c&&| z5KYM-e3nYAVe5SUP9?C0ZT>b}7Z0f+zc0+b=Zi-|kq*eU+0(pv>vpL;Ayr6i2_+yk zO69KVV0pRpvb0?9VR>VDIN97JEl0J%U?+kRpCisUITjZ_-T*Q2^?>@BriB5QjcD5I zfVF_f06zf4Z;hvJXxh7goi{b@V?g}&ip}xTR_5p~bu6AUqj&&r%22)pwr=oy1P#{D z&_7iz1F{x*=w}ddZs~@(WluY2zgXPE)-GD}Xw5SHvmg5Z5VrkbN8h;69OWu(Js>{< zNDccs0NV}d@7MTV#51?_)q-^;(+huD2r22g;C{UPxu)&Hn?^(50!PAq$ zBEi%8IDFo~M*5p~v?%g}`0N3V)|hP*1g$N*EcCP%>%(Zx z+lVm0=OS$Q$p@R*Ew)1lNPa{lLV0I&YsTR9yxyq)2L(@d@JT`6Kd7rNf^R)KzeB`> zZ+)cKJ>fA-=hp~5yo%R(+7A)_YXe%xZ4J0eJUqGuwg}uIFeb1^;DEp*0tW?V1X|<& zH@?`-Emk*FRR`*88mg=O4MAT`d%b^kZC(3nzrU)crZ!l&3go`38dpGRPvYY}o8IvL zYs{7C#HFjgcIJWwsY*P?T#=}%xH=+97ra%7DRFhTNz|SU!Mf^DK!~1d+Ek(XI+$+W z=}UAnS73J}vAc_-8t0l_@U|fojZ9*^po=SEA36vs7FIEf5c~(y)e#j$Lh&<~s&oSj zi*iF?9S!(YA9E?4-eBCT{-6JGoZ;L+<4z14ps=)ZumNcq!zMM(XNVQb896m|;`SVQus`HZkf6by4jlJ=kG zmF*zIl*ymwN5U(hGdFAfeW1j-hWu%MA(VtO$Y(zl}Aa_>ATyfppyxVf0*yM#OhyW`9Ze z5e}M-fwqKaKehN@6b6K3Php5BJYw-5779Ytn;ZEN{tA@l{OR{pgtLso@F?U*G2gcM z)AgT_?hDA?I(~jH{OR~JNmvTRcZ}vn$B$&EfWZ98|Cq!zgimnR_;2n1kDxL8XC-b* z_$R}Y6W0F!0^+%_(RJAP{Zz%&_T*1^1YuLL^t&wj{S}Ts zY}79u$De}?_n-XfekfLn){G5sF#eN2;TNDW`!lyNUB!|55mKXn;%@_iv8ex2H`kO3 lf9i)zd0#{$;!gsxe`_QET8qMZ{3qpZvRzO4TY_6y_8;_ak757- literal 0 HcmV?d00001 diff --git a/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_service b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_service new file mode 100755 index 0000000..f0b9db3 --- /dev/null +++ b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_service @@ -0,0 +1,63 @@ +#!/bin/bash + +#Author: Tino + +#VARIABLES NAGIOS +OK=0 +WARNING=1 +CRITICAL=2 +UNKNOWN=3 + +PROGNAME=`basename $0 .sh` +VERSION="Version 1.1" + +print_version() { + echo "$VERSION" +} + +print_help() { + print_version $PROGNAME $VERSION + echo "" + echo "$PROGNAME is a Nagios plugin to check a specific service using systemctl." + echo "" + echo "$PROGNAME -s " + exit $UNKNOWN +} + +if test -z "$1" +then + print_help + exit $CRITICAL +fi + +while test -n "$1"; do + case "$1" in + --help|-h) + print_help + exit $UNKNOWN + ;; + --version|-v) + print_version $PROGNAME $VERSION + exit $UNKNOWN + ;; + --service|-s) + SERVICE=$2 + shift + ;; + *) + echo "Unknown argument: $1" + print_help + exit $UNKNOWN + ;; + esac + shift +done + +if systemctl is-active $SERVICE >/dev/null 2>&1 +then + echo -e "OK: Service $SERVICE is running!" + exit $OK +else + echo -e "CRITICAL: Service $SERVICE is not running!" + exit $CRITICAL +fi diff --git a/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartctl b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartctl new file mode 100755 index 0000000..dd343bc --- /dev/null +++ b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartctl @@ -0,0 +1,302 @@ +#!/usr/bin/python + +# -*- coding: iso8859-1 -*- +# +# $Id: version.py 133 2006-03-24 10:30:20Z fuller $ +# +# check_smartmon +# Copyright (C) 2006 daemogorgon.net +# Copyright (C) 2010 Orcan Ogetbil (orcan at nbcs.rutgers.edu) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +"""Package versioning +""" + + +import os.path +import subprocess +import sys +import time + +from optparse import OptionParser +from operator import itemgetter, attrgetter + + +__author__ = "fuller " +__version__ = "$Revision$" + + +# path to smartctl +_smartctlPath = "/usr/sbin/smartctl" + +# application wide verbosity (can be adjusted with -v [0-3]) +_verbosity = 0 + +is_array = lambda var: isinstance(var, (list, tuple)) + +def parseCmdLine(args): + """Commandline parsing.""" + + usage = "usage: %prog [options] device" + version = "%%prog %s" % (__version__) + + parser = OptionParser(usage=usage, version=version) + parser.add_option("-d", "--devicetype", action="store", dest="devicetype", default="scsi", metavar="DEVICETYPE", + help="device type (scsi or megaraid,N or ...; defaults to scsi)") + parser.add_option("-v", "--verbosity", action="store", + dest="verbosity", type="int", default=0, + metavar="LEVEL", help="set verbosity level to LEVEL; defaults to 0 (quiet), \ + possible values go up to 3") + parser.add_option("-w", "--warning-threshold", metavar="TEMP", action="store", + type="int", dest="warningThreshold", default=55, + help="set temperature warning threshold to given temperature (defaults to 55)") + parser.add_option("-c", "--critical-threshold", metavar="TEMP", action="store", + type="int", dest="criticalThreshold", default="60", + help="set temperature critical threshold to given temperature (defaults to 60)") + + (options,devices) = parser.parse_args(sys.argv[1:]) + + if len(devices) ==0: + exitWithMessage(3,"UNKNOWN: Error, at least one device must be entered") + + return (options,devices) +# end + + +def checkDevice(path): + """Check if device exists and permissions are ok. + + Returns: + - 0 ok + - 1 no such device + """ + + vprint(3, "Check if %s does exist and can be read" % path) + if not os.access(path, os.F_OK): + return (1, "UNKNOWN: no such device found (%s)" % (path)) + # We can't check the read permissions as unprivileged user - Orcan + #elif not os.access(path, os.R_OK): + # return (2, "UNKNOWN: no read permission given (%s)" % (path)) + else: + return (0, "") + # fi +# end + + +def checkSmartMonTools(path): + """Check if smartctl is available and can be executed. + + Returns: + - 0 ok + - 1 no such file + - 2 cannot execute file + """ + + vprint(3, "Check if %s does exist and can be read" % path) + if not os.access(path, os.F_OK): + return (1, "UNKNOWN: cannot find %s" % path) + elif not os.access(path, os.X_OK): + return (2, "UNKNOWN: cannot execute %s" % path) + else: + return (0, "") + # fi +# end + + +def callSmartMonTools(path, devicetype, device): + # get health status + cmd = "sudo %s -d %s %s -a" % (path, devicetype, device) + vprint(3, "Get device health status: %s" % cmd) + + sp = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + # See if smartctl exits cleanly + # This is a lot hacky since smartctl output is not consistent. It doesn't always + # close output streams stdout, stderr etc. I really don't like the following + # code - Orcan + i = 0 + poll = False + while i < 5: + if sp.poll(): + poll = True + break + i = i+1 + vprint(3, "smartctl did not exit yet. Waiting...") + time.sleep(0.1) + + if poll: # clean + (child_stdin, child_stdout, child_stderr) = (sp.stdin, sp.stdout, sp.stderr) + child_stdout = child_stdout.readlines() + child_stderr = child_stderr.readline() + vprint(3, "smartctl did exit cleanly") + else: # not clean. let's gather what we have + vprint(3, "smartctl did not exit cleanly") + (child_stdout, child_stderr) = sp.communicate() + + if len(child_stderr): + return (3, "UNKNOWN: call exits unexpectedly (%s)" % child_stderr, "", + "") + StatusOutput = "" + faultline = "" + for line in child_stdout: + if line.find("INVALID ARGUMENT TO -d") > 0 or line.find("Unknown device type") > -1: + faultline = line + continue + if faultline != "": + return (3, faultline + line, "") + StatusOutput = StatusOutput + line + # done + return (0 ,"", StatusOutput) +# end + + +def parseOutput(Message): + """Parse smartctl output + + Returns (health status, temperature). + """ + + # parse health status and temperature + healthStatus="" + temperature = None + lines = Message.split("\n") + for line in lines: + if line.find("INQUIRY failed") > -1: + exitWithMessage(1, "UNKNOWN: " + line) + if line.startswith("SMART Health Status:") or line.startswith("SMART overall-health self-assessment"): + healthStatus = line.split()[-1] + if line.startswith("Temperature:"): + try: + temperature = int(line.split()[-2]) + except: + temperature = -100 + break + + vprint(3, "Health status: %s" % healthStatus) + vprint(3, "Temperature: %s" %temperature) + + return (healthStatus, temperature) +# end + + +def createReturnInfo(device, devicetype, healthStatus, temperature, warningThreshold, + criticalThreshold): + """Create return information according to given thresholds.""" + # this is absolutely critical! + if healthStatus != "PASSED" and healthStatus != "OK": + if healthStatus == "": + return (2, "CRITICAL: device %s of type %s did not pass a health status." % (device, devicetype)) + return (2, "CRITICAL: device %s of type %s passed health status: (%s)" % (device, devicetype, healthStatus)) + elif temperature == None and devicetype != "ata": + return (2, "CRITICAL: device %s of type %s does not pass temperature information" % (device, devicetype)) + + elif temperature > criticalThreshold: + return (2, "CRITICAL: device %s of type %s temperature (%d) exceeds critical temperature threshold (%s)" % (device, devicetype, temperature, criticalThreshold)) + elif temperature > warningThreshold: + return (1, "WARNING: device %s of type %s temperature (%d) exceeds warning temperature threshold (%s)" % (device, devicetype, temperature, warningThreshold)) + else: + if temperature == None: + temperature = "N/A" + return (0, "OK: device %s of type %s is functional and stable (temperature: %s C)" % ( device , devicetype, str(temperature))) + + # fi +# end + + +def exitWithMessage(value, message = ""): + """Exit with given value.""" + + if message: + print message + sys.exit(value) +# end + + +def vprint(level, message): + """Verbosity print. + + Decide according to the given verbosity level if the message will be + printed to stdout. + """ + + if level <= verbosity: + print message + # fi +# end + +def allDeviceTypes(devicetype): + dt_array = devicetype.split(",") + if len(dt_array) == 1: + return dt_array + dt_base = dt_array[0] + dt_all = [] + for ext in dt_array[1:]: + dt_all.append(dt_base+","+ext) + return dt_all + +if __name__ == "__main__": + (options, devices) = parseCmdLine(sys.argv) + verbosity = options.verbosity + + vprint(2, "Get device name(s)B") + overallvalue = 0 + devicetypes = allDeviceTypes(options.devicetype) + full_message = [] + + for device in devices: + for devicetype in devicetypes: + vprint(1, "Device: %s" % device) + + # check if we can access 'path' + vprint(2, "Check device") + (value, message) = checkDevice(device) + if value != 0: + exitWithMessage(3, message) + # fi + + # check if we have smartctl available + (value, message) = checkSmartMonTools(_smartctlPath) + if value != 0: + exitWithMessage(3, message) + # fi + vprint(1, "Path to smartctl: %s" % _smartctlPath) + + # call smartctl and parse output + vprint(2, "Call smartctl") + + (value, message, Output) = callSmartMonTools(_smartctlPath, devicetype, device) + if value != 0: + exitWithMessage(3, message) + vprint(2, "Parse smartctl output") + (healthStatus, temperature) = parseOutput(Output) + vprint(2, "Generate return information") + (value, message) = createReturnInfo(device, devicetype, healthStatus, temperature, + options.warningThreshold, options.criticalThreshold) + if value > overallvalue: + overallvalue = value + full_message.append((value,message)) + + full_message = sorted(full_message, key=itemgetter(1)) + message_string = "" + for value,message in full_message: + message_string += message + " " + + + # exit program + exitWithMessage(overallvalue, message_string[:-1]) + +# fi diff --git a/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartmon.py b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartmon.py new file mode 100755 index 0000000..1754977 --- /dev/null +++ b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartmon.py @@ -0,0 +1,414 @@ +#!/usr/bin/python +"""Nagios plugin for monitoring S.M.A.R.T. status.""" + +# -*- coding: iso8859-1 -*- +# +# $Id: version.py 133 2006-03-24 10:30:20Z fuller $ +# +# check_smartmon +# Copyright (C) 2006 daemogorgon.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# +# Fork author: nihlaeth +# + +import os.path +import sys +import re +import psutil +import subprocess +from optparse import OptionParser + +__author__ = "fuller " +__version__ = "$Revision$" + + +# path to smartctl +# TODO use which to fetch path +_smartctl_path = "/usr/sbin/smartctl" + +# application wide verbosity (can be adjusted with -v [0-3]) +_verbosity = 0 + + +def parse_cmd_line(arguments): + """Commandline parsing.""" + usage = "usage: %prog [options] device" + version = "%%prog %s" % (__version__) + + parser = OptionParser(usage=usage, version=version) + parser.add_option( + "-d", + "--device", + action="store", + dest="device", + default="", + metavar="DEVICE", + help="device to check") + parser.add_option( + "-a", + "--all-disks", + action="store_true", + dest="alldisks", + default="", + help="Check all disks") + parser.add_option( + "-v", + "--verbosity", + action="store", + dest="verbosity", + type="int", + default=0, + metavar="LEVEL", + help="set verbosity level to LEVEL; defaults to 0 (quiet), \ + possible values go up to 3") + parser.add_option( + "-w", + "--warning-threshold", + metavar="TEMP", + action="store", + type="int", + dest="warning_temp", + default=55, + help=("set temperature warning threshold to given temperature" + " (default:55)")) + parser.add_option( + "-c", + "--critical-threshold", + metavar="TEMP", + action="store", + type="int", + dest="critical_temp", + default="60", + help=("set temperature critical threshold to given temperature" + " (default:60)")) + + return parser.parse_args(arguments) + + +def check_device_permissions(path): + """Check if device exists and permissions are ok. + + Returns: + - 0 ok + - 1 no such device + - 2 no read permission given + """ + vprint(3, "Check if %s does exist and can be read" % path) + if not os.access(path, os.F_OK): + return (3, "UNKNOWN: no such device found") + elif not os.access(path, os.R_OK): + return (3, "UNKNOWN: no read permission given") + else: + return (0, "") + return (0, "") + + +def check_smartmontools(path): + """Check if smartctl is available and can be executed. + + Returns: + - 0 ok + - 1 no such file + - 2 cannot execute file + """ + vprint(3, "Check if %s does exist and can be read" % path) + if not os.access(path, os.F_OK): + print "UNKNOWN: cannot find %s" % path + sys.exit(3) + elif not os.access(path, os.X_OK): + print "UNKNOWN: cannot execute %s" % path + sys.exit(3) + + +def call_smartmontools(path, device): + """Get smartmontool output.""" + cmd = "%s -a %s" % (path, device) + vprint(3, "Get device health status: %s" % cmd) + result = "" + message = "" + code_to_return = 0 + try: + result = subprocess.check_output(cmd, shell=True) + except subprocess.CalledProcessError as error: + # smartctl passes a lot of information via the return code + return_code = error.returncode + if return_code % 2**1 > 0: + # bit 0 is set - command line did not parse + # output is not useful now, simply return + message += "UNKNOWN: smartctl parsing error " + return_code -= 2**0 + code_to_return = 3 + if return_code % 2**2 > 0: + # bit 1 is set - device open failed + # output is not useful now, simply return + message += "UNKNOWN: could not open device " + return_code -= 2**1 + code_to_return = 3 + if return_code % 2**3 > 0: + # bit 2 is set - some smart or ata command failed + # we still want to see what the output says + result = error.output + message += "CRITICAL: some SMART or ATA command to disk " + message += "failed " + return_code -= 2**2 + code_to_return = 2 + if return_code % 2**4 > 0: + # bit 3 is set - smart status returned DISK FAILING + # we still want to see what the output says + result = error.output + message += "CRITICAL: SMART statis is DISK FAILING " + return_code -= 2**3 + code_to_return = 2 + if return_code % 2**5 > 0: + # bit 4 is set - prefail attributes found + result = error.output + message += "CRITICAL: prefail attributes found " + return_code -= 2**4 + code_to_return = 2 + if return_code % 2**6 > 0: + # bit 5 is set - disk ok, but prefail attributes in the past + result = error.output + # this should be a warning, but that's too much hasle + message += "WARNING: some prefail attributes were critical " + message += "in the past " + return_code -= 2**5 + code_to_return = 1 + if return_code % 2**7 > 0: + # bit 6 is set - errors recorded in error log + result = error.output + message += "WARNING: errors recorded in error log " + return_code -= 2**6 + code_to_return = 1 + if return_code % 2**8 > 0: + # bit 7 is set - device self-test log contains errors + result = error.output + message += "CRITICAL: self-test log contains errors " + return_code -= 2**7 + code_to_return = 2 + except OSError as error: + code_to_return = 3 + message = "UNKNOWN: call exits unexpectedly (%s)" % error + + return (code_to_return, result, message) + + +def parse_output(output, warning_temp, critical_temp): + """ + Parse smartctl output. + + Returns status of device. + """ + # parse health status + # + # look for line '=== START OF READ SMART DATA SECTION ===' + status_line = "" + health_status = "" + reallocated_sector_ct = 0 + temperature = 0 + reallocated_event_count = 0 + current_pending_sector = 0 + offline_uncorrectable = 0 + error_count = 0 + + lines = output.split("\n") + for line in lines: + # extract status line + if "overall-health self-assessment test result" in line: + status_line = line + parts = status_line.rstrip().split() + health_status = parts[-1:][0] + vprint(3, "Health status: %s" % health_status) + # extract status line (compatibility with all smartctl versions) + if "Health Status" in line: + status_line = line + parts = status_line.rstrip().split() + health_status = parts[-1:][0] + vprint(3, "Health status: %s" % health_status) + + parts = line.split() + if len(parts) > 0: + # self test spans can also start with 5, so we + # need a tighter check here than elsewhere + if parts[0] == "5" and \ + parts[1] == "Reallocated_Sector_Ct" and \ + reallocated_sector_ct == 0: + # extract reallocated_sector_ct + # 5 is the reallocated_sector_ct id + reallocated_sector_ct = int(parts[9]) + vprint(3, "Reallocated_Sector_Ct: %d" % reallocated_sector_ct) + elif parts[0] == "190" and temperature == 0: + # extract temperature + # 190 can be temperature value id too + temperature = int(parts[9]) + vprint(3, "Temperature: %d" % temperature) + elif parts[0] == "194" and temperature == 0: + # extract temperature + # 194 is the temperature value id + temperature = int(parts[9]) + vprint(3, "Temperature: %d" % temperature) + elif parts[0] == "196" and reallocated_event_count == 0: + # extract reallocated_event_count + # 196 is the reallocated_event_count id + reallocated_event_count = int(parts[9]) + vprint( + 3, + "Reallocated_Event_Count: %d" % reallocated_event_count) + elif parts[0] == "197" and current_pending_sector == 0: + # extract current_pending_sector + # 197 is the current_pending_sector id + current_pending_sector = int(parts[9]) + vprint( + 3, + "Current_Pending_Sector: %d" % current_pending_sector) + elif parts[0] == "198" and offline_uncorrectable == 0: + # extract offline_uncorrectable + # 198 is the offline_uncorrectable id + offline_uncorrectable = int(parts[9]) + vprint( + 3, + "Offline_Uncorrectable: %d" % offline_uncorrectable) + elif "ATA Error Count" in line: + error_count = int(parts[3]) + vprint( + 3, + "ATA error count: %d" % error_count) + elif "No Errors Logged" in line: + error_count = 0 + vprint( + 3, + "ATA error count: 0") + + # now create the return information for this device + return_status = 0 + device_status = "" + + # check if smartmon could read device + if health_status == "": + return (3, "UNKNOWN: could not parse output") + + # check health status + while health_status not in ["PASSED", "OK"]: + return_status = 2 + device_status += "CRITICAL: device does not pass health status " + + # check sectors + if reallocated_sector_ct > 0 or \ + reallocated_event_count > 0 or \ + current_pending_sector > 0 or \ + offline_uncorrectable > 0: + return_status = 2 + device_status += "CRITICAL: there is a problem with bad sectors " + device_status += "on the drive. " + device_status += "Reallocated_Sector_Ct:%d, " % reallocated_sector_ct + device_status += "Reallocated_Event_Count:%d, " % reallocated_event_count + device_status += "Current_Pending_Sector:%d, " % current_pending_sector + device_status += "Offline_Uncorrectable:%d " % offline_uncorrectable + + # check temperature + if temperature > critical_temp: + return_status = 2 + device_status += "CRITICAL: device temperature (%d)" % temperature + device_status += "exceeds critical temperature " + device_status += "threshold (%s) " % critical_temp + elif temperature > warning_temp: + # don't downgrade return status! + if return_status < 2: + return_status = 1 + device_status += "WARNING: device temperature (%d) " % temperature + device_status += "exceeds warning temperature " + device_status += "threshold (%s) " % warning_temp + + # check error count + if error_count > 0: + if return_status < 2: + return_status = 1 + device_status += "WARNING: error count %d " % error_count + + if return_status == 0: + # no warnings or errors, report everything is ok + device_status = "OK: device is functional and stable " + device_status += "(temperature: %d) " % temperature + + return (return_status, device_status) + + +def vprint(level, text): + """Verbosity print. + + Decide according to the given verbosity level if the message will be + printed to stdout. + """ + if level <= verbosity: + print text + + +if __name__ == "__main__": + # pylint: disable=invalid-name + (options, args) = parse_cmd_line(sys.argv) + verbosity = options.verbosity + + check_smartmontools(_smartctl_path) + + vprint(2, "Get device name") + # assemble device list to be monitored + if not options.alldisks: + devices = [options.device] + else: + devices = [] + # Regex for Valid device name + valid_device_name = '/dev/[ahsv]d.*' + for partition in psutil.disk_partitions(): + if re.search(valid_device_name, partition.device): + devices.append(partition.device.strip(partition.device[-1])) + vprint(1, "Devices: %s" % devices) + + return_text = "" + exit_status = 0 + for device in devices: + vprint(1, "Device: %s" % device) + return_text += "%s: " % device + + # check if we can access 'path' + vprint(2, "Check device") + (return_status, message) = check_device_permissions(device) + if return_status != 0: + if exit_status < return_status: + exit_status = return_status + return_text += message + + # call smartctl and parse output + vprint(2, "Call smartctl") + return_status, output, message = call_smartmontools( + _smartctl_path, + device) + if return_status != 0: + if exit_status < return_status: + exit_status = return_status + return_text += message + if output != "": + vprint(2, "Parse smartctl output") + return_status, device_status = parse_output( + output, + options.warning_temp, + options.critical_temp) + if exit_status < return_status: + exit_status = return_status + return_text += device_status + + print return_text + sys.exit(exit_status) diff --git a/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartmon2.py b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartmon2.py new file mode 100755 index 0000000..3140ce3 --- /dev/null +++ b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_smartmon2.py @@ -0,0 +1,308 @@ +#!/usr/bin/python + +# -*- coding: iso8859-1 -*- +# +# $Id: version.py 133 2006-03-24 10:30:20Z fuller $ +# +# check_smartmon +# Copyright (C) 2006 daemogorgon.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# +# MOD by basos (basos= attrSpec[1]: + return (2,)+attrSpec ; # crit (val >= crit) + elif raw >= attrSpec[0]: + return (1,)+attrSpec; # warn (val >= warn) + return (0,)+attrSpec; # ok + #def + + def formatAttr(s_id, s_name, s_failed, s_value, s_thres): + return "Attribute "+str(s_name)+" ("+str(s_id)+") seems to fail ("+(str(s_failed) if s_failed != '-' else \ + str(s_value)+"<="+str(s_thres))+")" + + def pipeStuff(s_name, s_value, s_thres, s_cthres = None, s_min = "0", s_max = "254"): + if (None == s_cthres): s_cthres = s_thres + return "|"+str(s_name)+"="+str(s_value)+";"+str(s_thres)+";"+str(s_cthres)+((";"+s_min+((";"+s_max) if s_max != None else "")) if s_min != None else "") + + # parse health status + # + statusLine = "" + lines = healthMessage.split("\n") + getNext = 0 + healthStatus = '' + temperStuff = (None, "Temperature_not_found", 0 , 0) + in_attrs = 0 + ret = (3, "UNKNNOWN: smartctl encountered an error") + for line in lines: + if healthStatus == '' and re.search(r"^SMART overall-health self-assessment test result", line): + ps = line.split() + healthStatus = ps[-1] + vprint(3, "Health status: %s" % healthStatus) + # this is absolutely critical! + if healthStatus != "PASSED": + ret = (2, "CRITICAL: SMART overall health test failed") + else: + ret = (0, "OK: device is functional and stable") + continue; + # fi + if in_attrs == 1 and (not line or not re.search(r"\d+", line.split()[0])): + vprint(3, "End of Attributes parsing"); + in_attrs = 0 + if in_attrs: + ps = line.split() + s_id, s_name, s_flag, s_value, s_worst, s_thres, s_type, s_updated, s_failed, s_raw = \ + ps[0], ps[1], ps[2], ps[3], ps[4], ps[5], ps[6], ps[7], ps[8], ps[9] + vprint(2, "Checking Attr: %s (%s), v: %s (%s)" % (s_name, s_id, s_value, s_raw)) + if (s_failed != '-' or int(s_value) <= int(s_thres)): + if s_type.lower() == 'pre-fail' : + if s_failed.lower() != 'in_the_past': + ret = (2, "CRITICAL: "+formatAttr(s_id, s_name, s_failed, s_value, s_thres) + \ + pipeStuff(s_name, s_value, s_thres)) + elif ret[0] < 2: + ret = (1, "WARNING: "+formatAttr(s_id, s_name, s_failed, s_value, s_thres) + \ + pipeStuff(s_name, s_value, s_thres)) + elif ret[0] < 2 and s_failed.lower() != 'in_the_past': + ret = (1, "WARNING: "+formatAttr(s_id, s_name, s_failed, s_value, s_thres) + \ + pipeStuff(s_name, s_value, s_thres)) + # fi + tmp = checkAttr(s_id, s_raw, attrSpecs) + if tmp[0] > 0: + if ret[0] < 2: + #ret = (tmp[0], "CRITICAL" if tmp[0] == 2 else "WARNING"+": Attribute raw "+str(s_name)+" ("+str(s_id)+") over "+("critical" if tmp[0] == 2 \ + #else "warning")+"threshold ("+str(s_raw)+">="+str(tmp[2 if tmp[0] == 2 else 1]+")")) + vprint(2, "Attr "+str(s_id)+", "+str(s_raw)+" over thres "+str(tmp)); + ret = (tmp[0], ("CRITICAL" if tmp[0] == 2 else "WARNING")+": " + \ + formatAttr(s_id, s_name, "Raw_limits", s_raw, tmp[2 if tmp[0] == 2 else 1]) + \ + pipeStuff(s_name, s_raw, tmp[1], tmp[2], *(("0", "100") if len(tmp) == 4 and tmp[3] else ()))) + elif tmp[0] == 0 and len(tmp) == 4 and tmp[3]: + # found temperature + temperStuff = (s_name, s_raw) + tmp[1:3] + elif re.search(r"ID.?\s+ATTRIBUTE_NAME\s+FLAG\s+VALUE\s+WORST\s+THRESH\s+TYPE\s+UPDATED\s+WHEN_FAILED\s+RAW_VALUE", line): + vprint(3, "Start of Attributes parsing") + in_attrs = 1 + else: + vprint(3, "Ommiting smartctl row: %s" % line) + # ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE + # done + if ret[0] == 0 and temperStuff[0] != None: + temperStuff = temperStuff + ("0", "100") + ret = (0, ret[1] + pipeStuff(*temperStuff)) + + if ret[0] == 3: + vprint(3, "smartctl error, output: %s" % healthMessage); + return ret + ##(0, "OK: device is functional and stable (temperature: %d)" % temperature) +# end + + +def exitWithMessage(value, message): + """Exit with given value and status message.""" + + print message + sys.exit(value) +# end + + +def vprint(level, message): + """Verbosity print. + + Decide according to the given verbosity level if the message will be + printed to stdout. + """ + + if level <= verbosity: + print message + # fi +# end + + +if __name__ == "__main__": + (options, args) = parseCmdLine(sys.argv) + verbosity = options.verbosity + + vprint(2, "Get device name") + device = options.device + vprint(1, "Device: %s" % device) + + # check if we can access 'path' + vprint(2, "Check device") + (value, message) = checkDevice(device) + if value != 0: + exitWithMessage(3, message) + # fi + + # check if we have smartctl available + #(value, message) = checkSmartMonTools(options.smartctlPath) + #if value != 0: + # exitWithMessage(3, message) + # fi + vprint(1, "Path to smartctl: %s" % options.smartctlPath) + + # call smartctl and parse output + vprint(2, "Call smartctl") + (value, message, healthStatusOutput) = callSmartMonTools(options.smartctlPath, device, options.noCheckStandby, options.smartctlArgs) + if value != 0: + exitWithMessage(value, message) + + vprint(2, "Parse smartctl output and return info") + attrs = {} + if options.rawAttrs: + for at in options.rawAttrs: + attrs[at[0]] = at[1:3] + attrs[options.tempAttrId] = (options.warningThreshold, options.criticalThreshold, True) + (value, message) = createReturnInfo(healthStatusOutput, attrs) + + # exit program + exitWithMessage(value, message) + +# fi diff --git a/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_zpools.sh b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_zpools.sh new file mode 100755 index 0000000..ad5861e --- /dev/null +++ b/debian/nagios-plugins-ets/usr/lib64/nagios/plugins/check_zpools.sh @@ -0,0 +1,155 @@ +#!/usr/bin/env bash +######################################################################### +# Script: check_zpools.sh +# Purpose: Nagios plugin to monitor status of zfs pool +# Authors: Aldo Fabi First version (2006-09-01) +# Vitaliy Gladkevitch Forked (2013-02-04) +# Claudio Kuenzler Complete redo, perfdata, etc (2013-2023) +# Per von Zweigbergk Various fixes (2016-10-12) +# @waoki Trap zpool command errors (2022-03-01) +# @mrdsam Improvement (2022-05-24) +# Doc: http://www.claudiokuenzler.com/monitoring-plugins/check_zpools.php +# History: +# 2006-09-01 Original first version +# 2006-10-04 Updated (no change history known) +# 2013-02-04 Forked and released +# 2013-05-08 Make plugin work on different OS, pepp up plugin +# 2013-05-09 Bugfix in exit code handling +# 2013-05-10 Removed old exit vars (not used anymore) +# 2013-05-21 Added performance data (percentage used) +# 2013-07-11 Bugfix in zpool health check +# 2014-02-10 Bugfix in threshold comparison +# 2014-03-11 Allow plugin to run without enforced thresholds +# 2016-10-12 Fixed incorrect shell quoting and typos +# 2022-03-01 Merge PR #10, manually solve conflicts +# 2022-05-24 Removed need for 'awk', using bash-functions instead +# 2023-02-15 Bugfix in single pool CRITICAL output (issue #13) +######################################################################### +### Begin vars +STATE_OK=0 # define the exit code if status is OK +STATE_WARNING=1 # define the exit code if status is Warning +STATE_CRITICAL=2 # define the exit code if status is Critical +STATE_UNKNOWN=3 # define the exit code if status is Unknown +# Set path +PATH=$PATH:/usr/sbin:/sbin +export PATH +### End vars +######################################################################### +help="check_zpools.sh (c) 2006-2023 multiple authors\n +Usage: $0 -p (poolname|ALL) [-w warnpercent] [-c critpercent]\n +Example: $0 -p ALL -w 80 -c 90" +######################################################################### +# Check necessary commands are available +for cmd in zpool [ +do + if ! which "$cmd" 1>/dev/null + then + echo "UNKNOWN: ${cmd} does not exist, please check if command exists and PATH is correct" + exit ${STATE_UNKNOWN} + fi +done +######################################################################### +# Check for people who need help - we are nice ;-) +if [ "${1}" = "--help" ] || [ "${#}" = "0" ]; + then + echo -e "${help}"; + exit ${STATE_UNKNOWN}; +fi +######################################################################### +# Get user-given variables +while getopts "p:w:c:" Input; +do + case ${Input} in + p) pool=${OPTARG};; + w) warn=${OPTARG};; + c) crit=${OPTARG};; + *) echo -e "$help" + exit $STATE_UNKNOWN + ;; + esac +done +######################################################################### +# Did user obey to usage? +if [ -z "$pool" ]; then echo -e "$help"; exit ${STATE_UNKNOWN}; fi +######################################################################### +# Verify threshold sense +if [[ -n $warn ]] && [[ -z $crit ]]; then echo "Both warning and critical thresholds must be set"; exit $STATE_UNKNOWN; fi +if [[ -z $warn ]] && [[ -n $crit ]]; then echo "Both warning and critical thresholds must be set"; exit $STATE_UNKNOWN; fi +if [[ $warn -gt $crit ]]; then echo "Warning threshold cannot be greater than critical"; exit $STATE_UNKNOWN; fi +######################################################################### +# What needs to be checked? +## Check all pools +if [ "$pool" = "ALL" ] +then + POOLS=($(zpool list -Ho name)) + if [ $? -ne 0 ]; then + echo "UNKNOWN zpool query failed"; exit $STATE_UNKNOWN + fi + p=0 + for POOL in ${POOLS[*]} + do + CAPACITY=$(zpool list -Ho capacity "$POOL") + CAPACITY=${CAPACITY%\%} + HEALTH=$(zpool list -Ho health "$POOL") + if [ $? -ne 0 ]; then + echo "UNKNOWN zpool query failed"; exit $STATE_UNKNOWN + fi + # Check with thresholds + if [[ -n $warn ]] && [[ -n $crit ]] + then + if [[ $CAPACITY -ge $crit ]] + then error[${p}]="POOL $POOL usage is CRITICAL (${CAPACITY}%)"; fcrit=1 + elif [[ $CAPACITY -ge $warn && $CAPACITY -lt $crit ]] + then error[$p]="POOL $POOL usage is WARNING (${CAPACITY}%)" + elif [ "$HEALTH" != "ONLINE" ] + then error[${p}]="$POOL health is $HEALTH"; fcrit=1 + fi + # Check without thresholds + else + if [ "$HEALTH" != "ONLINE" ] + then error[${p}]="$POOL health is $HEALTH"; fcrit=1 + fi + fi + perfdata[$p]="$POOL=${CAPACITY}% " + let p++ + done + + if [[ ${#error[*]} -gt 0 ]] + then + if [[ $fcrit -eq 1 ]]; then exit_code=2; else exit_code=1; fi + echo "ZFS POOL ALARM: ${error[*]}|${perfdata[*]}"; exit ${exit_code} + else echo "ALL ZFS POOLS OK (${POOLS[*]})|${perfdata[*]}"; exit 0 + fi + +## Check single pool +else + CAPACITY=$(zpool list -Ho capacity "$pool" 2>&1 ) + CAPACITY=${CAPACITY%\%} + if [[ -n $(echo "${CAPACITY}" | egrep -q 'no such pool$') ]]; then + echo "zpool $pool does not exist"; exit $STATE_CRITICAL + fi + HEALTH=$(zpool list -Ho health "$pool") + if [ $? -ne 0 ]; then + echo "UNKNOWN zpool query failed"; exit $STATE_UNKNOWN + fi + + if [[ -n $warn ]] && [[ -n $crit ]] + then + # Check with thresholds + if [ "$HEALTH" != "ONLINE" ]; then echo "ZFS POOL $pool health is $HEALTH|$pool=${CAPACITY}%"; exit ${STATE_CRITICAL} + elif [[ $CAPACITY -ge $crit ]]; then echo "ZFS POOL $pool usage is CRITICAL (${CAPACITY}%)|$pool=${CAPACITY}%"; exit ${STATE_CRITICAL} + elif [[ $CAPACITY -ge $warn && $CAPACITY -lt $crit ]]; then echo "ZFS POOL $pool usage is WARNING (${CAPACITY}%)|$pool=${CAPACITY}%"; exit ${STATE_WARNING} + else echo "ALL ZFS POOLS OK ($pool)|$pool=${CAPACITY}%"; exit ${STATE_OK} + fi + else + # Check without thresholds + if [ "$HEALTH" != "ONLINE" ] + then echo "ZFS POOL $pool health is $HEALTH|$pool=${CAPACITY}%"; exit ${STATE_CRITICAL} + else echo "ALL ZFS POOLS OK ($pool)|$pool=${CAPACITY}%"; exit ${STATE_OK} + fi + fi + +fi + +echo "UNKNOWN - Should never reach this part" +exit ${STATE_UNKNOWN} diff --git a/debian/nagios-plugins-ets/usr/share/doc/nagios-plugins-ets/changelog.gz b/debian/nagios-plugins-ets/usr/share/doc/nagios-plugins-ets/changelog.gz new file mode 100644 index 0000000000000000000000000000000000000000..359b36c603f0caf934584fa6391724503ad68356 GIT binary patch literal 136 zcmV;30C)c%iwFP!000020}aU03c?^12H<<2;=ioOp(O}gMNw}sdH@?I5u6i`QoVh< z`}mUcVPTnL^C7XM%Gl`6Y|#=|_lh*26;EmUo#XNm0@&dl3Re`0 Date: Sun, 11 Aug 2024 17:29:53 -0700 Subject: [PATCH 24/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 5b5cf1a..4d4378f 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -16,6 +16,7 @@ jobs: run: | VERSION=$(grep -Eo "^Version: .+" debian/control | awk '{print $2}') echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "The extracted version is: $VERSION" - name: Install debuild run: | From 69bd209758f2442c3deb58c794a282d40af4dc3c Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Sun, 11 Aug 2024 17:39:04 -0700 Subject: [PATCH 25/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 4d4378f..0bae097 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -30,7 +30,7 @@ jobs: - name: Download the source tarball run: | - wget -O ../nagios-plugins-ets_${VERSION}.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/${VERSION}.tar.gz + wget -O ../nagios-plugins-ets_${VERSION}.orig.tar.gz https://github.com/ucsd-ets/nagios-plugins-ets/archive/refs/tags/1.2.tar.gz tar zxvf ../nagios-plugins-ets_${VERSION}.orig.tar.gz --strip-components=1 - name: Build DEB package From d71cf21a8a2b29a4877e631e2a37d19a896f7408 Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:45:15 -0700 Subject: [PATCH 26/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 0bae097..327122b 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -36,11 +36,11 @@ jobs: - name: Build DEB package run: | debuild -us -uc - cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_amd64.deb + cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb - name: Archive production artifacts uses: actions/upload-artifact@v4 with: - name: nagios-plugins-ets_amd64.deb + name: nagios-plugins-ets_${VERSION}_amd64.deb path: | - nagios-plugins-ets_amd64.deb + nagios-plugins-ets_${VERSION}_amd64.deb From ca9469c04dd596b7b5b5291e796984dccc3906f5 Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:49:00 -0700 Subject: [PATCH 27/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 327122b..4e4b6da 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -36,7 +36,7 @@ jobs: - name: Build DEB package run: | debuild -us -uc - cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb + cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_amd64.deb - name: Archive production artifacts uses: actions/upload-artifact@v4 From 4eda6c71141c7f2a48c05199f64d11e423ccaadd Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:01:54 -0700 Subject: [PATCH 28/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 4e4b6da..327122b 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -36,7 +36,7 @@ jobs: - name: Build DEB package run: | debuild -us -uc - cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_amd64.deb + cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb - name: Archive production artifacts uses: actions/upload-artifact@v4 From 0f613e569babd7c34509d7c7a49d1e485f1e62d1 Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:07:57 -0700 Subject: [PATCH 29/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 327122b..f291ae2 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -36,7 +36,7 @@ jobs: - name: Build DEB package run: | debuild -us -uc - cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb + cp ../nagios-plugins-ets_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb - name: Archive production artifacts uses: actions/upload-artifact@v4 From a3237fad8362af01eb0ed601b1ce0bdccb1d2662 Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:13:14 -0700 Subject: [PATCH 30/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index f291ae2..327122b 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -36,7 +36,7 @@ jobs: - name: Build DEB package run: | debuild -us -uc - cp ../nagios-plugins-ets_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb + cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb - name: Archive production artifacts uses: actions/upload-artifact@v4 From 16a3dd1fdef13c02a3340d15405f33a57a2a27ed Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:47:32 -0700 Subject: [PATCH 31/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 327122b..1f72c02 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -36,6 +36,7 @@ jobs: - name: Build DEB package run: | debuild -us -uc + ls -l ../ cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb - name: Archive production artifacts From 86bf341a97c03dfa01e27966d6b55ac992d427f1 Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:41:38 -0700 Subject: [PATCH 32/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 1f72c02..6ce11cb 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -37,11 +37,11 @@ jobs: run: | debuild -us -uc ls -l ../ - cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb + cp ../nagios-plugins-ets_${env.VERSION}_amd64.deb nagios-plugins-ets_${env.VERSION}_amd64.deb - name: Archive production artifacts uses: actions/upload-artifact@v4 with: - name: nagios-plugins-ets_${VERSION}_amd64.deb + name: nagios-plugins-ets_${env.VERSION}_amd64.deb path: | - nagios-plugins-ets_${VERSION}_amd64.deb + nagios-plugins-ets_${env.VERSION}_amd64.deb From 7846fdedea6ddb161b7de798f718231a4d516fa9 Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:48:37 -0700 Subject: [PATCH 33/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 6ce11cb..59d947a 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -37,7 +37,7 @@ jobs: run: | debuild -us -uc ls -l ../ - cp ../nagios-plugins-ets_${env.VERSION}_amd64.deb nagios-plugins-ets_${env.VERSION}_amd64.deb + cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb - name: Archive production artifacts uses: actions/upload-artifact@v4 From c84ba760e6ac1bbec3f5db18df3768e0eba8d6ef Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Mon, 19 Aug 2024 10:20:48 -0700 Subject: [PATCH 34/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 59d947a..8834d01 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -36,8 +36,11 @@ jobs: - name: Build DEB package run: | debuild -us -uc - ls -l ../ cp ../nagios-plugins-ets_${VERSION}_amd64.deb nagios-plugins-ets_${VERSION}_amd64.deb + + - name: Print path + run: | + ls -l ../ - name: Archive production artifacts uses: actions/upload-artifact@v4 From 1c4717fbc5ac24869339eb4ad47239ac8ad6189d Mon Sep 17 00:00:00 2001 From: swapnilucsd <156013287+swapnilucsd@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:41:27 -0700 Subject: [PATCH 35/35] Update build-deb.yml --- .github/workflows/build-deb.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index 8834d01..8433903 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -45,6 +45,6 @@ jobs: - name: Archive production artifacts uses: actions/upload-artifact@v4 with: - name: nagios-plugins-ets_${env.VERSION}_amd64.deb + name: nagios-plugins-ets_${{env.VERSION}}_amd64.deb path: | - nagios-plugins-ets_${env.VERSION}_amd64.deb + nagios-plugins-ets_${{env.VERSION}}_amd64.deb