GradientOne
  • Home
  • Solutions
    • Overview
    • Test Engineering
    • Compliance Labs
    • Product Features
    • Supported Instruments
  • Documentation
    • White Papers
    • Getting Started
    • Quality Analysis of Test Data
    • Rigol Automation
    • Waveform Upload
    • Visualization & Measurements
    • News
    • Case Study
  • Try For Free
  • Pricing
    • Buy Now
    • Pilot
  • RIGOL
  • Blog

Blog

Using Python To Query The GradientOne API For Equipment Utilization

8/7/2019

0 Comments

 
GradientOne supports rich interactions between instruments and cloud databases.  These include industry standard protocols such as SCPI, VISA, and VXI11.  Data derived from the frequency of instrument's interaction with the database as well as information in the embedded operating system support a range of utilization estimates.   This utilization data is presented to the user with automated reporting using bar graphs, pie charts, and other trend data.  For the cases where customers have custom applications they need to use in conjunction with utilization data, GradientOne provides users with an API or downloadable CSVs to get access to data in its more raw form.  This blog post will walk you through how to use the API to run custom queries for utilization data and generate CSV  and JSON files containing the data.
​
Step 1:  Download Configuration File
First, download your configuration file.  The configuration file manages the authentication and access details to perform queries.
The name of the file must be:  "GradientOneConfig.txt"
The file includes the following:
  • DOMAINNAME - this is the URL you are accessing via the API.
  • AUTH_TOKEN - this is the authentication string that allows access to the data.  To get your authentication token, visit your account page.  You can find this on  your dashboard url with /account  (example: https://examples.gradientone.com/account).  Click on Auth Info > Download Config.  Save the file in the location where you will be running the script.
Picture
Example GradientOneAuthConfig.txt

    
Step 2:  Download the sample API script
The GradientOne API offers a wide range of capabilities for uploading and downloading instrument usage data.  We've generated an example program written in Python you can execute.  

Step 3:  Run the API query
For this example, I will run a query against https://examples.gradientone.com to obtain a days worth of utilization data for an oscilloscope in the GradientOne lab.  Its asset_id is GradientOne_Keysight_600MHZ.

The time arguments are in UTC.  You will need to adjust accordingly for your time zone.  I am running this program from the Pacific time zone, so a full day would be from 07:00 to 07:00.

The query requires these arguments:
    asset_id -- the unique identifier string of the asset of interest (GradientOne_Keysight_600MHZ)
    start_date -- start date of the query (2019-07-17)
    start_time -- start time of the query (07:00)
    end_date -- end date of the query (2019-07-18)
    end_time -- end time of the query (07:00)
    mode -- query GradientOne API for minute or hourly summaries (hours or minutes)

> python utilizationInfo.py GradientOne_Keysight_600MHZ 2019-07-17 07:00 2019-07-18 07:00 hours
<Response [200]>

The Response [200] means that the query was completed successfully.  The data are available in the JSON and CSV files:

GradientOne_Keysight_600MHZ_avg_CPU.json
GradientOne_Keysight_600MHZ_avg_CPU.csv

This returns 24 hours worth of data.  Below is an example hour, which would be available in the .json file.  Interesting takeaways are:
  • utilization:  This instrument has an 85% utilization for this hour.  The default utilization uses historically defined baselines for CPU behavior that indicates usage above a certain threshold.  The CPU is the CPU usage of the test applications using this instrument.  The 85% utilization in this case is  determined by the minutes_active = 51 minutes divided by 60 minutes.
  • minutes_online:  This instrument was online for the entire hour (minutes_online = 60).
  • The remaining time, the instrument was idle (minutes_idle = 9).
  • ​The average CPU % for this hour was 43.5%.  This may be helpful for profiling different test routine behavior.
Example hour:

    
This script also generates a CSV file.  This shows the average CPU for a given hour and how many minutes the instrument was online during that hour.  It contains the below information:
Example CSV file

    
Example Python Script

    
If you'd like to see how this works in your environment, start your free trial today by clicking on the below link.  
Start Free Trial
0 Comments



Leave a Reply.

    Archives

    April 2020
    September 2019
    August 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    September 2017
    August 2017
    July 2017
    June 2017
    April 2017
    July 2016

    Categories

    All
    Instrument
    Usability

    RSS Feed


​Home
News
Jobs
​
Privacy Policy
Contact Us
OUR MISSION - 
GradientOne’s mission is to improve the work of engineers, manufacturing organizations, technical support teams, and scientists, by using cloud computing to streamline instrument management, data collection, analysis, reporting and search.
        ©2019 GradientOne Inc.  All Rights Reserved.
  • Home
  • Solutions
    • Overview
    • Test Engineering
    • Compliance Labs
    • Product Features
    • Supported Instruments
  • Documentation
    • White Papers
    • Getting Started
    • Quality Analysis of Test Data
    • Rigol Automation
    • Waveform Upload
    • Visualization & Measurements
    • News
    • Case Study
  • Try For Free
  • Pricing
    • Buy Now
    • Pilot
  • RIGOL
  • Blog