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-06-13 13:42:55 +02:00
|
|
|
#ifndef SERVICE_H
|
|
|
|
#define SERVICE_H
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2012-06-25 15:42:46 +02:00
|
|
|
enum ServiceState
|
|
|
|
{
|
|
|
|
StateOK,
|
|
|
|
StateWarning,
|
|
|
|
StateCritical,
|
2012-06-27 18:43:34 +02:00
|
|
|
StateUnknown,
|
2012-06-25 15:42:46 +02:00
|
|
|
StateUncheckable,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ServiceStateType
|
|
|
|
{
|
2012-06-27 18:43:34 +02:00
|
|
|
StateTypeSoft,
|
|
|
|
StateTypeHard
|
2012-06-25 15:42:46 +02:00
|
|
|
};
|
|
|
|
|
2012-07-01 13:21:49 +02:00
|
|
|
class CheckResult;
|
2012-07-03 14:18:46 +02:00
|
|
|
class ServiceStatusMessage;
|
2012-06-25 14:13:24 +02:00
|
|
|
|
2012-07-02 19:09:45 +02:00
|
|
|
class I2_CIB_API Service : public ConfigObjectAdapter
|
2012-06-13 13:42:55 +02:00
|
|
|
{
|
|
|
|
public:
|
2012-07-09 17:07:20 +02:00
|
|
|
Service(const ConfigObject::Ptr& configObject);
|
2012-06-13 13:42:55 +02:00
|
|
|
|
2012-06-30 13:39:55 +02:00
|
|
|
static bool Exists(const string& name);
|
2012-06-29 14:14:51 +02:00
|
|
|
static Service GetByName(const string& name);
|
2012-06-27 18:43:34 +02:00
|
|
|
|
2012-06-28 14:24:41 +02:00
|
|
|
string GetAlias(void) const;
|
2012-06-13 13:42:55 +02:00
|
|
|
Host GetHost(void) const;
|
|
|
|
Dictionary::Ptr GetMacros(void) const;
|
|
|
|
string GetCheckCommand(void) const;
|
|
|
|
long GetMaxCheckAttempts(void) const;
|
|
|
|
long GetCheckInterval(void) const;
|
|
|
|
long GetRetryInterval(void) const;
|
2012-06-27 18:43:34 +02:00
|
|
|
Dictionary::Ptr GetDependencies(void) const;
|
2012-07-09 10:09:53 +02:00
|
|
|
void GetDependenciesRecursive(const Dictionary::Ptr& result) const;
|
2012-06-30 13:39:55 +02:00
|
|
|
Dictionary::Ptr GetGroups(void) const;
|
2012-07-02 16:19:43 +02:00
|
|
|
Dictionary::Ptr GetCheckers(void) const;
|
2012-06-14 11:18:20 +02:00
|
|
|
|
2012-07-03 15:11:11 +02:00
|
|
|
bool IsReachable(void) const;
|
2012-07-03 14:18:46 +02:00
|
|
|
|
2012-06-14 11:18:20 +02:00
|
|
|
void SetNextCheck(time_t nextCheck);
|
2012-06-18 02:03:24 +02:00
|
|
|
time_t GetNextCheck(void);
|
2012-06-27 18:43:34 +02:00
|
|
|
void UpdateNextCheck(void);
|
2012-06-25 15:42:46 +02:00
|
|
|
|
2012-06-29 14:14:51 +02:00
|
|
|
void SetChecker(const string& checker);
|
2012-06-16 20:44:24 +02:00
|
|
|
string GetChecker(void) const;
|
2012-06-25 14:13:24 +02:00
|
|
|
|
2012-06-29 14:14:51 +02:00
|
|
|
bool IsAllowedChecker(const string& checker) const;
|
2012-06-27 18:43:34 +02:00
|
|
|
|
2012-06-25 15:42:46 +02:00
|
|
|
void SetCurrentCheckAttempt(long attempt);
|
|
|
|
long GetCurrentCheckAttempt(void) const;
|
|
|
|
|
|
|
|
void SetState(ServiceState state);
|
|
|
|
ServiceState GetState(void) const;
|
|
|
|
|
|
|
|
void SetStateType(ServiceStateType type);
|
|
|
|
ServiceStateType GetStateType(void) const;
|
|
|
|
|
2012-07-03 14:18:46 +02:00
|
|
|
bool HasLastCheckResult(void) const;
|
|
|
|
void SetLastCheckResult(const CheckResult& result);
|
|
|
|
CheckResult GetLastCheckResult(void) const;
|
2012-06-27 18:43:34 +02:00
|
|
|
|
|
|
|
void SetLastStateChange(time_t ts);
|
|
|
|
time_t GetLastStateChange(void) const;
|
|
|
|
|
|
|
|
void SetLastHardStateChange(time_t ts);
|
|
|
|
time_t GetLastHardStateChange(void) const;
|
|
|
|
|
2012-06-25 14:13:24 +02:00
|
|
|
void ApplyCheckResult(const CheckResult& cr);
|
2012-06-27 18:43:34 +02:00
|
|
|
|
2012-06-29 14:14:51 +02:00
|
|
|
static ServiceState StateFromString(const string& state);
|
2012-06-27 18:43:34 +02:00
|
|
|
static string StateToString(ServiceState state);
|
|
|
|
|
2012-06-29 14:14:51 +02:00
|
|
|
static ServiceStateType StateTypeFromString(const string& state);
|
2012-06-27 18:43:34 +02:00
|
|
|
static string StateTypeToString(ServiceStateType state);
|
2012-07-03 14:18:46 +02:00
|
|
|
|
2012-07-09 10:09:53 +02:00
|
|
|
static Dictionary::Ptr ResolveDependencies(Host host, const Dictionary::Ptr& dependencies);
|
2012-06-13 13:42:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-16 20:44:24 +02:00
|
|
|
#endif /* SERVICE_H */
|