2012-07-09 20:32:02 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
|
|
|
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-07-03 10:39:17 +02:00
|
|
|
#include "i2-cib.h"
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
|
|
|
bool ServiceStatusMessage::GetService(string *service) const
|
|
|
|
{
|
2012-07-09 16:19:56 +02:00
|
|
|
return Get("service", service);
|
2012-07-03 10:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceStatusMessage::SetService(const string& service)
|
|
|
|
{
|
2012-07-09 16:19:56 +02:00
|
|
|
Set("service", service);
|
2012-07-03 10:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ServiceStatusMessage::GetState(ServiceState *state) const
|
|
|
|
{
|
|
|
|
long value;
|
2012-07-09 16:19:56 +02:00
|
|
|
if (Get("state", &value)) {
|
2012-07-03 10:39:17 +02:00
|
|
|
*state = static_cast<ServiceState>(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceStatusMessage::SetState(ServiceState state)
|
|
|
|
{
|
2012-07-09 16:19:56 +02:00
|
|
|
Set("state", static_cast<long>(state));
|
2012-07-03 10:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const
|
|
|
|
{
|
|
|
|
long value;
|
2012-07-09 16:19:56 +02:00
|
|
|
if (Get("state_type", &value)) {
|
2012-07-03 10:39:17 +02:00
|
|
|
*type = static_cast<ServiceStateType>(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceStatusMessage::SetStateType(ServiceStateType type)
|
|
|
|
{
|
2012-07-09 16:19:56 +02:00
|
|
|
Set("state_type", static_cast<long>(type));
|
2012-07-03 10:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ServiceStatusMessage::GetCurrentCheckAttempt(long *attempt) const
|
|
|
|
{
|
2012-07-09 16:19:56 +02:00
|
|
|
return Get("current_attempt", attempt);
|
2012-07-03 10:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceStatusMessage::SetCurrentCheckAttempt(long attempt)
|
|
|
|
{
|
2012-07-09 16:19:56 +02:00
|
|
|
Set("current_attempt", attempt);
|
2012-07-03 10:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ServiceStatusMessage::GetNextCheck(time_t *ts) const
|
|
|
|
{
|
|
|
|
long value;
|
2012-07-09 16:19:56 +02:00
|
|
|
if (Get("next_check", &value)) {
|
2012-07-03 10:39:17 +02:00
|
|
|
*ts = value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceStatusMessage::SetNextCheck(time_t ts)
|
|
|
|
{
|
2012-07-09 16:19:56 +02:00
|
|
|
Set("next_check", static_cast<long>(ts));
|
2012-07-03 10:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
|
|
|
|
{
|
|
|
|
Dictionary::Ptr obj;
|
2012-07-09 16:19:56 +02:00
|
|
|
if (Get("result", &obj)) {
|
2012-07-03 10:39:17 +02:00
|
|
|
*cr = CheckResult(MessagePart(obj));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceStatusMessage::SetCheckResult(CheckResult cr)
|
|
|
|
{
|
2012-07-09 16:19:56 +02:00
|
|
|
Set("result", cr.GetDictionary());
|
|
|
|
}
|