コード例 #1
0
    def update(self,
               title=None,
               hosts=None,
               counters=None,
               screen_id=None,
               timespan=None,
               graph_type=None,
               method=None,
               position=None):

        title = self.title if title is None else title
        hosts = self.hosts if hosts is None else hosts
        hosts = hosts and ENDPOINT_DELIMITER.join(hosts) or ""

        counters = self.counters if counters is None else counters
        counters = counters and ENDPOINT_DELIMITER.join(counters) or ""

        screen_id = screen_id or self.screen_id
        timespan = timespan or self.timespan
        graph_type = graph_type or self.graph_type
        method = method if method is not None else self.method
        position = position or self.position
        db_conn.execute(
            '''update dashboard_graph set title=%s, hosts=%s, counters=%s, screen_id=%s,
                    timespan=%s, graph_type=%s, method=%s, position=%s where id=%s''',
            (title, hosts, counters, screen_id, timespan, graph_type, method,
             position, self.id))
        db_conn.commit()
        return DashboardGraph.get(self.id)
コード例 #2
0
ファイル: graph.py プロジェクト: masato25/dashboard
    def update(
        self,
        title=None,
        hosts=None,
        counters=None,
        screen_id=None,
        timespan=None,
        graph_type=None,
        method=None,
        position=None,
    ):

        title = self.title if title is None else title
        hosts = self.hosts if hosts is None else hosts
        hosts = hosts and ENDPOINT_DELIMITER.join(hosts) or ""

        counters = self.counters if counters is None else counters
        counters = counters and ENDPOINT_DELIMITER.join(counters) or ""

        screen_id = screen_id or self.screen_id
        timespan = timespan or self.timespan
        graph_type = graph_type or self.graph_type
        method = method if method is not None else self.method
        position = position or self.position
        db_conn.execute(
            """update dashboard_graph set title=%s, hosts=%s, counters=%s, screen_id=%s,
                    timespan=%s, graph_type=%s, method=%s, position=%s where id=%s""",
            (title, hosts, counters, screen_id, timespan, graph_type, method, position, self.id),
        )
        db_conn.commit()
        return DashboardGraph.get(self.id)
コード例 #3
0
ファイル: graph.py プロジェクト: Maikiki/open-flcon
 def update_multi(cls, rows):
     for x in rows:
         id = x["id"]
         hosts = x["hosts"] or []
         counters = x["counters"] or []
         db_conn.execute('''update dashboard_graph set hosts=%s, counters=%s where id=%s''',
                 (ENDPOINT_DELIMITER.join(hosts) or "", ENDPOINT_DELIMITER.join(counters) or "", id))
     db_conn.commit()
コード例 #4
0
 def update_multi(cls, rows):
     for x in rows:
         id = x["id"]
         hosts = x["hosts"] or []
         counters = x["counters"] or []
         db_conn.execute(
             '''update dashboard_graph set hosts=%s, counters=%s where id=%s''',
             (ENDPOINT_DELIMITER.join(hosts)
              or "", ENDPOINT_DELIMITER.join(counters) or "", id))
     db_conn.commit()
コード例 #5
0
ファイル: graph.py プロジェクト: Maikiki/open-flcon
 def add(cls, title, hosts, counters, screen_id,
             timespan=3600, graph_type='h', method='', position=0):
     cursor = db_conn.execute('''insert into dashboard_graph (title, hosts, counters, screen_id,
             timespan, graph_type, method, position)
             values(%s, %s, %s, %s, %s, %s, %s, %s)''',
             (title, ENDPOINT_DELIMITER.join(hosts) or "", ENDPOINT_DELIMITER.join(counters) or "", screen_id,
                 timespan, graph_type, method, position))
     id_ = cursor.lastrowid
     db_conn.execute('''update dashboard_graph set position=%s where id=%s''', (id_, id_))
     db_conn.commit()
     cursor and cursor.close()
     return cls.get(id_)
コード例 #6
0
ファイル: graph.py プロジェクト: Maikiki/open-flcon
 def add(cls, endpoints, counters):
     es = endpoints and ENDPOINT_DELIMITER.join(sorted(endpoints)) or ""
     cs = counters and COUNTER_DELIMITER.join(sorted(counters)) or ""
     ck = hashlib.md5("%s:%s" %(es.encode("utf8"), cs.encode("utf8"))).hexdigest()
     cursor = db_conn.execute('''insert ignore into tmp_graph (endpoints, counters, ck) values(%s, %s, %s) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id),time_=%s''',
             (es, cs, ck, datetime.datetime.now()))
     id_ = cursor.lastrowid
     db_conn.commit()
     cursor and cursor.close()
     return id_
コード例 #7
0
 def add(cls, endpoints, counters):
     es = endpoints and ENDPOINT_DELIMITER.join(sorted(endpoints)) or ""
     cs = counters and COUNTER_DELIMITER.join(sorted(counters)) or ""
     ck = hashlib.md5("%s:%s" %
                      (es.encode("utf8"), cs.encode("utf8"))).hexdigest()
     cursor = db_conn.execute(
         '''insert ignore into tmp_graph (endpoints, counters, ck) values(%s, %s, %s) ON DUPLICATE KEY UPDATE time_=%s''',
         (es, cs, ck, datetime.datetime.now()))
     id_ = cursor.lastrowid
     db_conn.commit()
     cursor and cursor.close()
     return id_
コード例 #8
0
ファイル: graph.py プロジェクト: hitripod/dashboard
 def add(cls, endpoints, counters):
     es = endpoints and ENDPOINT_DELIMITER.join(sorted(endpoints)) or ""
     cs = counters and COUNTER_DELIMITER.join(sorted(counters)) or ""
     ck = hashlib.md5("%s:%s" %(es.encode("utf8"), cs.encode("utf8"))).hexdigest()
     cursor = db_conn.execute('''insert ignore into tmp_graph (endpoints, counters, ck) values(%s, %s, %s) ON DUPLICATE KEY UPDATE time_=%s''',
             (es, cs, ck, datetime.datetime.now()))
     id_ = cursor.lastrowid
     if not id_:
         cursor = db_conn.execute("select id from tmp_graph where ck='" + ck + "'")
         id_ = cursor.fetchone()[0]
     db_conn.commit()
     cursor and cursor.close()
     return id_
コード例 #9
0
 def add(cls,
         title,
         hosts,
         counters,
         screen_id,
         timespan=3600,
         graph_type='h',
         method='',
         position=0):
     cursor = db_conn.execute(
         '''insert into dashboard_graph (title, hosts, counters, screen_id,
             timespan, graph_type, method, position)
             values(%s, %s, %s, %s, %s, %s, %s, %s)''',
         (title, ENDPOINT_DELIMITER.join(hosts)
          or "", ENDPOINT_DELIMITER.join(counters)
          or "", screen_id, timespan, graph_type, method, position))
     id_ = cursor.lastrowid
     db_conn.execute(
         '''update dashboard_graph set position=%s where id=%s''',
         (id_, id_))
     db_conn.commit()
     cursor and cursor.close()
     return cls.get(id_)
コード例 #10
0
ファイル: graph.py プロジェクト: minimum-hsu/dashboard
 def add(cls, endpoints, counters):
     es = endpoints and ENDPOINT_DELIMITER.join(sorted(endpoints)) or ""
     cs = counters and COUNTER_DELIMITER.join(sorted(counters)) or ""
     ck = hashlib.md5("%s:%s" %
                      (es.encode("utf8"), cs.encode("utf8"))).hexdigest()
     cursor = db_conn.execute(
         '''insert ignore into tmp_graph (endpoints, counters, ck) values(%s, %s, %s) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id),time_=%s''',
         (es, cs, ck, datetime.datetime.now()))
     id_ = cursor.lastrowid
     if not id_:
         cursor = db_conn.execute("select id from tmp_graph where ck='" +
                                  ck + "'")
         id_ = cursor.fetchone()[0]
     db_conn.commit()
     cursor and cursor.close()
     return id_