Created
March 11, 2017 13:51
-
-
Save sky-joker/77fd29edc3aa9f83869e0ff12e865098 to your computer and use it in GitHub Desktop.
VMwareのパフォーマンスカウンター値取得
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
#!/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