ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/client/Alert.java
Revision: 1.16
Committed: Tue May 29 17:02:34 2001 UTC (22 years, 11 months ago) by tdb
Branch: MAIN
Branch point for: SERVER_PIRCBOT
Changes since 1.15: +6 -6 lines
Log Message:
Major change in the java package naming. This has been held off for some time
now, but it really needed doing. The future packaging of all i-scream products
will be;

uk.org.iscream.<product>.<subpart>.*

In the case of the central monitoring system server this will be;

uk.org.iscream.cms.server.*

The whole server has been changed to follow this structure, and tested to a
smallish extent. Further changes in other parts of the CMS will follow.

File Contents

# User Rev Content
1 tdb 1.1 //---PACKAGE DECLARATION---
2 tdb 1.16 package uk.org.iscream.cms.server.client;
3 tdb 1.1
4     //---IMPORTS---
5 tdb 1.16 import uk.org.iscream.cms.server.util.*;
6 tdb 1.1
7     /**
8 ajm 1.15 * An object to hold the state of an Alert.
9     *
10     * When an alert is generated, it has lots of information about
11     * the cirscumstances and source of the alert. This object holds
12     * the information. It is created by Monitors (specifically in the
13     * fireAlert method of MonitorSkeleton). It then places the alert
14     * in the alert queue for Alerters to read and process.
15 tdb 1.1 *
16 tdb 1.16 * @author $Author: ajm4 $
17     * @version $Id: Alert.java,v 1.15 2001/03/23 02:30:44 ajm4 Exp $
18 tdb 1.1 */
19 ajm 1.3 public class Alert {
20 tdb 1.1
21     //---FINAL ATTRIBUTES---
22    
23     /**
24     * The current CVS revision of this class
25     */
26 tdb 1.16 public static final String REVISION = "$Revision: 1.15 $";
27 tdb 1.4
28 ajm 1.15 /**
29     * An internal representation of a NORMAL threshold
30     */
31 ajm 1.8 public static final int thresholdNORMAL = 0;
32 ajm 1.15
33     /**
34     * An internal representation of a LOWER threshold
35     */
36 ajm 1.8 public static final int thresholdLOWER = 1;
37 ajm 1.15
38     /**
39     * An internal representation of an UPPER threshold
40     */
41 ajm 1.8 public static final int thresholdUPPER = 2;
42 ajm 1.3
43 ajm 1.15 /**
44     * The textual names of the threshold levels. The position
45     * of the names in this array correspond to the internal
46     * integer representation constants.
47     */
48 ajm 1.8 public static final String[] thresholdLevels = {"NORMAL", "LOWER", "UPPER"};
49    
50 ajm 1.15 // note OK and FINAL MUST be present...at the beginning and the end
51 ajm 1.11
52 ajm 1.15 /**
53     * An internal representation of the OK alert
54     * This must ALWAYS be 0.
55     */
56 ajm 1.8 public static final int alertOK = 0;
57 ajm 1.15
58     /**
59     * An internal representation of the NOTICE alert
60     */
61 ajm 1.8 public static final int alertNOTICE = 1;
62 ajm 1.15
63     /**
64     * An internal representation of the WARNING alert
65     */
66 ajm 1.8 public static final int alertWARNING = 2;
67 ajm 1.15
68     /**
69     * An internal representation of the CAUTION alert
70     */
71 ajm 1.8 public static final int alertCAUTION = 3;
72 ajm 1.15
73     /**
74     * An internal representation of the CRITICAL alert
75     */
76 ajm 1.8 public static final int alertCRITICAL = 4;
77 ajm 1.15
78     /**
79     * An internal representation of the FINAL alert
80     * This must ALWAYS be the highest.
81     */
82 ajm 1.10 public static final int alertFINAL = 5;
83 ajm 1.8
84 ajm 1.15 /**
85     * The textual names of the alert levels. The position
86     * of the names in this array correspond to the internal
87     * integer representation constants.
88     */
89 ajm 1.10 public static final String[] alertLevels = {"OK", "NOTICE", "WARNING", "CAUTION", "CRITICAL", "FINAL"};
90 tdb 1.1
91     //---STATIC METHODS---
92    
93     //---CONSTRUCTORS---
94    
95     /**
96 ajm 1.15 * Construct an Alert object with the appropriate data
97 tdb 1.1 *
98 ajm 1.15 * @param alertLevel the alert level for this Alert object
99     * @param lastAlert the last alert level before this one
100     * @param thresholdLevel the threshold level that was broken to raise the alert
101     * @param source the source of the alert eg, hostname
102     * @param thresholdValue the configured value of the treshold level that was broken
103     * @param value the value of the attribute that raised the alert
104     * @param attributeName the textual representation of the attribute that has raised the alert
105     * @param timeTillNextAlert the time until the next alert will be sent concerning this attribute (in seconds)
106     * @param initialAlertTime the time the problem with this attribute first occured
107 tdb 1.1 */
108 ajm 1.11 public Alert(int alertLevel, int lastAlert, int thresholdLevel, String source, String thresholdValue, String value, String attributeName, String timeTillNextAlert, long initialAlertTime) {
109 ajm 1.8 _alertLevel = alertLevel;
110 ajm 1.9 _lastAlert = lastAlert;
111 ajm 1.8 _thresholdLevel = thresholdLevel;
112 tdb 1.5 _source = source;
113 ajm 1.3 _thresholdValue = thresholdValue;
114     _value = value;
115     _attributeName = attributeName;
116 ajm 1.8 _timeTillNextAlert = timeTillNextAlert;
117 ajm 1.11 _initialAlertTime = initialAlertTime;
118 tdb 1.1 }
119    
120     //---PUBLIC METHODS---
121 tdb 1.12
122     /**
123     * Prints a String representation of the Alert object. It
124     * is designed to resemble a HashMap.toString(), such that
125     * it is similar to the XMLPacket.printAll() method.
126     *
127 ajm 1.15 * This method is used by the WebFeeder specifically.
128     *
129 tdb 1.12 * @return a String representation of this Alert object.
130     */
131     public String printAll() {
132     String result = "{";
133     result += "alertLevel="+_alertLevel+", ";
134     result += "lastAlert="+_lastAlert+", ";
135     result += "thresholdLevel="+_thresholdLevel+", ";
136     result += "source="+_source+", ";
137     result += "thresholdValue="+_thresholdValue+", ";
138     result += "value="+_value+", ";
139     result += "attributeName="+_attributeName+", ";
140     result += "timeTillNextAlert="+_timeTillNextAlert+", ";
141     result += "initialAlertTime="+_initialAlertTime;
142     result += "}";
143     return result;
144     }
145 tdb 1.1
146     /**
147     * Overrides the {@link java.lang.Object#toString() Object.toString()}
148     * method to provide clean logging (every class should have this).
149     *
150 tdb 1.16 * This uses the uk.org.iscream.cms.server.util.FormatName class
151 tdb 1.1 * to format the toString()
152     *
153     * @return the name of this class and its CVS revision
154     */
155     public String toString() {
156     return FormatName.getName(
157     _name,
158     getClass().getName(),
159     REVISION);
160     }
161    
162     //---PRIVATE METHODS---
163    
164     //---ACCESSOR/MUTATOR METHODS---
165 tdb 1.2
166     /**
167 ajm 1.15 * Returns the alert level of this Alert object
168     *
169     * @return the level
170 tdb 1.2 */
171     public int getLevel() {
172 ajm 1.8 return _alertLevel;
173     }
174    
175 ajm 1.15 /**
176     * Returns the previous alert level for the attribute
177     *
178     * @return the previous level
179     */
180 ajm 1.9 public int getLastLevel() {
181     return _lastAlert;
182     }
183    
184 ajm 1.15 /**
185     * Returns the threshold level that was broken
186     *
187     * @return the threshold level
188     */
189 ajm 1.8 public int getThreshold() {
190     return _thresholdLevel;
191 tdb 1.2 }
192 ajm 1.3
193 ajm 1.15 /**
194     * Returns the source of the alert
195     *
196     * @return the alerts source eg, hostname
197     */
198 tdb 1.5 public String getSource() {
199     return _source;
200     }
201    
202 ajm 1.15 /**
203     * Returns the value that the alert level was caused by
204     *
205     * @return the value
206     */
207 ajm 1.3 public String getValue() {
208     return _value;
209     }
210    
211 ajm 1.15 /**
212     * Returns the value of the threshold level this alert broke
213     *
214     * @return the value
215     */
216 ajm 1.3 public String getThresholdValue() {
217     return _thresholdValue;
218     }
219    
220 ajm 1.15 /**
221     * Returns the textual representation of the name of
222     * the attribute that caused the alert.
223     *
224     * @return the attribute name
225     */
226 ajm 1.3 public String getAttributeName() {
227     return _attributeName;
228     }
229 ajm 1.8
230 ajm 1.15 /**
231     * Returns the time in seconds till the next
232     * alert will be sent
233     *
234     * @return the time till the next alert
235     */
236 ajm 1.8 public String getTimeTillNextAlert() {
237     return _timeTillNextAlert;
238     }
239 ajm 1.11
240 ajm 1.15 /**
241     * Returns the time in milliseconds when
242     * the initial alert for this problem with the attribute
243     * occured.
244     *
245     * @return the initial alert time
246     */
247 tdb 1.13 public long getInitialAlertTime() {
248 ajm 1.11 return _initialAlertTime;
249     }
250 tdb 1.1
251     //---ATTRIBUTES---
252    
253     /**
254     * This is the friendly identifier of the
255     * component this class is running in.
256     * eg, a Filter may be called "filter1",
257     * If this class does not have an owning
258     * component, a name from the configuration
259     * can be placed here. This name could also
260     * be changed to null for utility classes.
261     */
262     private String _name = ClientMain.NAME;
263    
264     /**
265 ajm 1.15 * The alert level of this Alert object
266 tdb 1.1 */
267 ajm 1.8 private int _alertLevel;
268 ajm 1.9
269 ajm 1.15 /**
270     * The last alert level for this attribute
271     */
272 ajm 1.9 private int _lastAlert;
273 ajm 1.8
274 ajm 1.15 /**
275     * The threshold level that was broken
276     */
277 ajm 1.8 private int _thresholdLevel;
278 ajm 1.3
279 ajm 1.15 /**
280     * The source of the alert, eg hostname
281     */
282 tdb 1.5 private String _source;
283 ajm 1.15
284     /**
285     * The attribute value that caused the alert
286     */
287 ajm 1.3 private String _value;
288 ajm 1.15
289     /**
290     * The threshold value that was broken
291     */
292 ajm 1.3 private String _thresholdValue;
293 ajm 1.15
294     /**
295     * The textual representation of the attribute
296     * that caused the alert.
297     */
298 ajm 1.3 private String _attributeName;
299 ajm 1.15
300     /**
301     * The time in seconds till the next alert
302     * for this attribute will occur.
303     */
304 ajm 1.8 private String _timeTillNextAlert;
305 ajm 1.11
306 ajm 1.15 /**
307     * The time in milliseconds that this
308     * alert first occured.
309     */
310 ajm 1.11 private long _initialAlertTime;
311 tdb 1.1
312     //---STATIC ATTRIBUTES---
313    
314     }