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/monitors/CPU__Monitor.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/monitors/CPU__Monitor.java (file contents):
Revision 1.11 by ajm, Sun Mar 4 02:41:16 2001 UTC vs.
Revision 1.15 by ajm, Tue Mar 6 02:33:55 2001 UTC

# Line 51 | Line 51 | public class CPU__Monitor implements PluginMonitor {
51                  if(reg.getLastThresholdLevel(attributeNum) != Alert.thresholdNORMAL) {
52                      // if the time since the last alert is more than the time for
53                      // its timeout, fire an alert, escalate the alert
54 <                    long timeout = reg.getAlertTimeout(reg.getLastAlertLevel(attributeNum), attributeNum);
54 >                    long timeout = reg.getLastAlertTimeout(attributeNum);
55                      if ((timeout > 0) && (reg.getTimeLastSent(attributeNum) > 0)) {
56                          if((System.currentTimeMillis() - reg.getTimeLastSent(attributeNum)) > timeout) {
57 +                            int lastAlert = reg.getLastAlertLevel(attributeNum);
58                              reg.escalateAlert(attributeNum);
59                              reg.setTimeLastSent(attributeNum, System.currentTimeMillis());
60 <                            fireAlert(reg, packet, attributeNum);
60 >                            reg.setLastAlertTimeout(attributeNum, reg.getAlertTimeout(reg.getLastAlertLevel(attributeNum), attributeNum));
61 >                            fireAlert(reg, lastAlert, packet, attributeNum);
62                          }
63                      // if we don't have a timeout configured...we got STRAIGHT to the next level
64                      } else {
65 +                        int lastAlert = reg.getLastAlertLevel(attributeNum);
66                          reg.escalateAlert(attributeNum);
67                          reg.setTimeLastSent(attributeNum, System.currentTimeMillis());
68 <                        fireAlert(reg, packet, attributeNum);
68 >                        reg.setLastAlertTimeout(attributeNum, reg.getAlertTimeout(reg.getLastAlertLevel(attributeNum), attributeNum));
69 >                        fireAlert(reg, lastAlert, packet, attributeNum);
70                      }
71                          
72                  // we must be on ok, check the timeout value for this
# Line 71 | Line 75 | public class CPU__Monitor implements PluginMonitor {
75                      // but if we weren't we only set OK, once the timout of the last
76                      // alert has occourd
77                      if (reg.getLastAlertLevel(attributeNum) != Alert.alertOK) {
78 <                        long timeout = reg.getAlertTimeout(reg.getLastAlertLevel(attributeNum), attributeNum);
78 >                        long timeout = reg.getLastAlertTimeout(attributeNum);
79                          if ((timeout > 0) && (reg.getTimeLastSent(attributeNum) > 0)) {
80                              if ((System.currentTimeMillis() - reg.getTimeLastSent(attributeNum)) > timeout) {
81 +                                int lastAlert = reg.getLastAlertLevel(attributeNum);
82                                  reg.setLastAlertLevel(attributeNum, Alert.alertOK);
83                                  reg.setTimeLastSent(attributeNum, System.currentTimeMillis());
84 <                                fireAlert(reg, packet, attributeNum);
84 >                                reg.setLastAlertTimeout(attributeNum, timeout);
85 >                                fireAlert(reg, lastAlert, packet, attributeNum);
86                              }
81                        } else {
82                            reg.setLastAlertLevel(attributeNum, Alert.alertOK);
83                            reg.setTimeLastSent(attributeNum, System.currentTimeMillis());
84                            fireAlert(reg, packet, attributeNum);
87                          }
88                      }
89                  }
# Line 131 | Line 133 | public class CPU__Monitor implements PluginMonitor {
133          return 0;
134      }
135  
136 <    private void fireAlert(Register reg, XMLPacket packet, int attributeNum) {
136 >    private void fireAlert(Register reg, int lastAlert, XMLPacket packet, int attributeNum) {
137          int alertLevel = reg.getLastAlertLevel(attributeNum);
138          int thresholdLevel = reg.getLastThresholdLevel(attributeNum);
139          String source = packet.getParam("packet.attributes.machine_name");
140          String currentValue = packet.getParam(_attributes[attributeNum]);
141          String attributeName = _attributeNames[attributeNum];
142          String thresholdValue = Double.toString(reg.getThreshold(thresholdLevel));
143 <        String time = Long.toString(reg.getAlertTimeout(reg.getLastAlertLevel(attributeNum), attributeNum) / 1000);
143 >        String timeout = Long.toString(reg.getAlertTimeout(reg.getLastAlertLevel(attributeNum), attributeNum) / 1000);
144          if (thresholdLevel == Alert.thresholdNORMAL) {
145              thresholdValue = "-";
146          }
147          if (alertLevel == Alert.alertOK) {
148 <            time = "0";
148 >            timeout = "0";
149          }
150 <        Alert alert = new Alert(alertLevel, thresholdLevel, source, thresholdValue, currentValue, attributeName, time);
150 >        Alert alert = new Alert(alertLevel, lastAlert, thresholdLevel, source, thresholdValue, currentValue, attributeName, timeout, reg.getInitialAlertTime(attributeNum));
151          _alerterQueue.add(alert);
152 <        _logger.write(toString(), Logger.DEBUG, "Fired alert for source:" + source + " at alert level:" + Alert.alertLevels[alertLevel] + " on:" + attributeName + " for threshold level:" + Alert.thresholdLevels[thresholdLevel] + " at:" +  currentValue + " exceeding threshold of:" +thresholdValue + " next alert sent in:" + time + "secs");
152 >        _logger.write(toString(), Logger.DEBUG, "Fired alert for source:" + source + " at alert level:" + Alert.alertLevels[alertLevel] + " on:" + attributeName + " for threshold level:" + Alert.thresholdLevels[thresholdLevel] + " at:" +  currentValue + " exceeding threshold of:" +thresholdValue + " next alert sent in:" + timeout + "secs");
153      }
154  
155   //---ACCESSOR/MUTATOR METHODS---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines