ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/filter/plugins/Telnet__ServiceCheck.java
Revision: 1.6
Committed: Tue May 21 16:47:18 2002 UTC (22 years ago) by tdb
Branch: MAIN
Changes since 1.5: +3 -2 lines
Log Message:
Added URL to GPL headers.

File Contents

# Content
1 /*
2 * i-scream central monitoring system
3 * http://www.i-scream.org.uk
4 * Copyright (C) 2000-2002 i-scream
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 //---PACKAGE DECLARATION---
22 package uk.org.iscream.cms.server.filter.plugins;
23
24 //---IMPORTS---
25 import uk.org.iscream.cms.server.filter.ServiceCheckSkeleton;
26 import java.net.*;
27 import java.io.*;
28
29 /**
30 * A quick Telnet service checker.
31 *
32 * @author $Author: tdb $
33 * @version $Id: Telnet__ServiceCheck.java,v 1.5 2002/05/18 18:16:02 tdb Exp $
34 */
35 public class Telnet__ServiceCheck extends ServiceCheckSkeleton {
36
37 //---FINAL ATTRIBUTES---
38
39 /**
40 * The current CVS revision of this class
41 */
42 public final String REVISION = "$Revision: 1.5 $";
43
44 public final String DESC = "Checks that a Telnet server is alive.";
45
46 //---STATIC METHODS---
47
48 //---CONSTRUCTORS---
49
50 //---PUBLIC METHODS---
51
52 /**
53 * Performs the service check on a given host.
54 *
55 * @param hostname the host to check
56 * @return XML data representing the result of the test
57 */
58 public String runServiceCheck(String hostname){
59 String message, status;
60 try {
61 // connect
62 Socket socket = new Socket(hostname, 23);
63 BufferedReader socketIn = new BufferedReader(new InputStreamReader(socket.getInputStream()));
64 // close
65 socketIn.close();
66 socket.close();
67
68 // we only get past here if we connected...
69 // ...which is all we care about
70 status = "0";
71 message = "Connect accepted";
72 } catch (IOException e) {
73 status = "1";
74 message = "Service check failed to establish connection to host: " + e.getMessage();
75 }
76 return "<Telnet status=\"" + status + "\" message=\"" + message + "\"></Telnet>";
77 }
78
79 /**
80 * return the String representation of what the filter does
81 */
82 public String getDescription(){
83 return DESC;
84 }
85
86 //---PRIVATE METHODS---
87
88 //---ACCESSOR/MUTATOR METHODS---
89
90 //---ATTRIBUTES---
91
92 //---STATIC ATTRIBUTES---
93
94 }