#
# $Id: test.pl,v 1.1 1998/12/21 16:16:42 trockij Exp trockij $
#
use Mon::SNMP;

open (T, "/home/trockij/snmp.trap") || die;
$buf = "";
sysread (T, $buf, 65536);
close (T);

$this = Mon::SNMP->new;

$this->buffer($buf);
%l = $this->decode;

print "$l{'community'}\n";

foreach $oid (keys %{$l{"varbindlist"}}) {
    print "oid=$oid\n";
}

exit;
__END__

$a = Mon::Client->new;

if (!defined $a->connect) {
    die "could not connect: " . $a->error . "\n";
} else {
    print "connected\n";
}

if (!defined (%o = $a->list_opstatus)) {
    die "could not get optstatus: " . $a->error . "\n";
} else {
    print "got opstatus\n";
}

#$a->username ("mon");
#$a->password ("supermon");
#if (!defined ($a->login)) {
#    die "could not log in: " . $a->error . "\n";
#} else {
#    print "logged in\n";
#}

#if (!defined $a->stop) {
#    die "could not stop: " . $a->error . "\n";
#}

#if (!defined $a->start) {
#    die "could not start: " . $a->error . "\n";
#} else {
#    print "started scheduler\n";
#}

#if (!defined (%o = $a->list_failures)) {
#    die "could not get failures: " . $a->error . "\n";
#}

#if (!defined (%d = $a->list_disabled)) {
#    die "could not get disabled: " . $a->error . "\n";
#}

#if (!defined (@group = $a->list_group ("software"))) {
#    die "could not list group: " . $a->error . "\n";
#}


#if (!defined ($a->enable_host ("pgupta-dsl"))) {
#    die "could not enable host: " . $a->error . "\n";
#}

#if (!defined (($server, @pids) = $a->list_pids)) {
#    die "could not get failures: " . $a->error . "\n";
#}

if (!defined $a->disconnect) {
    die "could not disconnect: " . $a->error . "\n";
} else {
    print "disconnected\n";
}


&show_opstatus;

exit 0;




sub show_disabled {
    print "HOSTS\n";
    foreach $g (keys %{$d{hosts}}) {
	foreach $h (keys %{$d{hosts}{$g}}) {
	    print "group $g [$h]\n";
	}
    }

    print "SERVICES\n";
    foreach $g (keys %{$d{services}}) {
	foreach $s (keys %{$d{services}{$g}}) {
	    print "[$g] [$s]\n";
	}
    }

    print "WATCHES\n";
    foreach $g (keys %{$d{watches}}) {
	print "[$g]\n";
    }
}

sub show_opstatus {
    my ($g, $s, $k);

    print "OPSTATUS\n";
    foreach $g (keys %o) {
    	foreach $s (keys %{$o{$g}}) {
	    foreach $k (keys %{$o{$g}{$s}}) {
	    	print "[$g] [$s] [$k] [$o{$g}{$s}{$k}]\n";
	    }
	}
    }
}
