Lab 14
Lab 14: Configuring Nagios on Linux Server and Adding Linux Client¶
1. Prerequisites¶
-
Install VirtualBox (latest version).
-
Download:
- Ubuntu Server ISO (22.04 LTS recommended).
- Debian/Ubuntu Minimal ISO for client.
2. Create Nagios Server VM¶
- Open VirtualBox → New → Name: NagiosServer.
-
Choose:
- Type:
Linux - Version:
Ubuntu (64-bit) - Memory:
2048 MB - Disk:
20 GB (VDI, Dynamically allocated)
- Type:
-
Attach the Ubuntu ISO to the VM and start installation.
-
During install:
- Set hostname:
nagios-server - Username:
student/ Password:student123 - Install OpenSSH server (select during setup).
- Set hostname:
3. Install Nagios Core on Server¶
sudo apt update
sudo apt install -y nagios4 nagios-plugins nagios-nrpe-plugin apache2
-
Access web UI:
- Open browser →
http://<server-ip>/nagios4 - Default user:
nagiosadmin(create password withhtpasswd).
- Open browser →
4. Create Linux Client VM¶
- In VirtualBox → New → Name: LinuxClient.
- Install minimal Ubuntu/Debian with hostname
linux-client. - Ensure network is Bridged Adapter so both VMs are in same LAN.
5. Install NRPE on Client¶
sudo apt update
sudo apt install -y nagios-nrpe-server nagios-plugins
- Edit config:
sudo nano /etc/nagios/nrpe.cfg
- Add server IP under:
allowed_hosts=<nagios-server-ip>
- Restart service:
sudo systemctl restart nagios-nrpe-server
6. Add Client to Nagios Server¶
On Nagios server:
sudo nano /etc/nagios4/conf.d/linuxclient.cfg
Example config:
define host {
use linux-server
host_name linux-client
address <client-ip>
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
- Restart Nagios:
sudo systemctl restart nagios4
✅ Check web UI → you should see linux-client as monitored host.
1. Setup EC2 Nagios Server¶
- Login to AWS Console → EC2 → Launch Instance.
- Name:
NagiosServer. - AMI: Ubuntu Server 22.04 LTS (Free Tier).
- Instance type:
t2.micro. - Configure Security Group: Allow inbound SSH (22), HTTP (80).
- Download key pair →
nagios-key.pem. - Launch instance → Connect via SSH:
chmod 400 nagios-key.pem
ssh -i nagios-key.pem ubuntu@<public-ip>
2. Install Nagios Core¶
(Same commands as VirtualBox).
3. Setup EC2 Linux Client¶
- Launch another EC2 instance: Name
LinuxClient. - Same AMI and type (
t2.micro). - Security group: Allow SSH, and allow Nagios server IP on port 5666 (NRPE).
- Install NRPE (same as VirtualBox client).
4. Add Client to Server¶
(Same Nagios config steps).
✅ Verify in web UI → client status visible.