Exemplo n.º 1
0
def configure_proxy(url, token):
    message.print_bold("Starting Wavefront Proxy Configuration!")
    url = api.clean_url(url) + "/api/"
    print url
    print token

    # replace token
    cmd = "sed -i -e '/token=/c\ttoken=%s' /etc/wavefront/wavefront-proxy/wavefront.conf" % (
        token)
    ret_code = system.run_command(cmd)
    if ret_code > 0:
        message.print_warn("Error Configuring Wavefront Proxy")

    # replace server url
    cmd = "sed -i -e '/server=/c\tserver=%s' /etc/wavefront/wavefront-proxy/wavefront.conf" % (
        url)

    ret_code = system.run_command(cmd)
    if ret_code > 0:
        message.print_warn("Error Configuring Wavefront Proxy")

    # restart proxy
    ret_code = system.restart_service("wavefront-proxy")
    if ret_code > 0:
        message.print_warn("Error restarting proxy service")
        return False

    message.print_success("Finished Wavefront Proxy Configuration!")
    message.print_success(
        "The Proxy's configuration file can be found at /etc/wavefront/wavefront-proxy/wavefront.conf"
    )

    return True
Exemplo n.º 2
0
def get_proxy_install_cmd(proxy_next):
    # dist = self.check_os()
    dist = system.check_os()

    if proxy_next:
        message.print_bold(
            "Using proxy-next option. This will install the latest beta version proxy."
        )

    print "Detected ", dist
    if dist == "Amazon Linux AMI" or dist == "Red Hat Enterprise Linux Server" or dist == "Red Hat Enterprise Linux Workstation" or dist == "CentOS" or dist == "CentOS Linux":

        pkg = proxy_pkg_rpm
        if proxy_next:
            pkg = proxy_next_pkg_rpm

        cmd = "curl -s %s | bash" % (pkg)
        cmd += " && yum -y -q install wavefront-proxy"
        return cmd
    elif dist == "Ubuntu" or dist == "debian":

        pkg = proxy_pkg_deb
        if proxy_next:
            pkg = proxy_next_pkg_deb

        cmd = "curl -s %s | bash" % (pkg)
        cmd += " && apt-get -y -q install wavefront-proxy"
        return cmd
    else:
        print "Error: Unsupported OS version: %s. Please contact [email protected]." % (
            dist)
        return None
Exemplo n.º 3
0
def install_proxy(proxy_next):

    message.print_bold("Starting Wavefront Proxy Installation!")
    cmd = get_proxy_install_cmd(proxy_next)
    try:
        ret_code = subprocess.call(cmd, shell=True)
        if ret_code > 0:
            message.print_warn("Error installing proxy.")
            return False
        else:
            message.print_success("Finished Wavefront Proxy Installation!")
            return True
    except:
        message.print_warn("Unable to install Wavefront Proxy")
        return False
Exemplo n.º 4
0
def tag_telegraf_config(comment, tags):

    message.print_bold("Adding custom tags to Telegraf configuration")

    tags_pre = "- %s -" % (comment)
    tags_post = "- end %s tags - " % (comment)
    tagStr = "  # %s\n" % (tags_pre)
    for k, v in tags.iteritems():
        tagStr += '  %s = "%s"\n' % (k.lower(), v)
    tagStr += "  # %s\n" % (tags_post)
    try:
        tagTxt = open("tags.txt", "w")
        tagTxt.write(tagStr)
        tagTxt.close()
    except:
        message.print_warn("Error writing tags.txt: " + sys.exc_info())
        return False

    # remove existing ec2 tags
    conf = conf_path
    cmd = "sed -i '/%s/,/%s/d' %s" % (tags_pre, tags_post, conf)

    ret_code = system.run_command(cmd)
    if ret_code > 0:
        message.print_warn("Error adding tags to Telegraf configuration")
        return False

    cmd = "sed -i '/\[global_tags\]/r tags.txt' %s" % (conf)

    ret_code = system.run_command(cmd)
    if ret_code > 0:
        message.print_warn(
            "Error overwriting telegraf.conf. Is the file located at " + conf +
            "? ")

    message.print_success("Finished adding tags to Telegraf configuration.")
    return True
Exemplo n.º 5
0
def install_agent():

    message.print_bold("Starting Telegraf Installation!")
    print "Downloading configuration to ", conf_path

    cmd = "mkdir -p /etc/telegraf && sudo curl -o %s %s" % (conf_path,
                                                            telegraf_conf)
    ret_code = system.run_command(cmd)
    if ret_code > 0:
        message.print_warn("Error downloading Telegraf config file.")
        return False

    cmd = get_install_agent_cmd()
    print "Running ", cmd
    ret_code = system.run_command(cmd)
    if ret_code > 0:
        message.print_warn("Error installing Telegraf")
        return False

    message.print_success("Finished Installing Telegraf!")
    message.print_success(
        "The Telegraf configuration file can be found at /etc/telegraf/telegraf.conf"
    )
    return True
Exemplo n.º 6
0
def tag_telegraf_config(aws_region, aws_key_id, aws_secret_key):

    message.print_bold("Starting Telegraf Configuration for EC2 Tags")
    tags = get_instance_tags(aws_key_id, aws_secret_key, aws_region)

    return agent.tag_telegraf_config("ec2 metadata", tags)