func (nxc *NxConfig) gelfTcpOutputsToString() string { var result bytes.Buffer for _, can := range nxc.Canned { if can.kind == "output-gelf-tcp" { result.WriteString("<Output " + can.name + ">\n") result.WriteString(" Module om_tcp\n") result.WriteString(" Host " + nxc.propertyString(can.properties["server"], 0) + "\n") result.WriteString(" Port " + nxc.propertyString(can.properties["port"], 0) + "\n") result.WriteString(" OutputType GELF_TCP\n") result.WriteString(" Exec $short_message = $raw_event; # Avoids truncation of the short_message field.\n") result.WriteString(" Exec $gl2_source_collector = '" + nxc.Context.CollectorId + "';\n") if nxc.isDisabled(can.properties["override_hostname"]) { result.WriteString(" Exec $Hostname = hostname_fqdn();\n") } if len(nxc.propertyStringMap(can.properties["fields"])) > 0 { for key, value := range nxc.propertyStringMap(can.properties["fields"]) { result.WriteString(" Exec $" + key + " = \"" + value.(string) + "\";\n") } } if nxc.isEnabled(can.properties["verbatim"]) { var verbatim = nxc.propertyStringIndented(can.properties["verbatim"], 0) result.WriteString(common.EnsureLineBreak(verbatim)) } result.WriteString("</Output>\n") } } result.WriteString("\n") return result.String() }
func (nxc *NxConfig) windowsEventLogInputsToString() string { var result bytes.Buffer for _, can := range nxc.Canned { if can.kind == "input-windows-event-log" { result.WriteString("<Input " + can.name + ">\n") result.WriteString(" Module im_msvistalog\n") result.WriteString(" PollInterval " + nxc.propertyString(can.properties["poll_interval"], 0) + "\n") result.WriteString(" SavePos " + nxc.propertyString(can.properties["save_position"], 0) + "\n") result.WriteString(" ReadFromLast " + nxc.propertyString(can.properties["read_last"], 0) + "\n") if nxc.isEnabled(can.properties["channel"]) { result.WriteString(" Channel " + nxc.propertyString(can.properties["channel"], 0) + "\n") } if nxc.isEnabled(can.properties["query"]) { result.WriteString(" Query " + nxc.propertyString(can.properties["query"], 0) + "\n") } if len(nxc.propertyStringMap(can.properties["fields"])) > 0 { for key, value := range nxc.propertyStringMap(can.properties["fields"]) { result.WriteString(" Exec $" + key + " = \"" + value.(string) + "\";\n") } } if nxc.isEnabled(can.properties["verbatim"]) { var verbatim = nxc.propertyStringIndented(can.properties["verbatim"], 0) result.WriteString(common.EnsureLineBreak(verbatim)) } result.WriteString("</Input>\n") } } result.WriteString("\n") return result.String() }
func (nxc *NxConfig) fileInputsToString() string { var result bytes.Buffer for _, can := range nxc.Canned { if can.kind == "input-file" { result.WriteString("<Input " + can.name + ">\n") result.WriteString(" Module im_file\n") result.WriteString(" File '" + nxc.propertyString(can.properties["path"], 0) + "'\n") result.WriteString(" PollInterval " + nxc.propertyString(can.properties["poll_interval"], 0) + "\n") result.WriteString(" SavePos " + nxc.propertyString(can.properties["save_position"], 0) + "\n") result.WriteString(" ReadFromLast " + nxc.propertyString(can.properties["read_last"], 0) + "\n") result.WriteString(" Recursive " + nxc.propertyString(can.properties["recursive"], 0) + "\n") result.WriteString(" RenameCheck " + nxc.propertyString(can.properties["rename_check"], 0) + "\n") result.WriteString(" Exec $FileName = file_name(); # Send file name with each message\n") if len(nxc.propertyStringMap(can.properties["fields"])) > 0 { for key, value := range nxc.propertyStringMap(can.properties["fields"]) { result.WriteString(" Exec $" + key + " = \"" + value.(string) + "\";\n") } } if nxc.isEnabled(can.properties["multiline"]) { result.WriteString(" InputType " + can.name + "-multiline\n") } if nxc.isEnabled(can.properties["verbatim"]) { var verbatim = nxc.propertyStringIndented(can.properties["verbatim"], 0) result.WriteString(common.EnsureLineBreak(verbatim)) } result.WriteString("</Input>\n") } } result.WriteString("\n") return result.String() }
func (nxc *NxConfig) tcpSyslogInputsToString() string { var result bytes.Buffer for _, can := range nxc.Canned { if can.kind == "input-tcp-syslog" { result.WriteString("<Input " + can.name + ">\n") result.WriteString(" Module im_tcp\n") result.WriteString(" Host " + nxc.propertyString(can.properties["host"], 0) + "\n") result.WriteString(" Port " + nxc.propertyString(can.properties["port"], 0) + "\n") if len(nxc.propertyStringMap(can.properties["fields"])) > 0 { for key, value := range nxc.propertyStringMap(can.properties["fields"]) { result.WriteString(" Exec $" + key + " = \"" + value.(string) + "\";\n") } } result.WriteString(" Exec parse_syslog_bsd();\n") if nxc.isEnabled(can.properties["verbatim"]) { var verbatim = nxc.propertyStringIndented(can.properties["verbatim"], 0) result.WriteString(common.EnsureLineBreak(verbatim)) } result.WriteString("</Input>\n") } } result.WriteString("\n") return result.String() }