2 # -*- coding: utf-8 -*-
4 # This file is part of Karesansui.
6 # Copyright (C) 2009-2010 HDE, Inc.
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
18 from optparse import OptionParser
20 from ksscommand import KssCommand, KssCommandException
26 from karesansui import __version__
27 from karesansui.lib.virt.virt import KaresansuiVirtConnection
28 from karesansui.lib.utils import gettimeofday
29 from karesansui.lib.utils import load_locale
31 print >>sys.stderr, "[Error] karesansui package was not found."
36 class GetMemoryUsage(KssCommand):
39 conn = KaresansuiVirtConnection()
41 guests = conn.search_guests()
43 nodeinfo = conn.get_nodeinfo()
55 pcentCurrMem = memory * 100.0 / (nodeinfo["memory"]*1024)
56 pcentMaxMem = maxMem * 100.0 / (nodeinfo["memory"]*1024)
58 print "%.3f%%" % pcentCurrMem
66 if __name__ == "__main__":
67 target = GetMemoryUsage()
68 sys.exit(target.run())