Host/Service Script Question
Kevin Keane
subscription at kkeane.com
Wed Apr 29 08:30:55 CEST 2009
Dei Bertine wrote:
> Hi guys,
>
> I was wondering if there's a way to incorporate all hosts into one
> host name instead of creating individual defines?
> I'm trying to add all of our servers into Nagios but there's huge
> amount of them.
> Need faster way to add all of them into one script.
> Here's what I'm trying to avoid:
> define host{
> use generic-host
> host_name sunbl.001.csaa.net
> alias UNIX-SERVER1
> address 172.168.1.35
> }
> define host{
> use generic-host
> host_name sunbl.002.csaa.net
> alias UNIX-SERVER2
> address 172.168.1.36
> }
>
> ....and so on to hundreds of define host....
Create a host template to minimize the information you need for each
host. note: generic-host actually is a template, so this is already
done. If you have additional configuration settings specific to your
situation but shared by all your hosts, it may make sense to derive your
own template from generic-host, and then use that template in each host.
> Here's what I'm trying to "hopefully" accomplish" if possible:
> define host{
> use all-host
> host_name allunixhosts
> alias ALL-UNIX
> address ALLIP
> }
You can't quite do that because there is no way to figure out which IP
goes with which host name.
But you could write a short bash script that automatically generates all
the host definitions.
echo "Start of script-generated config file" >my.cfg.
for i in 001 002
do
echo "define host {" >> my.cfg
echo " use my-hosttemplate" >>my.cfg
echo " host_name host_$i" >>my.cfg
echo " alias host sunbl.$i.csaa.net" >>my.cfg
echo " address sunbl.$i.csaa.net" >> my.cfg
echo "}" >>my.cfg
done
> ..done all hosts...
>
> And also have them in one "all host" services.cfg script.
> define service{
> use all-service
> host_name ALLHOSTSERVICE
> service_description SSH
> check_command check_ssh
> }
You can do that using host groups.
--
Kevin Keane
Owner
The NetTech
Find the Uncommon: Expert Solutions for a Network You Never Have to Think About
Office: 866-642-7116
http://www.4nettech.com
This e-mail and attachments, if any, may contain confidential and/or proprietary information. Please be advised that the unauthorized use or disclosure of the information is strictly prohibited. The information herein is intended only for use by the intended recipient(s) named above. If you have received this transmission in error, please notify the sender immediately and permanently delete the e-mail and any copies, printouts or attachments thereof.
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list