Tuesday, January 23, 2024

Configure Nagios to monitor Remote Windows Host

To configure Nagios to monitor a remote Windows host, you'll need to set up NSClient++ on the Windows machine. 

Install Nagios on the Monitoring Server 

I did it in Install Nagios Core on Oracle Linux 8.5 (OL8.5) post.

On the Windows Server

1. Download NSClient++ using this link  Nsclient05.2

2. For Installing Nsclient++ on the Windows server dot the following steps

Double-click on the installation file


Choose the generic option

Choose the typical option

Enter the Nagios server's IP address and check the (check_nt) option

Click install and finish

Go to the file C:\Program Files\NSClient++  path and edit nsclient.ini file and enable the following Item by changing disabled to enabled or (=1)

CheckExternalScripts = 1
CheckHelpers = 1
CheckEventLog = 1
CheckNSCP = 1
CheckDisk =1
CheckSystem = 1

Restart the nsclient service on windows


On the Nagios Server

1. In nagios server, edit nagios.cfg file and uncomment windows



2. Test whether the Nagios server can monitor the Windows server or not.

##Example: checking the Windows server uptime
[root@emcl libexec]# ./check_nt -H 192.168.56.4 -p 12489 -v UPTIME
System Uptime - 0 day(s) 1 hour(s) 27 minute(s) |uptime=87

##Example: Checking memory used in the Windows server
[root@emcl libexec]# ./check_nt -H 192.168.56.4 -p 12489 -v MEMUSE
Memory usage: total:11839.65 MB - used: 1655.86 MB (14%) - free: 10183.79 MB (86%) | 'Memory usage'=1655.86MB;0.00;0.00;0.00;11839.65

3. Edit windows.cfg file, and add the new Windows host machine that we want to monitor.


[root@emcl ~]# vi /usr/local/nagios/etc/objects/windows.cfg

define host {
        use                             windows-server         ; Inherit default values from a template
        host_name                       WIN-VV69BDNGNH2        ; The name we're giving to this server
        alias                           windows-servers         ; A longer name for the server
        address                         192.168.56.4           ; IP address of Windows remote
}

define hostgroup {

    hostgroup_name          windows-servers         ; The name of the hostgroup
    alias                   Windows Servers         ; Long name of the group
}

define service{
        use                     generic-service
        host_name               WIN-VV69BDNGNH2
        service_description     NSClient++ Version
        check_command           check_nt!CLIENTVERSION
        check_interval          1
        max_check_attempts      1
        retry_interval          1
        }

define service{
        use                     generic-service
        host_name               WIN-VV69BDNGNH2
        service_description     Drive C Disk usage
        check_command           check_nt!USEDDISKSPACE!-l C
        check_interval          1
        max_check_attempts      1
        retry_interval          1
        }
Save the file and check if every this is working without any errors and restart nagios service on Nageios server
[root@emcl etc]#  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[root@emcl libexec]# systemctl restart nagios


Check the Nagios in browser






Monday, January 22, 2024

Configure Nagios to monitor Oracle database on a remote Linux Host Using CHECK_ORACLE_HEALTH

Monitoring Oracle Database with Nagios involves using plugins and configurations that allow Nagios to check the status and performance of the Oracle Database.

Download and install oracle instant client for Nagios server

1. Install the libnsl package which is a required package for instant client for Linux 8

[root@emcl etc]# dnf install libnsl -y
Last metadata expiration check: 1:31:06 ago on Fri 15 Dec 2023 05:26:18 PM EST.
Package libnsl-2.28-164.0.1.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

2. For downloading instance client go to the oracle website https://www.oracle.com/ and do the following

From the top menu go to Resources then click Developer Downloads


Click Database


Click Instant Client


Then choose Instant client for Linux 64 bit


you should download these rpm files 
  • oracle-instantclient-basic-21.12.0.0.0-1.el8.x86_64.rpm
  • oracle-instantclient-devel-21.12.0.0.0-1.el8.x86_64.rpm
  • oracle-instantclient-sqlplus-21.12.0.0.0-1.el8.x86_64.rpm
Download and copy rpm file to /software and install them

[root@emcl software]# rpm -qa | grep instantclient
[root@emcl software]# rpm -Uvh oracle-instantclient-basic-21.12.0.0.0-1.el8.x86_64.rpm
warning: oracle-instantclient-basic-21.12.0.0.0-1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ad986da3: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:oracle-instantclient-basic-21.12.################################# [100%]
[root@emcl software]# rpm -Uvh oracle-instantclient-devel-21.12.0.0.0-1.el8.x86_64.rpm
warning: oracle-instantclient-devel-21.12.0.0.0-1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ad986da3: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:oracle-instantclient-devel-21.12.################################# [100%]
[root@emcl software]# rpm -Uvh oracle-instantclient-sqlplus-21.12.0.0.0-1.el8.x86_64.rpm
warning: oracle-instantclient-sqlplus-21.12.0.0.0-1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ad986da3: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:oracle-instantclient-sqlplus-21.1################################# [100%]
Configure oracle server (nagios client)
1. Creating nagios user in the database and giving it the required access
[oracle@emcl ~]$ sqlplus / as sysdba
create user nagios identified by nagios;
grant create session to nagios;
grant select any dictionary to nagios;
grant select on V_$SYSSTAT to nagios;
grant select on V_$INSTANCE to nagios;
grant select on V_$LOG to nagios;
grant select on SYS.DBA_DATA_FILES to nagios;
grant select on SYS.DBA_FREE_SPACE to nagios;

Set up Check_Oracle_Health on Nagios server
1. prerequisite for installing Check_Oracle_Health on OEL8.5 (our nagios server)
1_1. The installation of the Perl modules DBI and DBD::Oracle are required. perl-DBI.x86_64 rpm exists on OEL8 ISO image and we will install it. In addition, we need to install libaio and Perl-CPAN related RPMs, I checked my system it was already installed.
[root@emcl software]# yum search  perl-DBI
Last metadata expiration check: 1:04:11 ago on Wed 03 Jan 2024 03:03:33 PM EST.
======================================================== Name Exactly Matched: perl-DBI =========================================================
perl-DBI.x86_64 : A database access API for perl


[root@emcl software]# yum install perl-DBI.x86_64

[root@emcl software]# rpm -qa | grep perl-DBI
perl-DBI-1.641-3.module+el8.3.0+7665+79fef143.x86_64


[root@emcl software]# rpm -qa | grep libaio
libaio-0.3.112-1.el8.x86_64

[root@emcl DBD-Oracle-1.83-0]# rpm -qa | grep perl-CPAN
perl-CPAN-Meta-Requirements-2.140-396.el8.noarch
perl-CPAN-Meta-2.150010-396.el8.noarch
perl-CPAN-Meta-YAML-0.018-397.el8.noarch
perl-CPAN-2.18-397.el8.noarch
###Prerequisites:
####Oracle Instant Client:
[root@emcl software]# rpm -qa | grep oracle-instantclient
oracle-instantclient-sqlplus-21.12.0.0.0-1.el8.x86_64
oracle-instantclient-devel-21.12.0.0.0-1.el8.x86_64
oracle-instantclient-basic-21.12.0.0.0-1.el8.x86_64

The DBD::Oracle Perl module is not in an RPM repository, the good thing is that you can download it via CPAN. Run the following command with the root user.

 [root@emcl software]# perl -MCPAN -e shell 

During the installation, you may be prompted to provide the paths to the Oracle Instant Client libraries and include files. Make sure to provide the correct paths.

[root@emcl DBD-Oracle-1.83-0]# export ORACLE_HOME=/usr/lib/oracle/21/client64/
[root@emcl DBD-Oracle-1.83-0]# export LD_LIBRARY_PATH=/usr/lib/oracle/21/client64/lib
[root@emcl DBD-Oracle-1.83-0]# export PATH=$PATH:$ORACLE_HOME/bin:$LD_LIBRARY_PATH:${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin

[root@emcl DBD-Oracle-1.83-0]# cd /root/.cpan/build/DBD-Oracle-1.83-0
[root@emcl DBD-Oracle-1.83-0]# perl Makefile.PL

Then run the following
[root@emcl DBD-Oracle-1.83-0]# make
[root@emcl DBD-Oracle-1.83-0]# make install

Verify installation using the following command.
[root@emcl DBD-Oracle-1.83-0]# perl -e 'use DBD::Oracle; print "DBD::Oracle is installed\n";'
DBD::Oracle is installed

2. Download and Install check_oracle_health:
[root@emcl software]# cd /software/
[root@emcl software]# wget https://labs.consol.de/assets/downloads/nagios/check_oracle_health-3.3.2.1.tar.gz
--2024-01-03 16:14:26--  https://labs.consol.de/assets/downloads/nagios/check_oracle_health-3.3.2.1.tar.gz
Resolving labs.consol.de (labs.consol.de)... 94.185.89.33, 2a03:3680:0:2::21
Connecting to labs.consol.de (labs.consol.de)|94.185.89.33|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 173953 (170K) [application/octet-stream]
Saving to: ‘check_oracle_health-3.3.2.1.tar.gz’

check_oracle_health-3.3.2.1.tar.gz   100%[===================================================================>] 169.88K   721KB/s    in 0.2s

2024-01-03 16:14:27 (721 KB/s) - ‘check_oracle_health-3.3.2.1.tar.gz’ saved [173953/173953]



[root@emcl DBD-Oracle-1.83-0]# cd /software/
[root@emcl software]# tar xzf check_oracle_health-3.3.2.1.tar.gz
[root@emcl software]# cd check_oracle_health-3.3.2.1  
[root@emcl libexec]# ./configure -prefix=/usr/local/nagios -with-nagios-user=nagios
-bash: ./configure: No such file or directory
[root@emcl libexec]# cd /software/check_oracle_health-3.3.2.1
[root@emcl check_oracle_health-3.3.2.1]# ./configure -prefix=/usr/local/nagios -with-nagios-user=nagios


[root@emcl check_oracle_health-3.3.2.1]# make
[root@emcl check_oracle_health-3.3.2.1]# make install

Here are some examples of testing the Check_Oracle_health

###checking the existance of check_oracle_health are created under /usr/local/nagios/libexec/ path
[root@emcl check_oracle_health-3.3.2.1]# cd /usr/local/nagios/libexec/
[root@emcl libexec]# ll check_oracle
check_oracle         check_oracle_health


[root@emcl libexec]# /usr/local/nagios/libexec/check_oracle_health -V
check_oracle_health (3.3.2.1)
This nagios plugin comes with ABSOLUTELY NO WARRANTY. You may redistribute
copies of this plugin under the terms of the GNU General Public License.

##checking tnsping 
[root@emcl libexec]# /usr/local/nagios/libexec/check_oracle_health --connect=192.168.56.10:1521/pdb1.amir.net --username=nagios --password=nagios --mode tnsping     
OK - connection established to 192.168.56.10:1521/pdb1.amir.net.

##checking tablespaces usage 
[root@emcl libexec]# /usr/local/nagios/libexec/check_oracle_health --connect=192.168.56.10:1521/pdb1.amir.net --username=nagios --password=nagios --mode tablespace-usage
OK - tbs USERS usage is 0.00%, tbs UNDOTBS1 usage is 0.03%, tbs TEMP usage is 0.00%, tbs SYSTEM usage is 0.84%, tbs SYSAUX usage is 0.81% | 
'tbs_users_usage_pct'=0.00%;90;98 'tbs_users_usage'=1MB;29491;32112;0;32767 'tbs_users_alloc'=5MB;;;0;32767 'tbs_undotbs1_usage_pct'=0.03%;90;98 'tbs_undotbs1_usage'=9MB;29491;32112;0;32767 'tbs_undotbs1_alloc'=100MB;;;0;32767 'tbs_temp_usage_pct'=0.00%;90;98 'tbs_temp_usage'=0MB;265420;289013;0;294911 'tbs_temp_alloc'=1152MB;;;0;294911 'tbs_system_usage_pct'=0.84%;90;98 'tbs_system_usage'=276MB;29491;32112;0;32767 'tbs_system_alloc'=280MB;;;0;32767 'tbs_sysaux_usage_pct'=0.81%;90;98 'tbs_sysaux_usage'=264MB;29491;32112;0;32767 'tbs_sysaux_alloc'=280MB;;;0;32767

##checking ASM disks
[root@emcl ~]#  /usr/local/nagios/libexec/check_oracle_health --connect=192.168.56.10:1521/pdb1.amir.net --username=nagios --password=nagios --mode asm-diskgroup-usage
OK - dg DATA usage is 25.27%, dg FRA usage is 9.30% | 'dg_data_usage_pct'=25.27%;90;98 'dg_data_usage'=4140MB;14742;16052;0;16380 'dg_data_size'=16380MB 'dg_fra_usage_pct'=9.30%;90;98 'dg_fra_usage'=952MB;9212;10031;0;10236 'dg_fra_size'=10236MB
Configuring Nagios-related files on the Nagios server to check the Oracle server using CHECK_ORACLE_HEALTH

1. Configuration of Nagios server files including hosts.cfg, services.cfg and commands.cfg for checking tablespace usage
[root@emcl ~]#  vi /usr/local/nagios/etc/hosts.cfg

## Default
define host{
use                             linux-box               ; Inherit default values from a template
host_name                       src                     ; The name we're giving to this server
alias                           Oracle Linux Server release 7.9               ; A longer name for the server
address                         192.168.56.10           ; IP address of Remote Linux host
}

##add this to the end of following file
[root@emcl admin]# vi /usr/local/nagios/etc/services.cfg
define service {
    use                         generic-service
    host_name                   src
    service_description         Oracle Tablespace Usage
    check_command               check_oracle_health_tablespace!1521!pdb1.amir.net!nagios!nagios!tablespace-usage
        }

[root@emcl ~]# vi /usr/local/nagios/etc/objects/commands.cfg
define command {
     command_name check_oracle_health_tablespace
  command_line $USER1$/check_oracle_health --connect=$HOSTADDRESS$:$ARG1$/$ARG2$ --username=$ARG3$ --password=$ARG4$ --mode $ARG5$

}
2. Nagios configuration for tnsping

[root@emcl ~]# vi /usr/local/nagios/etc/services.cfg
define service {
    use                         generic-service
    host_name                   src
    service_description         TNS Ping
    check_command               check_oracle_health_tnsping!1521!pdb1.amir.net!tnsping
        }

[root@emcl ~]# vi /usr/local/nagios/etc/objects/commands.cfg

define command {
    command_name check_oracle_health_tnsping
    command_line $USER1$/check_oracle_health --connect=$HOSTADDRESS$:$ARG1$/$ARG2$ --mode $ARG3$
}
3. Nagios configuration for ASM Diskgroup Free Space

[root@emcl ~]# vi /usr/local/nagios/etc/services.cfg

define service {
    use                         generic-service
    host_name                   src
    service_description         ASM Diskgroup Free Space
    check_command               check_oracle_health_asm_disk_used!1521!pdb1.amir.net!nagios!nagios!asm-diskgroup-usage
        }

[root@emcl ~]# vi /usr/local/nagios/etc/objects/commands.cfg

define command {
  command_name check_oracle_health_asm_disk_used
  command_line $USER1$/check_oracle_health --connect=$HOSTADDRESS$:$ARG1$/$ARG2$ --username=$ARG3$ --password=$ARG4$ --mode $ARG5$
}


Configure Nagios to monitor Remote Linux Host

To monitor a remote Linux host using Nagios, we'll need to install Nagios Plugins and NRPE (Nagios Remote Plugin Executor) on the remote host. 


NRPE (Nagios Remote Plugin Executor):

NRPE is a Nagios agent that allows remote systems to execute Nagios plugins on them. It facilitates the monitoring of local resources and services on remote hosts. NRPE can be installed on various operating systems, including Linux and Windows.


Here's a brief overview of how NRPE works:

  • Nagios Server: The Nagios server initiates a check by sending a command to the NRPE daemon on the remote host.
  • NRPE Daemon: The NRPE daemon on the remote host receives the command, executes the specified plugin locally, and returns the results to the Nagios server.
  • Monitoring Plugins: Plugins are scripts or executables that perform specific checks (e.g., checking CPU usage, disk space, etc.) on the remote host.
  • Secure Communication: NRPE uses encryption and authentication to ensure secure communication between the Nagios server and the remote host.
Configuring  NRPE and Nagios Plugin on remote Linux host 

To monitor the remote Linux host we must install NRPE and Nagios Plugin, here are the steps:

1.  First let's check my Linux version

[root@src ~]# more /etc/*release;
::::::::::::::
/etc/oracle-release
::::::::::::::
Oracle Linux Server release 7.9
2. Install Required Packages
2_1. Configuring the YUM repository, I copied Linux 7 on my host in /software path.
[root@src ~]# more /etc/yum.repos.d/oracle-linux-ol7.repo
[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=file:///software/linux7
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=0
enabled=1
[root@src linux7]# yum update
2_2. Then install the following packages. 

[root@src linux7]# yum install -y gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel tar wget
2_3. Create Nagios user
[root@src linux7]# useradd nagios
[root@src linux7]# passwd nagios
Changing password for user nagios.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
 2_4. Create directory for Nagios Plugin and download the package in this directory
[root@src linux7]# mkdir /root/nagios
[root@src linux7]# cd /root/nagios
[root@src linux7]# wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
3. Compile and install nagios plugin
[root@src nagios]# tar -xvf nagios-plugins-2.3.3.tar.gz
[root@src nagios]# ls -l
total 2724
drwxr-xr-x 15 root root    4096 Mar 11  2020 nagios-plugins-2.3.3
-rw-r--r--  1 root root 2782610 Dec 15 16:36 nagios-plugins-2.3.3.tar.gz
[root@src nagios]# cd nagios-plugins-2.3.3
[root@src nagios-plugins-2.3.3]# ./configure
[root@src nagios-plugins-2.3.3]# make
[root@src nagios-plugins-2.3.3]# make install
##Set the permissions on the plugin directory using the chown command.
[root@src nagios-plugins-2.3.3]# chown nagios.nagios /usr/local/nagios
[root@src nagios-plugins-2.3.3]# chown -R nagios.nagios /usr/local/nagios/libexec
4. Install NRPE: Download the latest package, compile and install NRPE.
[root@src nagios]# cd /root/nagios
[root@src nagios]# wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.0.2/nrpe-4.0.2.tar.gz
[root@src nagios]# tar xzf nrpe-4.0.2.tar.gz
[root@src nagios]# cd nrpe-4.0.2

[root@src nrpe-4.0.2]# ./configure

[root@src nrpe-4.0.2]# make all
cd ./src/; make
make[1]: Entering directory `/root/nagios/nrpe-4.0.2/src'
gcc -g -O2 -I/usr/include/krb5   -DHAVE_CONFIG_H -I ../include -I ./../include -o nrpe ./nrpe.c ./utils.c ./acl.c -lssl -lcrypto   -lnsl
gcc -g -O2 -I/usr/include/krb5   -DHAVE_CONFIG_H -I ../include -I ./../include -o check_nrpe ./check_nrpe.c ./utils.c -lssl -lcrypto   -lnsl
make[1]: Leaving directory `/root/nagios/nrpe-4.0.2/src'

*** Compile finished ***

You can now continue with the installation or upgrade process.

Read the PDF documentation (docs/NRPE.pdf) for information on the next
steps you should take to complete the installation or upgrade.

[root@src nrpe-4.0.2]# make install-plugin
cd ./src/; make install-plugin
make[1]: Entering directory `/root/nagios/nrpe-4.0.2/src'
/usr/bin/install -c -m 755 -d /usr/local/nagios/bin
/usr/bin/install -c -m 755 ../uninstall /usr/local/nagios/bin/nrpe-uninstall
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios check_nrpe /usr/local/nagios/libexec
make[1]: Leaving directory `/root/nagios/nrpe-4.0.2/src'

[root@src nrpe-4.0.2]# make install-daemon
cd ./src/; make install-daemon
make[1]: Entering directory `/root/nagios/nrpe-4.0.2/src'
/usr/bin/install -c -m 755 -d /usr/local/nagios/bin
/usr/bin/install -c -m 755 ../uninstall /usr/local/nagios/bin/nrpe-uninstall
/usr/bin/install -c -m 755 nrpe /usr/local/nagios/bin
/usr/bin/install -c -m 755 -o nagios -g nagios -d /usr/local/nagios/var
/usr/bin/install -c -m 755 -d /usr/lib/tmpfiles.d
/usr/bin/install -c -m 644 ../startup/tmpfile.conf /usr/lib/tmpfiles.d/nrpe.conf
make[1]: Leaving directory `/root/nagios/nrpe-4.0.2/src'

[root@src nrpe-4.0.2]#  make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc

[root@src nrpe-4.0.2]# make install-init
/usr/bin/install -c -m 644 startup/default-service /usr/lib/systemd/system/nrpe.service


4_1. Now open /usr/local/nagios/etc/nrpe.cfg file and add the local host and IP address of the Nagios Monitoring Server.

[root@src nrpe-4.0.2]# vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.56.2

4_2. Restart NRPE:

[root@src nrpe-4.0.2]# systemctl enable nrpe
Created symlink from /etc/systemd/system/multi-user.target.wants/nrpe.service to /usr/lib/systemd/system/nrpe.service.
[root@src nrpe-4.0.2]# systemctl restart nrpe

4_3. Open NRPE Port in Firewall (I disabled the firewall in my Linux)
If a firewall is enabled on your Nagios server, you must allow traffic on the NRPE port (default is 5666). Update your firewall rules accordingly.

# firewall-cmd --zone=public --add-port=5666/tcp
# firewall-cmd --zone=public --add-port=5666/tcp --permanent
In my case firewall is disabled
[root@src nrpe-4.0.2]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
Run the following netstat command to verify the NRPE daemon working correctly.
[root@src nrpe-4.0.2]# netstat -na | grep "5666"
tcp        0      0 0.0.0.0:5666            0.0.0.0:*               LISTEN
tcp6       0      0 :::5666                 :::*                    LISTEN

##verify the NRPE daemon is functioning properly by running the “check_nrpe” command that was installed earlier for testing purposes.
[root@src nrpe-4.0.2]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
NRPE v4.0.2

Adding Remote Linux Host to Nagios Monitoring Server

we had installed  NRPE On the Nagios Monitoring Server in the previous article: Install Nagios Core on Oracle Linux 8.5 (OL8.5)

1. Verify NRPE Daemon Remotely

connect to the Nagios Server

# /usr/local/nagios/libexec/check_nrpe -H <remote_linux_ip_address>


[root@emcl libexec]# /usr/local/nagios/libexec/check_nrpe -H 192.168.56.10
-bash: /usr/local/nagios/libexec/check_nrpe: No such file or directory

# I checkedm, I the package source that I download for the Nagios server shit file was missing, therefore, I copied it from the remote host.
[root@emcl libexec]#  ll | wc -l
63

##on the client
[root@src libexec]# ll | wc -l
64

[root@src ~]# scp /usr/local/nagios/libexec/check_nrpe  root@192.168.56.2://usr/local/nagios/libexec/
The authenticity of host '192.168.56.2 (192.168.56.2)' can't be established.
ECDSA key fingerprint is SHA256:A8Z6mVuYWIrJWJkMuDJ7qiGkLHBBWvmcRbMQuoM2ZNM.
ECDSA key fingerprint is MD5:7b:35:06:3e:fe:43:90:7d:c6:a8:0a:00:2c:01:72:b5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.56.2' (ECDSA) to the list of known hosts.
root@192.168.56.2's password:
check_nrpe 

###Now, it is working on the server on server
[root@emcl libexec]# /usr/local/nagios/libexec/check_nrpe -H 192.168.56.10
NRPE v4.0.2

2. Adding the following information in nagios.cfg file
[root@emcl libexec]#  cd /usr/local/nagios/etc/
[root@emcl etc]# touch hosts.cfg
[root@emcl etc]# touch services.cfg

[root@emcl etc]# vi /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg

3. Configuring Nagios Host, Services and command Files

3_1. Configuring Host file

[root@emcl etc]# more /usr/local/nagios/etc/hosts.cfg
## Default Linux Host Template ##
define host{
name                            linux-box               ; Name of this template
use                             generic-host            ; Inherit default values
check_period                    24x7
check_interval                  5
retry_interval                  1
max_check_attempts              10
check_command                   check-host-alive
notification_period             24x7
notification_interval           30
notification_options            d,r
contact_groups                  admins
register                        0                       ; DONT REGISTER THIS - ITS A TEMPLATE
}

## Default
define host{
use                             linux-box               ; Inherit default values from a template
host_name                       src                     ; The name we're giving to this server
alias                           Oracle Linux Server release 7.9               ; A longer name for the server
address                         192.168.56.10           ; IP address of Remote Linux host
}
3_2. Configuring services.cfg file
define service{
        use                     generic-service
        host_name               src
        service_description     CPU Load
        check_command           check_nrpe!check_load
        }

define service{
        use                     generic-service
        host_name               src
        service_description     Total Processes
        check_command           check_nrpe!check_total_procs
        }

define service{
        use                     generic-service
        host_name               src
        service_description     Current Users
        check_command           check_nrpe!check_users
        }

define service{
        use                     generic-service
        host_name               src
        service_description     SSH Monitoring
        check_command           check_nrpe!check_ssh
        }

define service{
        use                     generic-service
        host_name               src
        service_description     FTP Monitoring
        check_command           check_nrpe!check_ftp
        }
 
3_3. Configuring NRPE Command Definition file
# vi /usr/local/nagios/etc/objects/commands.cfg
###add following to the end of the file
define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }
   
3_4. Checking the configuraion is done correctly [root@emcl etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
3_5. Restart the Nagios service on the Nagios server
[root@emcl etc]#  systemctl restart nagios




Thursday, December 21, 2023

Install Nagios Core on Oracle Linux 8.5 (OL8.5)

Nagios Core is an open-source monitoring system that helps organizations identify and resolve IT infrastructure problems. It is designed to monitor hosts, services, and network devices, providing administrators with insights into the health and performance of their systems. Nagios Core is widely used for its flexibility, extensibility, and scalability.

Doing the following steps we can install Nagios Core on OL8.5

1. Disable selinux


[root@emcl ~]# sestatus
SELinux status:                 enforcing

# disable selinux
[root@emcl ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
2. Install prerequired packages: 
2_1. First I checked that the dnf is installed on the OL8.5 by default
[root@emcl ~]# rpm -qa | grep  dnf
python3-dnf-plugins-core-4.0.21-3.0.1.el8.noarch
dnf-plugin-spacewalk-2.8.5-11.0.3.module+el8.3.0+20070+f5719e00.noarch
python3-libdnf-0.63.0-3.0.1.el8.x86_64
dnf-4.7.0-4.0.1.el8.noarch
dnf-plugins-core-4.0.21-3.0.1.el8.noarch
python3-dnf-plugin-spacewalk-2.8.5-11.0.3.module+el8.3.0+20070+f5719e00.noarch
libdnf-0.63.0-3.0.1.el8.x86_64
python3-dnf-4.7.0-4.0.1.el8.noarch
python3-dnf-plugin-ulninfo-0.3-2.module+el8.4.0+20142+f119a2fa.noarch
dnf-data-4.7.0-4.0.1.el8.noarch
2_2. To install Nagios Core on a Linux system, you must ensure that certain packages and dependencies are installed. The specific packages required may vary slightly depending on your Linux distribution. Here for OL8.5 we need to install the following packages, and then enable and start httpd service.
[root@emcl ~]# dnf install -y gcc glibc glibc-common perl httpd php wget gd gd-devel  
[root@emcl ~]# systemctl start httpd
[root@emcl ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@emcl ~]# systemctl start httpd
3. download, compile and install Nagios Core 
To download and install Nagios Core, follow these general steps. Please note that the version numbers and specific commands may vary based on the latest releases. Always refer to the official Nagios website (https://www.nagios.org/) for the most up-to-date information.

3_1. Download Nagios Core:

# Navigate to a directory where you want to download Nagios Core
cd /software

# Download the Nagios Core source tarball
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-.tar.gz

# Replace with the actual version number available on the Nagios website. for example wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.3.tar.gz
3_2. Compile and Install Nagios Core:
[root@emcl ~]# cd /software/
[root@emcl software]# tar xzf /software/nagioscore-nagios-4.4.3.tar.gz
[root@emcl software]# cd nagioscore-nagios-4.4.3/

# configure the source package and build it.
[root@emcl nagioscore-nagios-4.4.3]# ./configure
Compile and install Nagios
[root@emcl nagioscore-nagios-4.4.3]# make all

# create the Nagios User and Group, and add the Apache user to the Nagios Group 
[root@emcl nagioscore-nagios-4.4.3]# make install-groups-users
groupadd -r nagios
useradd -g nagios nagios
[root@emcl nagioscore-nagios-4.4.3]#  usermod -a -G nagios apache

# Install init scripts and set permissions
[root@emcl nagioscore-nagios-4.4.3]# make install
[root@emcl nagioscore-nagios-4.4.3]# make install-daemoninit
[root@emcl nagioscore-nagios-4.4.3]# make install-commandmode
[root@emcl nagioscore-nagios-4.4.3]# make install-config

# Install the Apache configuration file
[root@emcl nagioscore-nagios-4.4.3]# make install-webconf

4. Secure Nagios Core 
Securing Nagios Core is crucial to ensure that your monitoring system is protected from unauthorized access and potential security threats. Here are some key steps to help secure Nagios Core:
 
4_1. Change the default login credentials for the Nagios web interface. You can do this by modifying the htpasswd.users file.
[root@emcl nagioscore-nagios-4.4.3]#  htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
 
5. Installing Nagio Plugins in OEL8.5 
To install Nagios Plugins on Oracle Enterprise Linux (OEL) 8.5, you can follow these general steps. Please note that the specific package names and commands might vary based on the exact OEL version and package availability. Adjust the commands as needed.

5_1. install the required packages for compiling and building the plugin package.

# dnf install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
5_2. Download and Install Nagios Plugins:

# Navigate to a directory where you want to download Nagios Plugins
[root@emcl nagioscore-nagios-4.4.3]# cd /software/

# Download the Nagios Plugins source tarball
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz

# Extract the tarball
[root@emcl software]#  tar zxf nagios-plugins-release-2.2.1.tar.gz
5_3. Compile and Install Nagios Plugins:
[root@emcl nagios-plugins-release-2.2.1]# cd nagios-plugins-release-2.2.1/
[root@emcl nagios-plugins-release-2.2.1]# ./tools/setup
[root@emcl nagios-plugins-release-2.2.1]# ./configure
[root@emcl nagios-plugins-release-2.2.1]# make
[root@emcl nagios-plugins-release-2.2.1]# make install
5_4. Verify Installation: You can verify that the Nagios Plugins are installed correctly by running a simple check, for example:
/usr/local/nagios/libexec/check_disk -w 20% -c 10%

5_5. Restart Nagios: After making changes to the configuration, restart the Nagios service:

[root@emcl nagios-plugins-release-2.2.1]# systemctl restart httpd.service
[root@emcl nagios-plugins-release-2.2.1]# systemctl start nagios.service
Failed to start nagios.service: Unit nagios.service not found.
If you are encountering the error "Failed to start nagios.service: Unit nagios.service not found," it suggests that the Nagios service unit file is not present in the expected location or the service has not been properly installed or configured. Do the following to resolve this problem.
[root@emcl ~]#  vi /etc/systemd/system/nagios.service
[Unit]
Description=Nagios
BindTo=network.target


[Install]
WantedBy=multi-user.target

[Service]
User=nagios
Group=nagios
Type=simple
ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg

# Check the status of the Nagios service to see if it is running without issues:
[root@emcl ~]# systemctl  start nagios
[root@emcl ~]# systemctl  restart nagios
[root@emcl ~]# systemctl  status nagios


6. Add firewall rules (or disable firewall): To allow access to Nagios through the firewall, you'll need to add a rule to allow traffic on the port that Nagios is using. By default, Nagios uses port 80 for HTTP and port 443 for HTTPS. Here's how you can add a rule to allow traffic on port 80:

# Add a rule to allow traffic on port 80 (HTTP)
firewall-cmd --zone=public --add-port=80/tcp --permanent

# Reload the firewall to apply the changes
 firewall-cmd --reload
Make sure to adjust the port number based on your Nagios configuration. Note: The commands above assume that the "public" zone is appropriate for your network configuration. If you are using a different zone, replace "public" with the appropriate zone name. If you are running Nagios on a different port, adjust the port number accordingly in the commands. After adding the firewall rule, external systems should be able to access Nagios through the specified port. Always consider security best practices and limit access to only the necessary ports. 

 7. Accessing Nagios Web Console:  To access the Nagios web console, you need to use a web browser and navigate to the URL where Nagios is hosted.
http://192.168.56.2/nagios
You should be prompted with the Nagios login screen. Enter the username and password to log in. The default credentials are often: 
Username: nagiosadmin 
Password: The password you set during the installation process. 
If you have changed the login credentials, use the updated username and password.

8. Installing NRPE On the Nagios Monitoring Server: NRPE (Nagios Remote Plugin Executor) is a Nagios agent that allows remote systems to be monitored using scripts and plugins. To install NRPE on the Nagios monitoring server, you'll need to follow these steps:

cd /software
wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.0.2/nrpe-4.0.2.tar.gz

# Unpack the NRPE source code tarball.
[root@emcl software]# cd /software/
[root@emcl software]# tar xzf nrpe-4.0.2.tar.gz
[root@emcl software]# cd nrpe-4.0.2

# Compile and install the NRPE addon.
[root@emcl nrpe-4.0.2]# ./configure
[root@emcl nrpe-4.0.2]# make all

# install the NRPE plugin daemon, and sample config files.
[root@emcl nrpe-4.0.2]# make install-plugin
[root@emcl nrpe-4.0.2]# make install-daemon
[root@emcl nrpe-4.0.2]# make install-config


Monday, December 4, 2023

JBO-25077 OEM has a problem with collecting the information of a host

 When I opened the target host to view the related report, I got this page.










Here is the details of the error in the above image:


property:cpuUtilization on bean:oracle.sysman.si.extension.model.host.XHost@f365a80 of type:oracle.sysman.si.extension.model.host.XHost
JBO-25077: Name cpuUtilization not found in the given object: oracle.sysman.si.extension.model.host.XHost@f365a80.
JBO-25077: Name cpuUtilization not found in the given object: oracle.sysman.si.extension.model.host.XHost@f365a80.
JBO-25077: Name cpuUtilization not found in the given object: oracle.sysman.si.extension.model.host.XHost@f365a80.
JBO-25077: Name cpuUtilization not found in the given object: oracle.sysman.si.extension.model.host.XHost@f365a80.
    

This happens because none of the DBMS_scheduler jobs are running in the EM repository.

Solution:

I did the following steps to perform the partition maintenance and re-submit all mandatory DBMS scheduler jobs related to the EM repository: 

1. Log in as sys user on the EM repository database and check the value of the job_queue_processes parameter in the database : 

[oracle@cloudcontrol7 ~]$ sqlplus / as sysdba

SQL> show parameter job_queue_process

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
job_queue_processes                  integer     50
    

2. Set the job_queue_processes to 0


SQL> alter system set job_queue_processes = 0;
    

3. Connect as sysman, and remove em_dbms_jobs (EMD_MAINTENANCE controls maintenance jobs for Enterprise Manager.)

SQL> connect sysman
Enter password:
Connected.
SQL> exec emd_maintenance.remove_em_dbms_jobs;

PL/SQL procedure successfully completed.

SQL> exec gc_interval_partition_mgr.partition_maintenance;

PL/SQL procedure successfully completed.
4. Execute <OMS_HOME>/sysman/admin/emdrep/sql/core/latest/admin/admin_recompile_invalid.sql script to recompile the invalid objects:

5. Re-submit all mandatory DBMS scheduler jobs related to the EM repository:

SQL>  connect / as sysdba
Connected.
SQL> alter system set job_queue_processes = 1000;

System altered.

SQL> connect sysman
Enter password:
Connected.

SQL> exec emd_maintenance.submit_em_dbms_jobs;

PL/SQL procedure successfully completed.

SQL> commit;

Commit complete.
6. Now, we just need to resync the OEM to collect and update reports

[oracle@cloudcontrol7 ~]$ /home/oracle/app/oracle/middleware/bin/emcli login -username=SYSMAN
Enter password :

Login successful
[oracle@cloudcontrol7 ~]$ /home/oracle/app/oracle/middleware/bin/emcli sync
Synchronized successfully

Tuesday, October 24, 2023

AHF-00026 error when upgrading AHF

When running ahfctl upgrade command, "AHF-00026: Perl is not owned by root" occurs and the AHF upgrade fails. In this article, we will provide effective solutions to resolve the problem.,


This is a bug and here is the solution: First: Since in the ahfctl upgrade command we cannot change the perlhome directory, we must unzip the AHF software zipfile and use ahf setup command.

[root@]# cd /u01/AHF23.6/
[root@]# unzip AHF-LINUX_v23.6.0.zip 

Second: We should copy the path of perl in the above error to the /opt/perl and change the permission of this directory in the /opt/perl path.

[root@]# cp -pR /u01/app/19.3.0.0/grid/perl /opt/perl
[root@]# chown -R root:oinstall /opt/perl

Third: run the ahf_steup command with -perlhome option

[root@]# cd /u01/AHF23.6/
[root@]# ./ahf_setup -perlhome /opt/perl

Fourth: enter Y to upgrade the existing AHF version

 

steps 1 and 2

By running the following command, the AHF upgraded successfully.

Output of steps 3 and 4
steps 3 and 4

Check that the AHF is upgraded successfully.

[root@]# tfactl status
[root@]# ahfctl version


Configure Nagios to monitor Remote Windows Host

To configure Nagios to monitor a remote Windows host, you'll need to set up NSClient++ on the Windows machine.  Install Nagios on the...