Przeglądaj źródła

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

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2920 a333f486-631f-4898-b8df-5754b55c2be0
romainq 11 lat temu
rodzic
commit
b2ccd4b99c
2 zmienionych plików z 25 dodań i 10 usunięć
  1. 5 6
      application/itopwebpage.class.inc.php
  2. 20 4
      core/kpi.class.inc.php

+ 5 - 6
application/itopwebpage.class.inc.php

@@ -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$')
 		{

+ 20 - 4
core/kpi.class.inc.php

@@ -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!