Search in sources :

Example 1 with QYHCHCOP

use of com.ibm.nagios.util.QYHCHCOP in project nagios-for-i by IBM.

the class DiskConfig method execute.

public int execute(AS400 as400, Map<String, String> args, StringBuffer response) {
    int returnValue = Constants.UNKNOWN;
    String system = args.get("-H");
    String userID = HostConfigInfo.getSSTUserID(system);
    String pass = HostConfigInfo.getSSTPassword(system);
    if (userID == null || pass == null) {
        response.append("SST user profile not set");
        return returnValue;
    }
    int userLen = userID.length();
    String password = Base64Coder.decodeString(pass);
    int passLen = password.length();
    final int ccsid = as400.getCcsid();
    QYHCHCOP pgmCall = null;
    AS400Text userText = new AS400Text(userLen, ccsid, as400);
    AS400Text passText = new AS400Text(passLen, ccsid, as400);
    try {
        pgmCall = new QYHCHCOP();
        pgmCall.setParameter(pgmCall.USER_ID, userText.toBytes(userID));
        pgmCall.setParameter(pgmCall.USER_ID_LEN, BinaryConverter.intToByteArray(userLen));
        pgmCall.setParameter(pgmCall.PASSWORD, passText.toBytes(password));
        pgmCall.setParameter(pgmCall.PASSWOD_LEN, BinaryConverter.intToByteArray(passLen));
        String receiver = pgmCall.run(as400, response);
        if (receiver == null) {
            return returnValue;
        }
        ArrayList<Disk> disks = DiskXMLReader.getDiskConfigInfo(receiver.trim());
        int ASPNum;
        int unitNum;
        String resourceName = null;
        int status;
        int warningStatus = 0;
        returnValue = Constants.OK;
        for (int i = 0; i < disks.size(); i++) {
            Disk disk = disks.get(i);
            ASPNum = disk.getASPNum();
            unitNum = disk.getDiskNum();
            resourceName = disk.getResourceName();
            status = disk.getStatus();
            if (status != Hardware_OK && returnValue != Constants.WARN) {
                returnValue = Constants.WARN;
                warningStatus = status;
            }
            response.append("Unit " + ASPNum + "-" + unitNum + ": " + resourceName + " Status: " + STATUS[status] + "\n");
        }
        if (returnValue == Constants.OK) {
            response.insert(0, "Disk Status: OK\n");
        } else if (returnValue == Constants.WARN) {
            response.insert(0, "Disk Status: " + STATUS[warningStatus] + "\n");
        }
    } catch (Exception e) {
        response.setLength(0);
        response.append(Constants.retrieveDataException + " - " + e.toString());
        CommonUtil.printStack(e.getStackTrace(), response);
        e.printStackTrace();
    } finally {
        userText = null;
        passText = null;
        pgmCall = null;
    }
    return returnValue;
}
Also used : AS400Text(com.ibm.as400.access.AS400Text) QYHCHCOP(com.ibm.nagios.util.QYHCHCOP) Disk(com.ibm.nagios.model.Disk)

Aggregations

AS400Text (com.ibm.as400.access.AS400Text)1 Disk (com.ibm.nagios.model.Disk)1 QYHCHCOP (com.ibm.nagios.util.QYHCHCOP)1