--- /dev/null
+# check_telnet - v 1.0 May 18, 2000 - scarpe01@tufts.edu
+
+# Register the routine with the plugins registry
+$PLUGINS{'telnet'} = \&check_telnet;
+
+
+# We are checking the telnet server here. There are no real error codes
+# or anything...just see if its open and we can get a login prompt....
+
+eval "require Net::Telnet;";
+
+sub check_telnet {
+ my ($host) = @_;
+ # Find the list of ports to check
+ my @ports = $HOSTS{$host}->{'telnet_ports'} ||
+ $HOSTS_DEFAULTS{'telnet_ports'} ||
+ (23);
+ # Append mandatory ports from the 'ALL' host
+ @ports = ( @ports, @{$HOSTS_ALL{'telnet_ports'}} );
+ my ($color, $summary, $message) = ("green", "", "");
+
+ foreach $port (@ports) {
+ my $con = new Net::Telnet;
+ my $ok = $con->open(Host=> $host, Port => $port);
+ if (! $ok) {
+ $color = "red";
+ $message .= "$host:$port -\n" . $con->errmsg() . "\n";
+ next;
+ }
+
+ $con->print("\n\n");
+ my @data = $con->getlines((Timeout => 6));
+ 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 = "Telnet test(s) OK";
+ } else {
+ $summary = "Telnet Not OK";
+ }
+
+ &debug("telnet - $host - $color, $summary");
+ return( $color, $summary, $message);
+}
+
+1; # Leave me here
+