You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Check if there are an inventory aliases configured
17
19
# This should be maintained by the developer and not occur
@@ -56,10 +58,20 @@ function Invoke-IcingaApiChecksRESTCall()
56
58
}
57
59
58
60
if ((Test-IcingaRESTApiCommand-Command $ExecuteCommand-Endpoint 'apichecks') -eq$FALSE) {
61
+
62
+
Add-IcingaHashtableItem`
63
+
-Hashtable $ContentResponse`
64
+
-Key $ExecuteCommand`
65
+
-Value @{
66
+
'exitcode'=3;
67
+
'checkresult'= [string]::Format('[UNKNOWN] Icinga Permission error was thrown: Permission denied for command "{0}"{1}{1}The command "{0}" you are trying to execute over the REST-Api endpoint "apichecks" is not whitelisted for remote execution.',$ExecuteCommand, (New-IcingaNewLine));
-ContentBody ([string]::Format('The command "{0}" you are trying to execute over this REST-Api endpoint "apichecks" is not whitelisted for remote execution.',$ExecuteCommand))
74
+
-ContentBody $ContentResponse
63
75
) -Stream $Connection.Stream;
64
76
65
77
return;
@@ -100,9 +112,19 @@ function Invoke-IcingaApiChecksRESTCall()
100
112
-Value $CmdArgValue|Out-Null;
101
113
};
102
114
103
-
[int]$ExitCode=&$ExecuteCommand@Arguments;
115
+
try {
116
+
[int]$ExitCode=&$ExecuteCommand@Arguments;
117
+
} catch {
118
+
[int]$ExitCode=3;
119
+
$InternalError=$_.Exception.Message;
120
+
}
104
121
} elseif ($Request.Method-eq'GET') {
105
-
[int]$ExitCode=&$ExecuteCommand;
122
+
try {
123
+
[int]$ExitCode=&$ExecuteCommand;
124
+
} catch {
125
+
[int]$ExitCode=3;
126
+
$InternalError=$_.Exception.Message;
127
+
}
106
128
} else {
107
129
Send-IcingaTCPClientMessage-Message (
108
130
New-IcingaTCPClientRESTMessage`
@@ -115,7 +137,16 @@ function Invoke-IcingaApiChecksRESTCall()
115
137
116
138
# Once the check is executed, the plugin output and the performance data are stored
117
139
# within a special cache map we can use for accessing
0 commit comments