host object declarations

Andreas Ericsson ae at op5.se
Tue Oct 2 23:14:18 CEST 2012


On 10/02/2012 05:20 PM, Marki wrote:
> 
>> The only thing I'm saying in that bugreport is
>> that Nagios does not and will not complain when the "address" fields of
>> hosts are unique.
> 
> In fact you also said:
> 
>> that suggests that either your namestandard (used for the host_name field)
>> sucks, or that you or your co-workers are simply confused when it comes
>> to configuring Nagios.
> 
> So let's talk best practices.
> 
> In practice it did occur that when someone copy/pasted a bunch of service
> definitions (yeah I know you should use templates, call that confusion if
> you like) just forgot to update the address field and the newly created checks
> (or so they believed) did nothing more than check the old stuff once more.
> 

So use the "require unique address" scriptlet I provided in the ticket.
Nagios won't protect you against such config buglets, because for many
users its a very useful trick to do.

> According to what you suggest, it is wisest to indeed use DNS names where you
> can in the host_name field. (and only use the address field in special
> circumstances) (in Nagios4)
> 

Or just not fsck up when adding hosts, perhaps?

> If you define your nomenclature like that, possible confusion may be
> eliminated ;-)
> 

Could be.

> BTW I have all sorts things in place that
> - check for duplicate addresses

So this should've been caught then.

> - check for syntax errors all over the place

Which Nagios already does for you, so that seems moot.

> - check if the plugin specified in command_line actually exists thus preventing
> stupid error 127 or alike

You don't get that anymore. With Nagios 4 you get
  (No output on stdout) stderr: execvp() failed. errno is 2: No such file or directory

> 
> PS. As a sidenote: I once created a more or less functional version of a script
> allowing to change service names. It's not trivial but can be done.
> Does anyone know of something existing and working that allows to change
> service and also hostnames?
> 

Well, python, perl, ruby, php, sed, awk, whathaveyou can do that with
little or no hassle, so long as you know how to parse compound blocks
into key/value vectors (which is trivial).
Unless you're talking about modifying it runtime, in which case it's
a little trickier and requires an eventbroker module.

> 
> for f in $(grep command_line $NAGIOS/etc/checkcommands.cfg | awk '{print $2}' |\
> grep USER1 | sed 's/\$USER1\$\///'); do
>      if [ ! -f $NAGIOS/libexec/$f ]; then
>          echo "[KO] $f does not exist"
>          ERR=$(($ERR + 1))
>      fi
> done
> [ "$ERR" -eq 0 ] && echo "[OK] all commands seem to exist"
> 

This seems pretty error-prone. I've been thinking of adding something
similar to the Nagios binary, to make sure all (used) commands have
existing binaries and warn if some of them don't. It would be quite
trivial, but I haven't gotten around to it yet as not that many people
suffer from it for very long. Besides, with the special-purpose workers
on the way it's quite likely we'll just trigger false positives by the
dozen.

> # make sure to always update both statements!
> if [ "$(grep -r address $NAGIOS/etc/hosts* | grep -v '~' | grep -v svn |\
> grep -v '.bak' | cut -d: -f2 | tr -d ' \t' | awk -F'address' '{print $2}' |\
> sort | uniq -c | sort -n | grep -v ' 1 ' | wc -l)" -ne 0 ]; then
>      echo "[INFO] IP address defined more than once:"
>      grep -r address $NAGIOS/etc/hosts* | grep -v '~' | grep -v svn |\
>      grep -v '.bak' | cut -d: -f2 | tr -d ' \t' |\
>      awk -F'address' '{print $2}' | sort | uniq -c | sort -n | grep -v ' 1 '
> else
>      echo "[OK] Dup IP check ok"
> fi
> 

That's just insanely tricky. precache the objects and you can use
   grep address $precache | sort -k 2 | uniq -c | sort -n | grep -v ' 1 '
instead to list all the duplicate addresses.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
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