Perfdata and PluginOutput helpers, output slightly changed
This commit is contained in:
parent
b09ea7c690
commit
0e50547a01
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
||||||
|
|
||||||
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
{
|
{
|
||||||
|
@ -67,11 +67,11 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
. implode(',', array($green, $orange, $red, $gray))
|
. implode(',', array($green, $orange, $red, $gray))
|
||||||
. '</div>';
|
. '</div>';
|
||||||
} else {
|
} else {
|
||||||
$result .= '<tr><td><div class="inlinepie" title="' . htmlspecialchars($name) . '">'
|
$result .= '<tr><th><div class="inlinepie" title="' . htmlspecialchars($name) . '" style="float: left; margin: 0.2em 0.5em 0.2em 0;">'
|
||||||
. implode(',', array($green, $orange, $red, $gray))
|
. implode(',', array($green, $orange, $red, $gray))
|
||||||
. '</div></td><td>'
|
. '</div>'
|
||||||
. htmlspecialchars($name)
|
. htmlspecialchars($name)
|
||||||
. '</td><td>'
|
. '</th><td>'
|
||||||
. htmlspecialchars($ps[$name]->getFormattedValue() /* $val*/)
|
. htmlspecialchars($ps[$name]->getFormattedValue() /* $val*/)
|
||||||
//. htmlspecialchars($unit)
|
//. htmlspecialchars($unit)
|
||||||
. '</td></tr>';
|
. '</td></tr>';
|
||||||
|
@ -81,7 +81,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
$result = $perfdata;
|
$result = $perfdata;
|
||||||
}
|
}
|
||||||
if (! $compact && $result !== '') {
|
if (! $compact && $result !== '') {
|
||||||
$result = '<table style="width: 100%; border: none;">' . $result . '</table>';
|
$result = '<table class="perfdata">' . $result . '</table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -6,14 +6,18 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
|
||||||
|
|
||||||
public function pluginOutput($output)
|
public function pluginOutput($output)
|
||||||
{
|
{
|
||||||
|
if (empty($output)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$output = preg_replace('~<br[^>]+>~', "\n", $output);
|
||||||
if (preg_match('~<\w+[^>]*>~', $output)) {
|
if (preg_match('~<\w+[^>]*>~', $output)) {
|
||||||
// HTML
|
// HTML
|
||||||
$output = preg_replace('~<table~', '<table style="font-size: 0.65em"',
|
$output = preg_replace('~<table~', '<table style="font-size: 0.75em"',
|
||||||
$this->getPurifier()->purify($output)
|
$this->getPurifier()->purify($output)
|
||||||
);
|
);
|
||||||
} elseif (preg_match('~\\\n~', $output)) {
|
} elseif (preg_match('~\\\n~', $output)) {
|
||||||
// Plaintext
|
// Plaintext
|
||||||
$output = '<pre style="font-family: monospace; font-size: 0.95em;'
|
$output = '<pre style="font-family: monospace; font-size: 1em;'
|
||||||
. ' width: 90%; overflow: auto;">'
|
. ' width: 90%; overflow: auto;">'
|
||||||
. preg_replace(
|
. preg_replace(
|
||||||
'~\\\n~', "\n", preg_replace(
|
'~\\\n~', "\n", preg_replace(
|
||||||
|
@ -22,14 +26,16 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
|
||||||
preg_replace('~\[WARNING\]~', '<span class="warning">[WARNING]</span>',
|
preg_replace('~\[WARNING\]~', '<span class="warning">[WARNING]</span>',
|
||||||
preg_replace('~\[CRITICAL\]~', '<span class="error">[CRITICAL]</span>',
|
preg_replace('~\[CRITICAL\]~', '<span class="error">[CRITICAL]</span>',
|
||||||
preg_replace('~\@{6,}~', '@@@@@@',
|
preg_replace('~\@{6,}~', '@@@@@@',
|
||||||
$this->view->escape(wordwrap($output, 72, ' ', true))
|
$this->view->escape(wordwrap($output, 80, "\n", true))
|
||||||
))))
|
))))
|
||||||
)
|
)
|
||||||
) . '</pre>';
|
) . '</pre>';
|
||||||
} else {
|
} else {
|
||||||
$output = preg_replace('~\@{6,}~', '@@@@@@',
|
$output = '<pre style="font-family: monospace; font-size: 1em;'
|
||||||
$this->view->escape(wordwrap($output, 72, ' ', true))
|
. ' width: 90%; overflow: auto;">'
|
||||||
);
|
. preg_replace('~\@{6,}~', '@@@@@@',
|
||||||
|
$this->view->escape(wordwrap($output, 80, "\n", true))
|
||||||
|
) . '</pre>';
|
||||||
}
|
}
|
||||||
$output = $this->fixLinks($output);
|
$output = $this->fixLinks($output);
|
||||||
return $output;
|
return $output;
|
||||||
|
|
Loading…
Reference in New Issue