tayun has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I got the error

"problem enabling host (enable_watch) (Bad file descriptor)" when I try to run the following code (the code ran for a few years without any problem)
#!/usr/bin/perl use Mon::Client; use Sys::Hostname; $host = hostname(); $service = "test"; @services = ('test','diskspace', 'ora-listener','ping'); $c = new Mon::Client ( host => "moni", port => 2233 ); $c->connect(); %s = $c->list_opstatus; $c->enable_watch($host) || die "problem enabling host (enable_watch) ($!)\n";

what is wrong and how should I fix it?

Thanks for the help in advance

Replies are listed 'Best First'.
Re: Problem with enable_watch
by ikegami (Patriarch) on Jan 29, 2010 at 22:00 UTC

    enable_watch is not documented to return anything or to set $!. Peeking inside the source, it appears that it intentionally returns undef on error, and only on error. However, the error message is a not stored in $! It is accessible via $c->error().

    $c->enable_watch($host) or die("Can't enable watch of $host: ", $c->error(), "\n");

    For future reference, please wrap computer text such as code in <c>...</c> tags, and use <p> to start each paraphraph

      The error message is Can't enable watch of test: 520 enable error, unknown watch What does this mean? How do I fix this error? thanks so much for the help
        I don't know anything about Mon or Mon::Client, but it sounds like you need to create the watch somehow before you can enable it. list_watch might give a clue as to what is being expected.