-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Faircloth
committed
Jun 28, 2019
1 parent
8817488
commit befb63f
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #!/bin/bash | ||
| sleep 30 | ||
| while sleep 10 | ||
| do | ||
| TS=$(date +"%s") | ||
| tmpfilecsv=$(mktemp /tmp/syslog-ng-stats-XXXXXXX-csv) | ||
| tmpfilejson=$(mktemp /tmp/syslog-ng-stats-XXXXXXX-json) | ||
| /opt/syslog-ng/sbin/syslog-ng-ctl query get "*" --reset | tail -n +2 | grep \^. | grep -v "^The selected counters" >$tmpfilecsv | ||
| IFS=';' | ||
| while read -r SourceName SourceId SourceInstance State Type Number | ||
| do | ||
| echo "{ | ||
| \"time\":\"$TS.000\", | ||
| \"event\":\"metric\", | ||
| \"source\":\"syslog-ng\", | ||
| \"host\":\"$HOSTNAME\", | ||
| \"index\":\"$SPLUNK_METRICS_INDEX\", | ||
| \"fields\":{ | ||
| \"SourceId\":\"$SourceId\", | ||
| \"SourceInstance\":\"$SourceInstance\", | ||
| \"State\":\"$State\", | ||
| \"Type\":\"$Type\", | ||
| \"_value\":$Number, | ||
| \"metric_name\":\"$SourceName\" | ||
| } | ||
| } ">>$tmpfilejson | ||
| done < $tmpfilecsv | ||
|
|
||
| curl -s -S -k $SPLUNK_HEC_STATSURL -H "Authorization: Splunk $SPLUNK_HEC_TOKEN" -d "@$tmpfilejson" | ||
| done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Script to change all filters to use selected transport (UF, HEC, or kafka). | ||
| # If one or more filters uses a transport different from all the others, they will need to be | ||
| # managed by hand. Unpredictable results can occur if the script is used and | ||
| # individual filters are not checked for correctness. | ||
|
|
||
| case $SPLUNK_CONNECT_METHOD in | ||
| hec) | ||
| echo "Switching transport method for all filters to HEC" | ||
| sed '/^# / {/#--HEC--/ s/^#/ /}' -i /opt/syslog-ng/etc/conf.d/filters/*.conf; | ||
| sed '/^#/! {/#--KAFKA--/ s/^ /#/}' -i /opt/syslog-ng/etc/conf.d/filters/*.conf; | ||
| sed '/^#/! {/#--UF--/ s/^ /#/}' -i /opt/syslog-ng/etc/conf.d/filters/*.conf; | ||
| sed 's~__SPLUNK_HEC_URL__~"'"$SPLUNK_HEC_URL"'"~' -i /opt/syslog-ng/etc/conf.d/splunk.conf | ||
| sed 's/__SPLUNK_HEC_TOKEN__/'"$SPLUNK_HEC_TOKEN"'/' -i /opt/syslog-ng/etc/conf.d/splunk.conf | ||
| ;; | ||
| kafka) | ||
| echo "Switching transport method for all filters to Kafka" | ||
| sed '/^# / {/#--KAFKA--/ s/^#/ /}' -i /opt/syslog-ng/etc/conf.d/filters/*.conf; | ||
| sed '/^#/! {/#--HEC--/ s/^ /#/}' -i /opt/syslog-ng/etc/conf.d/filters/*.conf; | ||
| sed '/^#/! {/#--UF--/ s/^ /#/}' -i /opt/syslog-ng/etc/conf.d/filters/*.conf; | ||
| ;; | ||
| UF) | ||
| echo "Switching transport method for all filters to filesystem/UF" | ||
| sed '/^# / {/#--UF--/ s/^#/ /}' -i /opt/syslog-ng/etc/conf.d/filters/*.conf; | ||
| sed '/^#/! {/#--HEC--/ s/^ /#/}' -i /opt/syslog-ng/etc/conf.d/filters/*.conf; | ||
| sed '/^#/! {/#--KAFKA--/ s/^ /#/}' -i /opt/syslog-ng/etc/conf.d/filters/*.conf; | ||
| ;; | ||
| *) | ||
| echo "Usage: $0 hec|kafka|UF" | ||
| ;; | ||
| esac |