Exemplo n.º 1
0
 public ServiceState(NAGIOSSTAT state) {
   currentState = state;
   previousState = state;
   if (state.equals(NAGIOSSTAT.CRITICAL) || state.equals(NAGIOSSTAT.WARNING)) {
     fsm = State.PROBLEM_HARD;
     previousFSM = State.PROBLEM_HARD;
   } else {
     fsm = State.OKAY_HARD;
     previousFSM = State.OKAY_HARD;
   }
 }
Exemplo n.º 2
0
 public ServiceState(NAGIOSSTAT state, int maxSoft) {
   this.maxSoft = maxSoft;
   currentState = state;
   previousState = state;
   if (state.equals(NAGIOSSTAT.CRITICAL) || state.equals(NAGIOSSTAT.WARNING)) {
     fsm = State.PROBLEM_HARD;
     previousFSM = State.PROBLEM_HARD;
   } else {
     fsm = State.OKAY_HARD;
     previousFSM = State.OKAY_HARD;
   }
   softCount = maxSoft;
 }
Exemplo n.º 3
0
  // TODO implement - also move laststatusstate json to the ServiceStateInf and implement in
  // abstract method!
  public ServiceState(JSONObject json) {
    this();
    if (json != null) {
      currentState = NAGIOSSTAT.valueOf(json.getString("state"));
      previousState = NAGIOSSTAT.valueOf(json.getString("previousState"));
      softCount = json.getInt("softCount");
      String typeOfState = json.getString("type");

      if (currentState.equals(NAGIOSSTAT.CRITICAL) || currentState.equals(NAGIOSSTAT.WARNING)) {

        if ("HARD".equals(typeOfState)) {
          fsm = State.PROBLEM_HARD;
          if (softCount != 0) {
            previousFSM = State.PROBLEM_SOFT;
          } else {
            previousFSM = State.PROBLEM_HARD;
          }
        } else {
          fsm = State.PROBLEM_SOFT;
          if (previousState.equals(NAGIOSSTAT.OK)) {
            previousFSM = State.OKAY_HARD;
          } else {
            previousFSM = State.PROBLEM_SOFT;
          }
        }
      } else if (previousState.equals(NAGIOSSTAT.CRITICAL)
          || previousState.equals(NAGIOSSTAT.WARNING)
          || previousState.equals(NAGIOSSTAT.UNKNOWN)) {

        if (currentState.equals(NAGIOSSTAT.OK)) {
          fsm = State.OKAY_HARD;
          if (softCount != 0) {
            previousFSM = State.PROBLEM_SOFT;
          } else {
            previousFSM = State.PROBLEM_HARD;
          }
        } else {
          if (("HARD".equals(typeOfState))) {
            fsm = State.PROBLEM_HARD;
          } else {
            fsm = State.PROBLEM_SOFT;
          }
        }
      } else {
        fsm = State.OKAY_HARD;
        previousFSM = State.OKAY_HARD;
      }
    }

    LOGGER.debug("Construct state {}", this.toString());
  }