服务器 频道

虚拟化环境可用计算资源相关综合分析

  下面列出了查询VMware虚拟化环境下所有的虚拟化主机的名称、CPU、内存、磁盘空间、主机上所部属的虚拟机总数量的查询语句,其中“1130826000000000”代表是2013年8月26日的数据,TEMP1, TEMP2, TEMP3, TEMP4分别作为临时表,存放上述四个方面的基本信息数据。

  其查询结果如图1中所示。

WITH
TEMP1 AS
(SELECT A."Server_Hostname" as Server_Hostname, MAX(A."AVG_CPU_Utilization") AS AVG_CPU_Utilization
 FROM  ITMUSER.KVM_SERVER_CPU_D A
 WHERE A.SHIFTPERIOD = -1
 AND A.WRITETIME =  '1130826000000000'
 AND A."Server_Hostname" <>''
GROUP BY A."Server_Hostname"),

TEMP2 AS
(SELECT B."Server_Hostname" as Server_Hostname, MAX(B."MAX_Physical_Memory")- MAX(B."AVG_Memory_Usage") AS Free_Momory_MB
 FROM  ITMUSER.KVM_SERVER_Memory_D B
 WHERE B.SHIFTPERIOD = -1
 AND B.WRITETIME =  '1130826000000000'
 AND B."Server_Hostname" <>''
 AND B."AVG_Memory_Usage" >0
GROUP BY B."Server_Hostname"),

TEMP3 AS(SELECT C."Server_Hostname" as Server_Hostname, SUM(C."AVG_Free_Space") as Free_Space_MB
FROM ITMUSER.KVM_SERVER_DATASTORE_D C
WHERE  C.shiftperiod = -1
AND C.writetime = '1130826000000000'
AND C."Server_Hostname" <>''
GROUP BY C."Server_Hostname"),

TEMP4 AS
(SELECT  D."Server_Hostname" as Server_Hostname, MAX(D."MAX_Number_VMs_On") AS Max_Number_VMs_On
FROM  ITMUSER.KVM_SERVER_D D
WHERE D.SHIFTPERIOD = -1
 AND D.WRITETIME =  '1130826000000000'
 AND D."Server_Hostname" <>''
GROUP BY D."Server_Hostname")

SELECT TEMP1.Server_Hostname, TEMP1.AVG_CPU_Utilization, TEMP2.Free_Momory_MB, TEMP3.Free_Space_MB, TEMP4.Max_Number_VMs_On
FROM  TEMP1
LEFT OUTER JOIN TEMP2 ON TEMP1.Server_Hostname=TEMP2.Server_Hostname
LEFT OUTER JOIN TEMP3 ON TEMP1.Server_Hostname=TEMP3.Server_Hostname
LEFT OUTER JOIN TEMP4 ON TEMP1.Server_Hostname=TEMP4.Server_Hostname

 

5
相关文章