OMS Linux Agent - Install Apache, MySql, and Nagios
Managing Linux servers and Docker containers just got a whole lot easier with the new Operations Management Suite (OMS) agent for Linux. OMS is Microsoft’s simplified IT management solution that combines powerful log analytics, automation, backup, and site recovery solutions across your heterogeneous datacenter and public cloud environments.
The OMS agent for Linux enables rich and real-time analytics for operational data (syslog, performance, alerts, inventory) from Linux servers, Docker containers, and monitoring tools like Nagios, Zabbix, and System Center Operations Manager. Onboarding a Linux server takes less than five minutes and can be done with our free tier OMS plans. Here are the many supported Linux operating systems:
If you are interested to test the new OMS agent in a lab and try some of its capabilities for the LAMP stack and its integration with Nagios, then you can follow the following steps to install the LAMP stack and Nagios on an Ubuntu server.
Installing the LAMP stack
Installing Apache and PHP
sudo apt-get install python-software-properties
sudo apt-get install wget apache2 apache2-utils php5 libapache2-mod-php5 build-essential libgd2-xpm-dev
Installing MySQL and adding PHP package
sudo apt-get install mysql-server php5-mysql
During the installation you will be prompt to set the secure password for MYSQL, however you can also execute the following command (after installing MySQL) for initial settings of MySQL server. This command will ask you to set root password and apply for many security changes.
sudo mysql_secure_installation
After installing all services on your system, start all required services.
sudo /etc/init.d/apache2 restart
sudo /etc/init.d/mysql restart
Now create a new nagios user account and setup a password to this account
sudo useradd nagios sudo passwd nagios
Now create a group for nagios setup “g.nagios” and add nagios user to this group. Also add nagios user in apache group.
sudo groupadd g.nagios
sudo usermod -a -G g.nagios nagios
sudo usermod -a -G g.nagios www-data
After installing required dependencies and adding user accounts. Let’s start with Nagios core installation. Download latest nagios core service from official site (you should download the latest version).
cd /opt/ sudo wget https://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz
sudo tar xzf nagios-4.0.8.tar.gzcd nagios-4.0.8
sudo ./configure –with-command-group=g.nagios
sudo make allsudo make installsudo make install-init
sudo make install-config
sudo make install-commandmode
Now create nagios apache2 configuration file.
sudo vim /etc/apache2/sites-enabled/nagios.conf
ScriptAlias /nagios/cgi-bin “/usr/local/nagios/sbin”
<Directory “/usr/local/nagios/sbin”>
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName “Restricted Area”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Alias /nagios “/usr/local/nagios/share”
<Directory “/usr/local/nagios/share”>
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName “Restricted Area”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Configuring Apache Authentication
We need to setup apache authentication for user nagiosadmin. Untill more specific reason use this user name as “nagiosadmin” else you would required more changes in configuration.
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now restart Apache service to make the new settings take effect.
sudo service apache2 restart
Installing Nagios Plugins
After installing and configuring Nagios core service, Download latest nagios-plugins source and install using following commands.
cd /opt
sudo wget https://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
sudo tar xzf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
Now compile and install nagios plugins
sudo ./configure –with-nagios-user=nagios –with-nagios-group=nagios
sudo make
sudo make install
Access Nagios Web Interface
You will notice that there is a red X icon stating that Nagios is not running, and clicking on a CGI link will download the appropriate file – not the intended result.
The fix is simple – enable CGI!
sudo a2enmod cgi
sudo service apache2 restart
sudo service nagios restart
Now you have successfully installed and configured Nagios Monitoring Server core service in your system.
Enabling Apache HTTP Server Performance Counters
If Apache HTTP Server is detected on the computer when the omsagent bundle is installed, a performance monitoring provider for Apache HTTP Server will be automatically installed. This provider relies on an Apache “module” that must be loaded into the Apache HTTP Server in order to access performance data. The module can be loaded with the following command:
sudo /opt/microsoft/apache-cimprov/bin/apache_config.sh -c
If you installed the Agent before installing Apache, then you need to install the provider:
Extract the Agent Package
sudo sh omsagent-1.0.0-47.universal.x64.sh –extract
install the Apache Provider
sudo sh ./apache-cimprov-1.0.0-675.universal.1.x86_64.sh –install
you can also install the MySQL Provider
sudo sh ./mysql-cimprov-1.0.0-438.universal.1.x86_64.sh –install