Skip to content

Setup Additional Monitoring Plugins

Garðar Þorsteinsson edited this page Jan 25, 2023 · 14 revisions

Install MySQL / MariaDB health plugin - check_mysql_health

https://labs.consol.de/nagios/check_mysql_health/index.html

yum install -y perl-DBI perl-DBD-MySQL make gcc-c++
wget https://labs.consol.de/assets/downloads/nagios/check_mysql_health-2.2.2.tar.gz
tar -zxvf check_mysql_health-2.2.2.tar.gz
cd check_mysql_health-2.2.2
./configure --prefix=/usr/lib64/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl
make
make install
cp -p /usr/lib64/nagios/libexec/check_mysql_health /usr/lib64/nagios/plugins/.

Install Microsoft SQL server health plugin - check_mssql_health

https://labs.consol.de/nagios/check_mssql_health/index.html

yum install -y make gcc-c++ cpan freetds-devel freetds
export SYBASE="/usr"
cpan -fi DBD::Sybase
wget https://labs.consol.de/assets/downloads/nagios/check_mssql_health-2.7.2.1.tar.gz
tar -zxvf check_mssql_health-2.7.2.1.tar.gz
cd check_mssql_health-2.7.2.1
./configure --prefix=/usr/lib64/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl
make
make install
cp -p /usr/lib64/nagios/libexec/check_mssql_health /usr/lib64/nagios/plugins/.

Another method - Build RPM for DBD-Sybase (for EL7 when using check_mssql_health)

Requirements

  • dev tools installed
  • cpanspec installed
  • freedts & freetds-devel installed
yum install -y freetds-devel freetds cpanspec gcc-c++

Create the SPEC file and build RPM

sudo yum install cpanspec rpm-build
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

vim .rpmmacros
%packager Gardar <gardar@ok.is>
%vendor OK
%_topdir %(echo $HOME)/rpmbuild
%__perl_requires %{nil}

cpanspec DBD::Sybase
cp perl-DBD-Sybase.spec ~/rpmbuild/SPECS/
cp DBD-Sybase-1.22.tar.gz ~/rpmbuild/SOURCES/

# Remove test from spec file if you dont have a runnning sybase database
sed -i '/^%check/d' ~/rpmbuild/SPECS/perl-DBD-Sybase.spec
sed -i '/^make test/d' ~/rpmbuild/SPECS/perl-DBD-Sybase.spec

# unset PERL_LOCAL_LIB_ROOT
# unset PERL_MM_OPT
# unset INSTALL_BASE
# unset PERL_MB_OPT

cd ~/rpmbuild
SYBASE=/usr rpmbuild -ba SPECS/perl-DBD-Sybase.spec

Install the newly created rpm from ~/rpmbuild/RPMS/x86_64/

Custom location for perl modules

To be able to use Perl modules installed by other user than nagios user you can use custom location for perl modules in Nagios user environment

cp -r /root/perl5/lib/* /opt/perl5_custom_lib
chown -R nagios:root /opt/perl5_custom_lib

RHEL7 - SYSTEMD
mkdir /etc/systemd/system/nagios.service.d
vim /etc/systemd/system/nagios.service.d/env.conf
 [Service]
 Environment="PERL5LIB=$PERL5LIB:/opt/perl5_custom_lib"

sudo systemctl daemon-reload
sudo systemctl restart nagios