### Fix query with SSL no verify

```The queries to bcm were failing do to invalid cert validation.
Not clear what changed but it seems to be with the cacert bundle.
Just set the request to no-verify as a work around.```
parent bdf0221f
 %% Cell type:markdown id: tags: # Power Stats Use RestAPI to read power consumption info for cluster nodes and generate usage reports. this is based on the [pandas time series tutorial by Jennifer Walker](https://www.dataquest.io/blog/tutorial-time-series-analysis-with-pandas/) %% Cell type:code id: tags: ``` import requests import pprint import datetime import os import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import matplotlib.dates as mdates ``` %% Cell type:markdown id: tags: Set up credentials to query RestAPI. Bright controls access based on the user identity. The user's cert.pem and cert.key are automatically generated but the cacert.pem needs to be constructed from the certs returned by the master. %% Cell type:code id: tags: ``` cert_file='~/.cm/cert.pem' key_file='~/.cm/cert.key' ca_file='cacert.pem' ``` %% Cell type:code id: tags: ``` cert=(os.path.expanduser(cert_file), os.path.expanduser(key_file)) ``` %% Cell type:markdown id: tags: ## Gather Cluster Power Data %% Cell type:code id: tags: ``` startdate = '2020/01/01 00:00:00' enddate = '2020/07/10 00:00:00' ``` %% Cell type:code id: tags: ``` params = ( ('start', startdate), ('measurable', 'Pwr_Consumption'), ('indent', '1'), ) ``` %% Cell type:code id: tags: ``` response = requests.get('https://master:8081/rest/v1/monitoring/dump', params=params, cert=cert, verify=ca_file) response = requests.get('https://master:8081/rest/v1/monitoring/dump', params=params, cert=cert, verify=False) ``` %% Cell type:markdown id: tags: Simply read the json response into a dataframe for futher parsing. %% Cell type:code id: tags: ``` df = pd.DataFrame(response.json()["data"]) ``` %% Cell type:markdown id: tags: Some of data values report unrealistic power values. Any reading over 10kW is considered invalid. %% Cell type:code id: tags: ``` df = df.loc[df['raw'] < 10000] ``` %% Cell type:markdown id: tags: Create a datatime type column from the reported sample times. %% Cell type:code id: tags: ``` df['datetime'] = pd.to_datetime(df.time, format="%Y/%m/%d %H:%M:%S") ``` %% Cell type:markdown id: tags: Create an index for the hourly %% Cell type:code id: tags: ``` hourly_idx=pd.date_range(startdate, enddate, freq='H') ``` %% Cell type:code id: tags: ``` debug=False # prepare data frame to append to, use zeros for default column m6_hourly_pwr=pd.DataFrame(np.zeros((1,len(hourly_idx))).T, index=hourly_idx, columns=['sum']) for num, entity in enumerate(df.entity.unique()): if entity not in ['c0108', 'c0009']: node_pwr=df[df.entity==entity].set_index("datetime") node_pwr=node_pwr[['raw']].resample('H').mean() node_pwr=node_pwr[startdate:enddate].fillna(method="ffill") if debug: print(node_pwr) missing = node_pwr['raw'].isnull().sum() print("{}: {} missing {}\n".format(num, entity, missing)) m6_hourly_pwr[entity]= node_pwr[startdate:enddate] ``` %% Cell type:markdown id: tags: # Plot Power Usage Graph Pick the start and end date for the plots from the data range selected above. Generate the sum and plot only it's values. We skip over the first month of collection because it is uncommonly noisy. %% Cell type:code id: tags: ``` kW = m6_hourly_pwr['2020-02-01':'2020-07-09'].sum(axis=1)/1000 ``` %% Cell type:code id: tags: ``` ax = kW.plot() ax.set_ylabel("Power (kW)") ax.set_title("Cheaha compute and login node hourly power use") ``` %% Cell type:markdown id: tags: Resample hourly sum to support the seven day average. %% Cell type:code id: tags: ``` kW_d = kW.resample('D').mean() ``` %% Cell type:code id: tags: ``` # Compute the centered 7-day rolling mean # https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rolling.html kW_7d = kW_d.rolling(7, center=True).mean() ``` %% Cell type:code id: tags: ``` # Plot houry, daily, 7-day rolling mean fig, ax = plt.subplots() ax.plot(kW, marker='.', markersize=2, color='gray', linestyle='None', label='Hourly Average') ax.plot(kW_d, color='brown', linewidth=2, label='1-day Average') ax.plot(kW_7d, color='black', linewidth=4, label='7-day Rolling Average') label='Trend (7 day Rolling Mean)' ax.legend() ax.set_ylabel('Power (kW)') ax.set_title('Cheaha Trends in Electricity Consumption'); ``` ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
{"ft_lang_label":"__label__en","ft_lang_prob":0.93549997,"math_prob":0.5391045,"size":276,"snap":"2022-05-2022-21","text_gpt3_token_len":64,"char_repetition_ratio":0.073529415,"word_repetition_ratio":0.0,"special_character_ratio":0.21014492,"punctuation_ratio":0.054545455,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98019505,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-22T13:33:47Z\",\"WARC-Record-ID\":\"<urn:uuid:2b5861da-a85c-4175-bcaf-5ceb8a9f23c1>\",\"Content-Length\":\"356316\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4fcd7212-5001-432c-aab9-02b892776063>\",\"WARC-Concurrent-To\":\"<urn:uuid:3584b8f2-5532-404e-bfc9-6b16e93858f0>\",\"WARC-IP-Address\":\"164.111.161.34\",\"WARC-Target-URI\":\"https://gitlab.rc.uab.edu/jpr/power-study/-/commit/878e997de4e1c6649beae7ad52a285bdcb30d2ae\",\"WARC-Payload-Digest\":\"sha1:Y2ZESTMUYJU5EL6VJU2DNGNULNKU7VBM\",\"WARC-Block-Digest\":\"sha1:J5LIDVTCYD6ODXIOOJS2MLLRRXLVL6YH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662545548.56_warc_CC-MAIN-20220522125835-20220522155835-00148.warc.gz\"}"}