Skip to content

Commit 965988e

Browse files
authored
Add files via upload
1 parent 65e1d4a commit 965988e

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Pure-FA_prtg.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- coding: utf-8 -*-
2+
3+
#
4+
## Overview
5+
#
6+
# This short Python example illustrates how to build a simple PRTG custom sendor to monitor
7+
# Pure Storage FlashArrays. The Pure Storage Python REST Client is used to query the FlashArray
8+
# to get the basic performance counters.
9+
#
10+
## Installation
11+
#
12+
# The script should be copied into the appropriate folder on the Windows machine hosting the PRTG master
13+
# server or the proxy agent. This location is usually C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\python
14+
#
15+
## Dependencies
16+
#
17+
# purestorage Pure Storage Python REST Client (https://github.com/purestorage/rest-client)
18+
#
19+
20+
import sys
21+
import json
22+
import purestorage
23+
import urllib3
24+
25+
26+
# get CustomSensorResult from paepy package
27+
from paepy.ChannelDefinition import CustomSensorResult
28+
29+
if __name__ == "__main__":
30+
# interpret first command line parameter as json object
31+
data = json.loads(sys.argv[1])
32+
33+
# create sensor result
34+
params = json.loads(data['params'])
35+
result = CustomSensorResult("Pure Storage performance info")
36+
urllib3.disable_warnings()
37+
fa = purestorage.FlashArray(params['addr'], api_token=params['api_token'])
38+
fainfo = fa.get(action='monitor')
39+
fa.invalidate_cookie()
40+
41+
# add primary channel
42+
result.add_channel(channel_name="wr sec", unit="IOPS write", value=fainfo[0]['writes_per_sec'], primary_channel=True)
43+
# add additional channels
44+
result.add_channel(channel_name="rd sec", unit="IOPS read", value=fainfo[0]['reads_per_sec'])
45+
result.add_channel(channel_name="wr latency", unit="usec", value=fainfo[0]['usec_per_write_op'])
46+
result.add_channel(channel_name="rd latency", unit="usec", value=fainfo[0]['usec_per_read_op'])
47+
result.add_channel(channel_name="in sec", unit="BytesBandwidth", value=fainfo[0]['input_per_sec'])
48+
result.add_channel(channel_name="out sec", unit="BytesBandwidth", value=fainfo[0]['output_per_sec'])
49+
result.add_channel(channel_name="q depth", unit="avg queued", value=fainfo[0]['queue_depth'])
50+
# print sensor result to std
51+
print(result.get_json_result())

0 commit comments

Comments
 (0)