Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/setup-wizard-7163
- Loading branch information
Showing
29 changed files
with
602 additions
and
568 deletions.
There are no files selected for viewing
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
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,50 @@ | ||
<?php | ||
|
||
namespace Icinga\Application\Logger\Writer; | ||
|
||
use Icinga\Cli\Screen; | ||
use Icinga\Application\Logger\Logger; | ||
use Icinga\Application\Logger\LogWriter; | ||
use Zend_Config; | ||
|
||
/** | ||
* Class to write log messages to STDOUT | ||
*/ | ||
class StdoutWriter extends LogWriter | ||
{ | ||
protected $screen; | ||
|
||
protected function screen() | ||
{ | ||
if ($this->screen === null) { | ||
$this->screen = Screen::instance(); | ||
} | ||
return $this->screen; | ||
} | ||
|
||
/** | ||
* Log a message with the given severity | ||
* | ||
* @param int $severity The severity to use | ||
* @param string $message The message to log | ||
*/ | ||
public function log($severity, $message) | ||
{ | ||
$color = 'black'; | ||
switch ($severity) { | ||
case Logger::$ERROR: | ||
$color = 'red'; | ||
break; | ||
case Logger::$WARNING: | ||
$color = 'orange'; | ||
break; | ||
case Logger::$INFO: | ||
$color = 'green'; | ||
break; | ||
case Logger::$DEBUG: | ||
$color = 'blue'; | ||
break; | ||
} | ||
file_put_contents('php://stderr', $this->screen()->colorize($message, $color) . "\n"); | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -224,6 +224,7 @@ public static function getAvailableLocaleCodes() | |
} | ||
} | ||
} | ||
sort($codes); | ||
|
||
return $codes; | ||
} | ||
|
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,90 @@ | ||
<?php | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
|
||
namespace Icinga\Web\Menu; | ||
|
||
use Icinga\Module\Monitoring\Backend\MonitoringBackend; | ||
use Icinga\Web\Menu; | ||
use Icinga\Web\Url; | ||
|
||
class MonitoringMenuItemRenderer implements MenuItemRenderer { | ||
|
||
protected static $summary; | ||
|
||
protected $columns = array(); | ||
|
||
protected static function summary($column = null) | ||
{ | ||
if (self::$summary === null) { | ||
self::$summary = MonitoringBackend::instance()->select()->from( | ||
'statusSummary', | ||
array( | ||
'hosts_down_unhandled', | ||
'services_critical_unhandled' | ||
) | ||
)->getQuery()->fetchRow(); | ||
} | ||
|
||
if ($column === null) { | ||
return self::$summary; | ||
} elseif (isset(self::$summary->$column)) { | ||
return self::$summary->$column; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
protected function getBadgeTitle() | ||
{ | ||
$translations = array( | ||
'hosts_down_unhandled' => mt('monitoring', '%d unhandled hosts down'), | ||
'services_critical_unhandled' => mt('monitoring', '%d unhandled services critical') | ||
); | ||
|
||
$titles = array(); | ||
$sum = $this->summary(); | ||
|
||
foreach ($this->columns as $col) { | ||
if (isset($sum->$col) && $sum->$col > 0) { | ||
$titles[] = sprintf($translations[$col], $sum->$col); | ||
} | ||
} | ||
|
||
return implode(', ', $titles); | ||
} | ||
|
||
protected function countItems() | ||
{ | ||
$sum = self::summary(); | ||
$count = 0; | ||
|
||
foreach ($this->columns as $col) { | ||
if (isset($sum->$col)) { | ||
$count += $sum->$col; | ||
} | ||
} | ||
|
||
return $count; | ||
} | ||
|
||
public function render(Menu $menu) | ||
{ | ||
$count = $this->countItems(); | ||
$badge = ''; | ||
if ($count) { | ||
$badge = sprintf( | ||
'<div title="%s" class="badge-container"><span class="badge badge-critical">%s</span></div>', | ||
$this->getBadgeTitle(), | ||
$count | ||
); | ||
} | ||
return sprintf( | ||
'<a href="%s">%s%s%s</a>', | ||
$menu->getUrl() ?: '#', | ||
$menu->getIcon() ? '<img src="' . Url::fromPath($menu->getIcon()) . '" class="icon" /> ' : '', | ||
htmlspecialchars($menu->getTitle()), | ||
$badge | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,39 +1,11 @@ | ||
<?php | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
|
||
namespace Icinga\Web\Menu; | ||
|
||
use Icinga\Module\Monitoring\Backend; | ||
use Icinga\Web\Menu; | ||
use Icinga\Web\Url; | ||
|
||
class ProblemMenuItemRenderer implements MenuItemRenderer { | ||
|
||
public function render(Menu $menu) | ||
{ | ||
$statusSummary = Backend::createBackend() | ||
->select()->from( | ||
'statusSummary', | ||
array( | ||
'hosts_down_unhandled', | ||
'services_critical_unhandled' | ||
) | ||
)->getQuery()->fetchRow(); | ||
$unhandled = $statusSummary->hosts_down_unhandled + $statusSummary->services_critical_unhandled; | ||
$badge = ''; | ||
if ($unhandled) { | ||
$badge = sprintf( | ||
'<div class="badge-container"><span class="badge badge-critical">%s</span></div>', | ||
$unhandled | ||
); | ||
} | ||
return sprintf( | ||
'<a href="%s">%s%s %s</a>', | ||
$menu->getUrl() ?: '#', | ||
$menu->getIcon() ? '<img src="' . Url::fromPath($menu->getIcon()) . '" class="icon" /> ' : '', | ||
htmlspecialchars($menu->getTitle()), | ||
$badge | ||
); | ||
} | ||
class ProblemMenuItemRenderer extends MonitoringMenuItemRenderer | ||
{ | ||
protected $columns = array( | ||
'hosts_down_unhandled', | ||
'services_critical_unhandled' | ||
); | ||
} |
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 |
---|---|---|
@@ -1,38 +1,12 @@ | ||
<?php | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
|
||
namespace Icinga\Web\Menu; | ||
|
||
use Icinga\Module\Monitoring\Backend; | ||
use Icinga\Web\Menu; | ||
use Icinga\Web\Url; | ||
|
||
class UnhandledHostMenuItemRenderer implements MenuItemRenderer { | ||
|
||
public function render(Menu $menu) | ||
{ | ||
$statusSummary = Backend::createBackend() | ||
->select()->from( | ||
'statusSummary', | ||
array( | ||
'hosts_down_unhandled' | ||
) | ||
)->getQuery()->fetchRow(); | ||
$badge = ''; | ||
if ($statusSummary->hosts_down_unhandled) { | ||
$badge = sprintf( | ||
'<div title="%s" class="badge-container"><span class="badge badge-critical">%s</span></div>', | ||
t(sprintf('%d unhandled host problems', $statusSummary->hosts_down_unhandled)), | ||
$statusSummary->hosts_down_unhandled | ||
); | ||
} | ||
return sprintf( | ||
'<a href="%s">%s%s %s</a>', | ||
$menu->getUrl() ?: '#', | ||
$menu->getIcon() ? '<img src="' . Url::fromPath($menu->getIcon()) . '" class="icon" /> ' : '', | ||
htmlspecialchars($menu->getTitle()), | ||
$badge | ||
); | ||
} | ||
class UnhandledHostMenuItemRenderer extends MonitoringMenuItemRenderer | ||
{ | ||
protected $columns = array( | ||
'hosts_down_unhandled', | ||
); | ||
} |
Oops, something went wrong.