Adding a simple host to monitor Up / Down state
Adding a simple host to monitor Up / Down state
Hey all,
My question can NOT get any more easier.
I would like to know how to add a host to monitor nothing more than it's up / down state. Nothing more, nothing less. A straight ping will suffice and it need not be anything that requires the device to have an agent running on it. To be fair, I am a relative newbie to both Ubuntu Linux & Nagios. However, I already have the Nagios core running on a VM and is fully functional. The Nagios version I am running is Nagios® Core™ Version 4.1.1 August 19, 2015.
Any help is tremendously appreciated.
Thanks,
Vincent
My question can NOT get any more easier.
I would like to know how to add a host to monitor nothing more than it's up / down state. Nothing more, nothing less. A straight ping will suffice and it need not be anything that requires the device to have an agent running on it. To be fair, I am a relative newbie to both Ubuntu Linux & Nagios. However, I already have the Nagios core running on a VM and is fully functional. The Nagios version I am running is Nagios® Core™ Version 4.1.1 August 19, 2015.
Any help is tremendously appreciated.
Thanks,
Vincent
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Adding a simple host to monitor Up / Down state
Code: Select all
head /usr/local/nagios/etc/objects/localhost.cfg -n 34 > /usr/local/nagios/etc/objects/hosts.cfg
sed -i "s/localhost/your hostname/g" /usr/local/nagios/etc/objects/hosts.cfg
sed -i "s/127.0.0.1/192.168.0.23 or fqdn/g" /usr/local/nagios/etc/objects/hosts.cfg
echo "cfg_file=/usr/local/nagios/etc/objects/hosts.cfg" >> /usr/local/nagios/etc/nagios.cfg
service nagios restartThen I did a find and replace so it reflects the values you want
Told the nagios.cfg to look at the new file
Restarted Nagios.
You will now have a new Nagios host object that does a simple ping check (which it inherits from the linux-server template).
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Adding a simple host to monitor Up / Down state
Finally - AN END IN SIGHT!Box293 wrote:All I did here was copy the first 34 lines of the localhost.cfg file and put it into a new file called hosts.cfgCode: Select all
head /usr/local/nagios/etc/objects/localhost.cfg -n 34 > /usr/local/nagios/etc/objects/hosts.cfg sed -i "s/localhost/your hostname/g" /usr/local/nagios/etc/objects/hosts.cfg sed -i "s/127.0.0.1/192.168.0.23 or fqdn/g" /usr/local/nagios/etc/objects/hosts.cfg echo "cfg_file=/usr/local/nagios/etc/objects/hosts.cfg" >> /usr/local/nagios/etc/nagios.cfg service nagios restart
Then I did a find and replace so it reflects the values you want
Told the nagios.cfg to look at the new file
Restarted Nagios.
You will now have a new Nagios host object that does a simple ping check (which it inherits from the linux-server template).
At the very least, this added a workstation now, however, when I issue a restart command on a test computer to test the view in nagios, I never see it "down". My GUESS is that the "down time" is too short for nagios to notice it down? Also, do I have to run that script you wrote for EVERY workstation? I actually came across this link but have no idea as to how to implement it.
(https://exchange.nagios.org/directory/A ... ol/details)
Lastly, if you'd like to ssh into my vm box, I have no issues with that at all. This is a non-production, learning box that I am trying to get as my expousre to Linux / nagios as I can. At the end of the day, all i want is a monitoring solution which pings workstations every 10 minutes and observe when it goes down as well as having a nice little log to view the trends. Thats it. If you can help me with this, there is a free steak dinner in New York City for you!
Re: Adding a simple host to monitor Up / Down state
Downtime must be on the order of 7 minutes or longer before Nagios alerts about it. By default, the check is every five minutes, so you'll need to leave it down at least that long for Nagios to even know about it in the first place and change from HARD OK to SOFT CRITICAL (this would then change to HARD CRITICAL after a few, more frequent checks to confirm that it is really down).
If you want to know more about why that is the case, you'll need to learn more about Nagios.
You can test more easily than bringing the box down by using iptables to block ICMP for 5 minutes:
This might be easier than taking the box down.
If you want to know more about why that is the case, you'll need to learn more about Nagios.
You can test more easily than bringing the box down by using iptables to block ICMP for 5 minutes:
Code: Select all
Turn on ICMP (ping) blocking:
iptables -I INPUT -p icmp -m icmp --icmp-type any -j REJECT
Allow ICMP (ping) traffic again:
iptables -D INPUT -p icmp -m icmp --icmp-type any -j REJECT
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Re: Adding a simple host to monitor Up / Down state
Seems simple enough, but I have a feeling that i'm starting to clip in over my head. Meaning, trying to learn as I go with BOTH Ubuntu / Linux AND Nagios. It is - without question - no small feat. I will say this though - considering where I am at now (having Nagios up and accessible via the web) is further than I thought i'd get.eloyd wrote:Downtime must be on the order of 7 minutes or longer before Nagios alerts about it. By default, the check is every five minutes, so you'll need to leave it down at least that long for Nagios to even know about it in the first place and change from HARD OK to SOFT CRITICAL (this would then change to HARD CRITICAL after a few, more frequent checks to confirm that it is really down).
If you want to know more about why that is the case, you'll need to learn more about Nagios.
You can test more easily than bringing the box down by using iptables to block ICMP for 5 minutes:This might be easier than taking the box down.Code: Select all
Turn on ICMP (ping) blocking: iptables -I INPUT -p icmp -m icmp --icmp-type any -j REJECT Allow ICMP (ping) traffic again: iptables -D INPUT -p icmp -m icmp --icmp-type any -j REJECT
I guess the best thing to do at this point is to continue plugging away and thank you all for your help in advance. The only other thing I can do is to provide a visual as to what i'm actually trying to accomplish which is displayed in the pictorial view created in visio.
As you can see, there is nothing more than windows computers connecting on a WAN network. The computers are grouped by districts and every district has an average of about 20 to 30 computers per site location within each district. The hostnames have potentials of changing, but the static IPs on said workstations will NEVER change. So, with that, all I would need to know is when a terminal goes down - via ping only - and when it comes / came back online. There need not be ANY OTHER MONITORING on their and should require no agent. The checks per district should be distributed (i.e. check district 1, then 2, then 3.....all the way to 32 then repeat back to 1)
If someone could walk me through on how to get there, that'd be a GREAT leap forward and really does get a free steak dinner - and a good friend - in New York City!
Thanks,
Vince
Re: Adding a simple host to monitor Up / Down state
Edit the file @Box had you set up (/usr/local/nagios/etc/objects/hosts.cfg) and change "linux-server" to "windows-server" then copy/paste the define host{...} block for each host you need to monitor. Change the IP address of each block you copy and restart nagios. You should be all set.
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Re: Adding a simple host to monitor Up / Down state
I guess it's looking for a windows-server template because i am getting an error message that the template cannot be found....eloyd wrote:Edit the file @Box had you set up (/usr/local/nagios/etc/objects/hosts.cfg) and change "linux-server" to "windows-server" then copy/paste the define host{...} block for each host you need to monitor. Change the IP address of each block you copy and restart nagios. You should be all set.
Re: Adding a simple host to monitor Up / Down state
I must admit I didn't fully follow Box's comments, I just skipped to the end. 
For now, you can replace windows-server with linux-server again and it won't matter. You're just pinging the host. More details can be added later if that's what you want to do.
For now, you can replace windows-server with linux-server again and it won't matter. You're just pinging the host. More details can be added later if that's what you want to do.
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Re: Adding a simple host to monitor Up / Down state
First of all,
There is no need to say sorry. This is THE FURTHEST i've ever gotten on this issue and i've been trying for OVER 2 years.
Secondly - I will do my best to try and piece it together and let you know how it works out.
There is no need to say sorry. This is THE FURTHEST i've ever gotten on this issue and i've been trying for OVER 2 years.
Secondly - I will do my best to try and piece it together and let you know how it works out.
Re: Adding a simple host to monitor Up / Down state
Sounds good - let us know if you need any further assistance!
Former Nagios Employee