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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/monitors/Services__Monitor.java (file contents):
Revision 1.2 by tdb, Wed Mar 14 23:25:29 2001 UTC vs.
Revision 1.3 by ajm, Thu Mar 22 17:57:06 2001 UTC

# Line 36 | Line 36 | public class Services__Monitor extends MonitorSkeleton
36   //---PUBLIC METHODS---
37  
38      public void analysePacket(XMLPacket packet) {
39 <        if (packet.getParam("packet.attributes.type").equals("heartbeat")) {
40 <            String source = packet.getParam("packet.attributes.machine_name");
41 <            if (!_hosts.containsKey(source)) {
42 <                _hosts.put(source, new HashMap());
43 <            }
44 <                        
45 <            HashMap serviceRegisters = (HashMap) _hosts.get(source);
46 <            
47 <            // a tempory holder for all the disk attributes we find
48 <            ArrayList services = new ArrayList();
49 <            
50 <            // unfortunatly we need to check the whole packet
51 <            // to find the disks, and then get the data attributes
52 <            Set packetSet = packet.getSet();
53 <            Iterator i = packetSet.iterator();
54 <            while (i.hasNext()) {
55 <                String dataKey = (String) i.next();
56 <                if(dataKey.startsWith("packet.services.")) {
57 <                    if(!services.contains(dataKey)) {
58 <                        String serviceType = "";
59 <            
60 <                        // pos is after "packet.services."
61 <                        int pos = 16;
62 <                        while (dataKey.charAt(pos) != '.') {
63 <                            serviceType = serviceType + dataKey.charAt(pos);
64 <                            pos++;
65 <                        }
66 <
67 <                         // add the service to our list, with the packet data                      
68 <                        services.add("packet.services." + serviceType + ".attributes.status");
69 <                        String status = packet.getParam("packet.services." + serviceType + ".attributes.status");
70 <                      
71 <                        services.add("packet.services." + serviceType + ".attributes.message");
72 <                        String message = packet.getParam("packet.services." + serviceType + ".attributes.message");
73 <        
74 <                        // *** now process this service ***
75 <                        
76 <                        // check if we've seen this service before on a previous run
77 <                        // if not, we need to create a register for it
78 <                        if(!serviceRegisters.containsKey(serviceType)) {
79 <                            serviceRegisters.put(serviceType, new Register(source, _name));
80 <                        }
39 >        String source = packet.getParam("packet.attributes.machine_name");
40 >        if (!_hosts.containsKey(source)) {
41 >            _hosts.put(source, new HashMap());
42 >        }
43  
44 <                        // get the register for this service
45 <                        Register reg = (Register) serviceRegisters.get(serviceType);
46 <                        
47 <                        
48 <                        // as we don't really have a threshold for services,
49 <                        // a temporary fix is to use the status value as a threshold.
50 <                        // after all, a 0 status is a NORMAL threshold ;)
51 <                        int newThreshold = 0;
52 <                        try {
53 <                            newThreshold = Integer.parseInt(status);
54 <                        } catch (NumberFormatException e) {
55 <                            _logger.write(this.toString(), Logger.WARNING, "Received heartbeat from "+source+" with bad service information: "+e);
56 <                            // don't try to continue and go try the next service
57 <                            break;
58 <                        }
59 <                                      
60 <                        // say which service it was
61 <                        String attributeName = serviceType + " service";
62 <                        String displayValue = "";
63 <                        if (newThreshold == 0) {
102 <                            displayValue = "RUNNING";
103 <                        } else {
104 <                            displayValue = "FAILED";
105 <                        }
106 <                                                
107 <                        processAlert(newThreshold, attributeName, reg, source, displayValue);
44 >        HashMap serviceRegisters = (HashMap) _hosts.get(source);
45 >
46 >        // a tempory holder for all the disk attributes we find
47 >        ArrayList services = new ArrayList();
48 >
49 >        // unfortunatly we need to check the whole packet
50 >        // to find the disks, and then get the data attributes
51 >        Set packetSet = packet.getSet();
52 >        Iterator i = packetSet.iterator();
53 >        while (i.hasNext()) {
54 >            String dataKey = (String) i.next();
55 >            if(dataKey.startsWith("packet.services.")) {
56 >                if(!services.contains(dataKey)) {
57 >                    String serviceType = "";
58 >
59 >                    // pos is after "packet.services."
60 >                    int pos = 16;
61 >                    while (dataKey.charAt(pos) != '.') {
62 >                        serviceType = serviceType + dataKey.charAt(pos);
63 >                        pos++;
64                      }
65 +
66 +                     // add the service to our list, with the packet data                      
67 +                    services.add("packet.services." + serviceType + ".attributes.status");
68 +                    String status = packet.getParam("packet.services." + serviceType + ".attributes.status");
69 +
70 +                    services.add("packet.services." + serviceType + ".attributes.message");
71 +                    String message = packet.getParam("packet.services." + serviceType + ".attributes.message");
72 +
73 +                    // *** now process this service ***
74 +
75 +                    // check if we've seen this service before on a previous run
76 +                    // if not, we need to create a register for it
77 +                    if(!serviceRegisters.containsKey(serviceType)) {
78 +                        serviceRegisters.put(serviceType, new Register(source, _name));
79 +                    }
80 +
81 +                    // get the register for this service
82 +                    Register reg = (Register) serviceRegisters.get(serviceType);
83 +
84 +
85 +                    // as we don't really have a threshold for services,
86 +                    // a temporary fix is to use the status value as a threshold.
87 +                    // after all, a 0 status is a NORMAL threshold ;)
88 +                    int newThreshold = 0;
89 +                    try {
90 +                        newThreshold = Integer.parseInt(status);
91 +                    } catch (NumberFormatException e) {
92 +                        _logger.write(this.toString(), Logger.WARNING, "Received heartbeat from "+source+" with bad service information: "+e);
93 +                        // don't try to continue and go try the next service
94 +                        break;
95 +                    }
96 +
97 +                    // say which service it was
98 +                    String attributeName = serviceType + " service";
99 +                    String displayValue = "";
100 +                    if (newThreshold == 0) {
101 +                        displayValue = "RUNNING";
102 +                    } else {
103 +                        displayValue = "FAILED";
104 +                    }
105 +
106 +                    processAlert(newThreshold, attributeName, reg, source, displayValue);
107                  }
108              }
109          }
# Line 137 | Line 135 | public class Services__Monitor extends MonitorSkeleton
135   //---PRIVATE METHODS---
136  
137   //---ACCESSOR/MUTATOR METHODS---
138 +
139 +    protected Queue getQueue() {
140 +        return MonitorManager.getInstance().getHeartbeatQueue();
141 +    }
142  
143   //---ATTRIBUTES---
144  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines