diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..2be9520
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1 @@
+github: cliffparnitzky
diff --git a/system/modules/MonitoringScanClient/classes/MonitoringScanClient.php b/system/modules/MonitoringScanClient/classes/MonitoringScanClient.php
index 4c48795..9a0e683 100644
--- a/system/modules/MonitoringScanClient/classes/MonitoringScanClient.php
+++ b/system/modules/MonitoringScanClient/classes/MonitoringScanClient.php
@@ -53,19 +53,20 @@ public function __construct()
/**
* Get the data from the client.
*/
- public function scanClient($clientUrl, $token)
+ public function scanClient($clientUrl, $endpoint, $token)
{
if (!function_exists('curl_exec'))
{
return $GLOBALS['TL_LANG']['ERR']['monitoringScanClient']['CURL_NOT_INSTALLED'];
}
-
- $url = $clientUrl . "?token=" . $token;
-
+
+ $url = $clientUrl . "/contao-manager.phar.php" . $endpoint;
+
$agent = \Config::get('MONITORING_AGENT_NAME');
$headers = array(
'Content-Type: application/json',
- 'Connection: Close'
+ 'Connection: Close',
+ 'Authorization: Bearer ' . $token,
);
$curl = curl_init($url);
@@ -79,9 +80,32 @@ public function scanClient($clientUrl, $token)
$response = curl_exec ($curl);
curl_close($curl);
}
-
+
$arrData = json_decode($response, true);
-
+ if($arrData['status'] == 401) {
+ $url = $clientUrl . "/system/modules/MonitoringClient/api/api.php?token=" . $token;
+
+ $agent = \Config::get('MONITORING_AGENT_NAME');
+ $headers = array(
+ 'Content-Type: application/json',
+ 'Connection: Close',
+ );
+ $curl = curl_init($url);
+
+ if ($curl)
+ {
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_USERAGENT, $agent);
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
+
+ $response = curl_exec ($curl);
+ curl_close($curl);
+ }
+
+ $arrData = json_decode($response, true);
+ }
+
if($response === FALSE || empty($arrData))
{
return sprintf($GLOBALS['TL_LANG']['ERR']['monitoringScanClient']['FAILED'], $url, $url);
@@ -95,4 +119,4 @@ public function scanClient($clientUrl, $token)
}
}
-?>
\ No newline at end of file
+?>
diff --git a/system/modules/MonitoringScanClient/dca/tl_monitoring.php b/system/modules/MonitoringScanClient/dca/tl_monitoring.php
index c3d0a78..a668844 100644
--- a/system/modules/MonitoringScanClient/dca/tl_monitoring.php
+++ b/system/modules/MonitoringScanClient/dca/tl_monitoring.php
@@ -46,15 +46,6 @@
'eval' => array('tl_class'=>'clr', 'submitOnChange' => true, 'doNotCopy'=>true),
'sql' => "char(1) NOT NULL default ''"
);
-$GLOBALS['TL_DCA']['tl_monitoring']['fields']['client_url'] = array
-(
- 'label' => &$GLOBALS['TL_LANG']['tl_monitoring']['client_url'],
- 'exclude' => true,
- 'inputType' => 'text',
- 'save_callback' => array(array('tl_monitoring', 'prepareUrl')),
- 'eval' => array('tl_class'=>'clr long', 'mandatory'=>true, 'rgxp'=>'url', 'doNotCopy'=>true, 'maxlength'=>512, 'decodeEntities'=>true),
- 'sql' => "varchar(512) NOT NULL default ''"
-);
$GLOBALS['TL_DCA']['tl_monitoring']['fields']['client_token'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_monitoring']['client_token'],
@@ -103,13 +94,112 @@ public function __construct()
*/
public function getClientData($varValue, DataContainer $dc)
{
- if (!$dc->activeRecord || empty($dc->activeRecord->client_url) || empty($dc->activeRecord->client_token))
+ if (!$dc->activeRecord || empty($dc->activeRecord->website) || empty($dc->activeRecord->client_token))
{
return "";
}
$monitoringScanClient = new \MonitoringScanClient();
- $response = $monitoringScanClient->scanClient($dc->activeRecord->client_url, $dc->activeRecord->client_token);
- if (is_array($response))
+ $response = $monitoringScanClient->scanClient($dc->activeRecord->website, '/api/server/contao', $dc->activeRecord->client_token);
+
+ if( is_array($response) && !array_key_exists('monitoring.server.agent', $response) ) {
+
+ foreach($response as $responseKey=>$responseValue)
+ {
+ $varValue .= 'contao.' . $responseKey . ": " . $responseValue . "\n";
+ }
+
+ $response = $monitoringScanClient->scanClient($dc->activeRecord->website, '/api/server/self-update' , $dc->activeRecord->client_token);
+ if (is_array($response))
+ {
+ foreach($response as $responseKey=>$responseValue)
+ {
+ $varValue .= 'contao_manager.' . $responseKey . ": " . $responseValue . "\n";
+ }
+ }
+ else
+ {
+ \Message::addError($response);
+ }
+
+ $response = $monitoringScanClient->scanClient($dc->activeRecord->website, '/api/config/manager' , $dc->activeRecord->client_token);
+ if (is_array($response))
+ {
+ foreach($response as $responseKey=>$responseValue)
+ {
+ $varValue .= 'contao_manager.config.' . $responseKey . ": " . $responseValue . "\n";
+ }
+ }
+ else
+ {
+ \Message::addError($response);
+ }
+
+ $response = $monitoringScanClient->scanClient($dc->activeRecord->website, '/api/server/config' , $dc->activeRecord->client_token);
+ if (is_array($response))
+ {
+ foreach($response as $responseKey=>$responseValue)
+ {
+ $varValue .= 'server.' . $responseKey . ": " . $responseValue . "\n";
+ }
+ }
+ else
+ {
+ \Message::addError($response);
+ }
+
+ $response = $monitoringScanClient->scanClient($dc->activeRecord->website, '/api/server/php-web' , $dc->activeRecord->client_token);
+ if (is_array($response))
+ {
+ foreach($response as $responseKey=>$responseValue)
+ {
+ $varValue .= 'php.' . $responseKey . ": " . $responseValue . "\n";
+ }
+ }
+ else
+ {
+ \Message::addError($response);
+ }
+
+ $response = $monitoringScanClient->scanClient($dc->activeRecord->website, '/api/server/composer' , $dc->activeRecord->client_token);
+ if (is_array($response))
+ {
+ foreach($response as $responseKey=>$responseValue)
+ {
+ $varValue .= 'composer.' . $responseKey . ": " . $responseValue . "\n";
+ }
+ }
+ else
+ {
+ \Message::addError($response);
+ }
+
+ $response = $monitoringScanClient->scanClient($dc->activeRecord->website, '/api/config/composer' , $dc->activeRecord->client_token);
+ if (is_array($response))
+ {
+ foreach($response as $responseKey=>$responseValue)
+ {
+ $varValue .= 'composer.config.' . $responseKey . ": " . $responseValue . "\n";
+ }
+ }
+ else
+ {
+ \Message::addError($response);
+ }
+
+ $response = $monitoringScanClient->scanClient($dc->activeRecord->website, '/api/users' , $dc->activeRecord->client_token);
+ if (is_array($response))
+ {
+ foreach($response as $responseKey=>$responseValue)
+ {
+ $varValue .= 'users.' . $responseKey . ": " . $responseValue . "\n";
+ }
+ }
+ else
+ {
+ \Message::addError($response);
+ }
+ }
+ elseif (is_array($response) && array_key_exists('monitoring.server.agent', $response))
{
foreach($response as $responseKey=>$responseValue)
{
@@ -120,9 +210,7 @@ public function getClientData($varValue, DataContainer $dc)
{
\Message::addError($response);
}
-
+
return $varValue;
}
}
-
-?>
\ No newline at end of file
diff --git a/system/modules/MonitoringScanClient/languages/de/tl_monitoring.php b/system/modules/MonitoringScanClient/languages/de/tl_monitoring.php
index 103c81e..a5f5585 100644
--- a/system/modules/MonitoringScanClient/languages/de/tl_monitoring.php
+++ b/system/modules/MonitoringScanClient/languages/de/tl_monitoring.php
@@ -31,7 +31,6 @@
* Fields
*/
$GLOBALS['TL_LANG']['tl_monitoring']['client_scan_active'] = array('MonitoringClient Daten auslesen', 'Legen Sie fest, ob die internen Daten des überwachten Systems aus dem installierten MonitoringClient ausgelesen werden sollen.');
-$GLOBALS['TL_LANG']['tl_monitoring']['client_url'] = array('MonitoringClient API URL', 'Die Adresse zur API des MonitoringClient auf dem überwachten System. Eingabe mit Protokoll (z.B. http:// oder https://)!');
$GLOBALS['TL_LANG']['tl_monitoring']['client_token'] = array('MonitoringClient Token', 'Das Token des MonitoringClient zur Authentifizierung der Datenabfrage.');
$GLOBALS['TL_LANG']['tl_monitoring']['client_data'] = array('MonitoringClient Daten', 'Zeigt die internen Daten des überwachten Systems aus dem installierten MonitoringClient an.');
@@ -40,4 +39,4 @@
*/
$GLOBALS['TL_LANG']['tl_monitoring']['client_legend'] = 'MonitoringClient Daten';
-?>
\ No newline at end of file
+?>
diff --git a/system/modules/MonitoringScanClient/languages/en/tl_monitoring.php b/system/modules/MonitoringScanClient/languages/en/tl_monitoring.php
index 6805101..59c8577 100644
--- a/system/modules/MonitoringScanClient/languages/en/tl_monitoring.php
+++ b/system/modules/MonitoringScanClient/languages/en/tl_monitoring.php
@@ -31,7 +31,6 @@
* Fields
*/
$GLOBALS['TL_LANG']['tl_monitoring']['client_scan_active'] = array('Read MonitoringClient data', 'Define whether the internal data of the monitored system should be read from the installed MonitoringClient.');
-$GLOBALS['TL_LANG']['tl_monitoring']['client_url'] = array('MonitoringClient API URL', 'The address to the API of the MonitoringClient on the monitored system. Enter with protocol (for example http:// or https://)!');
$GLOBALS['TL_LANG']['tl_monitoring']['client_token'] = array('MonitoringClient token', 'The token of the MonitoringClient for authentication of the data query.');
$GLOBALS['TL_LANG']['tl_monitoring']['client_data'] = array('MonitoringClient data', 'Displays the internal data of the monitored system from the installed MonitoringClient.');
@@ -40,4 +39,4 @@
*/
$GLOBALS['TL_LANG']['tl_monitoring']['client_legend'] = 'MonitoringClient data';
-?>
\ No newline at end of file
+?>