<commit_before>package syslogng

import (
	"github.com/dynport/urknall"
	"github.com/dynport/urknall/cmd"
)

type Receiver struct {
	Version  string `urknall:"default=3.5.1"`
	AmqpHost string
}

func (p *Receiver) Package(r *urknall.Runlist) {
	r.Add(
		&Package{Version: p.Version},
		cmd.WriteFile("/etc/syslog-ng.conf", receiver, "root", 0644),
		restartCommand,
	)
}

const receiver = `@version: {{ .Version }}
@include "scl.conf"

options {
  chain_hostnames(0);
  keep_hostname(yes);
  time_reopen(10);
  time_reap(360);
  log_fifo_size(2048);
  create_dirs(yes);
  perm(0640);
  dir_perm(0755);
  use_dns(no);
  stats_freq(43200);
  frac_digits(6);
  ts_format(iso);
};

source s_network {
  udp(port(514));
  tcp(port(514));
};

source s_local {
    file("/proc/kmsg");
    unix-stream("/dev/log");
    internal();
};

{{ with .AmqpHost }}
destination d_amqp {
  amqp(
      vhost("/")
      host("{{ . }}")
      port(5672)
      username("guest") # required option, no default
      password("<PASSWORD>") # required option, no default
      exchange("syslog")
      exchange_declare(yes)
      exchange_type("fanout")
      routing_key("$HOST.$PROGRAM.$PRIORITY")
      body("$S_ISODATE $HOST $PROGRAM.$PRIORITY[$PID]: $MSG\n")
      persistent(yes)
      frac_digits(6)
      value-pairs(
          scope("selected-macros" "nv-pairs" "sdata")
      )
  );
};
{{ end }}

destination d_file {
  file(
    "/var/log/hourly/$R_YEAR/$R_MONTH/$R_DAY/$R_YEAR-$R_MONTH-${R_DAY}T${R_HOUR}.log"
    template("$S_ISODATE $HOST $PROGRAM.$PRIORITY[$PID]: $MSG\n")
    template_escape(no)
    perm( 0644 )
    dir_perm( 0775 )
    frac_digits(6)
  );
};

log {
  source(s_local);
  source(s_network);
  {{ with .AmqpHost }}destination(d_amqp);{{ end }}
  destination(d_file);
};
`
<commit_msg>use correct location for config and add script to create hourly symlinks<commit_after>package syslogng

import (
	"github.com/dynport/urknall"
	"github.com/dynport/urknall/cmd"
	"github.com/dynport/urknall/pkg/syslog"
)

type Receiver struct {
	Version  string `urknall:"default=3.5.1"`
	AmqpHost string
}

func (p *Receiver) Package(r *urknall.Runlist) {
	r.Add(
		&Package{Version: p.Version},
		cmd.WriteFile("/usr/local/etc/syslog-ng.conf", receiver, "root", 0644),
		&syslog.CreateHourlySymlinks{},
		restartCommand,
	)
}

const receiver = `@version: {{ .Version }}
@include "scl.conf"

options {
  chain_hostnames(0);
  keep_hostname(yes);
  time_reopen(10);
  time_reap(360);
  log_fifo_size(2048);
  create_dirs(yes);
  perm(0640);
  dir_perm(0755);
  use_dns(no);
  stats_freq(43200);
  frac_digits(6);
  ts_format(iso);
};

source s_network {
  udp(port(514));
  tcp(port(514));
};

source s_local {
    file("/proc/kmsg");
    unix-stream("/dev/log");
    internal();
};

{{ with .AmqpHost }}
destination d_amqp {
  amqp(
      vhost("/")
      host("{{ . }}")
      port(5672)
      username("guest") # required option, no default
      password("<PASSWORD>") # required option, no default
      exchange("syslog")
      exchange_declare(yes)
      exchange_type("fanout")
      routing_key("$HOST.$PROGRAM.$PRIORITY")
      body("$S_ISODATE $HOST $PROGRAM.$PRIORITY[$PID]: $MSG\n")
      persistent(yes)
      frac_digits(6)
      value-pairs(
          scope("selected-macros" "nv-pairs" "sdata")
      )
  );
};
{{ end }}

destination d_file {
  file(
    "/var/log/hourly/$R_YEAR/$R_MONTH/$R_DAY/$R_YEAR-$R_MONTH-${R_DAY}T${R_HOUR}.log"
    template("$S_ISODATE $HOST $PROGRAM.$PRIORITY[$PID]: $MSG\n")
    template_escape(no)
    perm( 0644 )
    dir_perm( 0775 )
    frac_digits(6)
  );
};

log {
  source(s_local);
  source(s_network);
  {{ with .AmqpHost }}destination(d_amqp);{{ end }}
  destination(d_file);
};
`

{'fraction_non_alphanumeric': 0.17498658078368223, 'fraction_numerical': 0.027375201288244767, 'mean_word_length': 3.618339529120198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6781086', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1479, 'n_words': 231}