In this guide, we will setup nagios monitoring server on Ubuntu. When monitoring comes in picture it plays vital role in maintaining infrastructure as well as application availability with 0% downtime. To provide better experience to end users with high availability monitoring plays very crucial role. We are here to guide you how to install nagios server on Ubuntu with few clicks.
Nagios is a monitoring tool which is widely use for monitoring items of server like CPU, Memory and Hard disk to maintain the health of servers. It is also use for monitoring application components. Using nagios we can monitor our servers as well as application and recovers it quickly if something went wrong like application went down or server slowness issue due to high usage of CPU , Memory or Hard disk. To maintain health of servers and high availability of application nagios is best monitoring tool.
We required given prerequisites to proceed further:
- AWS Account Access
- Need EC2 and Cloud Formation service access to setup nagios.
Step 1 – Login to AWS Account
To go further first login to AWS account and check you have access to EC2 and Cloud Formation service.
Step 2 – Create Cloud Formation Template
First of all Create Cloud Formation Template Using any of the editor with .yml format. Copy below CFT file and paste it to any editor and save as .yml extension on your local machine.
--- AWSTemplateFormatVersion: '2010-09-09' Description: Nagios Server Creation Parameters: LinuxAMI-ID: Type: String Subnet-ID: Type: AWS::EC2::Subnet::Id Security-Group: Type: AWS::EC2::SecurityGroup::Id Key-Name: Type: String Resources: NagiosInstance: Type: AWS::EC2::Instance Properties: ImageId: !Ref LinuxAMI-ID InstanceType: t2.small KeyName: !Ref Key-Name Tags: - Key: Name Value: !Sub NAGIOS-Server BlockDeviceMappings: - DeviceName: /dev/sda1 Ebs: VolumeType: gp2 VolumeSize: '30' DeleteOnTermination: 'true' NetworkInterfaces: - AssociatePublicIpAddress: "true" DeviceIndex: "0" GroupSet: - !Ref SecurityGroup SubnetId: !Ref SubnetID UserData: Fn::Base64: !Sub | #!/bin/bash sudo apt update -y sudo apt install -y autoconf bc gawk dc build-essential gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-dev libmcrypt-dev make libssl-dev snmp libnet-snmp-perl gettext cd ~/ wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz tar -xf nagios-4.4.6.tar.gz cd nagioscore-*/ sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled sudo make all sudo make install-groups-users sudo usermod -a -G nagios www-data sudo make install sudo make install-daemoninit sudo make install-commandmode sudo make install-config sudo make install-webconf sudo a2enmod rewrite cgi systemctl restart apache2 htpasswd -c -B -b /usr/local/nagios/etc/htpasswd.users nagiosadmin admin123 ufw allow Apache ufw allow ssh ufw enable sudo apt install monitoring-plugins nagios-nrpe-plugin -y cd /usr/local/nagios/etc mkdir -p /usr/local/nagios/etc/servers echo "cfg_dir=/usr/local/nagios/etc/servers" >> /usr/local/nagios/etc/nagios.cfg cd /usr/local/nagios/share/ wget github.com/ynlamy/vautour-style/releases/latest/download/vautour_style.zip echo "A" | unzip vautour_style.zip cd systemctl start nagios systemctl enable nagios Outputs: PublicIp: Description: Nagios Server Public IP Value: !GetAtt NagiosInstance.PublicIp Export: Name: Nagios-PublicIp InstanceID: Description: The Instance ID Value: !Ref NagiosInstance Export: Name: Nagios-InstanceID
Nagios monitoring server has been successfully setup using AWS cloud formation template. You are ready to use nagios server for monitoring critical issue and recovers it quickly if something went wrong.