OSSP CVS Repository

ossp - Check-in [3531]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3531
Date: 2003-Sep-02 14:12:55 (local)
2003-Sep-02 12:12:55 (UTC)
User:rse
Branch:
Comment: no more wrapper script needed, because snmpdx now can read from a config file
Tickets:
Inspections:
Files:
ossp-pkg/snmpdx/00TODO      added-> 1.2
ossp-pkg/snmpdx/snmpdx      1.1 -> 1.2     34 inserted, 6 deleted
ossp-pkg/snmpdx/snmpdx.cfg      added-> 1.1
ossp-pkg/snmpdx/snmpdx.sh      1.2->removed

ossp-pkg/snmpdx/00TODO -> 1.2

*** /dev/null    Sat Nov 23 02:12:20 2024
--- -    Sat Nov 23 02:12:22 2024
***************
*** 0 ****
--- 1,11 ----
+ 
+ - implement more probes [thl]
+ 
+ - support MIB SEQUENCEs [rse]
+ 
+ - split out MIB parts of each probe into own sub-MIBs
+ 
+ - Makefile and snmpdx.sh still contains some hard-coded things
+ 
+ - provide top-level MIB prefix name as variable
+ 


ossp-pkg/snmpdx/snmpdx 1.1 -> 1.2

--- snmpdx       2003/09/01 15:22:41     1.1
+++ snmpdx       2003/09/02 12:12:55     1.2
@@ -30,6 +30,7 @@
 require 5;
 use strict;
 use warnings;
+use FindBin;
 use Getopt::Long;
 use IO;
 
@@ -464,23 +465,27 @@
 
 package main;
 
+#   find path to ourself
+my $myroot    = "$FindBin::Bin";
+
 #   parameters (defaults)
+my $config    = "$myroot/snmpdx.cfg";
 my $version   = 0;
 my $help      = 0;
 my $tmpdir    = ($ENV{TMPDIR} || $ENV{TEMPDIR} || "/tmp");
 my $get       = 0;
 my $next      = 0;
 my $bindir    = "/cw/bin";
-my $probedir  = "./snmpdx.d";
+my $probedir  = "$myroot/snmpdx.d";
 my $probename = "*";
-my $mibdir    = "./snmpdx.mib";
+my $mibdir    = "$myroot/snmpdx.mib";
 my $mibname   = "snmpdx";
-my $logfile   = "./snmpdx.log";
+my $logfile   = "$myroot/snmpdx.log";
 my $loglevel  = 9;
 
 #   command line parsing
-Getopt::Long::Configure("bundling");
-my $result = GetOptions(
+my %options = (
+    'c|config=s'    => \$config,
     'V|version'     => \$version,
     'h|help'        => \$help,
     't|tmpdir=s'    => \$tmpdir,
@@ -493,10 +498,13 @@
     'm|mibname=s'   => \$mibname,
     'l|logfile=s'   => \$logfile,
     'L|loglevel=i'  => \$loglevel,
-) || die "option parsing failed";
+);
+Getopt::Long::Configure("bundling");
+my $result = GetOptions(%options) || die "option parsing failed";
 if ($help) {
     print "Usage: $progname [options] [SPECFILE ...]\n" .
           "Available options:\n" .
+          " -c,--config=PATH    read command line options from configuration fil\n" .
           " -V,--version        print program version\n" .
           " -h,--help           print out this usage page\n" .
           " -t,--tmpdir=PATH    filesystem path to temporary directory\n" .
@@ -516,6 +524,26 @@
     exit(0);
 }
 
+#   support external configuration file
+if (-f $config) {
+    my $cfg = new IO::File "<$config";
+    my $line;
+    while (defined($line = $cfg->getline())) {
+        $line =~ s|\r?\n$||s;
+        next if ($line =~ m/^\s*(#.*)?$/s);
+        my ($option, $value) = ($line =~ m|^\s*(\S+)\s+(.+?)\s*$|s);
+        die "invalid configuration line \"$line\""
+            if (not defined($option) or not defined($value));
+        my ($var) = map  { $options{$_} } 
+                    grep { $_ =~ m/^.\|\Q$option\E(=[si])?$/s }
+                    keys(%options);
+        die "invalid configuration option \"$option\""
+            if (not defined($var));
+        ${$var} = $value;
+    }
+    $cfg->close;
+}
+
 #   create daemon run-time context
 my $ctx = {};
 $ctx->{-log}      = new My::Log ($loglevel, $logfile);


ossp-pkg/snmpdx/snmpdx.cfg -> 1.1

*** /dev/null    Sat Nov 23 02:12:20 2024
--- -    Sat Nov 23 02:12:22 2024
***************
*** 0 ****
--- 1,8 ----
+ ##
+ ##  snmpdx.cfg -- configuration file for SNMP Daemon Extension
+ ##
+ 
+ mibdir    /u/rse/wrk/ossp/snmpdx/snmpdx.mib:/cw/share/snmp/mibs
+ probedir  /u/rse/wrk/ossp/snmpdx/snmpdx.d
+ logfile   /tmp/snmpdx-rse.log
+ 


ossp-pkg/snmpdx/snmpdx.sh 1.2 -> 1.3


CVSTrac 2.0.1