From 74573f16c391828094cffab301a4fdf35e9ccd11 Mon Sep 17 00:00:00 2001
From: John-Paul Robinson <jpr@uab.edu>
Date: Fri, 10 Jul 2020 16:49:58 -0500
Subject: [PATCH] Notebook that attempts connection to cmdaemon

---
 *.ipynb              |  0
 bright-connect.ipynb | 73 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)
 delete mode 100644 *.ipynb
 create mode 100644 bright-connect.ipynb

diff --git a/*.ipynb b/*.ipynb
deleted file mode 100644
index e69de29..0000000
diff --git a/bright-connect.ipynb b/bright-connect.ipynb
new file mode 100644
index 0000000..1c88b78
--- /dev/null
+++ b/bright-connect.ipynb
@@ -0,0 +1,73 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "The following code blocks are the required modules and initial example from the developers manual for working with the RPC-based client library for programatic control of cmd.\n",
+    "\n",
+    "The example is not yet working, possibly due to python version differences.  In 8.2 the library is build for python 2.7.5.\n",
+    "\n",
+    "```\n",
+    "!pip install pyOpenSSL==17.5.0 ply lxml tabulate monotonic humanfriendly six\n",
+    "```"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from pythoncm.cluster import Cluster\n",
+    "from pythoncm.settings import Settings"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "settings = Settings(host='master',\n",
+    "                    port=8081,\n",
+    "                    cert_file='~/.cm/cert.pem',\n",
+    "                    key_file='~/.cm/cert.key',\n",
+    "                    ca_file='pythoncm/etc/cacert.pem')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "cluster = Cluster(settings) #, check_api=False)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "use rest api for now to avoid RPC issues with library.\n",
+    "\n",
+    "convert curl command for currnet power to rest query\n",
+    "https://curl.trillworks.com/\n",
+    "\n",
+    "```curl --cert ~/.cm/cert.pem --key ~/.cm/cert.key --cacert pythoncm/etc/cacert.pem \"https://master:8081/rest/v1/monitoring/latest?measurable=Pwr_Consumption&indent=1\"```\n",
+    "\n",
+    "the sum on the commandline, dealing with weird outlier data from one node is:\n",
+    "\n",
+    "```curl --cert ~/.cm/cert.pem --key ~/.cm/cert.key -k \"https://master:8081/rest/v1/monitoring/latest?measurable=Pwr_Consumption&indent=1\" | jq '.data[] | select(.raw < 10000) .raw' | awk '{sum=$1+sum} END {print sum}'```"
+   ]
+  }
+ ],
+ "metadata": {
+  "language_info": {
+   "name": "python",
+   "pygments_lexer": "ipython3"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
-- 
GitLab