<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Stanley,<br>
<br>
I intend to produce a design/suage document shortly. It will be small
with dot points if I can get it out shortly. The rational for this
approach is 2 fold. Adding the burden to the plugin writer to produce
the output of the usage, help, version and other standard function in a
consistent and complete fashion seems to me to be unnecessary which has
led to the thinking that perhaps a framework for the entire operation
of a plugin would be a good idea, which has led to this approach being
adopted. The second is the thing that got me started on all of this,
which was needing to get consistent, complet and upto date usage
information and help information in machine processable form for entry
into a database. This database is then used to provide a user interface
that can prompt for data from the user when building Nagios
configurations. I need to be able to do type checking, provide value
checks where possible, confirm that parameters will be compatible (e.g.
SNMPv1 with SNMPv3 authorisation arguments do not make much sense) and
so on.<br>
<br>
Thus, I am led to the approach shown in the Plugin and
Plugin::Parameter modules. Probably coudl be done better, could
certainly use Perl smarter and give more consise files (but probably
not faster executing) but it does have some industrial strength and
will if finished provide a much easier environment within which plugins
of greater content can be written. I am working on standardising the
SNMP framework to allow the writer to concentrate on processing the MIB
results, as well as, providing a common error reporting framework and
output production framework.<br>
<br>
On a note I received from Karl and have responded to but is related to
peerformance. Our exeperience so far is that this has little eimpact on
a running monitor environment, where about 50% of our plugin executions
have now been changed to operate this. The cost of loading the Plugin
could be reduced considerabley if the POD is removed from the Plugin.pm
and Plugin::Parameter.pm files - this could be done at compile time by
fixing the Makefile. This would reduce the file size by > 50% thus
the overhead is about 35K source code. Further pounding on my style
could easily bring this down by 50% so for smaller machines we could
make this a not problem.<br>
<br>
I have not tested under ePN although I believe I have stuck to the
rules for compile once, run many operation. I would appreciate some
live running under ePN by someone and some feedback on what to fix, as
we will be implementign an ePN based environment later this year and I
would like to concentrate on getting working and not the plugin's.<br>
<br>
Another note. All of the plugins now have taint checking on by default,
and have been fixed to work in this environment.<br>
<br>
Regards, Howard.<br>
<br>
Stanley Hopcroft wrote:<br>
<blockquote type="cite"
 cite="mid20040331092123.B40094@IPAustralia.Gov.AU">
  <pre wrap="">Dear Sir,

I am writing to thank you for your 'small patches' and compliment you on 
your prolificity.

Well done !

Please would you consider a group posting of

. your rationale (small dot points for me please) for this approach

  - eg facilitate plugin integration in GUI config manager ?

. the performance impact of the new framework (/usr/bin/time repeatd a 
few times [vi] of the original plugin and that in the framework)

. how it performs under ePN - can't imagine it's a problem and I will 
  probably try this.

I like the 'opt in' approach to option checking; that alone should make 
a plugin authors lot a much easier one.

Yours sincerely.

--
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.
  </pre>
  <pre wrap="">
<hr width="90%" size="4">
#!/usr/bin/perl -w

use strict ;

#
#
#       dotime
#
#       L Wall, "Programming Perl 1st ed" p 331
#
#       usage dotime repeat command

#       updated for P 5 by S Hopcroft


die "Usage: dotime <repeat> <command>\n" if @ARGV < 2 ;

my $repeat = shift(@ARGV) ;
die "Invalid repeat: $repeat, stopped" 
  unless (($repeat > 0) && ($repeat < 999)) ;

use vars qw($arg) ;

my $times = ($repeat == 1 ? "once" : "$repeat times") ;
print qq/Running @ARGV $times\n/ ;
$| = 1 ;

my %run_time = (  real => { total => 0, list => [] },
                  user => { total => 0, list => [] },
                  sys  => { total => 0, list => [] }
               ) ;

for my $pass (1 .. $repeat) {
  print "$pass " ;
  open (TIMES, "/usr/bin/time @ARGV 2>&1 |") 
    || die "Can't run /usr/bin/time @ARGV 2>&1, stopped" ;
  while (<TIMES>) {
    my %t ;
    if ( @t{ qw(real user sys) } = /^\s*(\S+) real\s*(\S+) user\s*(\S+) sys/ ) {
      foreach my $time ( keys %run_time ) {
        $run_time{$time}{total} +=        $t{$time} ;
        push @{ $run_time{$time}{list} }, $t{$time} ;
      }
    }
  }
  close (TIMES) ;
}

print "done\n" ;

my $fields_per_line = 15 ;
my ($fields, $values, $avg, $form) ;

$form = "format STDOUT =\n" ;

if ( $repeat <= $fields_per_line) {

  $fields = '@<<<<@>>>>>>' . '@>>>>>>>>' x $repeat ;
  $values = '$arg,$avg   ' . ',shift @_' x $repeat ;
  $form .=<<EOF ;
$fields
$values
.
EOF

} else {

  # XXXX
  # The values must follow the picture lines.
  # So they must be wrapped also (otherwise a SEGV from the write statement).
  # XXXX

  my $data_fields = $fields_per_line - 2 ;
  #  Only $fields_per_line - 2 datum are displayed on each line of output

  my $spaces = ' ' x 12 ;

  # the multiple of ' ' is the number of chars used by the $arg and $avg fields in the first line 
  # PLUS the number 2 (for the '@' field markers) so that the fields line up for debugging.

  my $fields = '@<<<<@>>>>>>' . '@>>>>>>>>' x $data_fields ;
  my $values = '$arg,$avg  ' . ',shift @_'  x $data_fields ;

  $form .=<<EOF ;
$fields
$values
EOF

  my $line_pics = $spaces . '@>>>>>>>>' x $data_fields ;
  my $line_vals = $spaces . ',shift @_' x $data_fields ;

  my $lines_remaining = int( ($repeat - $data_fields)/$data_fields )  ;

  $form .=<<EOF x $lines_remaining ;
$line_pics
$line_vals
EOF

  my $fields_remaining = ($repeat - $data_fields) % $data_fields ;
  $fields = ( $fields_remaining ? $spaces . '@>>>>>>>>' x $fields_remaining : "\n" ) ;
  $values = ( $fields_remaining ? $spaces . ',shift @_' x $fields_remaining : "\n" ) ;

  $form .=<<EOF ;
$fields
$values
.
EOF

}

# XXXX

$arg = ' ' ;

# $arg __cannot__ be a lexical or its value is not displayed.
# XXXX

eval $form ;

sub write {
  $avg = shift ;
  write ;
}

&write('Avg', 1 .. $repeat) ;

&write(split(' ', ' ------' x ($repeat + 1))) ;

foreach $arg ( qw(real user sys) ) {
  &write( sprintf("%6.3f", $run_time{$arg}{total}/$repeat),
          @{ $run_time{$arg}{list} }
        ) ;
}
  </pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Signature</title>
<table cellpadding="2" cellspacing="2" border="0"
 style="text-align: left; width: 100%;">
  <tbody>
    <tr>
      <td style="vertical-align: top;">Howard Wilkinson<br>
      </td>
      <td style="vertical-align: top;">Phone:<br>
      </td>
      <td style="vertical-align: top;">+44(20)7690 7075<br>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Coherent Technology Limited<br>
      </td>
      <td style="vertical-align: top;">Fax:<br>
      </td>
      <td style="vertical-align: top;">+44(20)79230110<br>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">33 Belgrade Road, Stoke
Newington,<br>
      </td>
      <td style="vertical-align: top;">Mobile:<br>
      </td>
      <td style="vertical-align: top;">+44(7980)639379<br>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">London, United Kingdom, N16 8DH<br>
      </td>
      <td style="vertical-align: top;">Email:<br>
      </td>
      <td style="vertical-align: top;"><a name="howardcohtech.com"
 target="mailto:howard@cohtech.com" href="mailto:howard@cohtech.com"></a><a class="moz-txt-link-abbreviated" href="mailto:howard@cohtech.com">howard@cohtech.com</a><br>
      </td>
    </tr>
  </tbody>
</table>
<br>
</div>

<DIV><P><HR>
This message contains confidential information and is intended only<BR>
for the individual named. If you are not the named addressee you<BR>
should not disseminate, distribute or copy this e-mail. Please<BR>
notify the sender immediately by e-mail if you have received this<BR>
e-mail by mistake and delete this e-mail from you system.<BR>
<BR>
E-mail transmission cannot be guarenteed to be secure or error-free<BR>
as information could be intercepted, corrupted, lost, destroyed,<BR>
arrive late or incomplete, or contain viruses. The sender therefore<BR>
does not accept liability for any errors or omissions in the contents<BR>
of this message which arise as a result of e-mail transmission. If<BR>
verification is required please request a hard-copy version.
</P></DIV>
</body>
</html>