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

# User Rev Content
1 tdb 1.5 /*
2     * i-scream central monitoring system
3 tdb 1.6 * http://www.i-scream.org.uk
4 tdb 1.5 * 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 tdb 1.1 //---PACKAGE DECLARATION---
22 tdb 1.4 package uk.org.iscream.cms.server.filter.plugins;
23 tdb 1.1
24     //---IMPORTS---
25 tdb 1.4 import uk.org.iscream.cms.server.filter.ServiceCheckSkeleton;
26 tdb 1.1 import java.net.*;
27     import java.io.*;
28    
29     /**
30     * A quick Telnet service checker.
31     *
32 tdb 1.5 * @author $Author: tdb $
33 tdb 1.6 * @version $Id: Telnet__ServiceCheck.java,v 1.5 2002/05/18 18:16:02 tdb Exp $
34 tdb 1.1 */
35     public class Telnet__ServiceCheck extends ServiceCheckSkeleton {
36    
37     //---FINAL ATTRIBUTES---
38    
39     /**
40     * The current CVS revision of this class
41     */
42 tdb 1.6 public final String REVISION = "$Revision: 1.5 $";
43 tdb 1.1
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 tdb 1.2 // 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 tdb 1.1 // 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 tdb 1.2 }
78    
79     /**
80     * return the String representation of what the filter does
81     */
82     public String getDescription(){
83     return DESC;
84 tdb 1.1 }
85    
86     //---PRIVATE METHODS---
87    
88     //---ACCESSOR/MUTATOR METHODS---
89    
90     //---ATTRIBUTES---
91    
92     //---STATIC ATTRIBUTES---
93    
94     }