Commit 7ec575e1 7ec575e16ca762570d7f679ddb5985c28c4e6958 by Christian Gerdes

Added logging of the database or service name for the LongDelta logs.

1 parent 549ae858
......@@ -12,12 +12,17 @@ import java.util.Calendar;
class Collector {
ArrayList<LongDelta> list = new ArrayList<LongDelta>();
String name = "";
String dbname = null;
Boolean debugLog = false;
public Collector(String name) {
this.name = name;
}
public void setDBName(String name) {
if (this.dbname == null) this.dbname = name;
}
public void update(ResultSet rset) throws Throwable {
String timeStamp = null;
BufferedWriter writer = null;
......@@ -60,6 +65,7 @@ class Collector {
myDelta.update(value, timestamp);
} else {
myDelta = new LongDelta(name);
myDelta.setDBName(dbname);
myDelta.update(value, timestamp);
list.add(myDelta);
}
......@@ -78,19 +84,6 @@ class Collector {
return 0;
}
// public long getDelta(String name) throws Throwable {
// LongDelta myDelta = null;
// for(int x = 0; x<list.size() && myDelta == null; x++) {
// if(list.get(x).matches(name)) {
// myDelta = list.get(x);
// }
// }
// if(myDelta != null)
// return myDelta.getDelta();
// else
// return 0;
// }
public double getPerSecValue(String name) throws Throwable {
LongDelta myDelta = null;
for(int x = 0; x<list.size() && myDelta == null; x++) {
......
......@@ -9,6 +9,7 @@ import java.util.logging.Logger;
class LongDelta {
private final static Logger LOGGER = Logger.getLogger(LongDelta.class.getName());
private String name = null;
private String dbname = null;
private BigDecimal curValue = null;
private BigDecimal lastValue = null;
......@@ -27,9 +28,12 @@ class LongDelta {
private boolean haveGoodDelta = false;
public LongDelta(String name) {
this.name = name;
if(this.dbname == null) this.name = name;
}
public void setDBName(String name) {
this.dbname = name;
}
public void update(ResultSet rset) throws Throwable{
update(rset, 2, false, true);
}
......@@ -96,13 +100,13 @@ class LongDelta {
delta = this.curValue.subtract(this.lastValue).doubleValue();
lastGoodMilliseconds = numMilliSeconds;
lastGoodDelta = delta;
LOGGER.log(Level.WARNING, "Too high value detected (last printed value), causing an incorrect (too high) delta reported 3 measurements ago. Name: "
LOGGER.log(Level.WARNING, dbname + ": Too high historical value detected. Name: "
+ this.name + " Values:["+curValue+"]["+lastValue+"]["+last2Value+"]");
} else {
// Unhandled situation. Return cached delta.
numMilliSeconds = lastGoodMilliseconds;
delta = lastGoodDelta;
LOGGER.log(Level.WARNING, "No deltas to calculate, returning cached value:["+lastGoodDelta+"]. Name: "
LOGGER.log(Level.WARNING, dbname + ": No deltas to calculate, returning cached value:["+lastGoodDelta+"]. Name: "
+ this.name + " Values:["+curValue+"]["+lastValue+"]["+last2Value+"]");
}
......
......@@ -374,6 +374,13 @@ public class OraMon {
rset.close();
}
//Set the database name or service name in the collectors and single deltas (for logging)
String tname = getFriendlyName();
colOsStat.setDBName(tname);
colSysStat.setDBName(tname);
cpuTime.setDBName(tname);
niwTime.setDBName(tname);
// All other cases (CDB or an instance without containers) get the data from the database
//Get the entire V_$OSSTAT table from DB
......@@ -399,6 +406,7 @@ public class OraMon {
if(getPdbs) {
//CPU
if(colPdbCPU == null) colPdbCPU = new Collector("colPdbCPU");
colPdbCPU.setDBName(tname);
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'");
while(rset.next()) {
Timestamp ts = rset.getTimestamp(1);
......@@ -412,6 +420,7 @@ public class OraMon {
//SYSSTATS
if(colPdbSysStat == null) colPdbSysStat = new Collector("colPdbSysStat");
colPdbSysStat.setDBName(tname);
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"));
}
......