Added logging of the database or service name for the LongDelta logs.
Showing
4 changed files
with
22 additions
and
16 deletions
No preview for this file type
| ... | @@ -12,12 +12,17 @@ import java.util.Calendar; | ... | @@ -12,12 +12,17 @@ import java.util.Calendar; |
| 12 | class Collector { | 12 | class Collector { |
| 13 | ArrayList<LongDelta> list = new ArrayList<LongDelta>(); | 13 | ArrayList<LongDelta> list = new ArrayList<LongDelta>(); |
| 14 | String name = ""; | 14 | String name = ""; |
| 15 | String dbname = null; | ||
| 15 | Boolean debugLog = false; | 16 | Boolean debugLog = false; |
| 16 | 17 | ||
| 17 | public Collector(String name) { | 18 | public Collector(String name) { |
| 18 | this.name = name; | 19 | this.name = name; |
| 19 | } | 20 | } |
| 20 | 21 | ||
| 22 | public void setDBName(String name) { | ||
| 23 | if (this.dbname == null) this.dbname = name; | ||
| 24 | } | ||
| 25 | |||
| 21 | public void update(ResultSet rset) throws Throwable { | 26 | public void update(ResultSet rset) throws Throwable { |
| 22 | String timeStamp = null; | 27 | String timeStamp = null; |
| 23 | BufferedWriter writer = null; | 28 | BufferedWriter writer = null; |
| ... | @@ -60,6 +65,7 @@ class Collector { | ... | @@ -60,6 +65,7 @@ class Collector { |
| 60 | myDelta.update(value, timestamp); | 65 | myDelta.update(value, timestamp); |
| 61 | } else { | 66 | } else { |
| 62 | myDelta = new LongDelta(name); | 67 | myDelta = new LongDelta(name); |
| 68 | myDelta.setDBName(dbname); | ||
| 63 | myDelta.update(value, timestamp); | 69 | myDelta.update(value, timestamp); |
| 64 | list.add(myDelta); | 70 | list.add(myDelta); |
| 65 | } | 71 | } |
| ... | @@ -78,19 +84,6 @@ class Collector { | ... | @@ -78,19 +84,6 @@ class Collector { |
| 78 | return 0; | 84 | return 0; |
| 79 | } | 85 | } |
| 80 | 86 | ||
| 81 | // public long getDelta(String name) throws Throwable { | ||
| 82 | // LongDelta myDelta = null; | ||
| 83 | // for(int x = 0; x<list.size() && myDelta == null; x++) { | ||
| 84 | // if(list.get(x).matches(name)) { | ||
| 85 | // myDelta = list.get(x); | ||
| 86 | // } | ||
| 87 | // } | ||
| 88 | // if(myDelta != null) | ||
| 89 | // return myDelta.getDelta(); | ||
| 90 | // else | ||
| 91 | // return 0; | ||
| 92 | // } | ||
| 93 | |||
| 94 | public double getPerSecValue(String name) throws Throwable { | 87 | public double getPerSecValue(String name) throws Throwable { |
| 95 | LongDelta myDelta = null; | 88 | LongDelta myDelta = null; |
| 96 | for(int x = 0; x<list.size() && myDelta == null; x++) { | 89 | for(int x = 0; x<list.size() && myDelta == null; x++) { | ... | ... |
| ... | @@ -9,6 +9,7 @@ import java.util.logging.Logger; | ... | @@ -9,6 +9,7 @@ import java.util.logging.Logger; |
| 9 | class LongDelta { | 9 | class LongDelta { |
| 10 | private final static Logger LOGGER = Logger.getLogger(LongDelta.class.getName()); | 10 | private final static Logger LOGGER = Logger.getLogger(LongDelta.class.getName()); |
| 11 | private String name = null; | 11 | private String name = null; |
| 12 | private String dbname = null; | ||
| 12 | 13 | ||
| 13 | private BigDecimal curValue = null; | 14 | private BigDecimal curValue = null; |
| 14 | private BigDecimal lastValue = null; | 15 | private BigDecimal lastValue = null; |
| ... | @@ -27,9 +28,12 @@ class LongDelta { | ... | @@ -27,9 +28,12 @@ class LongDelta { |
| 27 | private boolean haveGoodDelta = false; | 28 | private boolean haveGoodDelta = false; |
| 28 | 29 | ||
| 29 | public LongDelta(String name) { | 30 | public LongDelta(String name) { |
| 30 | this.name = name; | 31 | if(this.dbname == null) this.name = name; |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 34 | public void setDBName(String name) { | ||
| 35 | this.dbname = name; | ||
| 36 | } | ||
| 33 | public void update(ResultSet rset) throws Throwable{ | 37 | public void update(ResultSet rset) throws Throwable{ |
| 34 | update(rset, 2, false, true); | 38 | update(rset, 2, false, true); |
| 35 | } | 39 | } |
| ... | @@ -96,13 +100,13 @@ class LongDelta { | ... | @@ -96,13 +100,13 @@ class LongDelta { |
| 96 | delta = this.curValue.subtract(this.lastValue).doubleValue(); | 100 | delta = this.curValue.subtract(this.lastValue).doubleValue(); |
| 97 | lastGoodMilliseconds = numMilliSeconds; | 101 | lastGoodMilliseconds = numMilliSeconds; |
| 98 | lastGoodDelta = delta; | 102 | lastGoodDelta = delta; |
| 99 | LOGGER.log(Level.WARNING, "Too high value detected (last printed value), causing an incorrect (too high) delta reported 3 measurements ago. Name: " | 103 | LOGGER.log(Level.WARNING, dbname + ": Too high historical value detected. Name: " |
| 100 | + this.name + " Values:["+curValue+"]["+lastValue+"]["+last2Value+"]"); | 104 | + this.name + " Values:["+curValue+"]["+lastValue+"]["+last2Value+"]"); |
| 101 | } else { | 105 | } else { |
| 102 | // Unhandled situation. Return cached delta. | 106 | // Unhandled situation. Return cached delta. |
| 103 | numMilliSeconds = lastGoodMilliseconds; | 107 | numMilliSeconds = lastGoodMilliseconds; |
| 104 | delta = lastGoodDelta; | 108 | delta = lastGoodDelta; |
| 105 | LOGGER.log(Level.WARNING, "No deltas to calculate, returning cached value:["+lastGoodDelta+"]. Name: " | 109 | LOGGER.log(Level.WARNING, dbname + ": No deltas to calculate, returning cached value:["+lastGoodDelta+"]. Name: " |
| 106 | + this.name + " Values:["+curValue+"]["+lastValue+"]["+last2Value+"]"); | 110 | + this.name + " Values:["+curValue+"]["+lastValue+"]["+last2Value+"]"); |
| 107 | } | 111 | } |
| 108 | 112 | ... | ... |
| ... | @@ -374,6 +374,13 @@ public class OraMon { | ... | @@ -374,6 +374,13 @@ public class OraMon { |
| 374 | rset.close(); | 374 | rset.close(); |
| 375 | } | 375 | } |
| 376 | 376 | ||
| 377 | //Set the database name or service name in the collectors and single deltas (for logging) | ||
| 378 | String tname = getFriendlyName(); | ||
| 379 | colOsStat.setDBName(tname); | ||
| 380 | colSysStat.setDBName(tname); | ||
| 381 | cpuTime.setDBName(tname); | ||
| 382 | niwTime.setDBName(tname); | ||
| 383 | |||
| 377 | // All other cases (CDB or an instance without containers) get the data from the database | 384 | // All other cases (CDB or an instance without containers) get the data from the database |
| 378 | 385 | ||
| 379 | //Get the entire V_$OSSTAT table from DB | 386 | //Get the entire V_$OSSTAT table from DB |
| ... | @@ -399,6 +406,7 @@ public class OraMon { | ... | @@ -399,6 +406,7 @@ public class OraMon { |
| 399 | if(getPdbs) { | 406 | if(getPdbs) { |
| 400 | //CPU | 407 | //CPU |
| 401 | if(colPdbCPU == null) colPdbCPU = new Collector("colPdbCPU"); | 408 | if(colPdbCPU == null) colPdbCPU = new Collector("colPdbCPU"); |
| 409 | colPdbCPU.setDBName(tname); | ||
| 402 | rset = stmt.executeQuery("select systimestamp, c.NAME, s.value as NIWT, t.value as DBCPU from V$CON_SYSSTAT s, V$CON_SYS_TIME_MODEL t, V$CONTAINERS c where s.CON_ID=t.CON_ID and s.CON_ID=c.CON_ID and s.name='non-idle wait time' and t.STAT_NAME='DB CPU'"); | 410 | rset = stmt.executeQuery("select systimestamp, c.NAME, s.value as NIWT, t.value as DBCPU from V$CON_SYSSTAT s, V$CON_SYS_TIME_MODEL t, V$CONTAINERS c where s.CON_ID=t.CON_ID and s.CON_ID=c.CON_ID and s.name='non-idle wait time' and t.STAT_NAME='DB CPU'"); |
| 403 | while(rset.next()) { | 411 | while(rset.next()) { |
| 404 | Timestamp ts = rset.getTimestamp(1); | 412 | Timestamp ts = rset.getTimestamp(1); |
| ... | @@ -412,6 +420,7 @@ public class OraMon { | ... | @@ -412,6 +420,7 @@ public class OraMon { |
| 412 | 420 | ||
| 413 | //SYSSTATS | 421 | //SYSSTATS |
| 414 | if(colPdbSysStat == null) colPdbSysStat = new Collector("colPdbSysStat"); | 422 | if(colPdbSysStat == null) colPdbSysStat = new Collector("colPdbSysStat"); |
| 423 | colPdbSysStat.setDBName(tname); | ||
| 415 | colPdbSysStat.update(stmt.executeQuery("select systimestamp, c.NAME || '" + strSeparator + "' || s.name, s.value from V$CON_SYSSTAT s, V$CONTAINERS c where s.CON_ID=c.CON_ID")); | 424 | colPdbSysStat.update(stmt.executeQuery("select systimestamp, c.NAME || '" + strSeparator + "' || s.name, s.value from V$CON_SYSSTAT s, V$CONTAINERS c where s.CON_ID=c.CON_ID")); |
| 416 | } | 425 | } |
| 417 | 426 | ... | ... |
-
Please register or sign in to post a comment