Reviewed the instrumentation to help in tuning the performance (added a message in the admin banner when logging is active)

SVN:trunk[2920]
This commit is contained in:
Romain Quetiez
2013-10-16 10:33:30 +00:00
parent 2d83f331e2
commit 5d402a5f9d
2 changed files with 25 additions and 10 deletions

View File

@@ -510,6 +510,11 @@ EOF
{
$sNorthPane .= $oExtensionInstance->GetNorthPaneHtml($this);
}
if (UserRights::IsAdministrator() && ExecutionKPI::IsEnabled())
{
$sNorthPane .= '<div id="admin-banner"><span style="padding:5px;">'.ExecutionKPI::GetDescription().'<span></div>';
}
$sSouthPane = '';
foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance)
@@ -610,12 +615,6 @@ EOF
$sHtml .= "</head>\n";
$sHtml .= "<body>\n";
// Render the revision number
if (ITOP_REVISION == '$WCREV$')
{

View File

@@ -60,15 +60,31 @@ class ExecutionKPI
self::$m_sAllowedUser = $sUser;
}
static public function ReportStats()
static public function IsEnabled()
{
if (self::$m_sAllowedUser != '*')
if (self::$m_bEnabled_Duration || self::$m_bEnabled_Memory)
{
if (UserRights::GetUser() != self::$m_sAllowedUser)
if ((self::$m_sAllowedUser == '*') || (UserRights::GetUser() == trim(self::$m_sAllowedUser)))
{
return;
return true;
}
}
return false;
}
static public function GetDescription()
{
$aFeatures = array();
if (self::$m_bEnabled_Duration) $aFeatures[] = 'Duration';
if (self::$m_bEnabled_Memory) $aFeatures[] = 'Memory usage';
$sFeatures = implode(', ', $aFeatures);
$sFor = self::$m_sAllowedUser == '*' ? 'EVERYBODY' : "'".trim(self::$m_sAllowedUser)."'";
return "KPI logging is active for $sFor. Measures: $sFeatures";
}
static public function ReportStats()
{
if (!self::IsEnabled()) return;
global $fItopStarted;
$sExecId = microtime(); // id to differentiate the hrefs!