use of com.ibm.as400.access.AS400 in project openicf by Evolveum.
the class OS400Connector method init.
/**
* Callback method to receive the {@link Configuration}.
*
* @see Connector#init(org.identityconnectors.framework.spi.Configuration)
*/
public void init(Configuration configuration1) {
this.configuration = (OS400Configuration) configuration1;
if (as400 == null) {
try {
final StringBuilder clear = new StringBuilder();
GuardedString.Accessor accessor = new GuardedString.Accessor() {
public void access(char[] clearChars) {
clear.append(clearChars);
}
};
configuration.getPassword().access(accessor);
if (configuration.isSsl()) {
as400 = new SecureAS400(configuration.getHost(), configuration.getRemoteUser(), clear.toString());
} else {
as400 = new AS400(configuration.getHost(), configuration.getRemoteUser(), clear.toString());
}
clear.setLength(0);
if (as400 == null) {
throw new ConnectorException("Connection Exception");
}
if (!as400.validateSignon()) {
throw new ConnectorSecurityException("Login Error");
}
try {
as400.setGuiAvailable(false);
fetchPasswordLevel();
} catch (Exception e) {
}
} catch (AS400SecurityException e) {
throw new ConnectorSecurityException(e);
} catch (IOException e) {
throw new ConnectorIOException(e);
}
}
}
use of com.ibm.as400.access.AS400 in project nagios-for-i by IBM.
the class QWCRSSTS method run.
public final byte[] run(AS400 system, StringBuffer response) throws Exception {
final ProgramCall pgm = new ProgramCall(system, programName_, parameters_);
init(system);
if (!pgm.run()) {
AS400Message[] msgList = pgm.getMessageList();
response.append(Constants.retrieveDataError + " - ");
for (int i = 0; i < msgList.length; i++) {
response.append(msgList[i].getID() + ": " + msgList[i].getText() + "\n");
}
return null;
}
byte[] receiver = parameters_[0].getOutputData().clone();
errorCode_ = null;
parameters_ = null;
return receiver;
}
use of com.ibm.as400.access.AS400 in project nagios-for-i by IBM.
the class QYASPOL method collectData.
/*
* Performs the program call using the qyaspol API to gather the disk information. Adds gathered data to the
* appropriate list The number of records returned is 1 for each disk within the system
*/
private final boolean collectData(AS400 system, boolean firstTime, int receiverLength) throws Exception {
AS400Text text8 = null;
AS400Text text4 = null;
byte[] filterInfo = null;
byte[] sortInfo = null;
byte[] data = null;
byte[] listInfo = null;
try {
final ProgramCall pgm = new ProgramCall(system, programName_, parameters_);
final int ccsid = system.getCcsid();
text8 = new AS400Text(8, ccsid, system);
text4 = new AS400Text(4, ccsid, system);
filterInfo = new byte[16];
BinaryConverter.intToByteArray(16, filterInfo, 0);
BinaryConverter.intToByteArray(1, filterInfo, 4);
BinaryConverter.intToByteArray(4, filterInfo, 8);
BinaryConverter.intToByteArray(-1, filterInfo, 12);
sortInfo = new byte[16];
BinaryConverter.intToByteArray(16, filterInfo, 0);
BinaryConverter.intToByteArray(1, filterInfo, 4);
BinaryConverter.intToByteArray(4, filterInfo, 8);
BinaryConverter.intToByteArray(-1, filterInfo, 12);
parameters_[0].setOutputDataLength(receiverLength);
parameters_[1].setInputData(BinaryConverter.intToByteArray(receiverLength));
parameters_[5].setInputData(filterInfo);
parameters_[6].setInputData(text8.toBytes(formatName_));
parameters_[8].setInputData(sortInfo);
if (!pgm.run()) {
throw new AS400Exception(pgm.getMessageList());
}
data = parameters_[0].getOutputData();
listInfo = parameters_[2].getOutputData();
rcdsReturned_ = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(listInfo, 4)), 0);
int totalRcds = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(listInfo, 0)), 0);
int firstRecord = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(listInfo, 36)), 0);
rqsHandle_ = new byte[4];
System.arraycopy(listInfo, 8, rqsHandle_, 0, 4);
if (debug) {
System.out.println("QYASPOL300.collectData: Total Records:" + totalRcds);
System.out.println("QYASPOL300.collectData: Records Returned:" + rcdsReturned_);
System.out.println("QYASPOL300.collectData: First Record:" + firstRecord);
if ((firstRecord + rcdsReturned_ - 1) != totalRcds) {
System.out.println("QYASPOL300.collectData: Not all records were returned");
}
}
sCountNew.clear();
nbCountNew.clear();
rRequestsNew.clear();
wRequestsNew.clear();
aspNumber.clear();
diskNumber.clear();
diskType.clear();
diskCapacity.clear();
percUsed.clear();
diskAvailable.clear();
aspProType.clear();
unitStatus.clear();
if (!firstTime) {
for (int i = 0; i < rcdsReturned_; i++) {
// The receiver struct has a length of 96
int offset = i * rcdLength_;
// Sample Count -- 80
int sInt = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (80 + offset))), 0);
// Not Busy Count -- 84
int nbInt = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (84 + offset))), 0);
// ASP Number -- 0
int aspNum = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (0 + offset))), 0);
// Disk Number -- 32
int dNum = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (32 + offset))), 0);
// Read Requests -- 64
int rReq = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (64 + offset))), 0);
// Write Requests -- 68
int wReq = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (68 + offset))), 0);
// Disk Type -- 4
String dType = ((String) text4.toObject(data, (4 + offset))).trim();
// Disk Capacity -- 36
int dSize = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (36 + offset))), 0);
// Storage Available -- 40
int storAvail = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (40 + offset))), 0);
// Storage Reserved For System -- 44
int storReser = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (44 + offset))), 0);
// Baseline is established so now just update value
sCountNew.add(sInt);
nbCountNew.add(nbInt);
rRequestsNew.add(rReq);
wRequestsNew.add(wReq);
// No baseline needed so just gather data normally
aspNumSet.add(aspNum);
aspNumber.add(aspNum);
diskNumber.add(dNum);
diskType.add(dType);
diskCapacity.add(dSize);
diskAvailable.add(storAvail);
percUsed.add(calcPercentUsed(dSize, storAvail, storReser));
}
} else {
for (int i = 0; i < rcdsReturned_; i++) {
// The receiver struct has a length of 96
int offset = i * 96;
// Sample Count -- 80
int sInt = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (80 + offset))), 0);
// Not Busy Count -- 84
int nbInt = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (84 + offset))), 0);
// Read Requests -- 64
int rReq = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (64 + offset))), 0);
// Write Requests -- 68
int wReq = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(data, (68 + offset))), 0);
sCountBase.add(sInt);
nbCountBase.add(nbInt);
rRequestsBase.add(rReq);
wRequestsBase.add(wReq);
}
}
ProgramParameter[] parameters = new ProgramParameter[] { new ProgramParameter(rqsHandle_), new ProgramParameter(BinaryConverter.intToByteArray(0)) };
ProgramCall pc = new ProgramCall(system, "/QSYS.LIB/QGY.LIB/QGYCLST.PGM", parameters);
if (!pc.run()) {
throw new AS400Exception(pc.getMessageList());
}
return true;
} catch (Exception e) {
System.err.println("QYASPOL300.collectData: " + e.getMessage());
e.printStackTrace();
throw new Exception("QYASPOL300.collectData: " + e.getMessage());
} finally {
text8 = null;
text4 = null;
filterInfo = null;
sortInfo = null;
data = null;
listInfo = null;
rqsHandle_ = null;
errorCode_ = null;
parameters_ = null;
}
}
use of com.ibm.as400.access.AS400 in project nagios-for-i by IBM.
the class QYASPOL method getPCLength.
private final int getPCLength(AS400 system) throws Exception {
AS400Text text8 = null;
AS400Text text4 = null;
byte[] filterInfo = null;
byte[] sortInfo = null;
try {
final ProgramCall pgm = new ProgramCall(system, programName_, parameters_);
final int ccsid = system.getCcsid();
text8 = new AS400Text(8, ccsid, system);
text4 = new AS400Text(4, ccsid, system);
filterInfo = new byte[16];
BinaryConverter.intToByteArray(16, filterInfo, 0);
BinaryConverter.intToByteArray(1, filterInfo, 4);
BinaryConverter.intToByteArray(4, filterInfo, 8);
BinaryConverter.intToByteArray(-1, filterInfo, 12);
sortInfo = new byte[16];
BinaryConverter.intToByteArray(16, filterInfo, 0);
BinaryConverter.intToByteArray(1, filterInfo, 4);
BinaryConverter.intToByteArray(4, filterInfo, 8);
BinaryConverter.intToByteArray(-1, filterInfo, 12);
parameters_[0].setOutputDataLength(0);
parameters_[1].setInputData(BinaryConverter.intToByteArray(0));
parameters_[5].setInputData(filterInfo);
parameters_[6].setInputData(text8.toBytes(formatName_));
parameters_[8].setInputData(sortInfo);
if (!pgm.run()) {
throw new AS400Exception(pgm.getMessageList());
}
final byte[] listInfo = parameters_[2].getOutputData();
rcdsReturned_ = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(listInfo, 4)), 0);
rqsHandle_ = new byte[4];
System.arraycopy(listInfo, 8, rqsHandle_, 0, 4);
int totalRcds = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(listInfo, 0)), 0);
rcdLength_ = BinaryConverter.byteArrayToInt(text4.toBytes(text4.toObject(listInfo, 12)), 0);
int receiverLength = totalRcds * rcdLength_;
ProgramParameter[] parameters = new ProgramParameter[] { new ProgramParameter(rqsHandle_), new ProgramParameter(BinaryConverter.intToByteArray(0)) };
ProgramCall pc = new ProgramCall(system, "/QSYS.LIB/QGY.LIB/QGYCLST.PGM", parameters);
if (!pc.run()) {
throw new AS400Exception(pc.getMessageList());
}
return receiverLength;
} catch (Exception e) {
System.err.println("QYASPOL300.collectData: " + e.toString());
e.printStackTrace();
throw new Exception("QYASPOL300.getPCLength: " + e.toString());
} finally {
text8 = null;
text4 = null;
filterInfo = null;
sortInfo = null;
}
}
use of com.ibm.as400.access.AS400 in project nagios-for-i by IBM.
the class QYHCHCOP method init.
private final void init(AS400 system) throws Exception {
AS400Text reqText = null;
try {
final int ccsid = system.getCcsid();
int requestLen = requestInfo.length();
reqText = new AS400Text(requestLen, ccsid, system);
parameters_[REQUEST].setInputData(reqText.toBytes(requestInfo));
parameters_[REQUEST_LEN].setInputData(BinaryConverter.intToByteArray(requestInfo.length()));
parameters_[REQUEST_TYPE].setInputData(BinaryConverter.intToByteArray(2));
parameters_[RECEIVER].setOutputDataLength(OUTPUT_LENGTH);
parameters_[RECEIVER_LEN].setInputData(BinaryConverter.intToByteArray(OUTPUT_LENGTH));
parameters_[RETURN_DATA].setOutputDataLength(4);
parameters_[CCSID].setInputData(BinaryConverter.intToByteArray(0));
} catch (PropertyVetoException pve) {
System.err.println("QYHCHCOP.init: Error setting parameters: " + pve.toString());
} finally {
reqText = null;
}
}
Aggregations