<commit_before>#
# ========================================================
# Copyright (c) 2012 Whamcloud, Inc.  All rights reserved.
# ========================================================


"""Rsyslog actions."""

from chroma_agent import shell
from chroma_agent.plugins import ActionPlugin

import os


def unconfigure_rsyslog(args):
    args.node = ""
    configure_rsyslog(args)


def configure_rsyslog(args):
    from tempfile import mkstemp
    tmp_f, tmp_name = mkstemp(dir = '/etc')
    f = open('/etc/rsyslog.conf', 'r')
    skip = False
    for line in f.readlines():
        if skip:
            if line == "# added by chroma-agent\n":
                skip = False
                continue
        if line == "# added by chroma-agent\n":
            skip = True
            continue
        if not skip:
            os.write(tmp_f, line)
    f.close()
    if args.node != "":
        os.write(tmp_f, "# added by chroma-agent\n*.* @@%s\n" \
                        "# added by chroma-agent\n" % args.node)
    os.close(tmp_f)<commit_msg>HYD-1116 Send TZ information with syslog entries<commit_after>#
# ========================================================
# Copyright (c) 2012 Whamcloud, Inc.  All rights reserved.
# ========================================================


"""Rsyslog actions."""

from chroma_agent import shell
from chroma_agent.plugins import ActionPlugin

import os


def unconfigure_rsyslog(args):
    args.node = ""
    configure_rsyslog(args)


def configure_rsyslog(args):
    from tempfile import mkstemp
    tmp_f, tmp_name = mkstemp(dir = '/etc')
    f = open('/etc/rsyslog.conf', 'r')
    skip = False
    for line in f.readlines():
        if skip:
            if line == "# added by chroma-agent\n":
                skip = False
                continue
        if line == "# added by chroma-agent\n":
            skip = True
            continue
        if not skip:
            os.write(tmp_f, line)
    f.close()
    if args.node != "":
        os.write(tmp_f, "# added by chroma-agent\n" \
                        "*.* @@%s;RSYSLOG_ForwardFormat\n" \
                        "# added by chroma-agent\n" % args.node)
    os.close(tmp_f)
{'fraction_non_alphanumeric': 0.21050228310502284, 'fraction_numerical': 0.005479452054794521, 'mean_word_length': 2.304675716440422, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2493633', 'n_tokens_mistral': 678, 'n_tokens_neox': 639, 'n_words': 165}