From: Thomas Jarosch Date: Fri, 29 Apr 2011 09:30:29 +0000 (+0200) Subject: Make the status notifcation cmd optional. Also make the status parameter optional X-Git-Tag: v1.0~57 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=2a686bc09e0425c56b8009c20400e766997cd510;p=pingcheck Make the status notifcation cmd optional. Also make the status parameter optional --- diff --git a/src/link/linkstatusanalyzer.cpp b/src/link/linkstatusanalyzer.cpp index 30e7b34..b85d77a 100644 --- a/src/link/linkstatusanalyzer.cpp +++ b/src/link/linkstatusanalyzer.cpp @@ -30,7 +30,6 @@ LinkStatusAnalyzer::LinkStatusAnalyzer( { BOOST_ASSERT( 0 <= hosts_down_limit ); BOOST_ASSERT( 0 <= link_up_interval_in_min ); - BOOST_ASSERT( !status_notifier_cmd.empty() ); } LinkStatusAnalyzer::~LinkStatusAnalyzer() @@ -104,14 +103,14 @@ void LinkStatusAnalyzer::notify_link_up() BOOST_ASSERT( CurrentLinkStatus == LinkStatus_Up ); BOOST_ASSERT( CurrentNotificationStatus == NotificationStatus_NotReported ); - bool replaced = StatusNotifierCmd.set_token_value( + StatusNotifierCmd.set_token_value( StatusNotifierCommand::StatusToken, "up" - ); + ); //lint !e534 bool executed = StatusNotifierCmd.execute(); - if ( replaced && executed ) + if ( executed ) { CurrentNotificationStatus = NotificationStatus_Reported; } @@ -127,14 +126,14 @@ void LinkStatusAnalyzer::notify_link_down() BOOST_ASSERT( CurrentLinkStatus == LinkStatus_Down ); BOOST_ASSERT( CurrentNotificationStatus == NotificationStatus_NotReported ); - bool replaced = StatusNotifierCmd.set_token_value( + StatusNotifierCmd.set_token_value( StatusNotifierCommand::StatusToken, "down" - ); + ); //lint !e534 bool executed = StatusNotifierCmd.execute(); - if ( replaced && executed ) + if ( executed ) { CurrentNotificationStatus = NotificationStatus_Reported; } diff --git a/src/link/statusnotifiercommand.cpp b/src/link/statusnotifiercommand.cpp index e894ff6..f652cd0 100644 --- a/src/link/statusnotifiercommand.cpp +++ b/src/link/statusnotifiercommand.cpp @@ -38,7 +38,6 @@ bool StatusNotifierCommand::set_token_value( { BOOST_ASSERT( !token.empty() ); BOOST_ASSERT( !value.empty() ); - BOOST_ASSERT( !CommandStr.empty() ); const size_t token_begin_pos = CommandStr.find( token ); if ( token_begin_pos == string::npos ) @@ -57,7 +56,9 @@ bool StatusNotifierCommand::set_token_value( bool StatusNotifierCommand::execute() const { - BOOST_ASSERT( !CommandStr.empty() ); + // Check if users wants notification at all + if (CommandStr.empty()) + return true; string app = get_application_string(); string args = get_arguments_string();