mirror of
https://github.com/moudsen/mailGraph
synced 2025-01-31 04:11:39 +01:00
Added ability to configure HTTP proxy (v1.24)
This commit is contained in:
parent
1c9786c549
commit
78061964c4
@ -29,6 +29,7 @@
|
|||||||
// a wrongly typed requested (should be ARRAY, not comma separated)!
|
// a wrongly typed requested (should be ARRAY, not comma separated)!
|
||||||
// 1.22 2021/03/10 - Mark Oudsen - Added ability to embed multiple periods (1-4) of the same graph
|
// 1.22 2021/03/10 - Mark Oudsen - Added ability to embed multiple periods (1-4) of the same graph
|
||||||
// 1.23 2021/03/12 - Mark Oudsen - Added graph support for 'Stacked', 'Pie' and 'Exploded'
|
// 1.23 2021/03/12 - Mark Oudsen - Added graph support for 'Stacked', 'Pie' and 'Exploded'
|
||||||
|
// 1.24 2021/03/12 - Mark Oudsen - Added support for HTTP proxy
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// (C) M.J.Oudsen, mark.oudsen@puzzl.nl
|
// (C) M.J.Oudsen, mark.oudsen@puzzl.nl
|
||||||
@ -51,7 +52,7 @@
|
|||||||
|
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
|
|
||||||
$cVersion = 'v1.23';
|
$cVersion = 'v1.24';
|
||||||
$cCRLF = chr(10).chr(13);
|
$cCRLF = chr(10).chr(13);
|
||||||
$maskDateTime = 'Y-m-d H:i:s';
|
$maskDateTime = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
@ -82,6 +83,7 @@
|
|||||||
global $cCRLF;
|
global $cCRLF;
|
||||||
global $cVersion;
|
global $cVersion;
|
||||||
global $cDebug;
|
global $cDebug;
|
||||||
|
global $HTTPProxy;
|
||||||
|
|
||||||
// Initialize Curl instance
|
// Initialize Curl instance
|
||||||
_log('% postJSON: '.$url);
|
_log('% postJSON: '.$url);
|
||||||
@ -92,6 +94,12 @@
|
|||||||
// Set options
|
// Set options
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Zabbix-mailGraph - '.$cVersion);
|
curl_setopt($ch, CURLOPT_USERAGENT, 'Zabbix-mailGraph - '.$cVersion);
|
||||||
|
|
||||||
|
if ((isset($HTTPProxy)) && ($HTTPProxy!=''))
|
||||||
|
{
|
||||||
|
_log('% Using proxy: '.$HTTPProxy);
|
||||||
|
curl_setopt($ch, CURLOPT_PROXY, $HTTPProxy);
|
||||||
|
}
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
|
||||||
@ -142,6 +150,7 @@
|
|||||||
global $z_url_api;
|
global $z_url_api;
|
||||||
global $cVersion;
|
global $cVersion;
|
||||||
global $cCRLF;
|
global $cCRLF;
|
||||||
|
global $HTTPProxy;
|
||||||
|
|
||||||
// Unique names
|
// Unique names
|
||||||
$thisTime = time();
|
$thisTime = time();
|
||||||
@ -164,6 +173,11 @@
|
|||||||
case 3:
|
case 3:
|
||||||
$z_url_graph = $z_server ."chart6.php";
|
$z_url_graph = $z_server ."chart6.php";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Catch all ...
|
||||||
|
_log('% Graph type #'.$graphType.' unknown; forcing "Normal"');
|
||||||
|
$z_url_graph = $z_server ."chart2.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
$z_url_fetch = $z_url_graph ."?graphid=" .$graphid ."&width=" .$width ."&height=" .$height .
|
$z_url_fetch = $z_url_graph ."?graphid=" .$graphid ."&width=" .$width ."&height=" .$height .
|
||||||
@ -186,6 +200,12 @@
|
|||||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Zabbix-mailGraph - '.$cVersion);
|
curl_setopt($ch, CURLOPT_USERAGENT, 'Zabbix-mailGraph - '.$cVersion);
|
||||||
|
|
||||||
|
if ((isset($HTTPProxy)) && ($HTTPProxy!=''))
|
||||||
|
{
|
||||||
|
_log('% Using proxy: '.$HTTPProxy);
|
||||||
|
curl_setopt($ch, CURLOPT_PROXY, $HTTPProxy);
|
||||||
|
}
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
@ -285,45 +305,6 @@
|
|||||||
return($requestCounter);
|
return($requestCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Create easy to read duration
|
|
||||||
|
|
||||||
function getNiceDuration($durationInSeconds)
|
|
||||||
{
|
|
||||||
$duration = '';
|
|
||||||
|
|
||||||
$days = floor($durationInSeconds / 86400);
|
|
||||||
$durationInSeconds -= $days * 86400;
|
|
||||||
$hours = floor($durationInSeconds / 3600);
|
|
||||||
$durationInSeconds -= $hours * 3600;
|
|
||||||
$minutes = floor($durationInSeconds / 60);
|
|
||||||
$seconds = $durationInSeconds - $minutes * 60;
|
|
||||||
|
|
||||||
if ($days>0)
|
|
||||||
{
|
|
||||||
$duration .= $days . ' day';
|
|
||||||
if ($days!=1) { $duration .= 's'; }
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($hours>0)
|
|
||||||
{
|
|
||||||
$duration .= ' ' . $hours . ' hr';
|
|
||||||
if ($hours!=1) { $duration .= 's'; }
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($minutes>0)
|
|
||||||
{
|
|
||||||
$duration .= ' ' . $minutes . ' min';
|
|
||||||
if ($minutes!=1) { $duration .= 's'; }
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($seconds>=0) { $duration .= ' ' . $seconds . ' sec'; }
|
|
||||||
if ($seconds!=1) { $duration .= 's'; }
|
|
||||||
|
|
||||||
return $duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Initialize ///////////////////////////////////////////////////////////////////////////////////////////
|
// Initialize ///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -343,6 +324,8 @@
|
|||||||
|
|
||||||
// --- CLI DATA ---
|
// --- CLI DATA ---
|
||||||
|
|
||||||
|
$HTTPProxy = '';
|
||||||
|
|
||||||
// Facilitate CLI based testing
|
// Facilitate CLI based testing
|
||||||
if (isset($argc))
|
if (isset($argc))
|
||||||
{
|
{
|
||||||
@ -368,6 +351,7 @@
|
|||||||
if (isset($config['cli_periods'])) { $problemData['periods'] = $config['cli_periods']; }
|
if (isset($config['cli_periods'])) { $problemData['periods'] = $config['cli_periods']; }
|
||||||
if (isset($config['cli_periods_headers'])) { $problemData['periods_headers'] = $config['cli_periods_headers']; }
|
if (isset($config['cli_periods_headers'])) { $problemData['periods_headers'] = $config['cli_periods_headers']; }
|
||||||
if (isset($config['cli_debug'])) { $problemData['debug'] = $config['cli_debug']; }
|
if (isset($config['cli_debug'])) { $problemData['debug'] = $config['cli_debug']; }
|
||||||
|
if (isset($config['cli_proxy'])) { $problemData['HTTPProxy'] = $config['cli_proxy']; }
|
||||||
|
|
||||||
// Switch on CLI log display
|
// Switch on CLI log display
|
||||||
$showLog = TRUE;
|
$showLog = TRUE;
|
||||||
@ -415,6 +399,8 @@
|
|||||||
$p_period = '48h';
|
$p_period = '48h';
|
||||||
if (isset($problemData['period'])) { $p_period = $problemData['period']; }
|
if (isset($problemData['period'])) { $p_period = $problemData['period']; }
|
||||||
|
|
||||||
|
if (isset($problemData['HTTPProxy'])) { $HTTPProxy = $problemData['HTTPPRoxy']; }
|
||||||
|
|
||||||
// DYNAMIC VARIABLES FROM ZABBIX
|
// DYNAMIC VARIABLES FROM ZABBIX
|
||||||
|
|
||||||
foreach($problemData as $aKey=>$aValue)
|
foreach($problemData as $aKey=>$aValue)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user