diff --git a/Classes/Controller/BaseController.php b/Classes/Controller/BaseController.php
index 7c3dd72..ff8d73e 100644
--- a/Classes/Controller/BaseController.php
+++ b/Classes/Controller/BaseController.php
@@ -11,6 +11,7 @@
use T3Monitor\T3monitoring\Domain\Model\Dto\ClientFilterDemand;
use T3Monitor\T3monitoring\Domain\Model\Dto\EmMonitoringConfiguration;
+use T3Monitor\T3monitoring\Domain\Repository\CheckResultRepository;
use T3Monitor\T3monitoring\Domain\Repository\ClientRepository;
use T3Monitor\T3monitoring\Domain\Repository\CoreRepository;
use T3Monitor\T3monitoring\Domain\Repository\StatisticRepository;
@@ -39,6 +40,9 @@ class BaseController extends ActionController
/** @var StatisticRepository */
protected $statisticRepository;
+ /** @var CheckResultRepository */
+ protected $checkResultRepository;
+
/** @var ClientRepository */
protected $clientRepository;
@@ -67,6 +71,7 @@ public function initializeAction()
{
$this->statisticRepository = $this->objectManager->get(StatisticRepository::class);
$this->filterDemand = $this->objectManager->get(ClientFilterDemand::class);
+ $this->checkResultRepository = $this->objectManager->get(CheckResultRepository::class);
$this->clientRepository = $this->objectManager->get(ClientRepository::class);
$this->coreRepository = $this->objectManager->get(CoreRepository::class);
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
diff --git a/Classes/Controller/StatisticController.php b/Classes/Controller/StatisticController.php
index 125665d..c0d6917 100644
--- a/Classes/Controller/StatisticController.php
+++ b/Classes/Controller/StatisticController.php
@@ -74,6 +74,7 @@ public function indexAction(ClientFilterDemand $filter = null)
$outdatedExtensionDemand = $this->getClientFilterDemand()->setWithOutdatedExtensions(true);
$clientsWithWarningInfo = $this->getClientFilterDemand()->setWithExtraWarning(true);
$clientsWithDangerInfo = $this->getClientFilterDemand()->setWithExtraDanger(true);
+ $clientsWithMissingProviderData = $this->getClientFilterDemand()->setWithMissingProviderData(true);
$emptyClientDemand = $this->getClientFilterDemand();
$feedItems = null;
@@ -97,9 +98,11 @@ public function indexAction(ClientFilterDemand $filter = null)
'clientsWithOutdatedCore' => $this->clientRepository->countByDemand($outdatedCoreDemand),
'clientsWithWarningInfo' => $this->clientRepository->countByDemand($clientsWithWarningInfo),
'clientsWithDangerInfo' => $this->clientRepository->countByDemand($clientsWithDangerInfo),
+ 'clientsWithMissingProviderData' => $this->clientRepository->countByDemand($clientsWithMissingProviderData),
'numberOfClients' => $this->clientRepository->countAll(),
'slaVersions' => $this->slaRepository->findAll(),
'tagVersions' => $this->tagRepository->findAll(),
+ 'rules' => $this->checkResultRepository->findAllWithFailCount(),
'feedItems' => $feedItems,
'importTimes' => [
'client' => $this->registry->get('t3monitoring', 'importClient'),
diff --git a/Classes/Domain/Model/Check.php b/Classes/Domain/Model/Check.php
new file mode 100644
index 0000000..2f1d0fc
--- /dev/null
+++ b/Classes/Domain/Model/Check.php
@@ -0,0 +1,110 @@
+title;
+ }
+
+ /**
+ * @param string $title
+ */
+ public function setTitle(string $title)
+ {
+ $this->title = $title;
+ }
+
+ /**
+ * @return string
+ */
+ public function getType(): string
+ {
+ return $this->type;
+ }
+
+ /**
+ * @param string $type
+ */
+ public function setType(string $type)
+ {
+ $this->type = $type;
+ }
+
+ /**
+ * @return string
+ */
+ public function getArgument(): string
+ {
+ return $this->argument;
+ }
+
+ /**
+ * @param string $argument
+ */
+ public function setArgument(string $argument)
+ {
+ $this->argument = $argument;
+ }
+
+ /**
+ * @return string
+ */
+ public function getOperator(): string
+ {
+ return $this->operator;
+ }
+
+ /**
+ * @param string $operator
+ */
+ public function setOperator(string $operator)
+ {
+ $this->operator = $operator;
+ }
+
+ /**
+ * @return string
+ */
+ public function getValue(): string
+ {
+ return $this->value;
+ }
+
+ /**
+ * @param string $value
+ */
+ public function setValue(string $value)
+ {
+ $this->value = $value;
+ }
+}
diff --git a/Classes/Domain/Model/CheckResult.php b/Classes/Domain/Model/CheckResult.php
new file mode 100644
index 0000000..37c7993
--- /dev/null
+++ b/Classes/Domain/Model/CheckResult.php
@@ -0,0 +1,85 @@
+
+ */
+ protected $failedRules;
+
+ /**
+ * @var bool
+ */
+ protected $missingProviderData;
+
+ public function __construct()
+ {
+ $this->failedRules = GeneralUtility::makeInstance(ObjectStorage::class);
+ }
+
+ /**
+ * @return Client
+ */
+ public function getClient()
+ {
+ return $this->client;
+ }
+
+ /**
+ * @param int $client
+ */
+ public function setClient($client)
+ {
+ $this->client = $client;
+ }
+
+ /**
+ * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Rule> failedRules
+ */
+ public function getFailedRules()
+ {
+ return $this->failedRules;
+ }
+
+ /**
+ * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Rule> $failedRules
+ * @return void
+ */
+ public function setFailedRules(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $failedRules)
+ {
+ $this->failedRules = $failedRules;
+ }
+
+ /**
+ * @param \T3Monitor\T3monitoring\Domain\Model\Rule
+ */
+ public function addFailedRule(Rule $failedRule)
+ {
+ $this->failedRules->attach($failedRule);
+ }
+
+ /**
+ * @return bool
+ */
+ public function getMissingProviderData()
+ {
+ return $this->missingProviderData;
+ }
+
+ /**
+ * @param bool $missingProviderData
+ */
+ public function setMissingProviderData(bool $missingProviderData)
+ {
+ $this->missingProviderData = $missingProviderData;
+ }
+}
diff --git a/Classes/Domain/Model/Client.php b/Classes/Domain/Model/Client.php
index decf83d..077bf7d 100644
--- a/Classes/Domain/Model/Client.php
+++ b/Classes/Domain/Model/Client.php
@@ -131,6 +131,11 @@ class Client extends AbstractEntity
*/
protected $lastSuccessfulImport = null;
+ /**
+ * @var \T3Monitor\T3monitoring\Domain\Model\CheckResult
+ */
+ protected $checkResult;
+
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Extension>
* @lazy
@@ -772,4 +777,20 @@ public function getExtraDangerAsArray()
}
return [];
}
+
+ /**
+ * @return \T3Monitor\T3monitoring\Domain\Model\CheckResult
+ */
+ public function getCheckResult()
+ {
+ return $this->checkResult;
+ }
+
+ /**
+ * @param \T3Monitor\T3monitoring\Domain\Model\CheckResult $checkResult
+ */
+ public function setCheckResult(CheckResult $checkResult)
+ {
+ $this->checkResult = $checkResult;
+ }
}
diff --git a/Classes/Domain/Model/Dto/ClientFilterDemand.php b/Classes/Domain/Model/Dto/ClientFilterDemand.php
index 2885784..217ab8a 100644
--- a/Classes/Domain/Model/Dto/ClientFilterDemand.php
+++ b/Classes/Domain/Model/Dto/ClientFilterDemand.php
@@ -55,6 +55,12 @@ class ClientFilterDemand extends AbstractEntity
/** @var bool */
protected $withEmailAddress;
+ /** @var int */
+ protected $withFailedRule;
+
+ /** @var bool */
+ protected $withMissingProviderData;
+
/**
* @return string
*/
@@ -288,4 +294,37 @@ public function setWithEmailAddress($withEmailAddress)
$this->withEmailAddress = $withEmailAddress;
return $this;
}
+
+ /**
+ * @return int
+ */
+ public function isWithFailedRule()
+ {
+ return $this->withFailedRule;
+ }
+
+ /**
+ * @param int $withFailedRule
+ */
+ public function setWithFailedRule($withFailedRule)
+ {
+ $this->withFailedRule = $withFailedRule;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isWithMissingProviderData()
+ {
+ return $this->withMissingProviderData;
+ }
+
+ /**
+ * @param bool $withMissingProviderData
+ */
+ public function setWithMissingProviderData($withMissingProviderData)
+ {
+ $this->withMissingProviderData = $withMissingProviderData;
+ return $this;
+ }
}
diff --git a/Classes/Domain/Model/Dto/ResolverData.php b/Classes/Domain/Model/Dto/ResolverData.php
new file mode 100644
index 0000000..53c5f0f
--- /dev/null
+++ b/Classes/Domain/Model/Dto/ResolverData.php
@@ -0,0 +1,105 @@
+client = $client;
+ $this->response = $response;
+ $this->responseHeaders = $responseHeaders;
+ }
+
+ /**
+ * @return array
+ */
+ public function getClient()
+ {
+ return $this->client;
+ }
+
+ /**
+ * @param array $client
+ */
+ public function setClient(array $client)
+ {
+ $this->client = $client;
+ }
+
+ /**
+ * @return array
+ */
+ public function getResponse()
+ {
+ return $this->response;
+ }
+
+ /**
+ * @param array $response
+ */
+ public function setResponse(array $response)
+ {
+ $this->response = $response;
+ }
+
+ /**
+ * @return array
+ */
+ public function getResponseHeaders()
+ {
+ return $this->responseHeaders;
+ }
+
+ /**
+ * @param array $responseHeaders
+ */
+ public function setResponseHeaders(array $responseHeaders)
+ {
+ $this->responseHeaders = $responseHeaders;
+ }
+
+ /**
+ * @return Rule
+ */
+ public function getRule()
+ {
+ return $this->rule;
+ }
+
+ /**
+ * @param Rule $rule
+ */
+ public function setRule(Rule $rule)
+ {
+ $this->rule = $rule;
+ }
+}
diff --git a/Classes/Domain/Model/Rule.php b/Classes/Domain/Model/Rule.php
new file mode 100644
index 0000000..e31ce18
--- /dev/null
+++ b/Classes/Domain/Model/Rule.php
@@ -0,0 +1,112 @@
+
+ */
+ protected $executionCriteria = null;
+
+ /**
+ * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Check>
+ */
+ protected $failureCriteria = null;
+
+ /**
+ * @var string
+ */
+ protected $messageCategory;
+
+ /**
+ * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Check> executionCriteria
+ */
+ public function getExecutionCriteria()
+ {
+ return $this->executionCriteria;
+ }
+
+ /**
+ * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Check> $executionCriteria
+ * @return void
+ */
+ public function setExecutionCriteria(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $executionCriteria)
+ {
+ $this->executionCriteria = $executionCriteria;
+ }
+
+ /**
+ * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Check> failureCriteria
+ */
+ public function getFailureCriteria()
+ {
+ return $this->failureCriteria;
+ }
+
+ /**
+ * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Check> $failureCriteria
+ * @return void
+ */
+ public function setFailureCriteria(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $failureCriteria)
+ {
+ $this->failureCriteria = $failureCriteria;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTitle(): string
+ {
+ return $this->title;
+ }
+
+ /**
+ * @param string $title
+ */
+ public function setTitle(string $title)
+ {
+ $this->title = $title;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription(): string
+ {
+ return $this->description;
+ }
+
+ /**
+ * @param string $description
+ */
+ public function setDescription(string $description)
+ {
+ $this->description = $description;
+ }
+
+ /**
+ * @return string
+ */
+ public function getMessageCategory(): string
+ {
+ return $this->messageCategory;
+ }
+
+ /**
+ * @param string $messageCategory
+ */
+ public function setMessageCategory(string $messageCategory)
+ {
+ $this->messageCategory = $messageCategory;
+ }
+}
diff --git a/Classes/Domain/Repository/CheckResultRepository.php b/Classes/Domain/Repository/CheckResultRepository.php
new file mode 100644
index 0000000..33665a5
--- /dev/null
+++ b/Classes/Domain/Repository/CheckResultRepository.php
@@ -0,0 +1,30 @@
+getDatabaseConnection()->createQueryBuilder();
+ $result = $queryBuilder->addSelectLiteral('
+ uid,
+ title,
+ description,
+ message_category,
+ (
+ SELECT
+ COUNT(*)
+ FROM tx_t3monitoring_checkresult_failed_rules_mm
+ LEFT JOIN tx_t3monitoring_domain_model_checkresult
+ ON tx_t3monitoring_domain_model_checkresult.uid=tx_t3monitoring_checkresult_failed_rules_mm.uid_local
+ WHERE uid_foreign=tx_t3monitoring_domain_model_rule.uid
+ AND tx_t3monitoring_domain_model_checkresult.uid IN (SELECT check_result FROM tx_t3monitoring_domain_model_client)
+ ) as fail_count')
+ ->from('tx_t3monitoring_domain_model_rule')
+ ->orderBy('title')
+ ->execute()
+ ->fetchAll();
+
+ return $result;
+ }
+}
diff --git a/Classes/Domain/Repository/ClientRepository.php b/Classes/Domain/Repository/ClientRepository.php
index acff50b..641c726 100644
--- a/Classes/Domain/Repository/ClientRepository.php
+++ b/Classes/Domain/Repository/ClientRepository.php
@@ -8,6 +8,7 @@
* LICENSE.txt file that was distributed with this source code.
*/
+use Doctrine\DBAL\DBALException;
use T3Monitor\T3monitoring\Domain\Model\Dto\ClientFilterDemand;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
@@ -76,7 +77,7 @@ public function getAllForReport($emailAddressRequired = false)
if ($emailAddressRequired) {
$constraints[] = $query->logicalNot(
- $query->equals('email', '')
+ $query->equals('email', '')
);
}
@@ -169,6 +170,20 @@ protected function getConstraints(ClientFilterDemand $demand, QueryInterface $qu
$constraints[] = $query->logicalNot($query->equals('extraDanger', ''));
}
+ // missing provider data
+ if ($demand->isWithMissingProviderData()) {
+ $constraints[] = $query->logicalNot($query->equals('checkResult.missingProviderData', ''));
+ }
+
+ // failed rules
+ if ($demand->isWithFailedRule() > 0) {
+ $clientIdsWithFailedRule = $this->getClientIdsByFailedRule($demand->isWithFailedRule());
+ if (count($clientIdsWithFailedRule) === 0) {
+ $clientIdsWithFailedRule[] = 0;
+ }
+ $constraints[] = $query->in('uid', $clientIdsWithFailedRule);
+ }
+
return $constraints;
}
@@ -179,4 +194,36 @@ protected function getFilterDemand()
{
return GeneralUtility::makeInstance(ClientFilterDemand::class);
}
+
+ /**
+ * @param int $ruleId
+ * @return array
+ * @throws DBALException
+ */
+ protected function getClientIdsByFailedRule(int $ruleId)
+ {
+ $queryBuilder = $this->getDatabaseConnection()->createQueryBuilder();
+ $select = sprintf('
+ tx_t3monitoring_domain_model_client.uid
+ FROM tx_t3monitoring_domain_model_client
+ LEFT JOIN tx_t3monitoring_domain_model_checkresult
+ ON tx_t3monitoring_domain_model_checkresult.uid = tx_t3monitoring_domain_model_client.check_result
+ LEFT JOIN tx_t3monitoring_checkresult_failed_rules_mm
+ ON tx_t3monitoring_checkresult_failed_rules_mm.uid_local = tx_t3monitoring_domain_model_checkresult.uid
+ WHERE tx_t3monitoring_checkresult_failed_rules_mm.uid_foreign = %d',
+ $ruleId
+ );
+
+ $rows = $queryBuilder
+ ->addSelectLiteral($select)
+ ->execute()
+ ->fetchAll();
+
+ $clientIds = [];
+ foreach ($rows as $row) {
+ $clientIds[] = $row['uid'];
+ }
+
+ return $clientIds;
+ }
}
diff --git a/Classes/Domain/Repository/RuleRepository.php b/Classes/Domain/Repository/RuleRepository.php
new file mode 100644
index 0000000..9a0e7de
--- /dev/null
+++ b/Classes/Domain/Repository/RuleRepository.php
@@ -0,0 +1,6 @@
+valueForComparison = $this->resolverData->getResponse()['backendUser'];
+ }
+
+ public function getProviderArguments()
+ {
+ return GeneralUtility::trimExplode(PHP_EOL, $this->argument, true);
+ }
+
+ protected function isActiveOperator()
+ {
+ if (!isset($this->resolverData->getResponse()['backendUser'])) {
+ return;
+ }
+
+ $unwantedActiveUsers = array_intersect($this->getProviderArguments(),
+ $this->resolverData->getResponse()['backendUser']);
+
+ if (count($unwantedActiveUsers) > 0) {
+ $this->addRuleData($unwantedActiveUsers);
+ }
+ return $unwantedActiveUsers !== 0;
+ }
+
+ protected function addRuleData($backendUsers)
+ {
+ $update = $this->resolverData->getResponse();
+ $messageCategory = $this->resolverData->getRule()->getMessageCategory();
+ $update['extra'][$messageCategory][$this->resolverData->getRule()->getTitle()] = implode(',',
+ $backendUsers);
+ $this->resolverData->setResponse($update);
+ }
+}
diff --git a/Classes/Resolver/BaseResolver.php b/Classes/Resolver/BaseResolver.php
new file mode 100644
index 0000000..eadb148
--- /dev/null
+++ b/Classes/Resolver/BaseResolver.php
@@ -0,0 +1,68 @@
+argument = $check->getArgument();
+ $this->operator = $check->getOperator();
+ $this->value = $check->getValue();
+ }
+
+ public function setup(ResolverData $resolverData)
+ {
+ $this->resolverData = $resolverData;
+ }
+
+ public function setValueForComparison()
+ {
+ }
+
+ /**
+ * Return value may be
+ *
+ * true = Check failed
+ * false = Check okay
+ * null = Missing provider data
+ *
+ * @return bool|null
+ */
+ public function execute()
+ {
+ $result = call_user_func_array([$this, $this->operator . 'Operator'], []);
+ return $result;
+ }
+
+ public function getProviderArguments()
+ {
+ }
+}
diff --git a/Classes/Resolver/ComposerVersionResolver.php b/Classes/Resolver/ComposerVersionResolver.php
new file mode 100644
index 0000000..a7017e3
--- /dev/null
+++ b/Classes/Resolver/ComposerVersionResolver.php
@@ -0,0 +1,17 @@
+valueForComparison, $this->value);
+ }
+
+ public function matchesNotVersionOperator()
+ {
+ return !Semver::satisfies($this->valueForComparison, $this->value);
+ }
+}
diff --git a/Classes/Resolver/ConfigurationResolver.php b/Classes/Resolver/ConfigurationResolver.php
new file mode 100644
index 0000000..1291e73
--- /dev/null
+++ b/Classes/Resolver/ConfigurationResolver.php
@@ -0,0 +1,47 @@
+resolverData->getResponse()['configuration'][$this->argument])) {
+ $this->valueForComparison = $this->resolverData->getResponse()['configuration'][$this->argument];
+ }
+ }
+
+ public function execute()
+ {
+ if (!isset($this->resolverData->getResponse()['configuration'])) {
+ return;
+ }
+ return parent::execute();
+ }
+
+ public function getProviderArguments()
+ {
+ return $this->argument;
+ }
+
+ public function isFalseOperator(): bool
+ {
+ return (bool)$this->valueForComparison === false;
+ }
+
+ public function isTrueOperator(): bool
+ {
+ return (bool)$this->valueForComparison === true;
+ }
+
+ public function isOperator(): bool
+ {
+ return $this->valueForComparison === $this->value;
+ }
+
+ public function isNotOperator(): bool
+ {
+ return $this->valueForComparison !== $this->value;
+ }
+}
diff --git a/Classes/Resolver/CoreVersionResolver.php b/Classes/Resolver/CoreVersionResolver.php
new file mode 100644
index 0000000..a28bd16
--- /dev/null
+++ b/Classes/Resolver/CoreVersionResolver.php
@@ -0,0 +1,12 @@
+valueForComparison = $this->resolverData->getResponse()['core']['typo3Version'];
+ }
+}
diff --git a/Classes/Resolver/ExtensionStateResolver.php b/Classes/Resolver/ExtensionStateResolver.php
new file mode 100644
index 0000000..735831a
--- /dev/null
+++ b/Classes/Resolver/ExtensionStateResolver.php
@@ -0,0 +1,27 @@
+argument, $this->resolverData->getResponse()['extensions']);
+ }
+
+ public function isNotPresentOperator(): bool
+ {
+ return !in_array($this->argument, $this->resolverData->getResponse()['extensions']);
+ }
+
+ public function isLoadedOperator(): bool
+ {
+ return (bool)$this->resolverData->getResponse()['extensions'][$this->argument]['isLoaded'] === true;
+ }
+
+ public function isNotLoadedOperator(): bool
+ {
+ return (bool)$this->resolverData->getResponse()['extensions'][$this->argument]['isLoaded'] === false;
+ }
+}
diff --git a/Classes/Resolver/ExtensionVersionResolver.php b/Classes/Resolver/ExtensionVersionResolver.php
new file mode 100644
index 0000000..230402c
--- /dev/null
+++ b/Classes/Resolver/ExtensionVersionResolver.php
@@ -0,0 +1,12 @@
+valueForComparison = $this->resolverData->getResponse()['extensions'][$this->argument]['version'];
+ }
+}
diff --git a/Classes/Resolver/HeaderResolver.php b/Classes/Resolver/HeaderResolver.php
new file mode 100644
index 0000000..7ffb7c3
--- /dev/null
+++ b/Classes/Resolver/HeaderResolver.php
@@ -0,0 +1,22 @@
+valueForComparison = $this->resolverData->getResponseHeaders()[$this->argument];
+ }
+
+ public function isSetOperator(): bool
+ {
+ return isset($this->valueForComparison);
+ }
+
+ public function isNotSetOperator(): bool
+ {
+ return !isset($this->valueForComparison);
+ }
+}
diff --git a/Classes/Resolver/ResolverInterface.php b/Classes/Resolver/ResolverInterface.php
new file mode 100644
index 0000000..3d2de50
--- /dev/null
+++ b/Classes/Resolver/ResolverInterface.php
@@ -0,0 +1,15 @@
+rules = $ruleRepository->findAll();
+ $this->checkResultRepository = $checkResultRepository;
+ $this->persistenceManager = $persistenceManager;
+ }
+
+ /**
+ * @return array
+ */
+ public function getProviderArguments()
+ {
+ if ($this->providerArguments) {
+ return $this->providerArguments;
+ }
+
+ $allProviderArguments = [];
+ $checks = [];
+ foreach ($this->rules as $rule) {
+ foreach ($rule->getFailureCriteria() as $check) {
+ $checks[$check->getUid()] = $check;
+ }
+ foreach ($rule->getExecutionCriteria() as $check) {
+ $checks[$check->getUid()] = $check;
+ }
+ }
+ foreach ($checks as $check) {
+ $providerArguments = $this->getResolver($check)->getProviderArguments();
+ if ($providerArguments) {
+ if (is_array($providerArguments)) {
+ $allProviderArguments[$check->getType()] = $providerArguments;
+ } else {
+ $allProviderArguments[$check->getType()][] = $providerArguments;
+ }
+ }
+ }
+
+ $this->providerArguments = $allProviderArguments;
+ return $allProviderArguments;
+ }
+
+ /**
+ * @param ResolverData $resolverData
+ * @return CheckResult
+ * @throws IllegalObjectTypeException
+ */
+ public function createCheckResult(ResolverData $resolverData)
+ {
+ $this->resolverData = $resolverData;
+ $checkResult = new CheckResult();
+ $checkResult->setClient($resolverData->getClient()['uid']);
+
+ foreach ($this->rules as $rule) {
+ $this->resolverData->setRule($rule);
+ $checkFailureCriterias = true;
+ foreach ($rule->getExecutionCriteria() as $executionCriteria) {
+ $checkFailureCriterias = $this->runCheck($executionCriteria);
+ if (is_null($checkFailureCriterias)) {
+ $checkResult->setMissingProviderData(true);
+ break;
+ } elseif ($checkFailureCriterias === false) {
+ break;
+ }
+ }
+ if ($checkFailureCriterias === true) {
+ foreach ($rule->getFailureCriteria() as $failureCritera) {
+ $result = $this->runCheck($failureCritera);
+ if ($result === true) {
+ $checkResult->addFailedRule($rule);
+ break;
+ } elseif (is_null($result)) {
+ $checkResult->setMissingProviderData(true);
+ break;
+ }
+ }
+ }
+ }
+
+ $this->checkResultRepository->add($checkResult);
+ $this->persistenceManager->persistAll();
+
+ return $checkResult;
+ }
+
+ /**
+ * @param Check $check
+ * @return null|bool
+ */
+ protected function runCheck(Check $check)
+ {
+ $resolver = $this->getResolver($check);
+ $resolver->setup($this->resolverData);
+ $resolver->setValueForComparison();
+ return $resolver->execute();
+ }
+
+ /**
+ * @param Check $check
+ * @return ResolverInterface
+ */
+ protected function getResolver(Check $check)
+ {
+ $resolverClass = $GLOBALS['TYPO3_CONF_VARS']['EXT']['t3monitoring']['resolver'][$check->getType()];
+ $resolver = GeneralUtility::makeInstance($resolverClass, $check);
+ return $resolver;
+ }
+}
diff --git a/Classes/Service/Import/ClientImport.php b/Classes/Service/Import/ClientImport.php
index 131ea1f..c4dc7f3 100644
--- a/Classes/Service/Import/ClientImport.php
+++ b/Classes/Service/Import/ClientImport.php
@@ -10,8 +10,10 @@
*/
use Exception;
+use T3Monitor\T3monitoring\Domain\Model\Dto\ResolverData;
use T3Monitor\T3monitoring\Domain\Model\Extension;
use T3Monitor\T3monitoring\Notification\EmailNotification;
+use T3Monitor\T3monitoring\Service\CheckResultService;
use T3Monitor\T3monitoring\Service\DataIntegrity;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
@@ -20,6 +22,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
/**
* Class ClientImport
@@ -28,6 +31,10 @@ class ClientImport extends BaseImport
{
const TABLE = 'tx_t3monitoring_domain_model_client';
+ const MESSAGE_INFO = 'info';
+ const MESSAGE_WARNING = 'warning';
+ const MESSAGE_DANGER = 'danger';
+
/** @var array */
protected $coreVersions = [];
@@ -37,9 +44,12 @@ class ClientImport extends BaseImport
/** @var array */
protected $failedClients = [];
- /** @var EmailNotification */
+ /** @var EmailNotification */
protected $emailNotification;
+ /** @var CheckResultService */
+ protected $checkResultService;
+
/**
* Constructor
*/
@@ -47,6 +57,10 @@ public function __construct()
{
$this->coreVersions = $this->getAllCoreVersions();
$this->emailNotification = GeneralUtility::makeInstance(EmailNotification::class);
+
+ $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
+ $this->checkResultService = $objectManager->get(CheckResultService::class);
+
parent::__construct();
}
@@ -101,7 +115,7 @@ public function getResponseCount()
protected function importSingleClient(array $row)
{
try {
- $response = $this->requestClientData($row);
+ list($response, $responseHeaders) = $this->requestClientData($row);
if (empty($response)) {
throw new \RuntimeException('Empty response from client ' . $row['title']);
}
@@ -123,9 +137,14 @@ protected function importSingleClient(array $row)
'error_count' => 0
];
- $this->addExtraData($json, $update, 'info');
- $this->addExtraData($json, $update, 'warning');
- $this->addExtraData($json, $update, 'danger');
+ $resolverData = new ResolverData($row, $json, $responseHeaders);
+ $checkResult = $this->checkResultService->createCheckResult($resolverData);
+ $json = $resolverData->getResponse();
+ $update['check_result'] = $checkResult->getUid();
+
+ $this->addExtraData($json, $update, self::MESSAGE_INFO);
+ $this->addExtraData($json, $update, self::MESSAGE_WARNING);
+ $this->addExtraData($json, $update, self::MESSAGE_DANGER);
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable(self::TABLE);
@@ -179,7 +198,7 @@ protected function handleError(array $client, Exception $error)
/**
* @param array $row
*
- * @return mixed
+ * @return array
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
@@ -199,6 +218,7 @@ protected function requestClientData(array $row)
'headers' => $headers,
'allow_redirects' => true,
'verify' => (bool)!$row['ignore_cert_errors'],
+ 'form_params' => $this->checkResultService->getProviderArguments()
];
if (!empty($row['basic_auth_username']) && !empty($row['basic_auth_password'])) {
$additionalOptions['auth'] = [ $row['basic_auth_username'], $row['basic_auth_password'] ];
@@ -206,15 +226,16 @@ protected function requestClientData(array $row)
if (!empty($row['force_ip_resolve'])) {
$additionalOptions['force_ip_resolve'] = $row['force_ip_resolve'];
}
- $response = $requestFactory->request($url, 'GET', $additionalOptions);
+ $response = $requestFactory->request($url, 'POST', $additionalOptions);
if (!empty($response->getReasonPhrase()) && $response->getReasonPhrase() !== 'OK') {
throw new \RuntimeException($response->getReasonPhrase());
}
+ $responseHeaders = $response->getHeaders();
if (in_array($response->getStatusCode(), [ 200, 301, 302 ], true)) {
$response = $response->getBody()->getContents();
}
- return $response;
+ return [$response, $responseHeaders];
}
/**
diff --git a/Classes/Utility/TcaUtility.php b/Classes/Utility/TcaUtility.php
new file mode 100644
index 0000000..bde0faa
--- /dev/null
+++ b/Classes/Utility/TcaUtility.php
@@ -0,0 +1,16 @@
+ $class) {
+ $config['items'][] = [
+ $class::TITLE,
+ $name
+ ];
+ }
+ return $config;
+ }
+}
diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_check.php b/Configuration/TCA/tx_t3monitoring_domain_model_check.php
new file mode 100644
index 0000000..e4e819c
--- /dev/null
+++ b/Configuration/TCA/tx_t3monitoring_domain_model_check.php
@@ -0,0 +1,189 @@
+ [
+ 'title' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_check',
+ 'label' => 'title',
+ 'default_sortby' => 'title',
+ 'tstamp' => 'tstamp',
+ 'crdate' => 'crdate',
+ 'cruser_id' => 'cruser_id',
+ 'delete' => 'deleted',
+ 'type' => 'type',
+ 'enablecolumns' => [
+ 'disabled' => 'hidden',
+ ],
+ 'searchFields' => 'title',
+ 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_check.gif'
+ ],
+ 'interface' => [
+ 'showRecordFieldList' => 'hidden, title, type, argument, operator, value',
+ ],
+ 'types' => [
+ '1' => [
+ 'showitem' => 'hidden, title, type, argument, operator, value',
+ ],
+ 'configurationValue' => [
+ 'showitem' => 'hidden, title, type, argument, operator, value',
+ 'columnsOverrides' => [
+ 'operator' => [
+ 'config' => [
+ 'items' => [
+ ['is', 'is'],
+ ['is not', 'isNot'],
+ ['is true', 'isTrue'],
+ ['is false', 'isFalse'],
+ ]
+ ]
+ ]
+ ]
+ ],
+ 'header' => [
+ 'showitem' => 'hidden, title, type, argument, operator',
+ 'columnsOverrides' => [
+ 'operator' => [
+ 'config' => [
+ 'items' => [
+ ['is set', 'isSet'],
+ ['is not set', 'isNotSet'],
+ ]
+ ]
+ ]
+ ]
+ ],
+ 'coreVersion' => [
+ 'showitem' => 'hidden, title, type, operator, value',
+ 'columnsOverrides' => [
+ 'operator' => [
+ 'config' => [
+ 'items' => [
+ ['matches', 'matchesVersion'],
+ ['does not matches', 'matchesNotVersion'],
+ ]
+ ]
+ ],
+ 'value' => [
+ 'label' => 'Composer version constraint'
+ ]
+ ]
+ ],
+ 'extensionState' => [
+ 'showitem' => 'hidden, title, type, argument, operator',
+ 'columnsOverrides' => [
+ 'operator' => [
+ 'config' => [
+ 'items' => [
+ ['is present', 'isPresent'],
+ ['is not present', 'isNotPresent'],
+ ['is loaded', 'isLoaded'],
+ ['is not loaded', 'isNotLoaded'],
+ ]
+ ]
+ ],
+ 'argument' => [
+ 'label' => 'Extension key'
+ ]
+ ]
+ ],
+ 'extensionVersion' => [
+ 'showitem' => 'hidden, title, type, operator, value',
+ 'columnsOverrides' => [
+ 'operator' => [
+ 'config' => [
+ 'items' => [
+ ['matches', 'matchesVersion'],
+ ['does not matches', 'matchesNotVersion'],
+ ]
+ ]
+ ],
+ 'value' => [
+ 'label' => 'Composer version constraint'
+ ]
+ ]
+ ],
+ 'backendUser' => [
+ 'showitem' => 'hidden, title, type, argument, operator',
+ 'columnsOverrides' => [
+ 'argument' => [
+ 'label' => 'List of backend users separated by newline',
+ 'config' => [
+ 'type' => 'text'
+ ]
+ ],
+ 'operator' => [
+ 'config' => [
+ 'items' => [
+ ['is active', 'isActive'],
+ ]
+ ]
+ ],
+ ]
+ ],
+ ],
+ 'columns' => [
+ 'hidden' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden',
+ 'config' => [
+ 'type' => 'check',
+ 'items' => [
+ '1' => [
+ '0' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.enabled'
+ ]
+ ],
+ ],
+ ],
+
+ 'title' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_rule.title',
+ 'config' => [
+ 'type' => 'input',
+ 'size' => 255,
+ 'eval' => 'trim'
+ ],
+ ],
+ 'type' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_check.type',
+ 'config' => [
+ 'type' => 'select',
+ 'renderType' => 'selectSingle',
+ 'itemsProcFunc' => \T3Monitor\T3monitoring\Utility\TcaUtility::class . '->getCheckTypes',
+ 'size' => 1,
+ 'maxitems' => 1,
+ 'onChange' => 'reload'
+ ],
+ ],
+ 'argument' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_check.argument',
+ 'config' => [
+ 'type' => 'input',
+ 'size' => 30,
+ 'eval' => 'trim'
+ ],
+ ],
+ 'operator' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_check.operator',
+ 'config' => [
+ 'required' => 1,
+ 'type' => 'select',
+ 'renderType' => 'selectSingle',
+ 'size' => 1,
+ 'maxitems' => 1,
+ 'items' => []
+ ],
+ ],
+ 'value' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_check.value',
+ 'config' => [
+ 'type' => 'input',
+ 'size' => 30,
+ 'eval' => 'trim'
+ ],
+ ],
+
+ ],
+];
diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_checkresult.php b/Configuration/TCA/tx_t3monitoring_domain_model_checkresult.php
new file mode 100644
index 0000000..9216977
--- /dev/null
+++ b/Configuration/TCA/tx_t3monitoring_domain_model_checkresult.php
@@ -0,0 +1,36 @@
+ [
+ 'title' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_checkresult',
+ 'crdate' => 'crdate',
+ 'hideTable' => true,
+ 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_rule.gif'
+ ],
+ 'columns' => [
+ 'client' => [
+ 'config' => [
+ 'type' => 'select',
+ 'renderType' => 'selectMultipleSideBySide',
+ 'foreign_table' => 'tx_t3monitoring_domain_model_client',
+ 'maxitems' => 1,
+ ],
+
+ ],
+ 'failed_rules' => [
+ 'config' => [
+ 'type' => 'select',
+ 'renderType' => 'selectMultipleSideBySide',
+ 'foreign_table' => 'tx_t3monitoring_domain_model_rule',
+ 'MM' => 'tx_t3monitoring_checkresult_failed_rules_mm',
+ 'maxitems' => 9999,
+ ],
+ ],
+ 'missing_provider_data' => [
+ 'config' => [
+ 'readOnly' => true,
+ 'type' => 'check',
+ 'default' => 0
+ ],
+ ],
+ ],
+];
diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_client.php b/Configuration/TCA/tx_t3monitoring_domain_model_client.php
index c3a660e..21fd9d9 100644
--- a/Configuration/TCA/tx_t3monitoring_domain_model_client.php
+++ b/Configuration/TCA/tx_t3monitoring_domain_model_client.php
@@ -299,5 +299,16 @@
'maxitems' => 1,
],
],
+ 'check_result' => [
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_client.check_result',
+ 'config' => [
+ 'readOnly' => true,
+ 'type' => 'select',
+ 'renderType' => 'selectSingle',
+ 'foreign_table' => 'tx_t3monitoring_domain_model_checkresult',
+ 'minitems' => 0,
+ 'maxitems' => 1,
+ ],
+ ],
],
];
diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_rule.php b/Configuration/TCA/tx_t3monitoring_domain_model_rule.php
new file mode 100644
index 0000000..7443171
--- /dev/null
+++ b/Configuration/TCA/tx_t3monitoring_domain_model_rule.php
@@ -0,0 +1,115 @@
+ [
+ 'title' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_rule',
+ 'label' => 'title',
+ 'default_sortby' => 'title',
+ 'tstamp' => 'tstamp',
+ 'crdate' => 'crdate',
+ 'cruser_id' => 'cruser_id',
+ 'delete' => 'deleted',
+ 'enablecolumns' => [
+ 'disabled' => 'hidden',
+ ],
+ 'searchFields' => 'title',
+ 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_rule.gif'
+ ],
+ 'interface' => [
+ 'showRecordFieldList' => 'hidden, title, description, message_category, execution_criteria, failure_criteria',
+ ],
+ 'types' => [
+ '1' => ['showitem' => 'hidden, title, description, message_category, execution_criteria, failure_criteria'],
+ ],
+ 'columns' => [
+ 'hidden' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden',
+ 'config' => [
+ 'type' => 'check',
+ 'items' => [
+ '1' => [
+ '0' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.enabled'
+ ]
+ ],
+ ],
+ ],
+
+ 'title' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_rule.title',
+ 'config' => [
+ 'type' => 'input',
+ 'size' => 255,
+ 'eval' => 'trim'
+ ],
+ ],
+
+ 'description' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_rule.description',
+ 'config' => [
+ 'type' => 'text',
+ 'eval' => 'trim'
+ ],
+ ],
+ 'execution_criteria' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_rule.execution_criteria',
+ 'config' => [
+ 'type' => 'select',
+ 'renderType' => 'selectMultipleSideBySide',
+ 'enableMultiSelectFilterTextfield' => true,
+ 'foreign_table' => 'tx_t3monitoring_domain_model_check',
+ 'MM' => 'tx_t3monitoring_rule_check_mm',
+ 'size' => 3,
+ 'autoSizeMax' => 30,
+ 'maxitems' => 9999,
+ 'fieldControl' => [
+ 'editPopup' => [
+ 'disabled' => false,
+ ],
+ 'addRecord' => [
+ 'disabled' => false,
+ ],
+ ],
+ ],
+
+ ],
+ 'failure_criteria' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_rule.failure_criteria',
+ 'config' => [
+ 'type' => 'select',
+ 'renderType' => 'selectMultipleSideBySide',
+ 'enableMultiSelectFilterTextfield' => true,
+ 'foreign_table' => 'tx_t3monitoring_domain_model_check',
+ 'MM' => 'tx_t3monitoring_rule_failure_criteria_check_mm',
+ 'size' => 3,
+ 'autoSizeMax' => 30,
+ 'maxitems' => 9999,
+ 'fieldControl' => [
+ 'editPopup' => [
+ 'disabled' => false,
+ ],
+ 'addRecord' => [
+ 'disabled' => false,
+ ],
+ ],
+ ],
+
+ ],
+ 'message_category' => [
+ 'exclude' => true,
+ 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang_db.xlf:tx_t3monitoring_domain_model_rule.message_category',
+ 'config' => [
+ 'type' => 'select',
+ 'size' => 1,
+ 'items' => [
+ ['Information', \T3Monitor\T3monitoring\Service\Import\ClientImport::MESSAGE_INFO],
+ ['Warning', \T3Monitor\T3monitoring\Service\Import\ClientImport::MESSAGE_WARNING],
+ ['Dangerous', \T3Monitor\T3monitoring\Service\Import\ClientImport::MESSAGE_DANGER]
+ ]
+ ],
+ ],
+ ],
+];
diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf
index 0ff62c8..bbed187 100644
--- a/Resources/Private/Language/locallang.xlf
+++ b/Resources/Private/Language/locallang.xlf
@@ -387,6 +387,12 @@
+
+ Missing provider data
+
+
+ Some rules can not be checked because monitoring client does not provide needed data (Outdated).
+
Core
@@ -491,6 +497,9 @@
The data of the client has been successfully fetched!
+
+ Rules
+