"""\r
son-emu monitor CLI\r
(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>\r
+Steven Van Rossem <steven.vanrossem@intec.ugent.be>\r
"""\r
\r
import argparse\r
import pprint\r
import zerorpc\r
-import prometheus\r
+from emuvim.cli import prometheus\r
\r
pp = pprint.PrettyPrinter(indent=4)\r
\r
(c) 2016 by Steven Van Rossem <steven.vanrossem@intec.ugent.be>
"""
-import urllib2
-import ast
+#import urllib2
+import requests
+#import ast
# set this to localhost for now
# this is correct for son-emu started outside of a container or as a container with net=host
def query_Prometheus(query):
url = prometheus_REST_api + '/' + 'api/v1/query?query=' + query
# logging.info('query:{0}'.format(url))
- req = urllib2.Request(url)
- ret = urllib2.urlopen(req).read()
- ret = ast.literal_eval(ret)
+ #req = urllib2.Request(url)
+ req = requests.get(url)
+ #ret = urllib2.urlopen(req).read()
+ #ret = ast.literal_eval(ret)
+ ret = req.json()
if ret['status'] == 'success':
# logging.info('return:{0}'.format(ret))
try:
# test if prometheus query worked
echo $cpu_load
+
+regex='\[[0-9.]*, .*\]'
+
if [[ $cpu_load =~ $regex ]] ; then
echo " cpu monitor test OK"
exit 0
echo "cpu monitor test not OK"
exit 1
fi
+
+