24
24
25
25
using namespace icinga ;
26
26
27
+ bool ExternalCommandProcessor::m_DownTimeRemoved;
27
28
boost::signals2::signal<void (double , const String&, const std::vector<String>&)> ExternalCommandProcessor::OnNewExternalCommand;
28
29
29
30
void ExternalCommandProcessor::Execute (const String& line)
@@ -970,10 +971,19 @@ void ExternalCommandProcessor::ScheduleSvcDowntime(double, const std::vector<Str
970
971
void ExternalCommandProcessor::DelSvcDowntime (double , const std::vector<String>& arguments)
971
972
{
972
973
int id = Convert::ToLong (arguments[0 ]);
973
- Log (LogNotice, " ExternalCommandProcessor" )
974
- << " Removing downtime ID " << arguments[0 ];
974
+ m_DownTimeRemoved = false ;
975
975
String rid = Downtime::GetDowntimeIDFromLegacyID (id);
976
- Downtime::RemoveDowntime (rid, true );
976
+
977
+ try {
978
+ Downtime::RemoveDowntime (rid, true );
979
+ } catch (std::runtime_error& error) {
980
+ m_DownTimeRemoved = true ;
981
+ Log (LogWarning, error.what ());
982
+ }
983
+
984
+ if (!m_DownTimeRemoved)
985
+ Log (LogNotice, " ExternalCommandProcessor" )
986
+ << " Removing downtime ID " << arguments[0 ];
977
987
}
978
988
979
989
void ExternalCommandProcessor::ScheduleHostDowntime (double , const std::vector<String>& arguments)
@@ -1072,10 +1082,19 @@ void ExternalCommandProcessor::ScheduleAndPropagateTriggeredHostDowntime(double,
1072
1082
void ExternalCommandProcessor::DelHostDowntime (double , const std::vector<String>& arguments)
1073
1083
{
1074
1084
int id = Convert::ToLong (arguments[0 ]);
1075
- Log (LogNotice, " ExternalCommandProcessor" )
1076
- << " Removing downtime ID " << arguments[0 ];
1077
1085
String rid = Downtime::GetDowntimeIDFromLegacyID (id);
1078
- Downtime::RemoveDowntime (rid, true );
1086
+ m_DownTimeRemoved = false ;
1087
+
1088
+ try {
1089
+ Downtime::RemoveDowntime (rid, true );
1090
+ } catch (std::runtime_error& error) {
1091
+ m_DownTimeRemoved = true ;
1092
+ Log (LogWarning, error.what ());
1093
+ }
1094
+
1095
+ if (!m_DownTimeRemoved)
1096
+ Log (LogNotice, " ExternalCommandProcessor" )
1097
+ << " Removing downtime ID " << arguments[0 ];
1079
1098
}
1080
1099
1081
1100
void ExternalCommandProcessor::DelDowntimeByHostName (double , const std::vector<String>& arguments)
@@ -1101,13 +1120,24 @@ void ExternalCommandProcessor::DelDowntimeByHostName(double, const std::vector<S
1101
1120
Log (LogWarning, " ExternalCommandProcessor" )
1102
1121
<< (" Ignoring additional parameters for host '" + arguments[0 ] + " ' downtime deletion." );
1103
1122
1123
+ m_DownTimeRemoved = false ;
1124
+ String downTimeName;
1104
1125
for (const Downtime::Ptr & downtime : host->GetDowntimes ()) {
1105
- Log (LogNotice, " ExternalCommandProcessor" )
1106
- << " Removing downtime '" << downtime->GetName () << " '." ;
1126
+ downTimeName = downtime->GetName ();
1107
1127
1108
- Downtime::RemoveDowntime (downtime->GetName (), true );
1128
+ try {
1129
+ Downtime::RemoveDowntime (downtime->GetName (), true );
1130
+ } catch (std::runtime_error& error) {
1131
+ m_DownTimeRemoved = true ;
1132
+ Log (LogWarning, error.what ());
1133
+ }
1134
+
1135
+ if (!m_DownTimeRemoved)
1136
+ Log (LogNotice, " ExternalCommandProcessor" )
1137
+ << " Removing downtime '" << downTimeName << " '." ;
1109
1138
}
1110
1139
1140
+ m_DownTimeRemoved = false ;
1111
1141
for (const Service::Ptr & service : host->GetServices ()) {
1112
1142
if (!serviceName.IsEmpty () && serviceName != service->GetName ())
1113
1143
continue ;
@@ -1119,10 +1149,19 @@ void ExternalCommandProcessor::DelDowntimeByHostName(double, const std::vector<S
1119
1149
if (!commentString.IsEmpty () && downtime->GetComment () != commentString)
1120
1150
continue ;
1121
1151
1122
- Log (LogNotice, " ExternalCommandProcessor" )
1123
- << " Removing downtime '" << downtime->GetName () << " '." ;
1152
+ downTimeName = downtime->GetName ();
1124
1153
1125
- Downtime::RemoveDowntime (downtime->GetName (), true );
1154
+ try {
1155
+ Downtime::RemoveDowntime (downtime->GetName (), true );
1156
+ } catch (std::runtime_error& error) {
1157
+ m_DownTimeRemoved = true ;
1158
+ Log (LogWarning, error.what ());
1159
+ }
1160
+
1161
+ if (!m_DownTimeRemoved) {
1162
+ Log (LogNotice, " ExternalCommandProcessor" )
1163
+ << " Removing downtime '" << downtime->GetName () << " '." ;
1164
+ }
1126
1165
}
1127
1166
}
1128
1167
}
0 commit comments