Renamed the limit-to-notify configuration option to limit-hosts-down, because it...
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Mon, 21 Mar 2011 09:51:09 +0000 (10:51 +0100)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Mon, 21 Mar 2011 10:01:41 +0000 (11:01 +0100)
Readme
conf/pingcheck.conf
src/config/configuration.cpp
src/config/configuration.h
src/config/configurationreader.cpp
src/config/configurationreader.h

diff --git a/Readme b/Readme
index 909dd46..70a0101 100644 (file)
--- a/Readme
+++ b/Readme
@@ -157,9 +157,9 @@ configuration block.
 4.1. General
 ---------------------------------------
 This configurations are shared among and affect all the hosts.
-- limit-to-notify: range from 0 to the number of hosts available. This value
-  represents minimum number of hosts that have to fail (i.e. do not reply the
-  ping) in order to alert any external system.
+- limit-hosts-down: ranges from 0 to the number of hosts available. This value
+  represents the minimum number of hosts that have to fail (i.e. do not reply
+  the ping) in order to alert any external system.
 
 
 4.2. Host
index 55f0e07..5e5548b 100644 (file)
@@ -1,4 +1,4 @@
-limit-to-notify=5
+limit-hosts-down=5
 
 [host]
 name=www.intra2net.com
index b20681f..ea6bce0 100644 (file)
@@ -10,10 +10,10 @@ using namespace std;
 
 Configuration::Configuration() :
     ConfigFileName( "" ),
-    LimitToNotify( 0 ),
+    LimitHostsDown( 0 ),
     Hosts(),
-    MinLimitToNotify( 0 ),
-    MaxLimitToNotify( 50 )
+    MinLimitHostsDown( 0 ),
+    MaxLimitHostsDown( 50 )
 {
 }
 
@@ -33,16 +33,16 @@ void Configuration::set_config_file_name( const std::string &config_file_name )
     this->ConfigFileName = config_file_name;
 }
 
-int Configuration::get_limit_to_notify() const
+int Configuration::get_limit_hosts_down() const
 {
-    return LimitToNotify;
+    return LimitHostsDown;
 }
 
-void Configuration::set_limit_to_notify( const int limit_to_notify )
+void Configuration::set_limit_hosts_down( const int limit_hosts_down )
 {
-    BOOST_ASSERT( ( MinLimitToNotify <= limit_to_notify ) && ( limit_to_notify <= MaxLimitToNotify) );
+    BOOST_ASSERT( ( MinLimitHostsDown <= limit_hosts_down ) && ( limit_hosts_down <= MaxLimitHostsDown) );
 
-    this->LimitToNotify = limit_to_notify;
+    this->LimitHostsDown = limit_hosts_down;
 }
 
 vector< HostItem > Configuration::get_hosts() const
index d4f30ee..b86335e 100644 (file)
@@ -21,19 +21,19 @@ public:
     std::string get_config_file_name() const;
     void set_config_file_name( const std::string &config_file_name );
 
-    int get_limit_to_notify() const;
-    void set_limit_to_notify( const int limit_to_notify );
+    int get_limit_hosts_down() const;
+    void set_limit_hosts_down( const int limit_hosts_down );
 
     std::vector<HostItem> get_hosts() const;
     void set_hosts( const std::vector<HostItem> &hosts_list );
 
 private:
     std::string ConfigFileName;
-    int LimitToNotify;
+    int LimitHostsDown;
     std::vector<HostItem> Hosts;
 
-    const int MinLimitToNotify;
-    const int MaxLimitToNotify;
+    const int MinLimitHostsDown;
+    const int MaxLimitHostsDown;
 
 };
 
index 07e1e53..2df1a63 100644 (file)
@@ -23,9 +23,9 @@ ConfigurationReader::ConfigurationReader() :
     DefaultConfigFileName( "pingcheck.conf" ),
     ConfigFileCmdStr( "config-file" ),
     ConfigFileCmdDesc( "Name of the configuration file." ),
-    DefaultLimitToNotify( 4 ),
-    LimitToNotifyCmdStr( "limit-to-notify" ),
-    LimitToNotifyCmdDesc( "Limit of host that have to be down in order to notify." ),
+    DefaultLimitHostsDown( 1 ),
+    LimitHostsDownCmdStr( "limit-hosts-down" ),
+    LimitHostsDownCmdDesc( "Limit of host that have to be down in order to notify." ),
     HostNameCmdStr( "host.name" ),
     HostNameCmdDesc( "Host address" ),
     DefaultHostInterval( 1 ),
@@ -109,7 +109,7 @@ options_description ConfigurationReader::get_configuration_options() const
 {
     options_description options( "Configuration" );
     options.add_options()
-        ( LimitToNotifyCmdStr.c_str(), value<int>()->default_value( DefaultLimitToNotify ), LimitToNotifyCmdDesc.c_str() )
+        ( LimitHostsDownCmdStr.c_str(), value<int>()->default_value( DefaultLimitHostsDown ), LimitHostsDownCmdDesc.c_str() )
         ( HostNameCmdStr.c_str(), value< vector<string> >(), HostNameCmdDesc.c_str() )
         ( HostIntervalCmdStr.c_str(), value< vector<int> >(), HostIntervalCmdDesc.c_str() )
     ;
@@ -127,12 +127,12 @@ bool ConfigurationReader::parse_configuration_options( const variables_map &vm )
         cout << ConfigFileCmdStr << "=" << config_file_name << endl;
     }
 
-    if ( vm.count( LimitToNotifyCmdStr ) )
+    if ( vm.count( LimitHostsDownCmdStr ) )
     {
-        int limit_to_notify = vm[ LimitToNotifyCmdStr ].as<int> ();
-        Config.set_limit_to_notify( limit_to_notify );
+        int limit_host_down = vm[ LimitHostsDownCmdStr ].as<int> ();
+        Config.set_limit_hosts_down( limit_host_down );
 
-        cout << LimitToNotifyCmdStr << "=" << limit_to_notify << endl;
+        cout << LimitHostsDownCmdStr << "=" << limit_host_down << endl;
     }
 
     int hosts_names_total = 0;
index 2c5bd3e..a6dded0 100644 (file)
@@ -61,9 +61,9 @@ private:
     const std::string DefaultConfigFileName;
     const std::string ConfigFileCmdStr;
     const std::string ConfigFileCmdDesc;
-    const int DefaultLimitToNotify;
-    const std::string LimitToNotifyCmdStr;
-    const std::string LimitToNotifyCmdDesc;
+    const int DefaultLimitHostsDown;
+    const std::string LimitHostsDownCmdStr;
+    const std::string LimitHostsDownCmdDesc;
     const std::string HostNameCmdStr;
     const std::string HostNameCmdDesc;
     const int DefaultHostInterval;