How to change the frontend of Nagios with VShell in Ubuntu and Debian
Here in this tutorial we will learn How to install Nagios V Shell to change the frontend.
This is continue of my last post on Installing Nagios in Ubuntu. Kindly read the post.
To install Nagios V Shell follow these steps :
Step 1 : Install php-apc
sudo su - apt-get install php-apc
Step 2 : Download the latest Nagios V Shell
wget http://assets.nagios.com/downloads/exchange/nagiosvshell/vshell.tar.gz
Step 3: Extract the vshell.tar.gz
tar -xvzf vshell.tar.gz
Step 4: Change to extracted directory vshell and edit 2 lines in the install.php file .
In TARGETDIR give the path where you want to install vshell,Here I have written /usr/local/vshell . This /usr/local/vshell directory will be created by install.php script itself
In APACHECONF give the apache configuration path where you want to save the file (vshell.conf ).
In Ubuntu and debian default path is /etc/apache2/conf.d hence it is given as it is.
cd vshell vi install.php define('TARGETDIR',"/usr/local/vshell"); define('APACHECONF',"/etc/apache2/conf.d");
Step 5: Now run the script install.php and it will give the output something similar like this.
root@ip1019621483:~/vshell# ./install.php Copying apache configuration file... Copying vshell configuration file... Creating web directory... Copying files... Cleaning up... Restarting apache... * Restarting web server apache2 ... waiting ...done. Checking for file locations... NOTICE: Objects file found at: /var/cache/nagios3/objects.cache ***Update this location in your /etc/vshell.conf file*** NOTICE: Status file found at: /var/cache/nagios3/status.dat ***Update this location in your /etc/vshell.conf file*** NOTICE: cgi.cfg file found at: /etc/nagios3/cgi.cfg ***Update this location in your /etc/vshell.conf file*** NOTICE: Nagios cmd file found at: /var/lib/nagios3/rw/nagios.cmd ***Update this location in your /etc/vshell.conf file*** Script Complete!
Step 6: If you have noticed in output vhsell is guiding us to change the file path in apache conf file. The file path may be different in your server as per your nagios installation.
I recommend you to carefully read the output or save this output in some notepad in your Desktop.
Step 7 : Take a backup of original vshell.conf file.
cp -p /etc/vshell.conf /etc/vshell.conf.`date +%F`.orig
Step 8: Now we will edit the vshell.conf file as per our nagios settings.
BASEURL = “vshell” (Give the baseurl name means when you open the vshell in web browser it will use this baseurl eg. http://nagios-server/vshell)
COREURL = “nagios3” (This is URL path of Nagios dashboard, in my case I am using http://nagios-server/nagios3/ hence I used the nagios3, if in your case it is different http://nagios-server/nagios/ then use nagios insted of nagios3)
STATUSFILE = “/var/cache/nagios3/status.dat” (Give status.dat file path check as per your system,if you have not find in this path,use find command to search for nagios status.dat file path )
OBJECTSFILE = “/var/cache/nagios3/objects.cache” (Give objects.cache file path check as per your system,if you have not find file in this path,use find command to search for nagios objects.cache file path )
CGICFG = “/etc/nagios3/cgi.cfg” (Give nagios cgi.cfg file path name here)
NAGCMD = “/var/lib/nagios3/rw/nagios.cmd” (Give nagios.cmd file path, check the file does it exist or not, if not then use find command and get the correct path)
NAGLOCK = “/usr/local/nagios/var/nagios.lock” (In this case might be the Directory /usr/local/nagios/var/ does not exist in your system so create a directory by using command mkdir -p /usr/local/nagios/var/
)
BASEURL = "vshell" COREURL = "nagios3" STATUSFILE = "/var/cache/nagios3/status.dat" OBJECTSFILE = "/var/cache/nagios3/objects.cache" CGICFG = "/etc/nagios3/cgi.cfg" NAGCMD = "/var/lib/nagios3/rw/nagios.cmd" NAGLOCK = "/usr/local/nagios/var/nagios.lock" RESULTLIMIT= 100 LANG = "en_GB" TTL = 90
Step 9: If you remember in install.php we gave apache conf file path.
Now we will see how it looks. The vshell.conf file was created by install.php itself.
root@ip-10-196-214-83:~# cat /etc/apache2/conf.d/vshell.conf #modify this file to fit your apache configuration Alias /vshell "/usr/local/vshell"# SSLRequireSSL Options None AllowOverride None Order allow,deny Allow from all # Allow from 127.0.0.1 #use the below lines for Nagios XI # AuthName "Nagios Monitor XI" # AuthType Basic # AuthUserFile /usr/local/nagiosxi/etc/htpasswd.users #Use the below lines for a typical Nagios Core installation AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user root@ip-10-196-214-83:~#
Step 10: See line no. 24 ( AuthUserFile /usr/local/nagios/etc/htpasswd.users)
Either you can change this file path if you want to use your already created htpasswd file. (Your nagios htpasswd file can be used here) OR we will create a new htpasswd file for vshell through which user/passwd authentication for Vshell will take place.
Now creating new htpasswd file for user nagiosadmin (for vshell)
mkdir -p /usr/local/nagios/etc htpasswd -m -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Step 11 : Now restart the apache
/etc/init.d/apache2 restart
Step 12 : Now open the web browser(eg. firefox,chrome) and type the URL of vshell
It must ask the User Name and password.
Give Username nagiosadmin and password which you have set.
Now you will see the vshell dashboard (Do’nt worry your bydefault nagios dashboard is also safe 🙂 i.e http://nagios-server/nagios or http://nagios-server/nagios3 )
NOTE: Why we use user nagiosadmin ? Why we have not use any other name ?
Answer: Because in nagios cgi.cfg file nagiosadmin has privileges.
Hence we use the same username nagiosadmin.
This is for reference.
# grep nagiosadmin /etc/nagios3/cgi.cfg authorized_for_system_information=nagiosadmin authorized_for_configuration_information=nagiosadmin authorized_for_system_commands=nagiosadmin authorized_for_all_services=nagiosadmin authorized_for_all_hosts=nagiosadmin authorized_for_all_service_commands=nagiosadmin authorized_for_all_host_commands=nagiosadmin