diff --git a/.github/workflows/rockylinux9.yaml b/.github/workflows/rockylinux9.yaml index 5c2fb01..499887d 100644 --- a/.github/workflows/rockylinux9.yaml +++ b/.github/workflows/rockylinux9.yaml @@ -12,20 +12,12 @@ jobs: image: rockylinux/rockylinux:9 steps: - uses: actions/checkout@v1 - - name: Enable EPEL - run: | - dnf install -y dnf-plugins-core - dnf config-manager --set-enabled crb - dnf install -y epel-release - name: Install dependencies run: | - dnf -y install nagios-plugins-perl perl-FindBin perl-lib - - name: Move Plugin to nagios-plugins dir - run: | - mv check_ro_mounts.pl /usr/lib64/nagios/plugins/ + dnf -y install perl perl-lib - name: Launch plugin with --help run: | - /usr/lib64/nagios/plugins/check_ro_mounts.pl --help + ./check_ro_mounts.pl --help launch-checks: needs: launch-help runs-on: ubuntu-latest @@ -33,32 +25,24 @@ jobs: image: rockylinux/rockylinux:9 steps: - uses: actions/checkout@v1 - - name: Enable EPEL - run: | - dnf install -y dnf-plugins-core - dnf config-manager --set-enabled crb - dnf install -y epel-release - name: Install dependencies run: | - dnf -y install nagios-plugins-perl perl-FindBin perl-lib - - name: Move Plugin to nagios-plugins dir - run: | - mv check_ro_mounts.pl /usr/lib64/nagios/plugins/ + dnf -y install perl perl-lib - name: Execute in debug mode (should detect read-only mounts) run: | - /usr/lib64/nagios/plugins/check_ro_mounts.pl -d + ./check_ro_mounts.pl -d continue-on-error: true - name: Execute with include overlay file system (should not detect any read-only mounts) run: | - /usr/lib64/nagios/plugins/check_ro_mounts.pl -T overlay + ./check_ro_mounts.pl -T overlay - name: Execute with excluded file systems and mount paths (should not detect any read-only mounts) run: | - /usr/lib64/nagios/plugins/check_ro_mounts.pl -X tmpfs -X proc -X devpts -X sysfs -X cgroup -X cgroup2 -x "/__e" + ./check_ro_mounts.pl -X tmpfs -X proc -X devpts -X sysfs -X cgroup -X cgroup2 -x "/__e" - name: Execute with file systems in missing fstab file (should alert for missing /etc/fstab) run: | - /usr/lib64/nagios/plugins/check_ro_mounts.pl -F + ./check_ro_mounts.pl -F continue-on-error: true - name: Execute with file systems in fstab file (should not detect any read-only mounts) run: | for mount in $(egrep "(ext3|ext4|xfs) rw" /proc/mounts); do echo "$mount" >> /etc/fstab; done - /usr/lib64/nagios/plugins/check_ro_mounts.pl -F + ./check_ro_mounts.pl -F diff --git a/.github/workflows/ubuntu-latest.yaml b/.github/workflows/ubuntu-latest.yaml index 58ee5fb..230abc0 100644 --- a/.github/workflows/ubuntu-latest.yaml +++ b/.github/workflows/ubuntu-latest.yaml @@ -12,13 +12,10 @@ jobs: - uses: actions/checkout@v1 - name: Install dependencies run: | - sudo apt-get install -yy libmonitoring-plugin-perl monitoring-plugins-common - - name: Move Plugin to nagios-plugins dir - run: | - sudo mv check_ro_mounts.pl /usr/lib/nagios/plugins/ + sudo apt-get install -yy perl - name: Launch plugin with --help run: | - /usr/lib/nagios/plugins/check_ro_mounts.pl --help + ./check_ro_mounts.pl --help launch-checks: needs: launch-help runs-on: ubuntu-latest @@ -26,25 +23,22 @@ jobs: - uses: actions/checkout@v1 - name: Install dependencies run: | - sudo apt-get install -yy libmonitoring-plugin-perl monitoring-plugins-common - - name: Move Plugin to nagios-plugins dir - run: | - sudo mv check_ro_mounts.pl /usr/lib/nagios/plugins/ + sudo apt-get install -yy perl - name: Execute in debug mode (should detect read-only mounts) run: | - /usr/lib/nagios/plugins/check_ro_mounts.pl -d + ./check_ro_mounts.pl -d continue-on-error: true - name: Execute with specific file system ext4 (should not detect any read-only mounts) run: | - /usr/lib/nagios/plugins/check_ro_mounts.pl -T ext4 + ./check_ro_mounts.pl -T ext4 - name: Execute with excluded file systems and mount paths (should not detect any read-only mounts) run: | - /usr/lib/nagios/plugins/check_ro_mounts.pl -X securityfs -X pstore -X autofs -X bpf -X mqueue -X debugfs -X tracefs -X fusectl -X configfs -X ramfs -X squashfs -X tmpfs -X proc -X devpts -X sysfs -X cgroup -X cgroup2 + ./check_ro_mounts.pl -X securityfs -X pstore -X autofs -X bpf -X mqueue -X debugfs -X tracefs -X fusectl -X configfs -X ramfs -X squashfs -X tmpfs -X proc -X devpts -X sysfs -X cgroup -X cgroup2 - name: Execute with file systems in missing fstab file (should alert for missing /etc/fstab) run: | - /usr/lib/nagios/plugins/check_ro_mounts.pl -F -f ./fstab + ./check_ro_mounts.pl -F -f ./fstab continue-on-error: true - name: Execute with file systems in fstab file (should not detect any read-only mounts) run: | for mount in $(egrep "(ext3|ext4|xfs) rw" /proc/mounts); do sudo echo "$mount" >> ./fstab; done - /usr/lib/nagios/plugins/check_ro_mounts.pl -F -f ./fstab + ./check_ro_mounts.pl -F -f ./fstab diff --git a/check_ro_mounts.pl b/check_ro_mounts.pl index 75c743a..e6da0f7 100755 --- a/check_ro_mounts.pl +++ b/check_ro_mounts.pl @@ -25,10 +25,6 @@ use strict; use Getopt::Long; -use FindBin; -use lib "$FindBin::Bin"; -use lib '@libexecdir@'; -use utils qw (%ERRORS &support); my $name = 'RO_MOUNTS'; my $mtab = '/proc/mounts'; @@ -42,6 +38,7 @@ my @ro_mounts = (); my $want_help = 0; my $debug = 0; +my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); Getopt::Long::Configure(qw(no_ignore_case)); my $res = GetOptions( @@ -186,8 +183,6 @@ sub print_help { Specify a different path for fstab (default is /etc/fstab) EOH - - support(); } # vim:sw=4:ts=4:et