--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#include "config/option/pingfaillimitoption.h"
+
+#include <logfunc.hpp>
+
+using namespace std;
+using boost::program_options::value;
+using boost::program_options::variables_map;
+using I2n::Logger::GlobalLogger;
+
+//-----------------------------------------------------------------------------
+// PingFailLimitOption
+//-----------------------------------------------------------------------------
+
+PingFailLimitOption::PingFailLimitOption() :
+ ConfigurationOption(
+ "ping-fail-limit",
+ value<int>()->default_value( 50 ), // 50 pings can fail at most
+ "Maximum percentage of pings that can fail for a given host."
+ )
+{
+}
+
+PingFailLimitOption::~PingFailLimitOption()
+{
+}
+
+bool PingFailLimitOption::validate( const variables_map& vm ) const
+{
+ bool is_valid = ( vm.count( get_command_string() ) > 0 );
+
+ return is_valid;
+}
+
+bool PingFailLimitOption::parse(
+ const variables_map& vm,
+ Configuration *configuration
+) const
+{
+ // ping-fail-limit
+ if ( vm.count( get_command_string() ) > 0 )
+ {
+ int ping_fail_limit = vm[ get_command_string() ].as<int> ();
+ configuration->set_ping_fail_limit( ping_fail_limit );
+
+ GlobalLogger.info() << get_command_string() << "="
+ << ping_fail_limit << endl;
+
+ return true;
+ }
+
+ return false;
+}
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#ifndef PING_FAIL_LIMIT_OPTION_H
+#define PING_FAIL_LIMIT_OPTION_H
+
+#include <boost/program_options.hpp>
+
+#include "config/option/configurationoption.h"
+
+//-----------------------------------------------------------------------------
+// PingFailLimitOption
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief This class represents the "ping-fail-limit" configuration option.
+ */
+class PingFailLimitOption : public ConfigurationOption
+{
+public:
+ PingFailLimitOption();
+ virtual ~PingFailLimitOption();
+
+ virtual bool validate(
+ const boost::program_options::variables_map &vm
+ ) const;
+
+ virtual bool parse(
+ const boost::program_options::variables_map &vm,
+ Configuration *configuration
+ ) const;
+
+};
+
+#endif // PING_FAIL_LIMIT_OPTION_H