#!/usr/bin/perl
#
#####################################################################
##                                                                 ##
##  bootp.monitor                                   Version 1.0.0  ##
##                                                  2000-01-10     ##
##  Copyright (C) 2000                                             ##
##  Peter Holzleitner (P.Holzleitner@computer.org)                 ##
##                                                                 ##
#####################################################################
#
# A MON plug-in monitor to test bootp servers.
#
# Arguments:
#
#  [-h|--hardware] [-d|--debug] serverlist
#
# Requirements:
#
#   This is actually just a mon wrapper for the bootptest program 
#   from the CMU bootpd distribution.  Please refer to bootptest(8)
#   for details about its operation.  The --hardware (-h) option is
#   passed through to bootptest.
#
# History:
#
#   1.0.0  initial release

use Getopt::Long;

# configure location if necessary
$bootptest = '/usr/sbin/bootptest';

GetOptions(\%opt, 'debug', 'hardware');

$redir = '>/dev/null 2>&1';
$redir = '' if $opt{'debug'};

$hwopt = '';
$hwopt = '-h' if $opt{'hardware'};
  
@failures = ();

foreach $host (@ARGV) {
    $res = system("$bootptest $hwopt $host $redir") / 256;
    print "\nRESULT FOR $host: $res\n\n" if $opt{"debug"};
    push (@failures, $host) if ($res != 0);
    }

exit 0 if (@failures == 0);

print "@failures\n";

exit 1;
