import re


def parse_df_command(capacity, bytes_multiplier=1024):
    """
    Parse the metrics from running `df -h` in a container.
    """
    output = []
    lines = capacity.strip("\n").split("\n")
    if (
        not lines[0].startswith("Filesystem")
        or "Used" not in lines[0]
        or "Available" not in lines[0]
    ):
        return output
    else:
        lines[0] = lines[0].replace("Mounted on", "Mounted_on")
        header = re.split(r"\s+", lines[0])

    for line in lines[1:]:
        data = dict(zip(header, re.split(r"\s+", line)))
        data["used_bytes"] = float(data["Used"]) * bytes_multiplier
        data["available_bytes"] = float(data["Available"]) * bytes_multiplier
        data["total_bytes"] = data["used_bytes"] + data["available_bytes"]
        output.append(data)

    return output