コード例 #1
0
    def filter_table(self, rows):
        name = html.get_unicode_input(self._varprefix + "name")
        if not name:
            return rows

        from_version = html.var(self._varprefix + "from_version")
        to_version = html.var(self._varprefix + "to_version")
        negate = html.get_checkbox(self._varprefix + "negate")
        match = html.var(self._varprefix + "match")
        if match == "regex":
            try:
                name = re.compile(name)
            except re.error:
                raise MKUserError(
                    self._varprefix + "name",
                    _('You search statement is not valid. You need to provide a regular '
                      'expression (regex). For example you need to use <tt>\\\\</tt> instead of <tt>\\</tt> '
                      'if you like to search for a single backslash.'))

        new_rows = []
        for row in rows:
            packages = inventory.get(row["host_inventory"],
                                     ".software.packages:")
            is_in = self.find_package(packages, name, from_version, to_version)
            if is_in != negate:
                new_rows.append(row)
        return new_rows
コード例 #2
0
ファイル: inventory.py プロジェクト: kjko14/check_mk
    def filter_table(self, rows):
        fromvar = self.htmlvars[0]
        fromtext = html.var(fromvar)
        lower = None
        if fromtext:
            try:
                lower = float(fromtext) * self._scale
            except:
                pass

        tovar = self.htmlvars[1]
        totext = html.var(tovar)
        upper = None
        if totext:
            try:
                upper = float(totext) * self._scale
            except:
                pass

        if lower == None and upper == None:
            return rows

        newrows = []
        for row in rows:
            invdata = inventory.get(row["host_inventory"], self._invpath)
            if lower != None and invdata < lower:
                continue
            if upper != None and invdata > upper:
                continue
            newrows.append(row)
        return newrows
コード例 #3
0
ファイル: inventory.py プロジェクト: millerbk/check_mk_mirror
    def filter_table(self, rows):
        fromvar = self.htmlvars[0]
        fromtext = html.var(fromvar)
        lower = None
        if fromtext:
            try:
                lower = float(fromtext) * self._scale
            except:
                pass

        tovar = self.htmlvars[1]
        totext = html.var(tovar)
        upper = None
        if totext:
            try:
                upper = float(totext) * self._scale
            except:
                pass

        if lower == None and upper == None:
            return rows

        newrows = []
        for row in rows:
            invdata = inventory.get(row["host_inventory"], self._invpath)
            if lower != None and invdata < lower:
                continue
            if upper != None and invdata > upper:
                continue
            newrows.append(row)
        return newrows
コード例 #4
0
def create_swpac_rows(hostname):
    tree = inventory.host(hostname)
    packages = inventory.get(tree, ".software.packages:")
    for package in packages:
        newrow = {}
        for key, value in package.items():
            newrow["invswpac_" + key] = value
        yield newrow
コード例 #5
0
ファイル: inventory.py プロジェクト: alberts/check_mk
def create_swpac_rows(hostname):
    tree     = inventory.host(hostname)
    packages = inventory.get(tree, ".software.packages:")
    for package in packages:
        newrow = {}
        for key, value in package.items():
            newrow["invswpac_" + key] = value
        yield newrow
コード例 #6
0
ファイル: inventory.py プロジェクト: davidedg/check_mk
def create_inv_rows(hostname, invpath, infoname):
    tree     = inventory.host(hostname)
    entries = inventory.get(tree, invpath)
    for entry in entries:
        newrow = {}
        for key, value in entry.items():
            newrow[infoname + "_" + key] = value
        yield newrow
コード例 #7
0
ファイル: inventory.py プロジェクト: parvathikonda/My-Repos
def paint_inv_tree(row, invpath = "."):
    hostname = row["host_name"]
    tree = row["host_inventory"]
    node = inventory.get(tree, invpath)
    html.plug()
    render_inv_subtree_container(hostname, invpath, node)
    code = html.drain()
    html.unplug()
    return "invtree", code
コード例 #8
0
ファイル: inventory.py プロジェクト: davidedg/check_mk
def paint_inv_tree(row, invpath = ".", column = "host_inventory"):
    hostname = row["host_name"]
    tree = row[column]
    if column == "host_inventory":
        tree_id = ""
    else:
        tree_id = "/" + str(row["invhist_time"])
    node = inventory.get(tree, invpath)
    html.plug()
    render_inv_subtree_container(hostname, tree_id, invpath, node)
    code = html.drain()
    html.unplug()
    return "invtree", code
コード例 #9
0
def paint_inv_tree(row, invpath=".", column="host_inventory"):
    hostname = row["host_name"]
    tree = row[column]
    if column == "host_inventory":
        tree_id = ""
    else:
        tree_id = "/" + str(row["invhist_time"])
    node = inventory.get(tree, invpath)
    html.plug()
    render_inv_subtree_container(hostname, tree_id, invpath, node)
    code = html.drain()
    html.unplug()
    return "invtree", code
コード例 #10
0
    def filter_table(self, rows):
        tri = self.tristate_value()
        if tri == -1:
            return rows
        else:
            wanted_value = tri == 1

            newrows = []
            for row in rows:
                invdata = inventory.get(row["host_inventory"], self._invpath)
                if wanted_value == invdata:
                    newrows.append(row)
            return newrows
コード例 #11
0
ファイル: inventory.py プロジェクト: parvathikonda/My-Repos
def inv_software_table(columns, add_headers, only_sites, limit, filters):
    # Create livestatus filter for filtering out hosts
    filter_code = ""
    for filt in filters:
        header = filt.filter("invswpacs")
        if not header.startswith("Sites:"):
            filter_code += header
    host_columns = list(set([ "host_name" ] + filter(lambda c: c.startswith("host_"), columns)))

    html.live.set_only_sites(only_sites)
    html.live.set_prepend_site(True)

    query = "GET hosts\n"
    query += "Columns: " + (" ".join(host_columns)) + "\n"
    query += filter_code

    if config.debug_livestatus_queries \
            and html.output_format == "html" and 'W' in html.display_options:
        html.write('<div class="livestatus message" onmouseover="this.style.display=\'none\';">'
                           '<tt>%s</tt></div>\n' % (query.replace('\n', '<br>\n')))

    html.live.set_only_sites(only_sites)
    html.live.set_prepend_site(True)

    data = html.live.query(query)

    html.live.set_prepend_site(False)
    html.live.set_only_sites(None)

    headers = [ "site" ] + host_columns

    # Now create big table of all software packages of these hosts
    rows = []
    hostnames = [ row[1] for row in data ]
    for row in data:
        site     = row[0]
        hostname = row[1]
        tree     = inventory.host(hostname)
        hostrow = dict(zip(headers, row))
        packages = inventory.get(tree, ".software.packages:")
        for package in packages:
            newrow = {}
            for key, value in package.items():
                newrow["invswpac_" + key] = value
            newrow.update(hostrow)
            rows.append(newrow)

    return rows
コード例 #12
0
ファイル: inventory.py プロジェクト: parvathikonda/My-Repos
def paint_host_inventory(row, invpath):
    invdata = inventory.get(row["host_inventory"], invpath)
    if not invdata:
        return "", "" # _("No inventory data available")

    hint = inv_display_hint(invpath)
    if "paint_function" in hint:
        return hint["paint_function"](invdata)
    elif invdata == None:
        return "", ""
    elif type(invdata) in ( str, unicode ):
        return "", invdata
    elif type(invdata) in ( list, dict ):
        return paint_inv_tree(row, invpath)
    else:
        return "number", str(invdata)
コード例 #13
0
ファイル: inventory.py プロジェクト: kjko14/check_mk
    def filter_table(self, rows):
        htmlvar = self.htmlvars[0]
        filtertext = html.var(htmlvar, "").strip().lower()
        if not filtertext:
            return rows

        regex = re.compile(filtertext, re.IGNORECASE)

        newrows = []
        for row in rows:
            invdata = inventory.get(row["host_inventory"], self._invpath)
            if invdata == None:
                invdata = ""
            if regex.search(invdata):
                newrows.append(row)
        return newrows
コード例 #14
0
def paint_host_inventory(row, invpath):
    invdata = inventory.get(row["host_inventory"], invpath)
    if not invdata:
        return "", ""  # _("No inventory data available")

    hint = inv_display_hint(invpath)
    if "paint_function" in hint:
        return hint["paint_function"](invdata)
    elif invdata == None:
        return "", ""
    elif type(invdata) in (str, unicode):
        return "", invdata
    elif not is_leaf_type(invdata):
        return paint_inv_tree(row, invpath)
    else:
        return "number", str(invdata)
コード例 #15
0
ファイル: inventory.py プロジェクト: millerbk/check_mk_mirror
    def filter_table(self, rows):
        htmlvar = self.htmlvars[0]
        filtertext = html.var(htmlvar, "").strip().lower()
        if not filtertext:
            return rows

        regex = re.compile(filtertext, re.IGNORECASE)

        newrows = []
        for row in rows:
            invdata = inventory.get(row["host_inventory"], self._invpath)
            if invdata == None:
                invdata = ""
            if regex.search(invdata):
                newrows.append(row)
        return newrows
コード例 #16
0
    def filter_table(self, rows):
        name = html.var_utf8(self._varprefix + "name")
        if not name:
            return rows

        from_version = html.var(self._varprefix + "from_version")
        to_version   = html.var(self._varprefix + "to_version")
        negate       = html.get_checkbox(self._varprefix + "negate")
        match        = html.var(self._varprefix + "match")
        if match == "regex":
            name = re.compile(name)

        new_rows = []
        for row in rows:
            packages = inventory.get(row["host_inventory"], ".software.packages:")
            is_in = self.find_package(packages, name, from_version, to_version)
            if is_in != negate:
                new_rows.append(row)
        return new_rows
コード例 #17
0
    def filter_table(self, rows):
        htmlvar = self.htmlvars[0]
        filtertext = html.var(htmlvar, "").strip().lower()
        if not filtertext:
            return rows

        try:
            regex = re.compile(filtertext, re.IGNORECASE)
        except re.error:
            raise MKUserError(
                htmlvar,
                _('You search statement is not valid. You need to provide a regular '
                  'expression (regex). For example you need to use <tt>\\\\</tt> instead of <tt>\\</tt> '
                  'if you like to search for a single backslash.'))

        newrows = []
        for row in rows:
            invdata = inventory.get(row["host_inventory"], self._invpath)
            if invdata == None:
                invdata = ""
            if regex.search(invdata):
                newrows.append(row)
        return newrows
コード例 #18
0
ファイル: inventory.py プロジェクト: parvathikonda/My-Repos
def cmp_inventory_node(a, b, invpath):
    val_a = inventory.get(a["host_inventory"], invpath)
    val_b = inventory.get(b["host_inventory"], invpath)
    return cmp(val_a, val_b)
コード例 #19
0
def cmp_inventory_node(a, b, invpath):
    val_a = inventory.get(a["host_inventory"], invpath)
    val_b = inventory.get(b["host_inventory"], invpath)
    return cmp(a, b)