This repository has been archived by the owner on Aug 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andy Southgate
committed
Apr 16, 2008
1 parent
b095abf
commit f344e48
Showing
7 changed files
with
146 additions
and
40 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,59 @@ | ||
# Copyright (c) Citrix Systems 2008. All rights reserved. | ||
# xsconsole is proprietary software. | ||
# | ||
# Xen, the Xen logo, XenCenter, XenMotion are trademarks or registered | ||
# trademarks of Citrix Systems, Inc., in the United States and other | ||
# countries. | ||
|
||
if __name__ == "__main__": | ||
raise Exception("This script is a plugin for xsconsole and cannot run independently") | ||
|
||
from XSConsoleStandard import * | ||
|
||
class XSFeatureHostInfo: | ||
@classmethod | ||
def StatusUpdateHandler(cls, inPane): | ||
inPane.AddTitleField("Host Performance Information") | ||
|
||
host = HotAccessor().local_host | ||
numCPUs = len(host.host_CPUs({})) | ||
try: | ||
cpuUsage = sum( [cpu.utilisation() for cpu in host.host_CPUs] ) / numCPUs # Allow divide-by-zero to throw | ||
cpuUsage = max(0.0, min(1.0, cpuUsage)) | ||
cpuUsageStr = "%d%% of %d CPUs" % (int(cpuUsage * 100), numCPUs) | ||
except Exception, e: | ||
cpuUsageStr = Lang('<Unavailable>') | ||
|
||
try: | ||
totalMemory = float(host.metrics.memory_total(0)) | ||
freeMemory = float(host.metrics.memory_free(0)) | ||
memoryUsage = (totalMemory - freeMemory) / totalMemory # Allow divide-by-zero to throw | ||
memoryUsage = max(0.0, min(1.0, memoryUsage)) | ||
memoryUsageStr = "%d%% of %s" % (int(memoryUsage * 100), SizeUtils.MemorySizeString(totalMemory)) | ||
except Exception, e: | ||
memoryUsageStr = Lang('<Unavailable>') | ||
|
||
inPane.AddStatusField(Lang("CPU Usage", 16), cpuUsageStr) | ||
inPane.AddStatusField(Lang("Memory Usage", 16), memoryUsageStr) | ||
|
||
inPane.AddKeyHelpField( { Lang("<Enter>") : Lang("Control This Host") } ) | ||
|
||
@classmethod | ||
def ActivateHandler(cls): | ||
pass | ||
|
||
def Register(self): | ||
Importer.RegisterNamedPlugIn( | ||
self, | ||
'HOST_INFO', # Key of this plugin for replacement, etc. | ||
{ | ||
'menuname' : 'MENU_VM', | ||
'menupriority' : 200, | ||
'menutext' : Lang('Host Performance Information') , | ||
'activatehandler' : XSFeatureHostInfo.ActivateHandler, | ||
'statusupdatehandler' : XSFeatureHostInfo.StatusUpdateHandler | ||
} | ||
) | ||
|
||
# Register this plugin when module is imported | ||
XSFeatureHostInfo().Register() |
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