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.20
Committed: Sun Aug 1 10:40:40 2004 UTC (19 years, 9 months ago) by tdb
Branch: MAIN
CVS Tags: HEAD
Changes since 1.19: +3 -3 lines
Error occurred while calculating annotation data.
Log Message:
Catch a lot of old URL's and update them. Also remove a couple of old files
that aren't used.

File Contents

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