Ejemplo n.º 1
0
 def test_path_with_ds(self):
     """Chemin complet vers le fichier RRD."""
     self.assertEquals(
         get_rrd_path("localhost", ds="Ping", path_mode="flat"),
         "/var/lib/vigilo/rrds/localhost/Ping.rrd"
     )
     self.assertEquals(
         get_rrd_path("localhost", ds="Ping", path_mode="name"),
         "/var/lib/vigilo/rrds/l/lo/localhost/Ping.rrd"
     )
     self.assertEquals(
         get_rrd_path("localhost", ds="Ping", path_mode="hash"),
         "/var/lib/vigilo/rrds/4/42/localhost/Ping.rrd"
     )
Ejemplo n.º 2
0
 def test_path_modes(self):
     """Différents modes de hachage pour le chemin."""
     self.assertEquals(
         get_rrd_path("localhost", path_mode="flat"),
         "/var/lib/vigilo/rrds/localhost"
     )
     self.assertEquals(
         get_rrd_path("localhost", path_mode="name"),
         "/var/lib/vigilo/rrds/l/lo/localhost"
     )
     self.assertEquals(
         get_rrd_path("localhost", path_mode="hash"),
         "/var/lib/vigilo/rrds/4/42/localhost"
     )
Ejemplo n.º 3
0
    def get_cdef(self, cdef, ds_list, i, start):
        """
        Retourne la partie de la commande RRD concernant la définition des
        valeurs à grapher (CDEFs, et valeurs après application du facteur
        défini dans la conf).

        @param cdef: objet Cdef à considérer
        @type  cdef: L{Cdef}
        @param ds_list: liste complète d'objets PerfDataSource à afficher sur
            le graphe
        @type  ds_list: C{list}
        @param i: index courant dans L{ds_list}
        @type  i: C{int}
        """
        result = []
        cmd_list = cdef.cdef.split(",")
        for cmd_index, cmd in enumerate(cmd_list):
            if len(cmd) == 1:
                continue # c'est un opérateur
            ds_names = [ ds.name for ds in ds_list ]
            if cmd in ds_names:
                cmd_list[cmd_index] = "data_%d" % ds_names.index(cmd)
            else: # c'est un autre RRD, pas sur ce graphe
                rrd_path_mode = config.get("rrd_path_mode", "flat")
                rrdfile = get_rrd_path(self.server, cmd,
                                       base_dir=config['rrd_base'],
                                       path_mode=rrd_path_mode)
                cf = RRD(rrdfile).getPeriodCF(start)
                result.append("DEF:data_%s_source=%s:DS:%s" %
                              (i, rrdfile, cf))
                cmd_list[cmd_index] = "data_%d_source" % i
        result.append("CDEF:data_%s_orig=%s" % (i, ",".join(cmd_list)))
        return result
Ejemplo n.º 4
0
 def test_unicode(self):
     """Chemin complet vers le fichier RRD avec paramètres en unicode."""
     self.assertEquals(
         get_rrd_path(u"testserver éçà", u"Ping' éçà", path_mode="flat"),
         "/var/lib/vigilo/rrds/testserver+%C3%A9%C3%A7%C3%A0/"
         "Ping%27+%C3%A9%C3%A7%C3%A0.rrd"
     )
     self.assertEquals(
         get_rrd_path(u"testserver éçà", u"Ping' éçà", path_mode="name"),
         "/var/lib/vigilo/rrds/t/te/testserver+%C3%A9%C3%A7%C3%A0/"
         "Ping%27+%C3%A9%C3%A7%C3%A0.rrd"
     )
     self.assertEquals(
         get_rrd_path(u"testserver éçà", u"Ping' éçà", path_mode="hash"),
         "/var/lib/vigilo/rrds/0/08/testserver+%C3%A9%C3%A7%C3%A0/"
         "Ping%27+%C3%A9%C3%A7%C3%A0.rrd"
     )
Ejemplo n.º 5
0
def listFiles(host):
    """
    List the relevant RRD files for the specified host during the \
    specified time
    """
    files = []
    rrd_base_dir = config['rrd_base']
    rrd_path_mode = config.get("rrd_path_mode", "flat")
    host_path = get_rrd_path(host, base_dir=rrd_base_dir,
                             path_mode=rrd_path_mode)
    rrd_pattern = os.path.join(host_path, '*.rrd')
    LOGGER.debug(rrd_pattern)
    files.extend(glob.glob(rrd_pattern))
    files.sort()
    return files
Ejemplo n.º 6
0
    def setUp(self):
        # Loading the application:
        super(SortDSTestCase, self).setUp()

        # spécifique VigiRRD
        conffile.reload()
        rrdfilename = get_rrd_path("testserver", "sysUpTime",
                                   base_dir=tg.config['rrd_base'],
                                   path_mode=tg.config["rrd_path_mode"])
        rrdfilenames = {
            "DS1": rrdfilename,
            "DS2": rrdfilename,
        }
        self.rrd = rrd.RRD(rrdfilenames, "testserver")
        self.template = {"cdefs": [], "draw":
                    [{ "type": "LINE1", "color": "#EE0088" },
                     { "type": "LINE1", "color": "#FF5500" }],
               }
Ejemplo n.º 7
0
def getEncodedFileName(server, ds):
    """
    Étant donné un nom d'hôte et un indicateur sur cet hôte,
    renvoie le nom du fichier qui contient les informations
    sur cet hôte et cet indicateur.

    @param server: Nom de l'hôte dont les données de métrologie
        nous intéressent.
    @type server: C{basestring}
    @param ds: Nom de l'indicateur qui nous intéresse
        sur l'hôte.
    @type ds: C{basestring}
    @return: Nom du fichier contenant les informations sur
        cet hôte/indicateur.
    @rtype: C{str}
    """
    rrd_base_dir = config['rrd_base']
    rrd_path_mode = config.get("rrd_path_mode", "flat")
    filename = get_rrd_path(server, ds, base_dir=rrd_base_dir,
                            path_mode=rrd_path_mode)
    return filename
Ejemplo n.º 8
0
 def getFilename(self, msgdata):
     filename = get_rrd_path(msgdata["host"], msgdata["datasource"],
                     self.rrdtool.rrd_base_dir, self.rrdtool.rrd_path_mode)
     return filename
Ejemplo n.º 9
0
 def test_default_values(self):
     """Valeurs par défaut des paramètres pour 'get_rrd_path'."""
     self.assertEquals(
         get_rrd_path("localhost"),
         "/var/lib/vigilo/rrds/localhost"
     )
Ejemplo n.º 10
0
 def test_non_default_base_dir(self):
     """Surcharge du dossier par défaut des RRDs."""
     self.assertEquals(
         get_rrd_path("localhost", base_dir="/tmp"),
         "/tmp/localhost"
     )