Exemple #1
0
    def getJobMonData_hc(self, jid, start_time=None, stop_time=None):
        d = self.getJobMonData(jid, start_time, stop_time)
        if not d:
            return None

        # save data suitable for highchart
        cpu_rlt, mem_rlt, ior_rlt, iow_rlt = [], [], [], []
        for node, points in d.items():
            cpu_rlt.append({
                'name':
                node,
                'data': [[
                    p['time'],
                    MyTool.getDictNumValue(p, 'cpu_system_util') +
                    MyTool.getDictNumValue(p, 'cpu_user_util')
                ] for p in points]
            })
            mem_rlt.append({
                'name':
                node,
                'data': [[p['time'],
                          MyTool.getDictNumValue(p, 'mem_rss_K')]
                         for p in points]
            })
            ior_rlt.append({
                'name':
                node,
                'data':
                [[p['time'],
                  MyTool.getDictNumValue(p, 'io_read_rate')] for p in points]
            })
            iow_rlt.append({
                'name':
                node,
                'data':
                [[p['time'],
                  MyTool.getDictNumValue(p, 'io_write_rate')] for p in points]
            })

        # get min, max timestamp of cpu_rlt and return them as the values for all result
        minTS = min([n['data'][0][0] for n in cpu_rlt if n['data']])
        maxTS = max([n['data'][-1][0] for n in cpu_rlt if n['data']])

        return minTS, maxTS, cpu_rlt, mem_rlt, ior_rlt, iow_rlt
Exemple #2
0
    def getSlurmNodeMonData(self, node, start_time, stop_time=''):
        query = "select * from autogen.cpu_uid_mon where hostname = '{}'".format(
            node)
        query = self.extendQuery(query, start_time, stop_time)
        results = self.query(query)
        if results:
            points = list(results.get_points())
            uid2seq = {}
            for point in points:  #points are sorted by point['time']
                ts = point['time']
                uid = point['uid']
                if uid not in uid2seq: uid2seq[uid] = {}
                if 'mem_rss_K' in point:
                    mem_rss_K = MyTool.getDictNumValue(point, 'mem_rss_K')
                else:
                    mem_rss_K = int(
                        MyTool.getDictNumValue(point, 'mem_rss') / 1024)
                uid2seq[uid][ts] = [
                    MyTool.getDictNumValue(point, 'cpu_system_util') +
                    MyTool.getDictNumValue(point, 'cpu_user_util'), mem_rss_K,
                    MyTool.getDictNumValue(point, 'io_read_rate'),
                    MyTool.getDictNumValue(point, 'io_write_rate')
                ]

            if len(points) > 0:
                start_time = points[0]['time']
                stop_time = points[len(points) - 1]['time']
                return uid2seq, start_time, stop_time

        return None, start_time, stop_time
Exemple #3
0
    def getSlurmUidMonData_All(self, uid, start_time, stop_time=''):
        if stop_time:  # if stop_time equal to today, set it to '' to retrive up to date data
            if stop_time == time.mktime(date.today().timetuple()
                                        ):  # mostly from report page to today
                stop_time = ''
        cut_ts = int(time.time()) - 3 * ONE_DAY_SECS
        if start_time < cut_ts:  # more than 3 days
            node2seq = self.getSlurmUidMonData_Hourly(uid, start_time,
                                                      cut_ts - 1)
            start_time = cut_ts

        query = "select * from autogen.cpu_uid_mon where uid='{}'".format(uid)
        query = self.extendQuery(query, start_time, stop_time)
        results = self.query(query, 'ms')
        points = results.get_points()  # lists of dictionaries
        for point in points:  #points are sorted by point['time']
            ts = point['time']
            node = point['hostname']
            if 'mem_rss_K' in point:
                mem_rss_K = MyTool.getDictNumValue(point, 'mem_rss_K')
            else:
                mem_rss_K = int(
                    MyTool.getDictNumValue(point, 'mem_rss') / 1024)
            node2seq[node][ts] = [
                MyTool.getDictNumValue(point, 'cpu_system_util') +
                MyTool.getDictNumValue(point, 'cpu_user_util'), mem_rss_K,
                MyTool.getDictNumValue(point, 'io_read_rate'),
                MyTool.getDictNumValue(point, 'io_write_rate')
            ]
        return node2seq
Exemple #4
0
    def getSlurmUidMonData(self, uid, nodelist, start_time, stop_time):
        t1 = time.time()

        #prepare query
        g = ('(' + n + ')' for n in nodelist)
        hostnames = '|'.join(g)
        query = "select * from autogen.cpu_uid_mon where uid = '" + str(
            uid) + "' and hostname=~/" + hostnames + "/ and time >= " + str(
                int(start_time)) + "000000000 and time <= " + str(
                    int(stop_time) + 1) + "000000000"

        #execute query, returned time is local timestamp, epoch is for returned result, not for query
        results = self.query(query)
        if not results:
            return None

        points = results.get_points()
        node2seq = {n: {} for n in nodelist}
        for point in points:  #points are sorted by point['time']
            ts = point['time']
            node = point['hostname']
            if 'mem_rss_K' in point:
                mem_rss_K = MyTool.getDictNumValue(point, 'mem_rss_K')
            else:
                mem_rss_K = int(
                    MyTool.getDictNumValue(point, 'mem_rss') / 1024)
            node2seq[node][ts] = [
                MyTool.getDictNumValue(point, 'cpu_system_util') +
                MyTool.getDictNumValue(point, 'cpu_user_util'),
                MyTool.getDictNumValue(point, 'io_read_rate'),
                MyTool.getDictNumValue(point, 'io_write_rate'), mem_rss_K
            ]

        #print(repr(node2seq))
        logger.info("INFO: getSlurmUidMonData take time " +
                    str(time.time() - t1))
        return node2seq