15 Креирање прилагођених имена бројача перформанси за VMware

Преглед

Путања бројача VMware перформанси има group/counter[rollup] формат где:

  • group - група бројача перформанси, на пример cpu
  • counter - назив бројача перформанси, на пример usagemhz
  • rollup - тип сумирања за перформансне бројаче, на пример
    • average*

Дакле, горњи пример би дао следећу путању бројача: cpu/usagemhz[average]

Описи група бројача перформанси, имена бројача и типови груписања се могу наћи у VMware документацији.

Могуће је добити интерна имена и креирати прилагођена имена бројача перформанси коришћењем ставке скрипте у Zabbix-у.

Configuration

  1. Create disabled Script item on the main VMware host (where the eventlog[] item is present) with the following parameters:

  • Name:VMware metrics
  • Type: Script
  • Key: vmware.metrics
  • Type of information: Text
  • Script: copy and paste the script provided below
  • Timeout: 10
  • History: Do not store
  • Enabled: unmarked

Script

try { Zabbix.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:typePerformanceManager</urn:type>
urn:pathSetperfCounter</urn:pathSet>
</urn:propSet>
urn:objectSet
<urn:obj type="PerformanceManager">PerfMgr</urn:obj>
</urn:objectSet>
</urn:specSet>
</urn:RetrieveProperties>
</soapenv:Body>
</soapenv:Envelope> 'resp = req.post("{$VMWARE.URL}", query); if (req.getStatus() != 200) { throw 'Response code: '+req.getStatus(); } Zabbix.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) { Zabbix.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]