Created
November 25, 2015 08:26
-
-
Save faxm0dem/50cb4588ea7f1e136946 to your computer and use it in GitHub Desktop.
collecd Exec sudo
This file contains hidden or 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
#!/bin/ksh | |
INTERVAL=10 | |
HOSTNAME="${COLLECTD_HOSTNAME:-$(/bin/hostname)}" | |
HOSTNAME=${HOSTNAME%%.in2p3.fr}.in2p3.fr | |
SUDO=sudo | |
SYSLOG_NG_CTL="/sbin/syslog-ng-ctl" | |
[ -x $SYSLOG_NG_CTL ] || SYSLOG_NG_CTL="/usr$SYSLOG_NG_CTL" | |
AWK="/bin/awk" | |
[ -x $AWK ] || AWK="awk" | |
PLUGIN="syslog_ng" | |
while :; do | |
$SUDO $SYSLOG_NG_CTL stats | $AWK -vinterval=$INTERVAL -vhost=$HOSTNAME -vplugin=$PLUGIN -F\; 'NR!=1 && $1 != "src.none" {if ($2 == "") { t=$3 } else {t=$2} {}if ($5 == "stored") {type="gauge"} else {type="derive"} printf "PUTVAL %s/%s-%s/%s-%s %s:%s interval=%s\n",host,plugin,t,type,$5,systime(),$6,interval}' | |
sleep $INTERVAL | |
done |
This file contains hidden or 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
# file managed by puppet | |
# configuration 'syslog_ng_collectd' for plugin 'exec' | |
<Plugin "exec"> | |
Exec "collectd:collectd" "/opt/collectd/bin/syslog_ng-exec.sh" | |
</Plugin> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment