-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
'renamed check_oracle_health-tablespace-free, added check_xxx_health-…
…tablespace-usage'
- Loading branch information
1 parent
c373eb9
commit afedd32
Showing
2 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...t/check_oracle_health-tablespace-free.php → ...ault/check_xxx_health-tablespace-free.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/** | ||
This template is used for check_oracle_health/check_db2_health mode: tabelspace-usage. | ||
PHP version 5 | ||
@category Template_File | ||
@package Histou/templates/default | ||
@author Philip Griesbacher <griesbacher@consol.de> | ||
@license http://opensource.org/licenses/gpl-license.php GNU Public License | ||
@link https://github.com/Griesbacher/histou | ||
**/ | ||
|
||
$rule = new \histou\template\Rule( | ||
$host = '.*', | ||
$service = '.*', | ||
$command = '.*', | ||
$perfLabel = array('^tbs_(.*?)_usage(_pct)?$') | ||
); | ||
|
||
$genTemplate = function ($perfData) { | ||
$colors = array('#085DFF', '#07ff78', "#BA43A9", "#C15C17"); | ||
$dashboard = \histou\grafana\dashboard\DashboardFactory::generateDashboard($perfData['host'].'-'.$perfData['service']); | ||
$dashboard->addDefaultAnnotations($perfData['host'], $perfData['service']); | ||
$templateName = 'Database'; | ||
$dashboard->addTemplateForPerformanceLabel( | ||
$templateName, | ||
$perfData['host'], | ||
$perfData['service'], | ||
$regex = '^tbs_(.*?)_usage$', | ||
$multiFormat = true, | ||
$includeAll = false | ||
); | ||
$tempalteVariableString = $dashboard->genTemplateVariable($templateName); | ||
$database = ""; | ||
|
||
foreach ($perfData['perfLabel'] as $key => $value) { | ||
if (preg_match(';^tbs_(.*?)_usage$;', $key, $hit)) { | ||
$database = $key; | ||
break; | ||
} | ||
} | ||
$types = array( | ||
'pct' => array("usage_pct"), | ||
'fix' => array("usage") | ||
); | ||
$numberPanels = 0; | ||
$row = new \histou\grafana\Row($perfData['service'].' '.$perfData['command']); | ||
|
||
foreach ($types as $type => $labels) { | ||
$panel = \histou\grafana\graphpanel\GraphPanelFactory::generatePanel($perfData['service']." $tempalteVariableString ". $type); | ||
$panel->setSpan(6); | ||
if ($type == 'fix' && isset($perfData['perfLabel'][$database]['unit'])) { | ||
$panel->setLeftUnit($perfData['perfLabel'][$database]['unit']); | ||
} elseif ($type == 'pct') { | ||
$panel->setLeftUnit('%'); | ||
} | ||
|
||
$currentColorIndex = 0; | ||
foreach ($labels as $label) { | ||
if (DATABASE_TYPE == ELASTICSEARCH) { //https://github.com/grafana/grafana/issues/4075 | ||
$perfLabel = "tbs_".$tempalteVariableString."\_".$label; | ||
} else { | ||
$perfLabel = "tbs_".$tempalteVariableString."_".$label; | ||
} | ||
$target = $panel->genTargetSimple($perfData['host'], $perfData['service'], $perfData['command'], $perfLabel); | ||
$panel->addTarget($panel->genDowntimeTarget($perfData['host'], $perfData['service'], $perfData['command'], $perfLabel)); | ||
$target = $panel->addWarnToTarget($target, $perfLabel, false); | ||
$target = $panel->addCritToTarget($target, $perfLabel, false); | ||
$panel->addTarget($target); | ||
$panel->addRegexColor("/^tbs_.*?_$label-value$/", $colors[$currentColorIndex++]); | ||
} | ||
$panel->addRegexColor('/^tbs_.*?-warn-?(min|max)?$/', '#FFFC15'); | ||
$panel->addRegexColor('/^tbs_.*?-crit-?(min|max)?$/', '#FF3727'); | ||
|
||
$row->addPanel($panel); | ||
} | ||
$row->setCustomProperty("repeat", $templateName); | ||
$dashboard->addRow($row); | ||
return $dashboard; | ||
}; |