forked from outlyerapp/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexchange.py
More file actions
67 lines (59 loc) · 2.63 KB
/
exchange.py
File metadata and controls
67 lines (59 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
import subprocess
import sys
import re
'''
details taken from:
http://blogs.technet.com/b/samdrey/archive/2015/01/26/exchange-2013-performance-counters-and-their-thresholds.aspx
'''
counters = ['MSExchange ADAccess Domain Controllers(*)\LDAP Read Time',
'MSExchange ADAccess Domain Controllers(*)\LDAP Search Time',
'MSExchange ADAccess Processes(*)\LDAP Read Time',
'MSExchange ADAccess Processes(*)\LDAP Search Time',
'Processor(*)\% Processor Time',
'Processor(*)\% User Time',
'Processor(*)\% Privileged Time',
'System\Processor Queue Length (all instances)',
'Memory\Available Mbytes',
'Memory\% Committed Bytes In Use',
'.NET CLR Memory(*)\% Time in GC',
'.NET CLR Exceptions(*)\# of Excepts Thrown / sec',
'Network Interface(*)\Packets Outbound Errors',
'TCPv4\Connections Reset',
'TCPv6\Connections Reset',
'MSExchange Database ==> Instances(*)\I/O Database Reads (Attached) Average Latency',
'MSExchange Database ==> Instances(*)\I/O Log Writes Average Latency',
'MSExchange Database ==> Instances(*)\I/O Database Writes (Attached) Average Latency',
'MSExchange Database ==> Instances(*)\I/O Database Reads (Recovery) Average Latency',
'MSExchange Database ==> Instances(*)\I/O Database Writes (Recovery) Average Latency',
'ASP.NET\Application Restarts',
'ASP.NET\Worker Process Restarts',
'ASP.NET\Request Wait Time',
'ASP.NET Applications(*)\Requests In Application Queue',
'MSExchange RpcClientAccess\RPC Averaged Latency',
'MSExchange RpcClientAccess\RPC Requests',
'MSExchangeIS Client Type(*)\RPC Average Latency',
'MSExchangeIS Client Type\RPC Requests',
'MSExchangeIS Store(*)\RPC Average Latency'
]
command = [r'c:\windows\system32\typeperf.exe', '-sc', '1']
try:
output = subprocess.check_output(command + counters)
except Exception, e:
print "Plugin Failed!: %s" % e
sys.exit(2)
s_counters = output.splitlines()[1].split(',')
perf_data = {}
i = 1
for s_counter in s_counters:
if 'PDH-CSV' not in s_counter:
metric = s_counter.rsplit('\\', 1)[1].strip('"').lower()
metric = re.sub('[^0-9a-zA-Z]+', '_', metric).strip('_')
value = output.splitlines()[2].split(',')[i].replace('"','').strip()
perf_data[metric] = value
i += 1
response = "OK | "
for k, v in perf_data.iteritems():
response += k + '=' + v + ';;;; '
print response
sys.exit(0)