Commit version 24.12.13800
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,33 +6,40 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage alerting
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
$message_keys = array_keys($message_tags);
|
||||
|
||||
// Export all tags for external program usage
|
||||
foreach (array_keys($message_tags) as $key)
|
||||
{
|
||||
putenv("OBSERVIUM_$key=" . $message_tags[$key]);
|
||||
$unescape = [];
|
||||
foreach ($message_keys as $key) {
|
||||
putenv("OBSERVIUM_$key=" . $message_tags[$key]);
|
||||
$unescape['from'][] = '\$OBSERVIUM_' . $key;
|
||||
$unescape['to'][] = '$OBSERVIUM_' . $key;
|
||||
}
|
||||
|
||||
// Clean script from injections and
|
||||
// Revert back OBSERVIUM variables from escaping
|
||||
// I.e.: "\$OBSERVIUM_TITLE \$OBSERVIUM_TIMESTAMP \$OBSERVIUM_DURATION"
|
||||
$script_cmd = str_replace($unescape['from'], $unescape['to'], escapeshellcmd($endpoint['script']));
|
||||
|
||||
// Execute given script
|
||||
external_exec($endpoint['script']);
|
||||
external_exec($script_cmd, $exec_status);
|
||||
|
||||
// If script's exit code is 0, success. Otherwise we mark it as failed.
|
||||
if ($GLOBALS['exec_status']['exitcode'] == 0)
|
||||
{
|
||||
$notify_status['success'] = TRUE;
|
||||
// If script's exit code is 0, success. Otherwise, we mark it as failed.
|
||||
if ($exec_status['exitcode'] === 0) {
|
||||
$notify_status['success'] = TRUE;
|
||||
} else {
|
||||
$notify_status['success'] = FALSE;
|
||||
$notify_status['success'] = FALSE;
|
||||
}
|
||||
|
||||
// Clean out all set environment variable we set before execution
|
||||
foreach (array_keys($message_tags) as $key)
|
||||
{
|
||||
putenv("OBSERVIUM_$key");
|
||||
// Clean out all set environment variables we set before execution
|
||||
foreach ($message_keys as $key) {
|
||||
putenv("OBSERVIUM_$key");
|
||||
}
|
||||
|
||||
unset($message, $output, $exitcode);
|
||||
unset($exec_status, $unescape, $script_cmd);
|
||||
|
||||
// EOF
|
||||
|
Reference in New Issue
Block a user