§±§å§ä§Ñ?§Ñ §Ò§â§à?§Ñ§é§Ñ VMware §á§Ö§â§æ§à§â§Þ§Ñ§ß§ã§Ú §Ú§Þ§Ñ group/counter[rollup]
§æ§à§â§Þ§Ñ§ä §Ô§Õ§Ö:
group
- §Ô§â§å§á§Ñ §Ò§â§à?§Ñ§é§Ñ §á§Ö§â§æ§à§â§Þ§Ñ§ß§ã§Ú, §ß§Ñ §á§â§Ú§Þ§Ö§â cpucounter
- §ß§Ñ§Ù§Ú§Ó §Ò§â§à?§Ñ§é§Ñ §á§Ö§â§æ§à§â§Þ§Ñ§ß§ã§Ú, §ß§Ñ §á§â§Ú§Þ§Ö§â usagemhzrollup
- §ä§Ú§á §ã§å§Þ§Ú§â§Ñ?§Ñ §Ù§Ñ §á§Ö§â§æ§à§â§Þ§Ñ§ß§ã§ß§Ö §Ò§â§à?§Ñ§é§Ö, §ß§Ñ §á§â§Ú§Þ§Ö§â §á§â§à§ã§Ö§Ü§¥§Ñ§Ü§Ý§Ö, §Ô§à§â?§Ú §á§â§Ú§Þ§Ö§â §Ò§Ú §Õ§Ñ§à §ã§Ý§Ö§Õ§Ö?§å §á§å§ä§Ñ?§å §Ò§â§à?§Ñ§é§Ñ: cpu/usagemhz[average]
§°§á§Ú§ã§Ú §Ô§â§å§á§Ñ §Ò§â§à?§Ñ§é§Ñ §á§Ö§â§æ§à§â§Þ§Ñ§ß§ã§Ú, §Ú§Þ§Ö§ß§Ñ §Ò§â§à?§Ñ§é§Ñ §Ú §ä§Ú§á§à§Ó§Ú §Ô§â§å§á§Ú§ã§Ñ?§Ñ §ã§Ö §Þ§à§Ô§å §ß§Ñ?§Ú §å .
§®§à§Ô§å?§Ö ?§Ö §Õ§à§Ò§Ú§ä§Ú §Ú§ß§ä§Ö§â§ß§Ñ §Ú§Þ§Ö§ß§Ñ §Ú §Ü§â§Ö§Ú§â§Ñ§ä§Ú §á§â§Ú§Ý§Ñ§Ô§à?§Ö§ß§Ñ §Ú§Þ§Ö§ß§Ñ §Ò§â§à?§Ñ§é§Ñ §á§Ö§â§æ§à§â§Þ§Ñ§ß§ã§Ú §Ü§à§â§Ú§ê?§Ö?§Ö§Þ §ã§ä§Ñ§Ó§Ü§Ö §ã§Ü§â§Ú§á§ä§Ö §å Áú»¢¶Ä²©-§å.
try {
Áú»¢¶Ä²©.log(4, 'vmware metrics script');
var result, resp,
req = new HttpRequest();
req.addHeader('Content-Type: application/xml');
req.addHeader('SOAPAction: "urn:vim25/6.0"');
login = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">\.
<soapenv:Header/>\
<soapenv:Body>\
<urn:Login>\
<urn:_this type="SessionManager">SessionManager</urn:_this>\
<urn:userName>{$VMWARE.USERNAME}</urn:userName>\
<urn:password>{$VMWARE.PASSWORD}</urn:password>\
</urn:Login>\
</soapenv:Body>\
</soapenv:Envelope>'
resp = req.post("{$VMWARE.URL}", login);
if (req.getStatus() != 200) {
throw 'Response code: '+req.getStatus();
}
query = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">\
<soapenv:Header/>\
<soapenv:Body>\
<urn:RetrieveProperties>\
<urn:_this type="PropertyCollector">propertyCollector</urn:_this>\
<urn:specSet>\
<urn:propSet>\
<urn:type>PerformanceManager</urn:type>\
<urn:pathSet>perfCounter</urn:pathSet>\
</urn:propSet>\
<urn:objectSet>\
<urn:obj type="PerformanceManager">PerfMgr</urn:obj>\
</urn:objectSet>\
<urn:obj type="PerformanceManager">PerfMgr</urn:obj>\
/urn:RetrieveProperties>\
</soapenv:Body>\
</soapenv:Envelope>'
resp = req.post("{$VMWARE.URL}", query);
if (req.getStatus() != 200) {
throw 'Response code: '+req.getStatus();
}
Áú»¢¶Ä²©.log(4, 'vmware metrics=' + resp);
result = resp;
logout = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">\
<soapenv:Header/>\
<soapenv:Body>\
<urn:Logout>\
<urn:_this type="SessionManager">SessionManager</urn:_this>\
</urn:Logout>\
</soapenv:Body>\
</soapenv:Envelope>'
resp = req.post("{$VMWARE.URL}",logout);
if (req.getStatus() != 200) {
throw 'Response code: '+req.getStatus();}
}
catch (error) {
Áú»¢¶Ä²©.log(4, 'vmware call failed : '+error);
result = {};
}
return result;
§¬§Ñ§Õ§Ñ ?§Ö §ã§ä§Ñ§Ó§Ü§Ñ §Ü§à§ß§æ§Ú§Ô§å§â§Ú§ã§Ñ§ß§Ñ, §á§â§Ú§ä§Ú§ã§ß§Ú§ä§Ö §Õ§å§Ô§Þ§Ö §´§Ö§ã§ä, §Ñ §Ù§Ñ§ä§Ú§Þ §á§â§Ú§ä§Ú§ã§ß§Ú§ä§Ö §±§â§Ö§å§Ù§Þ§Ú §Ó§â§Ö§Õ§ß§à§ã§ä.
§¬§à§á§Ú§â§Ñ?§ä§Ö §á§â§Ú§Þ?§Ö§ß§Ú XML §å §Ò§Ú§Ý§à §Ü§à?§Ú XML §æ§à§â§Þ§Ñ§ä§Ö§â §Ú §á§â§à§ß§Ñ?§Ú§ä§Ö §Ø§Ö?§Ö§ß§å §Þ§Ö§ä§â§Ú§Ü§å.
§±§â§Ú§Þ§Ö§â XML-§Ñ §Ù§Ñ ?§Ö§Õ§ß§å §Þ§Ö§ä§â§Ú§Ü§å:
<PerfCounterInfo xsi:type="PerfCounterInfo"> <key>6</key> <nameInfo> <label>Usage in MHz</label> <summary>CPU usage in megahertz during the interval</summary> <key>usagemhz</key> </nameInfo> <groupInfo> <label>CPU</label> <summary>CPU</summary> <key>cpu</key> </groupInfo> <unitInfo> <label>MHz</label> <summary>Megahertz</summary> <key>megaHertz</key> </unitInfo><rollupType>average</rollupType> <statsType>rate</statsType> <level>1</level> <perDeviceLevel>3</perDeviceLevel> </PerfCounterInfo>
§¬§à§â§Ú§ã§ä§Ú§ä§Ö XPath §Õ§Ñ §Ú§Ù§Õ§Ó§à?§Ú§ä§Ö §á§å§ä§Ñ?§å §Ò§â§à?§Ñ§é§Ñ §Ú§Ù §á§â§Ú§Þ?§Ö§ß§à§Ô XML-§Ñ. §©§Ñ §Ô§à§â?§Ú §á§â§Ú§Þ§Ö§â, XPath ?§Ö §Ò§Ú§ä§Ú:
field | xPath | value |
---|---|---|
group | //groupInfo[../key=6]/key | cpu |
counter | //nameInfo[../key=6]/key | usagemhz |
rollup | //rollupType[../key=6] | average |
§²§Ö§Ù§å§Ý§ä§Ñ§ä §á§å§ä§Ñ?§Ö §Ò§â§à?§Ñ§é§Ñ §á§Ö§â§æ§à§â§Þ§Ñ§ß§ã§Ú §å §à§Ó§à§Þ §ã§Ý§å§é§Ñ?§å ?§Ö: cpu/usagemhz[average]