Exemplo n.º 1
0
    def test_proc_error_es(self):
        log = ESNetLogger()
        log.proc_error(11111, 22, "epic fail")
        log.proc_error(11112, 9758, "fail")
        log.proc_error(11113, 7364, "little fail")
        log.close()
        time.sleep(1)
        data = self.es.search(index=config.DB_NAME, body='{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}')
        items = data["hits"]["hits"]
        self.assertEqual(3, len(items), "number of mem sys items logged")
#        print(str(items[0]["_source"]))
        self.assert_proc_error(items[0]["_source"], 11111, 22, "epic fail")
        self.assert_proc_error(items[1]["_source"], 11112, 9758, "fail")
        self.assert_proc_error(items[2]["_source"], 11113, 7364, "little fail")
Exemplo n.º 2
0
 def test_proc_error_es(self):
     log = ESNetLogger()
     log.proc_error(11111, 22, "epic fail")
     log.proc_error(11112, 9758, "fail")
     log.proc_error(11113, 7364, "little fail")
     log.close()
     time.sleep(1)
     data = self.es.search(
         index=config.DB_NAME,
         body=
         '{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}'
     )
     items = data["hits"]["hits"]
     self.assertEqual(3, len(items), "number of mem sys items logged")
     #        print(str(items[0]["_source"]))
     self.assert_proc_error(items[0]["_source"], 11111, 22, "epic fail")
     self.assert_proc_error(items[1]["_source"], 11112, 9758, "fail")
     self.assert_proc_error(items[2]["_source"], 11113, 7364, "little fail")
Exemplo n.º 3
0
 def test_cpu_sys_es(self):
     log = ESNetLogger()
     log.cpu_sys(0, 1, 1, 1, 1)
     log.cpu_sys(1, 3, 2, 5, 6)
     log.cpu_sys(3, 22, 99, 11, 4)
     log.cpu_sys(5, 155, 122, 12, 22)
     log.close()
     time.sleep(1)
     data = self.es.search(index=config.DB_NAME, body='{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}')
     items = data["hits"]["hits"]
     self.assertEqual(4, len(items), "number of cpu sys items logged")
     self.assert_cpu_sys(items[0]["_source"], 0, 1, 1, 1, 1)
     self.assert_cpu_sys(items[1]["_source"], 1, 3, 2, 5, 6)
     self.assert_cpu_sys(items[2]["_source"], 3, 22, 99, 11, 4)
     self.assert_cpu_sys(items[3]["_source"], 5, 155, 122, 12, 22)
Exemplo n.º 4
0
 def test_cpu_sys_es(self):
     log = ESNetLogger()
     log.cpu_sys(0, 1, 1, 1, 1)
     log.cpu_sys(1, 3, 2, 5, 6)
     log.cpu_sys(3, 22, 99, 11, 4)
     log.cpu_sys(5, 155, 122, 12, 22)
     log.close()
     time.sleep(1)
     data = self.es.search(
         index=config.DB_NAME,
         body=
         '{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}'
     )
     items = data["hits"]["hits"]
     self.assertEqual(4, len(items), "number of cpu sys items logged")
     self.assert_cpu_sys(items[0]["_source"], 0, 1, 1, 1, 1)
     self.assert_cpu_sys(items[1]["_source"], 1, 3, 2, 5, 6)
     self.assert_cpu_sys(items[2]["_source"], 3, 22, 99, 11, 4)
     self.assert_cpu_sys(items[3]["_source"], 5, 155, 122, 12, 22)
Exemplo n.º 5
0
 def test_proc_info_es(self):
     log = ESNetLogger()
     log.proc_info(11111, 22, "proc1")
     log.proc_info(11111, 9758, "proc2")
     log.proc_info(11111, 7364, "proc4")
     log.proc_info(11111, 3332, "proc3")
     log.close()
     time.sleep(1)
     data = self.es.search(
         index=config.DB_NAME,
         body=
         '{"query":{"match_all":{}}, "sort": { "pid": { "order": "asc" }}}')
     items = data["hits"]["hits"]
     self.assertEqual(4, len(items), "number of mem sys items logged")
     #        print(str(items[0]["_source"]))
     self.assert_proc_error(items[0]["_source"], 11111, 22, "proc1")
     self.assert_proc_error(items[1]["_source"], 11111, 3332, "proc3")
     self.assert_proc_error(items[2]["_source"], 11111, 7364, "proc4")
     self.assert_proc_error(items[3]["_source"], 11111, 9758, "proc2")
Exemplo n.º 6
0
    def test_proc_info_es(self):
        log = ESNetLogger()
        log.proc_info(11111, 22, "proc1")
        log.proc_info(11111, 9758, "proc2")
        log.proc_info(11111, 7364, "proc4")
        log.proc_info(11111, 3332, "proc3")
        log.close()
        time.sleep(1)
        data = self.es.search(index=config.DB_NAME, body='{"query":{"match_all":{}}, "sort": { "pid": { "order": "asc" }}}')
        items = data["hits"]["hits"]
        self.assertEqual(4, len(items), "number of mem sys items logged")
#        print(str(items[0]["_source"]))
        self.assert_proc_error(items[0]["_source"], 11111, 22, "proc1")
        self.assert_proc_error(items[1]["_source"], 11111, 3332, "proc3")
        self.assert_proc_error(items[2]["_source"], 11111, 7364, "proc4")
        self.assert_proc_error(items[3]["_source"], 11111, 9758, "proc2")
Exemplo n.º 7
0
def init():
    global loggers
    global proc_poller
    global cpu_poller
    global mem_poller
    global io_poller

    loggers = []
    if (config.ES_FILE_ENABLED): loggers.append(ESFileLogger())
    if (config.ES_NW_ENABLED): loggers.append(ESNetLogger())
    if (config.MYSQL_ENABLED): loggers.append(MySqlLogger())
    if (config.CSV_ENABLED): loggers.append(CSVFileLogger())
    if (config.KAFKA_ENABLED): loggers.append(KafkaLogger())
    proc_poller = ProcPoller(loggers)
    cpu_poller = CPUPoller(proc_poller, loggers)
    mem_poller = MemPoller(proc_poller, loggers)
    io_poller = IOPoller(loggers)
Exemplo n.º 8
0
    def test_cpu_proc_es(self):
        log = ESNetLogger()
        log.cpu_proc(0, 1, 1, 1, 1, 1, 1, 1, "p1")
        log.cpu_proc(1, 2, 1, 3, 4, 2, 3, 1, "p2")
        log.cpu_proc(2, 3, 2, 122, 7, 5, 8, 11, "p3")
        log.cpu_proc(10, 1, 1, 1, 1, 1, 1, 1, "p1")
        log.cpu_proc(11, 2, 1, 3, 4, 2, 3, 1, "p2")
        log.cpu_proc(12, 3, 2, 122, 7, 5, 8, 11, "p3")
        log.cpu_proc(20, 1, 1, 5, 1, 4, 3, 2, "p1")
        log.cpu_proc(21, 3, 2, 555, 7, 11, 55, 32, "p3")
        log.close()
        time.sleep(1)
        data = self.es.search(index=config.DB_NAME, body='{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}')
        items = data["hits"]["hits"]
        self.assertEqual(8, len(items), "number of cpu proc items logged")
#        print(str(items[0]["_source"]))
        self.assert_cpu_proc(items[0]["_source"], 0, 1, 1, 1, 1, 1, 1, 1, "p1")
        self.assert_cpu_proc(items[1]["_source"], 1, 2, 1, 3, 4, 2, 3, 1, "p2")
        self.assert_cpu_proc(items[2]["_source"], 2, 3, 2, 122, 7, 5, 8, 11, "p3")
        self.assert_cpu_proc(items[3]["_source"], 10, 1, 1, 1, 1, 1, 1, 1, "p1")
        self.assert_cpu_proc(items[4]["_source"], 11, 2, 1, 3, 4, 2, 3, 1, "p2")
        self.assert_cpu_proc(items[5]["_source"], 12, 3, 2, 122, 7, 5, 8, 11, "p3")
        self.assert_cpu_proc(items[6]["_source"], 20, 1, 1, 5, 1, 4, 3, 2, "p1")
        self.assert_cpu_proc(items[7]["_source"], 21, 3, 2, 555, 7, 11, 55, 32, "p3")
Exemplo n.º 9
0
    def test_io_sys_es(self):
        log = ESNetLogger()
        log.io_sys(11111, 22, 22, 34, 43, 11, 11, 5, 3)
        log.io_sys(22222, 55, 23, 44, 34, 23, 17, 15, 4)
        log.io_sys(22233, 65, 23, 777, 44, 28, 18, 35, 5)
        log.io_sys(25555, 78, 44, 1911, 53, 99434, 43, 43, 21)
        log.close()
        time.sleep(1)
        data = self.es.search(index=config.DB_NAME, body='{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}')
        items = data["hits"]["hits"]
        self.assertEqual(4, len(items), "number of mem sys items logged")
#        print(str(items[0]["_source"]))
        self.assert_io_sys(items[0]["_source"], 11111, 22, 22, 34, 43, 11, 11, 5, 3)
        self.assert_io_sys(items[1]["_source"], 22222, 55, 23, 44, 34, 23, 17, 15, 4)
        self.assert_io_sys(items[2]["_source"], 22233, 65, 23, 777, 44, 28, 18, 35, 5)
        self.assert_io_sys(items[3]["_source"], 25555, 78, 44, 1911, 53, 99434, 43, 43, 21)
Exemplo n.º 10
0
    def test_mem_proc_es(self):
        log = ESNetLogger()
        log.mem_proc(0, 1, 11, 15, 5, "p1")
        log.mem_proc(1, 2, 1, 3, 2, "p2")
        log.mem_proc(2, 5432, 21, 33, 9, "p3")
        log.mem_proc(5, 1, 22, 11, 3, "p1")
        log.mem_proc(6, 5432, 7, 55, 7, "p3")
        log.mem_proc(66, 1, 11, 15, 5, "p1")
        log.mem_proc(67, 2, 11, 0, 22, "p2")
        log.mem_proc(68, 5432, 212, 334, 44, "p3")
        log.close()
        time.sleep(1)
        data = self.es.search(index=config.DB_NAME, body='{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}')
        items = data["hits"]["hits"]
        self.assertEqual(8, len(items), "number of mem proc items logged")
#        print(str(items[0]["_source"]))
        self.assert_mem_proc(items[0]["_source"], 0, 1, 11, 15, 5, "p1")
        self.assert_mem_proc(items[1]["_source"], 1, 2, 1, 3, 2, "p2")
        self.assert_mem_proc(items[2]["_source"], 2, 5432, 21, 33, 9, "p3")
        self.assert_mem_proc(items[3]["_source"], 5, 1, 22, 11, 3, "p1")
        self.assert_mem_proc(items[4]["_source"], 6, 5432, 7, 55, 7, "p3")
        self.assert_mem_proc(items[5]["_source"], 66, 1, 11, 15, 5, "p1")
        self.assert_mem_proc(items[6]["_source"], 67, 2, 11, 0, 22, "p2")
        self.assert_mem_proc(items[7]["_source"], 68, 5432, 212, 334, 44, "p3")
Exemplo n.º 11
0
 def test_mem_sys_es(self):
     log = ESNetLogger()
     log.mem_sys(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
     log.mem_sys(10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
     log.mem_sys(12, 34, 654, 24, 33, 23, 442, 1, 13, 21, 44)
     log.mem_sys(15, 3445, 345, 345, 44, 745, 367, 32, 1111, 33, 55)
     log.mem_sys(33, 33, 453, 998, 347, 976, 8544, 45, 5555, 66, 33)
     log.close()
     time.sleep(1)
     data = self.es.search(index=config.DB_NAME, body='{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}')
     items = data["hits"]["hits"]
     self.assertEqual(5, len(items), "number of mem sys items logged")
     self.assert_mem_sys(items[0]["_source"], 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
     self.assert_mem_sys(items[1]["_source"], 10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
     self.assert_mem_sys(items[2]["_source"], 12, 34, 654, 24, 33, 23, 442, 1, 13, 21, 44)
     self.assert_mem_sys(items[3]["_source"], 15, 3445, 345, 345, 44, 745, 367, 32, 1111, 33, 55)
     self.assert_mem_sys(items[4]["_source"], 33, 33, 453, 998, 347, 976, 8544, 45, 5555, 66, 33)
Exemplo n.º 12
0
 def test_cpu_proc_es(self):
     log = ESNetLogger()
     log.cpu_proc(0, 1, 1, 1, 1, 1, 1, 1, "p1")
     log.cpu_proc(1, 2, 1, 3, 4, 2, 3, 1, "p2")
     log.cpu_proc(2, 3, 2, 122, 7, 5, 8, 11, "p3")
     log.cpu_proc(10, 1, 1, 1, 1, 1, 1, 1, "p1")
     log.cpu_proc(11, 2, 1, 3, 4, 2, 3, 1, "p2")
     log.cpu_proc(12, 3, 2, 122, 7, 5, 8, 11, "p3")
     log.cpu_proc(20, 1, 1, 5, 1, 4, 3, 2, "p1")
     log.cpu_proc(21, 3, 2, 555, 7, 11, 55, 32, "p3")
     log.close()
     time.sleep(1)
     data = self.es.search(
         index=config.DB_NAME,
         body=
         '{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}'
     )
     items = data["hits"]["hits"]
     self.assertEqual(8, len(items), "number of cpu proc items logged")
     #        print(str(items[0]["_source"]))
     self.assert_cpu_proc(items[0]["_source"], 0, 1, 1, 1, 1, 1, 1, 1, "p1")
     self.assert_cpu_proc(items[1]["_source"], 1, 2, 1, 3, 4, 2, 3, 1, "p2")
     self.assert_cpu_proc(items[2]["_source"], 2, 3, 2, 122, 7, 5, 8, 11,
                          "p3")
     self.assert_cpu_proc(items[3]["_source"], 10, 1, 1, 1, 1, 1, 1, 1,
                          "p1")
     self.assert_cpu_proc(items[4]["_source"], 11, 2, 1, 3, 4, 2, 3, 1,
                          "p2")
     self.assert_cpu_proc(items[5]["_source"], 12, 3, 2, 122, 7, 5, 8, 11,
                          "p3")
     self.assert_cpu_proc(items[6]["_source"], 20, 1, 1, 5, 1, 4, 3, 2,
                          "p1")
     self.assert_cpu_proc(items[7]["_source"], 21, 3, 2, 555, 7, 11, 55, 32,
                          "p3")
Exemplo n.º 13
0
 def test_io_sys_es(self):
     log = ESNetLogger()
     log.io_sys(11111, 22, 22, 34, 43, 11, 11, 5, 3)
     log.io_sys(22222, 55, 23, 44, 34, 23, 17, 15, 4)
     log.io_sys(22233, 65, 23, 777, 44, 28, 18, 35, 5)
     log.io_sys(25555, 78, 44, 1911, 53, 99434, 43, 43, 21)
     log.close()
     time.sleep(1)
     data = self.es.search(
         index=config.DB_NAME,
         body=
         '{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}'
     )
     items = data["hits"]["hits"]
     self.assertEqual(4, len(items), "number of mem sys items logged")
     #        print(str(items[0]["_source"]))
     self.assert_io_sys(items[0]["_source"], 11111, 22, 22, 34, 43, 11, 11,
                        5, 3)
     self.assert_io_sys(items[1]["_source"], 22222, 55, 23, 44, 34, 23, 17,
                        15, 4)
     self.assert_io_sys(items[2]["_source"], 22233, 65, 23, 777, 44, 28, 18,
                        35, 5)
     self.assert_io_sys(items[3]["_source"], 25555, 78, 44, 1911, 53, 99434,
                        43, 43, 21)
Exemplo n.º 14
0
 def test_mem_proc_es(self):
     log = ESNetLogger()
     log.mem_proc(0, 1, 11, 15, 5, "p1")
     log.mem_proc(1, 2, 1, 3, 2, "p2")
     log.mem_proc(2, 5432, 21, 33, 9, "p3")
     log.mem_proc(5, 1, 22, 11, 3, "p1")
     log.mem_proc(6, 5432, 7, 55, 7, "p3")
     log.mem_proc(66, 1, 11, 15, 5, "p1")
     log.mem_proc(67, 2, 11, 0, 22, "p2")
     log.mem_proc(68, 5432, 212, 334, 44, "p3")
     log.close()
     time.sleep(1)
     data = self.es.search(
         index=config.DB_NAME,
         body=
         '{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}'
     )
     items = data["hits"]["hits"]
     self.assertEqual(8, len(items), "number of mem proc items logged")
     #        print(str(items[0]["_source"]))
     self.assert_mem_proc(items[0]["_source"], 0, 1, 11, 15, 5, "p1")
     self.assert_mem_proc(items[1]["_source"], 1, 2, 1, 3, 2, "p2")
     self.assert_mem_proc(items[2]["_source"], 2, 5432, 21, 33, 9, "p3")
     self.assert_mem_proc(items[3]["_source"], 5, 1, 22, 11, 3, "p1")
     self.assert_mem_proc(items[4]["_source"], 6, 5432, 7, 55, 7, "p3")
     self.assert_mem_proc(items[5]["_source"], 66, 1, 11, 15, 5, "p1")
     self.assert_mem_proc(items[6]["_source"], 67, 2, 11, 0, 22, "p2")
     self.assert_mem_proc(items[7]["_source"], 68, 5432, 212, 334, 44, "p3")
Exemplo n.º 15
0
 def test_mem_sys_es(self):
     log = ESNetLogger()
     log.mem_sys(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
     log.mem_sys(10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
     log.mem_sys(12, 34, 654, 24, 33, 23, 442, 1, 13, 21, 44)
     log.mem_sys(15, 3445, 345, 345, 44, 745, 367, 32, 1111, 33, 55)
     log.mem_sys(33, 33, 453, 998, 347, 976, 8544, 45, 5555, 66, 33)
     log.close()
     time.sleep(1)
     data = self.es.search(
         index=config.DB_NAME,
         body=
         '{"query":{"match_all":{}}, "sort": { "time": { "order": "asc" }}}'
     )
     items = data["hits"]["hits"]
     self.assertEqual(5, len(items), "number of mem sys items logged")
     self.assert_mem_sys(items[0]["_source"], 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                         1)
     self.assert_mem_sys(items[1]["_source"], 10, 2, 2, 2, 2, 2, 2, 2, 2, 2,
                         2)
     self.assert_mem_sys(items[2]["_source"], 12, 34, 654, 24, 33, 23, 442,
                         1, 13, 21, 44)
     self.assert_mem_sys(items[3]["_source"], 15, 3445, 345, 345, 44, 745,
                         367, 32, 1111, 33, 55)
     self.assert_mem_sys(items[4]["_source"], 33, 33, 453, 998, 347, 976,
                         8544, 45, 5555, 66, 33)