shinken-monitoring / mod-livestatus

Shinken module for presenting data with a MK/Livestatus comptabile interface
GNU Affero General Public License v3.0
15 stars 20 forks source link

Livestatus "service_pnpgraph_present" Service Name Char Cleanup #16

Open Frescha opened 10 years ago

Frescha commented 10 years ago

There should be a character cleanup for function "find_pnp_perfdataxml" 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
Frescha commented 10 years ago

Issue https://github.com/naparuba/shinken/issues/726