Esempio n. 1
0
int CompatUtility::GetCheckableIsVolatile(const Checkable::Ptr& checkable)
{
	return (checkable->GetVolatile() ? 1 : 0);
}
Esempio n. 2
0
double CompatUtility::GetCheckablePercentStateChange(const Checkable::Ptr& checkable)
{
	return checkable->GetFlappingCurrent();
}
Esempio n. 3
0
int CompatUtility::GetCheckableProcessPerformanceData(const Checkable::Ptr& checkable)
{
	return (checkable->GetEnablePerfdata() ? 1 : 0);
}
Esempio n. 4
0
int CompatUtility::GetCheckableIsFlapping(const Checkable::Ptr& checkable)
{
	return (checkable->IsFlapping() ? 1 : 0);
}
Esempio n. 5
0
int CompatUtility::GetCheckableIsReachable(const Checkable::Ptr& checkable)
{
	return (checkable->IsReachable() ? 1 : 0);
}
Esempio n. 6
0
int CompatUtility::GetCheckableEventHandlerEnabled(const Checkable::Ptr& checkable)
{
	return (checkable->GetEnableEventHandler() ? 1 : 0);
}
Esempio n. 7
0
int CompatUtility::GetCheckableFlapDetectionEnabled(const Checkable::Ptr& checkable)
{
	return (checkable->GetEnableFlapping() ? 1 : 0);
}
Esempio n. 8
0
int CompatUtility::GetCheckableAcknowledgementType(const Checkable::Ptr& checkable)
{
	return static_cast<int>(checkable->GetAcknowledgement());
}
Esempio n. 9
0
int CompatUtility::GetCheckableActiveChecksEnabled(const Checkable::Ptr& checkable)
{
	return (checkable->GetEnableActiveChecks() ? 1 : 0);
}
Esempio n. 10
0
int CompatUtility::GetCheckableProblemHasBeenAcknowledged(const Checkable::Ptr& checkable)
{
	return (checkable->GetAcknowledgement() != AcknowledgementNone ? 1 : 0);
}
Esempio n. 11
0
int CompatUtility::GetCheckableHasBeenChecked(const Checkable::Ptr& checkable)
{
	return (checkable->GetLastCheckResult() ? 1 : 0);
}
Esempio n. 12
0
double CompatUtility::GetCheckableRetryInterval(const Checkable::Ptr& checkable)
{
	return checkable->GetRetryInterval() / 60.0;
}
Esempio n. 13
0
int CompatUtility::GetCheckableCheckType(const Checkable::Ptr& checkable)
{
	return (checkable->GetEnableActiveChecks() ? 0 : 1);
}
Esempio n. 14
0
/* service */
String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable)
{
	CheckCommand::Ptr command = checkable->GetCheckCommand();

	Dictionary::Ptr args = new Dictionary();

	if (command) {
		Host::Ptr host;
		Service::Ptr service;
		tie(host, service) = GetHostService(checkable);
		String command_line = GetCommandLine(command);

		Dictionary::Ptr command_vars = command->GetVars();

		if (command_vars) {
			ObjectLock olock(command_vars);
			for (const Dictionary::Pair& kv : command_vars) {
				String macro = "$" + kv.first + "$"; // this is too simple
				if (command_line.Contains(macro))
					args->Set(kv.first, kv.second);

			}
		}

		Dictionary::Ptr host_vars = host->GetVars();

		if (host_vars) {
			ObjectLock olock(host_vars);
			for (const Dictionary::Pair& kv : host_vars) {
				String macro = "$" + kv.first + "$"; // this is too simple
				if (command_line.Contains(macro))
					args->Set(kv.first, kv.second);
				macro = "$host.vars." + kv.first + "$";
				if (command_line.Contains(macro))
					args->Set(kv.first, kv.second);
			}
		}

		if (service) {
			Dictionary::Ptr service_vars = service->GetVars();

			if (service_vars) {
				ObjectLock olock(service_vars);
				for (const Dictionary::Pair& kv : service_vars) {
					String macro = "$" + kv.first + "$"; // this is too simple
					if (command_line.Contains(macro))
						args->Set(kv.first, kv.second);
					macro = "$service.vars." + kv.first + "$";
					if (command_line.Contains(macro))
						args->Set(kv.first, kv.second);
				}
			}
		}

		String arg_string;
		ObjectLock olock(args);
		for (const Dictionary::Pair& kv : args) {
			arg_string += Convert::ToString(kv.first) + "=" + Convert::ToString(kv.second) + "!";
		}
		return arg_string;
	}

	return Empty;
}