monitor device on internet?
monitor device on internet?
Have what I would think is a unique situation. Curious if nagios can resolve it. Have windows 2012 essentials which has a remote management console that configures itself automatically on the router to be accessible from the net. Sometimes it doesn't work right or if you loose temp internet access it just stops working. Is there anything nagios has while running in my internal network to see if the website is accessible from outside my house?
Thanks.
JR
Thanks.
JR
Re: monitor device on internet?
If I'm understanding your question correctly you want to do something like this:
Naigos ---> Your PC ---> Website
If the communication between your PC and website fails, have your PC alert Nagios?
This could be done with NSClient. Have it run a ping script from your PC, and report back to the Nagios server. I'll dig that link up for you if I'm understanding correctly.
Naigos ---> Your PC ---> Website
If the communication between your PC and website fails, have your PC alert Nagios?
This could be done with NSClient. Have it run a ping script from your PC, and report back to the Nagios server. I'll dig that link up for you if I'm understanding correctly.
Former Nagios Employee.
me.
me.
Re: monitor device on internet?
Kind of but here's the rub.
Nagios sits inside my network.
Server sits inside my network.
So if I go to the website from the Nagios server or another computer on the network it comes up fine.
If I access the server at my home say from Work, a lot of times it won't come up and the Windows 2012 Essentials server has to be restarted in order to properly configure the router to allow access from outside to the management console. Somehow it stops responding from time to time. So almost need a way for an external computer to see if the website is up or not.
So Nagios requests some external system to check a server -> External server tries doing a http://<server>.com request -> Reports back if it times out, and if it does force a reboot of Windows 2012 R2 Essentials server.
Not sure if there are external webpage test sites that could be used to do this and if so curious how to hook it in.
So looking for a way to make sure the website is working on the INTERNET as it usually still does on the INTRANET.
Thanks.
JR
Nagios sits inside my network.
Server sits inside my network.
So if I go to the website from the Nagios server or another computer on the network it comes up fine.
If I access the server at my home say from Work, a lot of times it won't come up and the Windows 2012 Essentials server has to be restarted in order to properly configure the router to allow access from outside to the management console. Somehow it stops responding from time to time. So almost need a way for an external computer to see if the website is up or not.
So Nagios requests some external system to check a server -> External server tries doing a http://<server>.com request -> Reports back if it times out, and if it does force a reboot of Windows 2012 R2 Essentials server.
Not sure if there are external webpage test sites that could be used to do this and if so curious how to hook it in.
So looking for a way to make sure the website is working on the INTERNET as it usually still does on the INTRANET.
Thanks.
JR
Re: monitor device on internet?
Do you have an external server to check with that you can use with your Nagios server?
Alternatively, instead of relying on the the ports to be opened automatically - why not set a static IP for your windows server and then setup forwarding through NAT?
Alternatively, instead of relying on the the ports to be opened automatically - why not set a static IP for your windows server and then setup forwarding through NAT?
Former Nagios Employee
Re: monitor device on internet?
I don't. Am trying to get something like Uptime Robot to work thru a script or something right now.
With you suggestion will look into it however it's the design of Windows 2012 R2 Essentials to directly modify the router continuously to allow it external access. Unfortunately whatever check it's doing doesn't work. Not sure if redirecting thru the router manually would work but can try. In the interum interested conceptually on getting this internal/external monitoring working.
Thanks.
Steve
With you suggestion will look into it however it's the design of Windows 2012 R2 Essentials to directly modify the router continuously to allow it external access. Unfortunately whatever check it's doing doesn't work. Not sure if redirecting thru the router manually would work but can try. In the interum interested conceptually on getting this internal/external monitoring working.
Thanks.
Steve
Re: monitor device on internet?
OK I'm half way there. Tweaked a PHP script that goes to Uptime and using my API key pulls the current status of that computer. They check one computer every 5 minutes for free. I have a basic result but could just have one word if I wanted. Right now the PHP webpage returns:
Remote Offline 0%
Note Remote is the friendly name of the server being monitored that I ented in Uptime's website when setting up the monitoring job. How would I do something in Nagios that would run the PHP file, check if the resulting file contained "Offline" and if so rebooted a Windows system? Perhaps there is a service I can restart but starting with this known fix. Thinking this script should also only be triggered every half hour or so as to eliminate false restart attempts if the computer is still rebooting after the last check. Plus Uptime doesn't check every minute so don't want false reboots.
Thanks for the advice.
JR
here's the script to:
Remote Offline 0%
Note Remote is the friendly name of the server being monitored that I ented in Uptime's website when setting up the monitoring job. How would I do something in Nagios that would run the PHP file, check if the resulting file contained "Offline" and if so rebooted a Windows system? Perhaps there is a service I can restart but starting with this known fix. Thinking this script should also only be triggered every half hour or so as to eliminate false restart attempts if the computer is still rebooting after the last check. Plus Uptime doesn't check every minute so don't want false reboots.
Thanks for the advice.
JR
here's the script to:
Code: Select all
<?php
echo "<table>";
$apiKey = "<API_KEY_HERE>";
$url = "http://api.uptimerobot.com/getMonitors?apiKey=" . $apiKey . "&format=xml";
$xml = file_get_contents($url);
$xml = new SimpleXMLElement ($xml);
foreach($xml->monitor as $monitor) {
echo "<tr>";
echo "<td>";
echo $monitor['friendlyname'];
echo "</td><td>";
if ($monitor['status'] == 2) {
echo "Online";
}
elseif ($monitor['status'] == 9) {
echo "Offline";
}
else {
echo "Not Available";
}
echo "</td><td>";
if ($monitor['alltimeuptimeratio'] > 95) {
echo "<b style=\"color:green;\">" . $monitor['alltimeuptimeratio'] . "%</b></td></tr>";
}
else {
echo "<b style=\"color:red;\">" . $monitor['alltimeuptimeratio'] . "%</b></td></tr>";
}
}
echo "</table>";
?>Re: monitor device on internet?
You should be able to use the check_http command in Nagios, to check that URL for text with the -s "Offline". This will create the trigger that looks for the Offline word.
Next, you'll want to use event handlers with your service check. See https://assets.nagios.com/downloads/nag ... dlers.html - here's an example for your specific check
Setup a command called 'restart-win2012' for example. From there, you'll need to install NSClient++ on the Windows server - this will allow remote execution of scripts.
Create a simple .bat/.ps script that will restart the machine, and include it in your NSClient++\scripts folder on your windows machine. In your NSClient configuration, define the restartwin command to run the scripts\yourscript.bat. See this link for examples on setting up NSClient, http://docs.nsclient.org/howto/external_scripts.html
Next, you'll want to use event handlers with your service check. See https://assets.nagios.com/downloads/nag ... dlers.html - here's an example for your specific check
Code: Select all
In your service definition -
event_handler restart-win2012
define command{
command_name restart-win2012
command_line /usr/local/nagios/libexec/check_nrpe -H lan.ip.of.winserver -c restartwin
}
Create a simple .bat/.ps script that will restart the machine, and include it in your NSClient++\scripts folder on your windows machine. In your NSClient configuration, define the restartwin command to run the scripts\yourscript.bat. See this link for examples on setting up NSClient, http://docs.nsclient.org/howto/external_scripts.html
Former Nagios Employee
Re: monitor device on internet?
Thanks for the guidance. I'll give that a try when I get to the systems since I can't get to them now. If I want to try stopping and restarting a specific service, if I figure that part out, is that doable?
So say it failed the check, restart service named "Remote Desktop Gateway"
Thanks.
JR
So say it failed the check, restart service named "Remote Desktop Gateway"
Thanks.
JR
Re: monitor device on internet?
Take a look at these:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Is this what you're looking to do?
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Is this what you're looking to do?
Former Nagios Employee.
me.
me.
Re: monitor device on internet?
Thanks for the info. Looks like things got slightly easier. Noticed if I internally go directly at the external URL I can NOT get to the site when down. However can with the IP address. So guess if I query the website at it's external HTTPS URL, and it's not responding I can reboot the system. Eliminates using an external party to query the system and get the results back from them. Couldn't find the right service to restart that would bring it back up externally but guess will settle for rebooting for now.
So as it's been years since I setup Nagios and starting again at my home environment, is this the right way to do it?
In the commands.cfg (created one separate from built in http one):
In my Windows.cfg did:
If so I'll start working on the reboot piece to add in.
Also when Nagios runs and says all is good is there anyway to see what the final parameter is it ran?
JR
So as it's been years since I setup Nagios and starting again at my home environment, is this the right way to do it?
In the commands.cfg (created one separate from built in http one):
Code: Select all
# 'check_http' special
define command{
command_name check_https
command_line $USER1$/check_http $ARG1$
}
Code: Select all
define service{
use generic-service
host homeserver
service_description HTTPS
check_command check_https!-H URL.OF.MACHINE -S
}
Also when Nagios runs and says all is good is there anyway to see what the final parameter is it ran?
JR
Last edited by jriker1 on Tue Dec 22, 2015 10:59 am, edited 3 times in total.