Implement validator for the check_interval attribute

fixes #7591
This commit is contained in:
Gunnar Beutner 2014-12-05 12:59:57 +01:00
parent cc8fe684fe
commit ec99efbc28
3 changed files with 15 additions and 0 deletions

View File

@ -18,14 +18,17 @@
******************************************************************************/
#include "icinga/checkable.hpp"
#include "config/configcompilercontext.hpp"
#include "base/objectlock.hpp"
#include "base/utility.hpp"
#include "base/scriptfunction.hpp"
#include <boost/foreach.hpp>
#include <boost/bind/apply.hpp>
using namespace icinga;
REGISTER_TYPE(Checkable);
REGISTER_SCRIPTFUNCTION(ValidateCheckableCheckInterval, &Checkable::ValidateCheckInterval);
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnablePerfdataChanged;
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, double, const MessageOrigin&)> Checkable::OnAcknowledgementSet;
@ -263,3 +266,11 @@ Endpoint::Ptr Checkable::GetCommandEndpoint(void) const
{
return Endpoint::GetByName(GetCommandEndpointRaw());
}
void Checkable::ValidateCheckInterval(const String& location, const Checkable::Ptr& object)
{
if (object->GetCheckInterval() <= 0) {
ConfigCompilerContext::GetInstance()->AddMessage(true, "Validation failed for " +
location + ": check_interval must be greater than 0.");
}
}

View File

@ -276,6 +276,8 @@ public:
void RemoveReverseDependency(const intrusive_ptr<Dependency>& dep);
std::set<intrusive_ptr<Dependency> > GetReverseDependencies(void) const;
static void ValidateCheckInterval(const String& location, const Checkable::Ptr& object);
protected:
virtual void Start(void);

View File

@ -26,6 +26,8 @@
}
%type Checkable {
%validator "ValidateCheckableCheckInterval",
%attribute %string "display_name",
%require "check_command",