[Israel.pm] Hash cleanup

sawyer x xsawyerx at gmail.com
Mon Mar 30 00:49:06 PDT 2009


I'm having the same technical issue with Nagios. What I do is keep a
scalar as a template, and run loops that determine each time each host
and then create the host entry using the template, and put it in
another scalar. That way I keep adding hosts to it within these loops
till I got a scalar complete with everything. Then I write that scalar
in a definitions file.

If your current situation is using a hash for all of them and
considering it's legacy code (global! oh my god, the horror! :) ),
then it probably won't be easy at all for you to convert it to loops.

But, I'm going to rewrite it in the near future and do it with Moose
objects and subtypes and Template Toolkit. That way each host and
service is an object, and the subtypes make sure that I'm feeding (or
reading from a conf) the correct type of the field. The Template
Toolkit will help me define and create templates more easily.

The best way to keep the information would obviously be a MySQL DB but
sometimes it's too much overhead. When you deal with multiple servers,
or have a lot of changes.. you'll need to either write (and maintain)
a web interface or program to help maintain the database to help
maintain Nagios to help maintain servers. It's a lot of hassle. I use
YAML (or JSON) configuration files. Easier to ship, easier to edit.

More information about the Perl mailing list