Page 1 of 1

Auto Login to Nagios Webpage

Posted: Thu May 14, 2015 8:23 am
by nathanplatt
Hi Guys,

I'm trying to setup Nagios to auto load in a raspberry PI so I can have it mounted on a screen. I've managed to get the system to load directly in Chromium but it asks for the username and password, here's how I've done it so far. Can you help me by passing the password through?

GNU nano 2.2.6 File: /etc/xdg/lxsession/LXDE-pi/autostart

@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash

@xset s noblank
@xset s off
@xset -dpms

@python /home/pi/launch_nagios.py

GNU nano 2.2.6 File: /home/pi/launch_nagios.py

# Python script to launch nagios on Raspberry Pi.

import subprocess

def open_browser():
# Start chromium and redirect output.
url = "http://192.168.1.11/nagios3/"
chromium_log_file = open("/home/pi/log-chromium.txt", "w")
subprocess.Popen(["chromium", "--disable-infobars", "--disable-session-$

open_browser()

Thank you

Re: Auto Login to Nagios Webpage

Posted: Thu May 14, 2015 12:24 pm
by jdalrymple
Does passing the un/pw in the URL work and if so is it a viable option?

Code: Select all

import subprocess

def open_browser():
# Start chromium and redirect output.
url = "http://username:[email protected]/nagios3/"
chromium_log_file = open("/home/pi/log-chromium.txt", "w")
subprocess.Popen(["chromium", "--disable-infobars", "--disable-session-$

open_browser()

Re: Auto Login to Nagios Webpage

Posted: Tue May 19, 2015 10:37 am
by nathanplatt
That worked great it logged in without asking for the password, do you know if there's a way to have the map page set as the default page?

Re: Auto Login to Nagios Webpage

Posted: Tue May 19, 2015 11:12 am
by ssax
To change the default homepage, you can edit /usr/local/nagios/share/index.php

Change:

Code: Select all

$url = 'main.php';
To:

Code: Select all

$url = 'map.html?host=all';

Re: Auto Login to Nagios Webpage

Posted: Wed May 20, 2015 2:57 am
by nathanplatt
Hi ssax,

I tried that and although the local of my files was different it didn't work quiet as expected, it loaded the left side but in the main window its just showing as Not Found. The default locations for my files are in /usr/share/nagios3/htdocs

In there I have the following files;

config.inc.php
includes
main.php
rss-corefeed.php
ssi
contexthelp
index.php
media
rss-newsfeed.php
images
js
robots.txt
side.php

I reviewed the main.php file and found the place to make the edit, but I considered the link I was looking for must have been in the side.php file, this is what i found.

<li><a href="<?php echo $cfg["cgi_base_url"];?>/statusmap.cgi?host=all" target="<?php echo $link_target;?>">Map</a></li>

So at a guess i tried to put statusmap.cgi?host=all in as the default page, but i had the same problem as before? Any ideas?

Nathan

Re: Auto Login to Nagios Webpage

Posted: Wed May 20, 2015 12:01 pm
by ssax
Sorry about that, I assumed you were running Core 4. :oops:

Modify your /usr/share/nagios3/htdocs/index.php and change:

Code: Select all

$corewindow="main.php";
To:

Code: Select all

$corewindow="cgi-bin/statusmap.cgi?host=all";

Re: Auto Login to Nagios Webpage

Posted: Thu May 21, 2015 3:25 am
by nathanplatt
That worked perfectly thank you Ssax!

Re: Auto Login to Nagios Webpage

Posted: Thu May 21, 2015 9:17 am
by tmcdonald
I'll be closing this thread now, but feel free to open another if you need anything in the future!