Auto Login to Nagios Webpage

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Auto Login to Nagios Webpage

Post 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
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Auto Login to Nagios Webpage

Post 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:password@192.168.1.11/nagios3/"
chromium_log_file = open("/home/pi/log-chromium.txt", "w")
subprocess.Popen(["chromium", "--disable-infobars", "--disable-session-$

open_browser()
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Auto Login to Nagios Webpage

Post 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?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Auto Login to Nagios Webpage

Post 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';
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Auto Login to Nagios Webpage

Post 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
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Auto Login to Nagios Webpage

Post 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";
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Auto Login to Nagios Webpage

Post by nathanplatt »

That worked perfectly thank you Ssax!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Auto Login to Nagios Webpage

Post by tmcdonald »

I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee
Locked