in code/src/main/java/DataProviderSMON.java [389:485]
public void getSMONJobData() throws JCoException
{
System.out.println("Executing RFC '/SDF/SMON_ANALYSIS_READ'...");
final JCoDestination destination = JCoDestinationManager.getDestination(config.destination_name);
if (function_read == null) {
function_read = destination.getRepository().getFunction("/SDF/SMON_ANALYSIS_READ");
} else {
System.out.println("Use function definition from cache...");
}
if (function_read == null) {
throw new RuntimeException("RFC '/SDF/SMON_ANALYSIS_READ' not found! Check the SAP user authorization and required SAP release!");
}
//START IMPORT PARAMETERS
final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
final Calendar cal = Calendar.getInstance();
cal.setTime(config.system_date);
String end_time = sdf.format(cal.getTime());
cal.add(Calendar.MINUTE, -frequency);
String start_time = sdf.format(cal.getTime());
//MAKE SURE START TIME < END TIME
if (Utils.startAfterEndTime(start_time,end_time)) {
start_time = "00:00:01";
System.out.println("Time adjusted!");
}
SimpleDateFormat de_formatter = new SimpleDateFormat("dd.MM.yyyy");
System.out.println("-> GUID: " + config.guid);
System.out.println("-> DATUM: " + de_formatter.format(config.system_date));
System.out.println("-> START_TIME: " + start_time);
System.out.println("-> END_TIME: " + end_time);
function_read.getImportParameterList().setValue("GUID", config.guid);
function_read.getImportParameterList().setValue("DATUM", config.system_date);
function_read.getImportParameterList().setValue("START_TIME", start_time); //min "00:00:01"
function_read.getImportParameterList().setValue("END_TIME", end_time); //max "23:59:00"
//END IMPORT PARAMETERS
final long startTime = System.currentTimeMillis();
try {
function_read.execute(destination);
//reportUptime(true);
} catch (final AbapException e) {
System.out.println(e.toString());
//reportUptime(false);
throw new RuntimeException("Connection lost: " + e.toString());
}
final long stopTime = System.currentTimeMillis();
final long elapsedTime = stopTime - startTime;
System.out.println("PING: " + elapsedTime + " ms");
System.out.println("RFC '/SDF/SMON_ANALYSIS_READ' finished!");
final JCoTable result = function_read.getTableParameterList().getTable("HEADER");
reportPing(config.destination_name, elapsedTime);
final Integer monresult = result.getNumRows();
System.out.println("/SDF/SMON Result Set: " + monresult);
System.out.println();
if(config.debug)
System.out.println(result.toXML());
for (int i = 0; i < monresult; i++) {
result.setRow(i);
final String SERVER = result.getString("SERVER");
if (SERVER != "") {
final JCoFieldIterator iter = result.getFieldIterator();
while (iter.hasNextField()) {
final JCoField f = iter.nextField();
final String NAME = f.getName();
final Object VALUE = result.getValue(f.getName());
reportResult(SERVER, NAME, VALUE);
}
}
}
if (monresult == 0) {
System.out.println("Clearing guid from cache!");
config.guid = null;
throw new RuntimeException("No measurements found! Check if job is still running and timezones match!");
}
utils.submitResultsEmbedded("/SDF/SMON");
}