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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/monitors/Disk__Monitor.java (file contents):
Revision 1.12 by tdb, Wed Nov 7 17:55:40 2001 UTC vs.
Revision 1.18 by tdb, Wed Feb 5 16:43:45 2003 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
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.monitors;
23  
# Line 9 | Line 29 | import java.util.Iterator;
29   import java.text.NumberFormat;
30   import uk.org.iscream.cms.server.client.*;
31   import uk.org.iscream.cms.server.core.*;
32 < import uk.org.iscream.cms.server.util.*;
32 > import uk.org.iscream.cms.util.*;
33   import uk.org.iscream.cms.server.componentmanager.*;
34  
35   /**
# Line 99 | Line 119 | public class Disk__Monitor extends MonitorSkeleton {
119  
120                      // check if we've seen this disk before on a previous run
121                      // if not, we need to create a register for it
122 <                    //   nb. use the device as the key as this is unlikely to change,
122 >                    //   nb. use the mount as the key as this is unlikely to change,
123                      //       unlike diskNumber which could easily change
124                      //         (diskNumber is based on the order of df's output!)
125 <                    if(!diskRegisters.containsKey(device)) {
126 <                        diskRegisters.put(device, new Register(source, _name, mount));
125 >                    if(!diskRegisters.containsKey(mount)) {
126 >                        diskRegisters.put(mount, new Register(source, _name, mount));
127                      }
128  
129                      // get the register for this disk
130 <                    Register reg = (Register) diskRegisters.get(device);
130 >                    Register reg = (Register) diskRegisters.get(mount);
131  
132                      // get the packet data
133                      double diskTotal, diskAvail;
# Line 126 | Line 146 | public class Disk__Monitor extends MonitorSkeleton {
146  
147                      boolean useValue = false;
148                      try {
149 <                        String option = _cp.getProperty("Host." + source, "Monitor." + _name + ".thresholdMeasure");
149 >                        // try looking for a mount-point specific thresholdMeasure first
150 >                        String option = _cp.getProperty("Host." + source, "Monitor." + _name + "." + mount + ".thresholdMeasure");
151                          if (option.equals("VALUE")) {
152                              useValue = true;
153 <                        }                            
153 >                        }
154                      } catch (PropertyNotFoundException e) {
155 <                        // we default to percentage
155 >                        try {
156 >                            // now look for a more general thresholdMeasure
157 >                            String option = _cp.getProperty("Host." + source, "Monitor." + _name + ".thresholdMeasure");
158 >                            if (option.equals("VALUE")) {
159 >                                useValue = true;
160 >                            }
161 >                        } catch (PropertyNotFoundException f) {
162 >                            // we default to percentage in any case
163 >                        }
164                      }
165  
166                      // this  bit determines if the disk check is a % check
# Line 172 | Line 201 | public class Disk__Monitor extends MonitorSkeleton {
201       * Overrides the {@link java.lang.Object#toString() Object.toString()}
202       * method to provide clean logging (every class should have this).
203       *
204 <     * This uses the uk.org.iscream.cms.server.util.NameFormat class
204 >     * This uses the uk.org.iscream.cms.util.NameFormat class
205       * to format the toString()
206       *
207       * @return the name of this class and its CVS revision
# Line 207 | Line 236 | public class Disk__Monitor extends MonitorSkeleton {
236       * @param negateCheck whether to negate the check
237       * @return the threshold level breached, if any
238       */
239 <    private int checkAttributeThreshold(double diskInUse, Register reg, boolean negateCheck) {
239 >    private int checkAttributeThreshold(double value, Register reg, boolean negateCheck) {
240          for(int thresholdLevel = Alert.thresholdLevels.length - 1; thresholdLevel >= 0; thresholdLevel--) {
241              if (reg.getThreshold(thresholdLevel) != -1.0) {
242                  if(!negateCheck) {
243                      // normal check - has the value gone *over* the threshold
244 <                    if(((double) reg.getThreshold(thresholdLevel)) < diskInUse) {
244 >                    if(((double) reg.getThreshold(thresholdLevel)) < value) {
245                          return thresholdLevel;
246                      }
247                  }
248                  else {
249                      // negated check - has the value gone *under* the threshold
250 <                    if(((double) reg.getThreshold(thresholdLevel)) > diskInUse) {
250 >                    if(((double) reg.getThreshold(thresholdLevel)) > value) {
251                          return thresholdLevel;
252                      }
253                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines