Performance
This section gives examples of the following performance functionality:
Registering an Array For Performance Data Collection
Arrays can be enabled for both diagnostic and real-time performance data collection using PyU4V. The example below demonstrates enabling both varieties and confirming the registration has been successful.
1"""docs/source/programmers_guide_src/code/performance-registration.py"""
2
3import PyU4V
4
5# Initialise PyU4V Unisphere connection
6conn = PyU4V.U4VConn()
7
8# Check if the primary array is registered for diagnostic performance data
9# collection
10if not conn.performance.is_array_diagnostic_performance_registered():
11 # If not, enable diagnostic data collection
12 conn.performance.enable_diagnostic_data_collection()
13 # Confirm the enable operation was successful
14 assert conn.performance.is_array_diagnostic_performance_registered()
15
16# Check if the primary array is registered for real-time performance data
17# collection
18if not conn.performance.is_array_real_time_performance_registered():
19 # If not, enable real-time data collection
20 conn.performance.enable_real_time_data_collection()
21 # Confirm the enable operation was successful
22 assert conn.performance.is_array_real_time_performance_registered()
23
24# Close the session
25conn.close_session()
Diagnostic Metrics Gathering
This example demonstrates a range of diagnostics (5 minute interval) performance functionality such as getting performance categories and metrics, timestamps from Unisphere for an array, get recent only performance information, and getting ResponseTime for all SRPs in an array.
1"""docs/source/programmers_guide_src/code/performance-diagnostic_calls.py"""
2
3import PyU4V
4
5# Initialise PyU4V Unisphere connection
6conn = PyU4V.U4VConn()
7
8# Get a list of performance categories
9category_list = conn.performance.get_performance_categories_list()
10
11# Get a list of supported metrics for the category 'FEDirector'
12fe_dir_metrics = conn.performance.get_performance_metrics_list(
13 category='FEDirector')
14
15# Get a list of KPI only metrics for the category 'StorageGroup'
16storage_group_metrics = conn.performance.get_performance_metrics_list(
17 category='StorageGroup', kpi_only=True)
18
19# Get array KPI performance metrics for the most recent timestamp only, set
20# recency so timestamp has to be less than 5 minutes old
21array_performance_data = conn.performance.get_array_stats(metrics='KPI',
22 recency=5)
23
24# Get ResponseTime for each SRP for the last 4 hours
25# Firstly get the most recent performance timestamp for your array
26recent_timestamp = conn.performance.get_last_available_timestamp()
27# Set the performance recency value to 10 minutes and check if the most
28# recent timestamp meets that recency value
29conn.performance.recency = 10
30is_recent_ten = conn.performance.is_timestamp_current(recent_timestamp)
31# Recency can also be passed to is_timestamp_current
32is_recent_five = conn.performance.is_timestamp_current(recent_timestamp,
33 minutes=5)
34
35# Get the start and end times by providing the most recent timestamp and
36# specifying a 4 hour difference
37start_time, end_time = conn.performance.get_timestamp_by_hour(
38 end_time=recent_timestamp, hours_difference=4)
39# Get the list of SRPs
40srp_keys = conn.performance.get_storage_resource_pool_keys()
41srp_list = list()
42for key in srp_keys:
43 srp_list.append(key.get('srpId'))
44# Get the performance data for each of the SRPs in the list
45for srp in srp_list:
46 srp_data = conn.performance.get_storage_resource_pool_stats(
47 srp_id=srp, metrics='ResponseTime', start_time=start_time,
48 end_time=end_time)
49
50# Close the session
51conn.close_session()
Real-Time Metrics Gathering
With the PyU4V 9.2 release it is possible to retrieve real-time performance data from Unisphere for arrays which have been registered for real-time data. This example demonstrates getting supported real-time peformance metrics for a given category, getting the keys for that category (the assets which we can obtain real-time data for), and retrieving real-time data for the last hour.
Note
The maximum amount of real-time data that can be retrieved from Unisphere via PyU4V in one call is one hour. If more than one hour of data is required then more calls can be run, however if you find yourself doing this often it is a good idea to save data locally for easy retrieval and reduce the amount of REST calls required.
Note
Storage Groups are supported for real-time metrics but these must be
enabled in Unisphere via Settings > Performance > System Registrations
.
Under the table heading Storage Group Real Time
and for the array you
want to enable real-time for, select the option
Real Time Storage Groups
and add up to 100 Storage Groups for real-time
data collection.
1"""docs/source/programmers_guide_src/code/performance-real_time_calls.py"""
2
3import random
4import time
5
6import PyU4V
7
8# Initialise PyU4V Unisphere connection
9conn = PyU4V.U4VConn()
10
11# Get a list of real-time performance categories
12category_list = conn.performance.real_time.get_categories()
13
14# Get the first and last available timestamps for my primary array
15array_timestamps = conn.performance.real_time.get_timestamps(
16 array_id=conn.array_id)
17# Get the first and last available timestamps for all registered arrays
18all_timestamps = conn.performance.real_time.get_timestamps()
19
20# Get storage groups enabled for real-time data on primary array
21rt_sg_list = conn.performance.real_time.get_storage_group_keys()
22# Get the real-time metrics for storage groups
23rt_sg_metrics = conn.performance.real_time.get_storage_group_metrics()
24
25# Get the current time in milliseconds since epoch
26current_time = int(time.time()) * 1000
27# Set the start time as one hour previous to current time, one hour is the
28# maximum amount of data that can be retrieved in one call for real-time
29start_time = current_time - (60 * 60 * 1000)
30
31# Get real-time storage group data for a random group and random selection of
32# metrics
33sg_metrics = random.choices(rt_sg_metrics, k=5)
34sg_name = random.choice(rt_sg_list)
35
36# Retrieve the performance data from Unisphere
37rt_sg_data = conn.performance.real_time.get_storage_group_stats(
38 start_date=start_time, end_date=current_time, metrics=sg_metrics,
39 instance_id=sg_name)
40
41# Close the session
42conn.close_session()
Backup Performance Database
Backup of a performance database is a recommended practice. The backup performance database option is available for one or more storage systems, regardless of their registration status.
By default, only Trending & Planning (Historical) data is backed up. The performance databases backups should be stored in a safe location. Performance database backups can be restored. For more information on restoring backups please see Unisphere for PowerMax official documentation, for now only performing backups is supported via REST.
To create a backup of a performance data simply call
performance.backup_performance_database()
, both the array_id
and
filename
are optional values, if no filename
is provided then the
client hostname will be used.
Note
Underscores will be stripped from any filename provided, this is due to
Unisphere restricting the length of the filename string when underscores
are provided. The backup filename format will be as follows when viewed in
Unisphere: {array_id}_{date}{time}_{TZ}_{filename}_SPABackup.dat
1"""docs/source/programmers_guide_src/code/performance-db_backup.py"""
2
3import PyU4V
4
5# Initialise PyU4V connection to Unisphere
6conn = PyU4V.U4VConn()
7
8# Backup the performance database
9conn.performance.backup_performance_database(
10 array_id=conn.array_id, filename='PyU4V_Example')
11
12# Close the session
13conn.close_session()
To view this performance database backup in Unisphere navigate to
Settings > Unisphere Databases > Performance Databases
. Use the performance
databases list view to view and manage databases.
Thresholds
In this example both performance threshold calls and CSV file handling with PyU4V are demonstrated. A call is made to retrieve a full list of performance threshold settings and output the results to a CSV file at a path specified by the user. That CSV file is read into a Python dictionary and the respective values within are updated. Once complete the updated threshold settings are uploaded to Unisphere to take immediate effect.
1"""docs/source/programmers_guide_src/code/performance-thresholds.py."""
2
3import os
4import PyU4V
5
6# Initialise PyU4V connection to Unisphere
7conn = PyU4V.U4VConn()
8
9# Set the CSV file name and path
10current_directory = os.getcwd()
11output_csv_name = 'thresholds-test.csv'
12output_csv_path = os.path.join(current_directory, output_csv_name)
13
14# Generate a CSV file with all of the thresholds and corresponding values
15conn.performance.generate_threshold_settings_csv(
16 output_csv_path=output_csv_path)
17
18# Read the CSV values into a dictionary, cast all string booleans and
19# numbers to their proper types
20threshold_dict = PyU4V.utils.file_handler.read_csv_values(output_csv_path,
21 convert=True)
22
23# Increase all of the first threshold values by 5 and second threshold
24# values by 10, alert only on the KPIs
25for i in range(0, len(threshold_dict.get('metric'))):
26 threshold_dict['firstThreshold'][i] += 5
27 threshold_dict['secondThreshold'][i] += 5
28 if threshold_dict['kpi'][i] is True:
29 threshold_dict['alertError'][i] = True
30
31# Process the CSV file and update the thresholds with their corresponding
32# values, we are only going to set the threshold value if it is a KPI
33conn.performance.set_thresholds_from_csv(csv_file_path=output_csv_path,
34 kpi_only=True)
35
36# It is also possible to set a threshold value without editing the values
37# in a CSV, the threshold metric and be edited directly
38threshold_settings = conn.performance.update_threshold_settings(
39 category='Array', metric='PercentCacheWP', first_threshold=60,
40 first_threshold_occurrences=2, first_threshold_samples=6,
41 first_threshold_severity='INFORMATION', second_threshold=90,
42 second_threshold_occurrences=1, second_threshold_samples=3,
43 second_threshold_severity='CRITICAL', alert=True)
44
45# Close the session
46conn.close_session()