Exemplo n.º 1
0
def healthcheck(par):
    SERVER = par.get("SERVER")
    result = SERVER
    session = client.session()
    db = client['esb-data']
    query_hc = cloudant.query.Query(db,
                                    selector={
                                        "SERVER": SERVER,
                                        "CPU": {
                                            "$gt": 0
                                        }
                                    })
    time.sleep(1)
    queryresult_hc = QueryResult(query_hc)
    for doc in queryresult_hc:
        print(doc["SERVER"] + " has CPU:" + str(doc["CPU"]) + " and Memory:" +
              str(doc["MEMORY"]))
        print(doc["QMGR"] + " is " + doc["QM_STATUS"] + " and" +
              doc["CLUSTER_STATUS"] + " in the Cluster")
        print("Listener port :" + str(doc["LISTENER"]) + " is " +
              doc["LISTENER_STATUS"])
        result_tmp = doc["SERVER"] + " is " + doc[
            "CLUSTER_STATUS"] + " in the Cluster<br>" + "with CPU:" + str(
                doc["CPU"]) + " and Memory:" + str(
                    doc["MEMORY"]
                ) + "<br>Broker/QMGR: " + doc["QMGR"] + " is " + doc[
                    "QM_STATUS"] + " with Listener port :" + str(
                        doc["LISTENER"]) + " is " + doc["LISTENER_STATUS"]
    return result_tmp
Exemplo n.º 2
0
def dailyreport(par):
    session = client.session()
    db = client['esb-data']
    query_pa_o1 = cloudant.query.Query(db, selector={"CPU": {"$gt": 0}})
    query_result = QueryResult(query_pa_o1)
    health_report(query_result)
    link = "Please download daily report for today below<br><a href=\"https://jarvis-walgreens-webhook.herokuapp.com/HCdocx\" class=\"btn btn-primary\">DOWNLOAD</a>"
    return link
Exemplo n.º 3
0
    def create_result(self,
                      selector={'_id': {
                          '$gt': 0
                      }},
                      fields=['_id', 'name', 'age'],
                      **kwargs):
        if kwargs.get('q_parms', None):
            query = Query(self.db, **kwargs['q_parms'])
        else:
            query = Query(self.db)

        if kwargs.get('qr_parms', None):
            return QueryResult(query,
                               selector=selector,
                               fields=fields,
                               **kwargs['qr_parms'])
        else:
            return QueryResult(query, selector=selector, fields=fields)
Exemplo n.º 4
0
 def test_constructor_with_query_skip_limit(self):
     """
     Test instantiating a QueryResult when query callable already has
     skip and/or limit
     """
     query = Query(self.db, skip=10, limit=10)
     result = QueryResult(query)
     self.assertIsInstance(result, QueryResult)
     self.assertDictEqual(result.options, {'skip': 10, 'limit': 10})
     self.assertEqual(result._ref, query)
Exemplo n.º 5
0
 def test_constructor_without_options(self):
     """
     Test instantiating a Query without parameters
     """
     query = Query(self.db)
     result = QueryResult(query)
     self.assertIsInstance(result, QueryResult)
     self.assertEqual(result.options, {})
     self.assertEqual(result._ref, query)
     self.assertEqual(result._page_size, 100)
Exemplo n.º 6
0
 def test_constructor_with_options(self):
     """
     Test instantiating a QueryResult by passing in query parameters
     """
     query = Query(self.db)
     result = QueryResult(query, foo='bar', page_size=10)
     self.assertIsInstance(result, QueryResult)
     self.assertEqual(result.options, {'foo': 'bar'})
     self.assertEqual(result._ref, query)
     self.assertEqual(result._page_size, 10)
Exemplo n.º 7
0
 def test_constructor_with_query_skip_limit_options_skip_limit(self):
     """
     Ensure that options skip and/or limit override the values in the query
     callable if present when constructing a QueryResult
     """
     query = Query(self.db, skip=10, limit=10)
     result = QueryResult(query, skip=100, limit=100)
     self.assertIsInstance(result, QueryResult)
     self.assertDictEqual(result.options, {'skip': 100, 'limit': 100})
     self.assertEqual(result._ref, query)
Exemplo n.º 8
0
def troubleshoot(par):
    SERVER = par.get("SERVER")
    APPLICATION = par.get("APPLICATION")
    session = client.session()
    db = client['esb-data']
    query_ts = cloudant.query.Query(db,
                                    selector={
                                        "SERVER":
                                        SERVER,
                                        "APPLICATION":
                                        APPLICATION,
                                        "$or": [{
                                            "GET": "DISABLED"
                                        }, {
                                            "PUT": "DISABLED"
                                        }, {
                                            "CURDEPTH": {
                                                "$gt": 4000
                                            }
                                        }, {
                                            "IP_PROCS": {
                                                "$gt": 0
                                            }
                                        }, {
                                            "OP_PROCS": {
                                                "$gt": 0
                                            }
                                        }, {
                                            "CH_STATUS": "STOPPED"
                                        }, {
                                            "EG_STATUS": "RUNNING"
                                        }, {
                                            "FLOW_STATUS": "RUNNING"
                                        }, {
                                            "MSG_INSTANCES": {
                                                "$gt": 25
                                            }
                                        }]
                                    })
    time.sleep(1)
    queryresult_ts = QueryResult(query_ts)
    #print(queryresult_ts)
    for doc in queryresult_ts:
        try:
            issue = "ISSUE WITH " + doc['FLOW_NAME']
            details = str(doc)
        except:
            issue = "ISSUE WITH " + doc['QUEUE']
            details = str(doc)
    result = issue + "<br>" + details
    details = {}
    logdb = client['jarvis-interaction']
    doc = logdb.create_document(details)
    doc.save()
    return result
Exemplo n.º 9
0
def predictiveanalysis(par):
    session = client.session()
    db = client['esb-data']
    query_pa_o1 = cloudant.query.Query(db, selector={"CPU": {"$gt": 0}})
    query_result = QueryResult(query_pa_o1)
    health_report(query_result)
    time.sleep(1)
    '''for doc in query_pa_o1:
      SERVER = doc["SERVER"]
      print(SERVER)
      query_pa_o2 = cloudant.query.Query(db,selector={"SERVER":SERVER})
      time.sleep(1)
      for doc in query_pa_i1:
        print(doc["CPU"])
        print(doc["Memory"])'''

    return "From my analysis there seems to be no issues as of now"