shinken-monitoring / mod-livestatus

Shinken module for presenting data with a MK/Livestatus comptabile interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Livestatus "service_pnpgraph_present" Service Name Char Cleanup

Frescha opened this issue · comments

There should be a character cleanup for function "find_pnp_perfdata_xml" to avoid problems with service names like "fs_/" or "Interface 2" which are typical names in a check_mk environment.

Chars like "/" ":" "" SPACE must be replaced with "_"

Quick fix:
def find_pnp_perfdata_xml(name, request):
"""Check if a pnp xml file exists for a given host or service name."""

if request.pnp_path_readable:
    if '/' in name:
        # It is a service
        name = name.split('/',1)

        replace = { "/": "_", " ": "_", "\\": "_", ":": "_"}
        name[1] = "".join(replace.get(c, c) for c in name[1])

        #if os.access(request.pnp_path + '/' + name + '.xml', os.R_OK):
        if os.access(request.pnp_path + '/' + name[0] + '/' + name[1] + '.xml', os.R_OK):
            return 1
    else:
        # It is a host
        if os.access(request.pnp_path + '/' + name + '/_HOST_.xml', os.R_OK):
            return 1
# If in doubt, there is no pnp file
return 0