Skip to content

Instantly share code, notes, and snippets.

@sky-joker
Created March 11, 2017 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sky-joker/77fd29edc3aa9f83869e0ff12e865098 to your computer and use it in GitHub Desktop.
Save sky-joker/77fd29edc3aa9f83869e0ff12e865098 to your computer and use it in GitHub Desktop.
VMwareのパフォーマンスカウンター値取得
#!/usr/bin/python3
from pyVim.connect import SmartConnect, Disconnect
from pyVmomi import vim, vmodl
import ssl
import atexit
# 接続先情報
host = 'ESXi or vCenter IP'
username = 'username'
password = 'password'
def main():
# SSL証明書対策
context = None
if hasattr(ssl, '_create_unverified_context'):
context = ssl._create_unverified_context()
# 接続
si = SmartConnect(host = host,
user = username,
pwd = password,
sslContext = context)
# 処理完了時にvCenterから切断
atexit.register(Disconnect, si)
content = si.content
r = content.perfManager.perfCounter
for i in r:
key_num = i.key
label = i.nameInfo.label
summary = i.nameInfo.summary
unit = i.nameInfo.key
print("%s,%s,%s,%s" % (key_num, label, summary, unit))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment