mirror of
https://github.com/Icinga/icingaweb2-module-graphite.git
synced 2026-02-18 18:25:09 -05:00
commit
dae46c61d5
12 changed files with 54 additions and 53 deletions
2
.github/workflows/php.yml
vendored
2
.github/workflows/php.yml
vendored
|
|
@ -39,4 +39,4 @@ jobs:
|
|||
|
||||
- name: PHP CodeSniffer
|
||||
if: success() || matrix.allow_failure
|
||||
run: phpcs
|
||||
run: phpcs -wps --colors
|
||||
|
|
|
|||
25
.phpcs.xml
25
.phpcs.xml
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="PHP_CodeSniffer">
|
||||
<description>Sniff our code a while</description>
|
||||
|
||||
<file>./</file>
|
||||
|
||||
<exclude-pattern>vendor/*</exclude-pattern>
|
||||
|
||||
<arg value="wps"/>
|
||||
<arg name="report-width" value="auto"/>
|
||||
<arg name="report-full"/>
|
||||
<arg name="report-gitblame"/>
|
||||
<arg name="report-summary"/>
|
||||
<arg name="encoding" value="UTF-8"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
|
||||
<rule ref="PSR2"/>
|
||||
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<properties>
|
||||
<property name="lineLimit" value="120"/>
|
||||
<property name="absoluteLineLimit" value="0"/>
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2018 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Graphite\Clicommands;
|
||||
|
|
@ -124,11 +125,13 @@ EOT
|
|||
$macros['service_name_template'] = [''];
|
||||
|
||||
foreach ($this->cartesianProduct($macros) as $macroValues) {
|
||||
if (preg_match(
|
||||
'/\A\.[^.]+\.(.+)\.[^.]+\z/',
|
||||
$metricFilter->resolve($macroValues),
|
||||
$match
|
||||
)) {
|
||||
if (
|
||||
preg_match(
|
||||
'/\A\.[^.]+\.(.+)\.[^.]+\z/',
|
||||
$metricFilter->resolve($macroValues),
|
||||
$match
|
||||
)
|
||||
) {
|
||||
$perfdata[$match[1]] = $max;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,10 +145,13 @@ class CommonForm extends Form
|
|||
$params = $this->getRedirectUrl()->getParams();
|
||||
$seconds = TimeRangePickerTools::getRelativeSeconds($params);
|
||||
|
||||
if ($seconds === null && count(array_intersect_key(
|
||||
$params->toArray(false),
|
||||
array_keys(TimeRangePickerTools::getAllRangeParameters())
|
||||
)) === 0) {
|
||||
if (
|
||||
$seconds === null
|
||||
&& count(array_intersect_key(
|
||||
$params->toArray(false),
|
||||
array_keys(TimeRangePickerTools::getAllRangeParameters())
|
||||
)) === 0
|
||||
) {
|
||||
$seconds = TimeRangePickerTools::getDefaultRelativeTimeRange();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,8 @@ class Template
|
|||
if (! isset($handledCurves[$curveName2])) {
|
||||
foreach ($metrics1 as $metric1 => & $vars1) {
|
||||
foreach ($metrics2 as $metric2 => & $vars2) {
|
||||
if (count(array_intersect_assoc($vars1, $vars2))
|
||||
if (
|
||||
count(array_intersect_assoc($vars1, $vars2))
|
||||
=== count(array_intersect_key($vars1, $vars2))
|
||||
) {
|
||||
$possibleCombinations[$curveName1][$curveName2][$metric1][$metric2] = true;
|
||||
|
|
|
|||
|
|
@ -71,14 +71,16 @@ class Templates
|
|||
*/
|
||||
public function loadDir($path)
|
||||
{
|
||||
foreach (new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator(
|
||||
$path,
|
||||
RecursiveDirectoryIterator::KEY_AS_PATHNAME | RecursiveDirectoryIterator::CURRENT_AS_FILEINFO
|
||||
foreach (
|
||||
new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator(
|
||||
$path,
|
||||
RecursiveDirectoryIterator::KEY_AS_PATHNAME | RecursiveDirectoryIterator::CURRENT_AS_FILEINFO
|
||||
| RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::FOLLOW_SYMLINKS
|
||||
),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY
|
||||
) as $filepath => $fileinfo) {
|
||||
),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY
|
||||
) as $filepath => $fileinfo
|
||||
) {
|
||||
/** @var SplFileInfo $fileinfo */
|
||||
|
||||
if ($fileinfo->isFile() && preg_match('/\A[^.].*\.ini\z/si', $fileinfo->getFilename())) {
|
||||
|
|
@ -171,10 +173,12 @@ class Templates
|
|||
);
|
||||
}
|
||||
|
||||
if (count(array_intersect(
|
||||
$curves[$curve][0]->getMacros(),
|
||||
['host_name_template', 'service_name_template']
|
||||
)) !== 1) {
|
||||
if (
|
||||
count(array_intersect(
|
||||
$curves[$curve][0]->getMacros(),
|
||||
['host_name_template', 'service_name_template']
|
||||
)) !== 1
|
||||
) {
|
||||
throw new ConfigurationError(
|
||||
'Bad metrics filter "%s" for curve "%s" of template "%s" in file "%s": must include'
|
||||
. ' either the macro $host_name_template$ or $service_name_template$, but not both',
|
||||
|
|
|
|||
|
|
@ -6,5 +6,4 @@ use Icinga\Module\Icingadb\Hook\IcingadbSupportHook;
|
|||
|
||||
class IcingadbSupport extends IcingadbSupportHook
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Icinga\Module\Graphite\ProvidedHook\Icingadb;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
|
||||
use Icinga\Module\Graphite\Util\InternalProcessTracker as IPT;
|
||||
use Icinga\Module\Graphite\Web\Controller\TimeRangePickerTrait;
|
||||
use Icinga\Module\Graphite\Web\Widget\Graphs;
|
||||
|
|
|
|||
|
|
@ -246,10 +246,12 @@ abstract class Graphs extends AbstractWidget
|
|||
IPT::recordf("Icinga check command: %s", $this->checkCommand);
|
||||
IPT::recordf("Obscured check command: %s", $this->obscuredCheckCommand);
|
||||
|
||||
foreach ([
|
||||
foreach (
|
||||
[
|
||||
['template', $concreteTemplates, []],
|
||||
['default_template', $allTemplates->getDefaultTemplates(), $excludedMetrics],
|
||||
] as $templateSet) {
|
||||
] as $templateSet
|
||||
) {
|
||||
list($urlParam, $templates, $excludeMetrics) = $templateSet;
|
||||
|
||||
if ($urlParam === 'template') {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb;
|
|||
use Icinga\Module\Graphite\Graphing\Template;
|
||||
use Icinga\Module\Graphite\Web\Widget\Graphs;
|
||||
use Icinga\Web\Url;
|
||||
use \Icinga\Module\Icingadb\Model\Host;
|
||||
use Icinga\Module\Icingadb\Model\Host;
|
||||
|
||||
class IcingadbHost extends Graphs
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb;
|
|||
use Icinga\Module\Graphite\Graphing\Template;
|
||||
use Icinga\Module\Graphite\Web\Widget\Graphs;
|
||||
use Icinga\Web\Url;
|
||||
use \Icinga\Module\Icingadb\Model\Service;
|
||||
use Icinga\Module\Icingadb\Model\Service;
|
||||
|
||||
class IcingadbService extends Graphs
|
||||
{
|
||||
|
|
|
|||
15
phpcs.xml
Normal file
15
phpcs.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="PSR12">
|
||||
<!-- Test all PHP files except those in vendor/ -->
|
||||
<file>./</file>
|
||||
<arg name="extensions" value="php"/>
|
||||
<exclude-pattern>vendor/*</exclude-pattern>
|
||||
|
||||
<arg name="report-width" value="auto"/>
|
||||
<arg name="report-full"/>
|
||||
<arg name="report-gitblame"/>
|
||||
<arg name="report-summary"/>
|
||||
<arg name="encoding" value="UTF-8"/>
|
||||
|
||||
<rule ref="PSR12"/>
|
||||
</ruleset>
|
||||
Loading…
Reference in a new issue