Skip to content

Commit

Permalink
Independence (#4)
Browse files Browse the repository at this point in the history
* Remove dependency on nagios plugins utils.pm to run the script independently
  • Loading branch information
Napsty authored Jan 19, 2024
1 parent 8c13782 commit 4663576
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 44 deletions.
32 changes: 8 additions & 24 deletions .github/workflows/rockylinux9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,37 @@ 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
container:
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
22 changes: 8 additions & 14 deletions .github/workflows/ubuntu-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,33 @@ 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
steps:
- 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
7 changes: 1 addition & 6 deletions check_ro_mounts.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(
Expand Down Expand Up @@ -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

0 comments on commit 4663576

Please sign in to comment.