--- /dev/null
+# plugin to monitor the GNU Gatekeeper (http://www.gnugk.org/)
+# $Id: check_gnugk,v 1.1 2005/09/13 13:14:34 willamowius Exp $
+# Author: Jan Willamowius, jan@willamowius.de, http://www.willamowius.de
+
+# Register the routine with the plugins registry
+$PLUGINS{'gnugk'} = \&check_gnugk;
+
+eval "require Net::Telnet;";
+
+sub check_gnugk {
+ my ($host) = @_;
+ # Find the list of ports to check
+ my @ports = $HOSTS{$host}->{'gnugk_ports'} ||
+ $HOSTS_DEFAULTS{'gnugk_ports'} ||
+ (7000);
+ # Append mandatory ports from the 'ALL' host
+ @ports = ( @ports, @{$HOSTS_ALL{'gnugk_ports'}} );
+ my ($color, $summary, $message) = ("green", "", "");
+
+ foreach $port (@ports) {
+ my $con = new Net::Telnet;
+ $con->errmode('return');
+ my $ok = $con->open(Host=> $host, Port => $port);
+ if (! $ok) {
+ $color = "red";
+ $message .= "$host:$port -\n" . $con->errmsg() . "\n";
+ next;
+ }
+
+ $con->waitfor("/;/");
+ my @data = $con->cmd(String => "Statistics", Prompt => "/;/", Timeout => 3);
+ if (@data) {
+ $message .= "$host:$port -\n@data\n";
+ } else {
+ $color = "yellow" unless $color eq "red";
+ $message .= "$host:$port -\n Timed out reading data\n";
+ }
+ $con->close();
+ }
+
+ if ($color eq "green") {
+ $summary = "GnuGk OK";
+ } else {
+ $summary = "GnuGk Not OK";
+ }
+
+ &debug("gnugk - $host - $color, $summary");
+ return( $color, $summary, $message);
+}
+
+1; # Leave me here
+