Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions application/controllers/IcingadbimgController.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ public function indexAction()
}
if ($this->dataSource == "graphite") {
$arr[1] = Util::graphiteReplace($arr[1]);
} elseif ($this->dataSource == "taos") {
$arr[1] = Util::taosReplace($arr[1]);
}
$customVars .= '&' . $arr[0] . '=' . rawurlencode($arr[1]);
}
Expand All @@ -205,6 +207,11 @@ public function indexAction()
$hostName = Util::graphiteReplace($hostName);
}

// Replace special chars for tsdb
if ($this->dataSource == "taos") {
$serviceName = Util::taosReplace($serviceName);
}

$imageHtml = "";
$result = $this->getMyimageHtml($serviceName, $hostName, $imageHtml);

Expand Down
1 change: 1 addition & 0 deletions application/forms/Config/GeneralConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public function createElements(array $formData)
'multiOptions' => [
'influxdb' => $this->translate('InfluxDB'),
'graphite' => $this->translate('Graphite'),
'taos' => $this->translate('TDengine'),
],
'description' => $this->translate('Select the Grafana datasource.')
]
Expand Down
7 changes: 7 additions & 0 deletions library/Grafana/Helpers/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public static function graphiteReplace(string $string = ''): string
return $string;
}

public static function taosReplace(string $string = ''): string
{
$string = preg_replace('/[^a-zA-Z0-9\*\-:]/', '_', $string);

return $string;
}

/**
* getUserThemeMode returns the users configured Theme Mode.
* Since we cannot handle the 'system' setting (it's client-side),
Expand Down
9 changes: 8 additions & 1 deletion library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ public function getPreviewHtml(Model $object, $report = false)
$hostName = Util::graphiteReplace($hostName);
}

// Replace special chars for tsdb
if ($this->dataSource == "taos" && $this->accessMode !== "indirectproxy") {
$serviceName = Util::taosReplace($serviceName);
}

if (! empty($this->customVars)) {
// replace template to customVars from Icinga2
foreach ($customvars as $k => $v) {
Expand All @@ -408,6 +413,8 @@ public function getPreviewHtml(Model $object, $report = false)
}
if ($this->dataSource === "graphite") {
$arr[1] = Util::graphiteReplace($arr[1]);
} elseif ($this->dataSource == "taos") {
$arr[1] = Util::taosReplace($arr[1]);
}
$customVars .= '&' . $arr[0] . '=' . rawurlencode(implode('=', array_slice($arr, 1)));
}
Expand All @@ -424,7 +431,7 @@ public function getPreviewHtml(Model $object, $report = false)
$this->dashboarduid,
$this->dashboard,
rawurlencode(($this->dataSource === 'graphite' ? Util::graphiteReplace($hostName) : $hostName)),
rawurlencode(($this->dataSource === 'graphite' ? Util::graphiteReplace($serviceName) : $serviceName)),
rawurlencode(($this->dataSource === 'graphite' ? Util::graphiteReplace($serviceName) : ($this->dataSource === 'taos' ? Util::taosReplace($serviceName) : $serviceName))),
rawurlencode($object->checkcommand_name),
$this->customVars,
urlencode($this->timerange),
Expand Down