Xymon Mailing List Archive search

Patch for including directories in hosts.cfg

3 messages in this thread

list Paul Root · Tue, 29 Mar 2016 16:16:20 +0000 ·
Hi,
                I just reorganized my xymon hosts.cfg to use directories to better organize my machines.  I completely forgot devmon -readbbhosts.

                So I made a quick change to dm_config.pm to pick up *.cfg files in directories.

*** dm_config.pm        Tue Mar 29 10:35:58 2016
--- /usr/local/devmon/modules/dm_config.pm      Fri Jan 23 09:41:27 2009
***************
*** 1267,1274 ****
            next FILEREAD;
        }

- #       print "working on $bbfile\n";
• # Now interate through our file and suck out the juicy bits
        FILELINE: while ( my $line= <BBFILE> ) {
          chomp $line;
--- 1267,1272 ----
***************
*** 1287,1311 ****
            push @bbfiles, $file;
          }

-          # Check for directory includes
-               if($line =~ /^\s*(?:disp|net)?directory\s+(.+)$/i) {
-                       my $directory = $1;
-                  # Tack on our etc dir if this isn't an absolute path
-                       $directory = "$etcdir/$directory" if $directory !~ /^\//;
-      #                 print "reading $directory\n";
• -                  # Add the file to our read array
-               opendir (DIR, $directory) || warn "Cannot open $directory\n";
-                       my $file;
-                       while ($file = readdir (DIR)) {
-                          # I name all config files with a .cfg
-                               if (grep (/\.cfg/, $file)) {
-                                       push @bbfiles, $directory . '/' . $file;
-                               }
-                       }
-                       close (DIR);
-               }
• # Else see if this line matches the ip/host bb-hosts format
          elsif($line =~ /^\s*(\d+\.\d+\.\d+\.\d+)\s+(\S+)(.*)$/i) {
            my ($ip, $host, $bbopts) = ($1, $2, $3);
--- 1285,1290 ----


Devmon version 0.3.1-beta1.

Paul Root
Lead Engineer
CenturyLink Network Reliability Operations Center

390 Commerce Dr
Woodbury, MN 55125
Direct: (651)312-5207
user-76fdb6883669@xymon.invalid

This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
list Francois Claire · Wed, 30 Mar 2016 19:37:24 +0200 ·
Hi Paul,


Nice !  I always work around this limitation of devmon by putting all my snmp devices altogether in a single config file under /etc/xymon/hosts.d/

Maybe you could submit this patch to the devmon-devel mailing list ? Devmon project has been quite active over the last weeks, maybe we'll get a new -beta- version one day...


Cheers,
Francois.
quoted from Paul Root


Le 29/03/2016 18:16, Root, Paul T a écrit :
Hi,

                I just reorganized my xymon hosts.cfg to use directories to better organize my machines.  I completely forgot devmon –readbbhosts.

                So I made a quick change to dm_config.pm to pick up *.cfg files in directories.

*** dm_config.pm        Tue Mar 29 10:35:58 2016

--- /usr/local/devmon/modules/dm_config.pm      Fri Jan 23 09:41:27 2009

***************

*** 1267,1274 ****

            next FILEREAD;

        }

- #       print "working on $bbfile\n";

• # Now interate through our file and suck out the juicy bits

        FILELINE: while ( my $line= <BBFILE> ) {

          chomp $line;

--- 1267,1272 ----

***************

*** 1287,1311 ****

            push @bbfiles, $file;

          }

-          # Check for directory includes

-               if($line =~ /^\s*(?:disp|net)?directory\s+(.+)$/i) {

-                       my $directory = $1;

-                  # Tack on our etc dir if this isn’t an absolute path

-                       $directory = "$etcdir/$directory" if $directory !~ /^\//;

-      #                 print "reading $directory\n";

• -                  # Add the file to our read array

-               opendir (DIR, $directory) || warn "Cannot open $directory\n";

-                       my $file;

-                       while ($file = readdir (DIR)) {

-                          # I name all config files with a .cfg

-                               if (grep (/\.cfg/, $file)) {

- push @bbfiles, $directory . '/' . $file;

-                               }

-                       }

-                       close (DIR);

-               }

• # Else see if this line matches the ip/host bb-hosts format

          elsif($line =~ /^\s*(\d+\.\d+\.\d+\.\d+)\s+(\S+)(.*)$/i) {

            my ($ip, $host, $bbopts) = ($1, $2, $3);

--- 1285,1290 ----

Devmon version 0.3.1-beta1.

*Paul Root*

Lead Engineer

CenturyLink Network Reliability Operations Center

390 Commerce Dr

Woodbury, MN 55125

Direct: (651)312-5207

user-76fdb6883669@xymon.invalid

This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.

list David Baldwin · Thu, 31 Mar 2016 12:10:20 +1100 ·
My workaround to this is to edit devmon.cfg

BBHOSTS=/home/xymon/server/bin/bbhostshow|

It works because perl is just doing 'open BBFILE, $bbfile' which will
work just as well on stdout of a pipe as a file name :)

David.
quoted from Francois Claire
Hi Paul,


Nice !  I always work around this limitation of devmon by putting all
my snmp devices altogether in a single config file under
/etc/xymon/hosts.d/

Maybe you could submit this patch to the devmon-devel mailing list ?
Devmon project has been quite active over the last weeks, maybe we'll
get a new -beta- version one day...


Cheers,
Francois.


Le 29/03/2016 18:16, Root, Paul T a écrit :
Hi,

                I just reorganized my xymon hosts.cfg to use
directories to better organize my machines.  I completely forgot
devmon –readbbhosts.

 
                So I made a quick change to dm_config.pm to pick up
*.cfg files in directories.  

 
*** dm_config.pm        Tue Mar 29 10:35:58 2016

--- /usr/local/devmon/modules/dm_config.pm      Fri Jan 23 09:41:27 2009

***************

*** 1267,1274 ****

            next FILEREAD;

        }

 
- #       print "working on $bbfile\n";

• # Now interate through our file and suck out the juicy bits

        FILELINE: while ( my $line= <BBFILE> ) {

          chomp $line;

--- 1267,1272 ----

***************

*** 1287,1311 ****

            push @bbfiles, $file;

          }

 
-          # Check for directory includes

-               if($line =~ /^\s*(?:disp|net)?directory\s+(.+)$/i) {

-                       my $directory = $1;

-                  # Tack on our etc dir if this isn’t an absolute path

-                       $directory = "$etcdir/$directory" if
$directory !~ /^\//;

-      #                 print "reading $directory\n";

• -                  # Add the file to our read array

-               opendir (DIR, $directory) || warn "Cannot open
$directory\n";

-                       my $file;

-                       while ($file = readdir (DIR)) {

-                          # I name all config files with a .cfg

-                               if (grep (/\.cfg/, $file)) {

-                                       push @bbfiles, $directory .
'/' . $file;

-                               }

-                       }

-                       close (DIR);

-               }

• # Else see if this line matches the ip/host bb-hosts format

          elsif($line =~ /^\s*(\d+\.\d+\.\d+\.\d+)\s+(\S+)(.*)$/i) {

            my ($ip, $host, $bbopts) = ($1, $2, $3);

--- 1285,1290 ----

 
Devmon version 0.3.1-beta1.

 
*Paul Root*

Lead Engineer

CenturyLink Network Reliability Operations Center

 
390 Commerce Dr

Woodbury, MN 55125

Direct: (651)312-5207

user-76fdb6883669@xymon.invalid

 
This communication is the property of CenturyLink and may contain
confidential or privileged information. Unauthorized use of this
communication is strictly prohibited and may be unlawful. If you have
received this communication in error, please immediately notify the
sender by reply e-mail and destroy all copies of the communication
and any attachments.

-- 

David Baldwin - Senior Systems Administrator (Datacentres + Networks)
Digital Information Management and Technology
Australian Sports Commission          http://ausport.gov.au
Tel 02 62147830 Fax 02 62141830       PO Box 176 Belconnen ACT 2616
user-cbbf693f2c89@xymon.invalid          1 Leverrier Street Bruce ACT 2617
Our Values: RESPECT + INTEGRITY + TEAMWORK + EXCELLENCE


Keep up to date with what's happening in Australian sport visit http://www.ausport.gov.au

This message is intended for the addressee named and may contain confidential and privileged information. If you are not the intended recipient please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you receive this message in error, please delete it and notify the sender.