Page 1 of 1

No NRPE Output from XI GUI

Posted: Sat Sep 01, 2018 10:01 am
by IT-OPS-SYS
Good morning,

I built a quick and dirty python script that utilizes Selenium to test authentication to a login page and return if the attempt was successful or not. I'm tested the script locally on the selenium server via the command line and remotely from the XI server via the command line. Upon getting ready to deploy and run one last check from the GUI, I discovered that the run test command returns a blank output with no errors. I search online but could not find what the cause may be. I have attached the python script with some information redacted, I'm not sure if maybe there is a formatting error somewhere. I am using NagiosXI 5.5.2.

Code: Select all

#!/usr/bin/python
import sys, os
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException

URL="http://webserver.test.com:2020/home/index.html"
options = Options()
options.set_headless(headless=True)

driver = webdriver.Firefox(firefox_options=options)
driver.implicitly_wait(30)
driver.verificationErrors = []
driver.accept_next_alert = True

try:
            driver.get(URL)
except:
            s = "Warning - Site Unavailable"
            print (s)
            driver.quit()
            sys.exit(1) #exit warning
try:
            driver.find_element_by_id("UserID").click()
            driver.find_element_by_id("UserID").clear()
            driver.find_element_by_id("UserID").send_keys("web.admin")
            driver.find_element_by_id("UserPassword").click()
            driver.find_element_by_id("UserPassword").clear()
            driver.find_element_by_id("UserPassword").send_keys("ITGeek!")
            driver.find_element_by_id("btnLogin").click()
            driver.find_element_by_id("btnLogout_Outer").click()
            s = "OK - Authentication Successful"
            print(s)
except:
            s = "Critical - Authentication Failed"
            print (s)
            driver.quit()
            sys.exit(2)

driver.quit()
sys.exit(0)

Re: No NRPE Output from XI GUI

Posted: Tue Sep 04, 2018 10:51 am
by scottwilkerson
If this line fails it would not print anything and exit silently

Code: Select all

driver.get(URL)
While I have not tested this, this may be more appropriate

Code: Select all

#!/usr/bin/python
import sys, os
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException

URL="http://webserver.test.com:2020/home/index.html"
options = Options()
options.set_headless(headless=True)

driver = webdriver.Firefox(firefox_options=options)
driver.implicitly_wait(30)
driver.verificationErrors = []
driver.accept_next_alert = True

try:
            driver.get(URL)
except:
            s = "Warning - Site Unavailable"
            print (s)
            driver.quit()
            sys.exit(1) #exit warning
try:
            driver.find_element_by_id("UserID").click()
            driver.find_element_by_id("UserID").clear()
            driver.find_element_by_id("UserID").send_keys("web.admin")
            driver.find_element_by_id("UserPassword").click()
            driver.find_element_by_id("UserPassword").clear()
            driver.find_element_by_id("UserPassword").send_keys("ITGeek!")
            driver.find_element_by_id("btnLogin").click()
            driver.find_element_by_id("btnLogout_Outer").click()
            s = "OK - Authentication Successful"
            print(s)
            driver.quit()
            sys.exit(0) #exit ok
except:
            s = "Critical - Authentication Failed"
            print (s)
            driver.quit()
            sys.exit(2)

s = "Unknown - Could not get URL"
print (s)
driver.quit()
sys.exit(3) #exit unknown