def send_database_status(self):
     cassandra_status_uve = CassandraStatusUVE()
     cassandra_status = CassandraStatusData()
     cassandra_status.cassandra_compaction_task = CassandraCompactionTask()
     # Get compactionstats
     compaction_count = subprocess.Popen("nodetool compactionstats|grep 'pending tasks:'",
         shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     op, err = compaction_count.communicate()
     if compaction_count.returncode != 0:
         msg = "Failed to get nodetool compactionstats " + err
         self.msg_log(msg, level=SandeshLevel.SYS_ERR)
         return
     cassandra_status.cassandra_compaction_task.pending_compaction_tasks = \
         self.get_pending_compaction_count(op)
     # Get the tpstats value
     tpstats_op = subprocess.Popen(["nodetool", "tpstats"], stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
     op, err = tpstats_op.communicate()
     if tpstats_op.returncode != 0:
         msg = "Failed to get nodetool tpstats " + err
         self.msg_log(msg, level=SandeshLevel.SYS_ERR)
         return
     cassandra_status.thread_pool_stats = self.get_tp_status(op)
     cassandra_status.name = socket.gethostname()
     cassandra_status_uve = CassandraStatusUVE(data=cassandra_status)
     msg = 'Sending UVE: ' + str(cassandra_status_uve)
     self.sandesh_global.logger().log(SandeshLogger.get_py_logger_level(
                         SandeshLevel.SYS_DEBUG), msg)
     cassandra_status_uve.send()
Пример #2
0
    def send_database_status(self, event_mgr):
        status = CassandraStatusData()
        status.cassandra_compaction_task = CassandraCompactionTask()
        # Get compactionstats
        base_cmd = "nodetool -p {}".format(self.db_jmx_port)
        try:
            res = self.exec_cmd(base_cmd + " compactionstats")
            status.cassandra_compaction_task.pending_compaction_tasks = \
                self.get_pending_compaction_count(res)
        except Exception as e:
            msg = "Failed to get nodetool compactionstats: {}".format(e)
            event_mgr.msg_log(msg, level=SandeshLevel.SYS_ERR)
            return

        # Get the tpstats value
        try:
            res = self.exec_cmd(base_cmd + " tpstats")
            status.thread_pool_stats = self.get_tp_status(res)
        except Exception as e:
            msg = "Failed to get nodetool tpstats {}".format(e)
            event_mgr.msg_log(msg, level=SandeshLevel.SYS_ERR)
            return

        status.name = self.hostname
        status_uve = CassandraStatusUVE(data=status)
        if self.has_cassandra_status_changed(status, self.status_old):
            # Assign status to status_old
            self.status_old.thread_pool_stats = status.thread_pool_stats
            self.status_old.cassandra_compaction_task.\
                pending_compaction_tasks = status.\
                cassandra_compaction_task.pending_compaction_tasks
            msg = 'Sending UVE: ' + str(status_uve)
            event_mgr.msg_log(msg, level=SandeshLevel.SYS_DEBUG)
            status_uve.send()
 def send_database_status(self):
     cassandra_status_uve = CassandraStatusUVE()
     cassandra_status = CassandraStatusData()
     cassandra_status.cassandra_compaction_task = CassandraCompactionTask()
     # Get compactionstats
     compaction_count = subprocess.Popen(
         "nodetool compactionstats|grep 'pending tasks:'",
         shell=True,
         stdout=subprocess.PIPE,
         stderr=subprocess.PIPE)
     op, err = compaction_count.communicate()
     if compaction_count.returncode != 0:
         msg = "Failed to get nodetool compactionstats " + err
         self.msg_log(msg, level=SandeshLevel.SYS_ERR)
         return
     cassandra_status.cassandra_compaction_task.pending_compaction_tasks = \
         self.get_pending_compaction_count(op)
     # Get the tpstats value
     tpstats_op = subprocess.Popen(["nodetool", "tpstats"],
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
     op, err = tpstats_op.communicate()
     if tpstats_op.returncode != 0:
         msg = "Failed to get nodetool tpstats " + err
         self.msg_log(msg, level=SandeshLevel.SYS_ERR)
         return
     cassandra_status.thread_pool_stats = self.get_tp_status(op)
     cassandra_status.name = socket.gethostname()
     cassandra_status_uve = CassandraStatusUVE(data=cassandra_status)
     msg = 'Sending UVE: ' + str(cassandra_status_uve)
     self.sandesh_global.logger().log(
         SandeshLogger.get_py_logger_level(SandeshLevel.SYS_DEBUG), msg)
     cassandra_status_uve.send()
Пример #4
0
 def send_database_status(self, event_mgr):
     cassandra_status_uve = CassandraStatusUVE()
     cassandra_status = CassandraStatusData()
     cassandra_status.cassandra_compaction_task = CassandraCompactionTask()
     # Get compactionstats
     cpt_cmd = "nodetool -h " + self.nodetool_ip + " compactionstats|grep 'pending tasks:'"
     compaction_count = subprocess.Popen(cpt_cmd,
                                         shell=True,
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE,
                                         close_fds=True)
     op, err = compaction_count.communicate()
     if compaction_count.returncode != 0:
         msg = "Failed to get nodetool compactionstats " + err
         event_mgr.msg_log(msg, level=SandeshLevel.SYS_ERR)
         return
     cassandra_status.cassandra_compaction_task.pending_compaction_tasks = \
         self.get_pending_compaction_count(op)
     # Get the tpstats value
     tpstats_op = subprocess.Popen(
         ["nodetool", "-h", self.nodetool_ip, "tpstats"],
         stdout=subprocess.PIPE,
         stderr=subprocess.PIPE,
         close_fds=True)
     op, err = tpstats_op.communicate()
     if tpstats_op.returncode != 0:
         msg = "Failed to get nodetool tpstats " + err
         event_mgr.msg_log(msg, level=SandeshLevel.SYS_ERR)
         return
     cassandra_status.thread_pool_stats = self.get_tp_status(op)
     cassandra_status.name = socket.gethostname()
     cassandra_status_uve = CassandraStatusUVE(data=cassandra_status)
     if self.has_cassandra_status_changed(cassandra_status,
                                          self.cassandra_status_old):
         # Assign cassandra_status to cassandra_status_old
         self.cassandra_status_old.thread_pool_stats = \
             cassandra_status.thread_pool_stats
         self.cassandra_status_old.cassandra_compaction_task.\
             pending_compaction_tasks = cassandra_status.\
             cassandra_compaction_task.pending_compaction_tasks
         msg = 'Sending UVE: ' + str(cassandra_status_uve)
         event_mgr.msg_log(msg, level=SandeshLevel.SYS_DEBUG)
         cassandra_status_uve.send()
 def send_database_status(self):
     cassandra_status_uve = CassandraStatusUVE()
     cassandra_status = CassandraStatusData()
     cassandra_status.cassandra_compaction_task = CassandraCompactionTask()
     # Get compactionstats
     compaction_count = subprocess.Popen("nodetool compactionstats|grep 'pending tasks:'",
         shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
         close_fds=True)
     op, err = compaction_count.communicate()
     if compaction_count.returncode != 0:
         msg = "Failed to get nodetool compactionstats " + err
         self.msg_log(msg, level=SandeshLevel.SYS_ERR)
         return
     cassandra_status.cassandra_compaction_task.pending_compaction_tasks = \
         self.get_pending_compaction_count(op)
     # Get the tpstats value
     tpstats_op = subprocess.Popen(["nodetool", "tpstats"], stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE, close_fds=True)
     op, err = tpstats_op.communicate()
     if tpstats_op.returncode != 0:
         msg = "Failed to get nodetool tpstats " + err
         self.msg_log(msg, level=SandeshLevel.SYS_ERR)
         return
     cassandra_status.thread_pool_stats = self.get_tp_status(op)
     cassandra_status.name = socket.gethostname()
     cassandra_status_uve = CassandraStatusUVE(data=cassandra_status)
     if self.has_cassandra_status_changed(cassandra_status, self.cassandra_status_old):
         # Assign cassandra_status to cassandra_status_old
         self.cassandra_status_old.thread_pool_stats = \
             cassandra_status.thread_pool_stats
         self.cassandra_status_old.cassandra_compaction_task.\
             pending_compaction_tasks = cassandra_status.\
             cassandra_compaction_task.pending_compaction_tasks
         msg = 'Sending UVE: ' + str(cassandra_status_uve)
         self.msg_log(msg, level=SandeshLevel.SYS_DEBUG)
         cassandra_status_uve.send()