Skip to content

Instantly share code, notes, and snippets.

@oprietop
Created February 13, 2017 15:39
Show Gist options
  • Save oprietop/eb19a918a1395797939e7d62652d245e to your computer and use it in GitHub Desktop.
Save oprietop/eb19a918a1395797939e7d62652d245e to your computer and use it in GitHub Desktop.
Simple collectd Exec plugin example
# plugin_exec.conf
LoadPlugin exec
<Plugin exec>
Exec "user" "/opt/collectd/etc/metrics/grep_stuff.sh"
</Plugin>
# grep_stuff.sh
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
INTERVAL="${COLLECTD_INTERVAL:-60}"
while sleep "$INTERVAL"; do
RES=$(find /logs/file.*.log -mtime -1 -exec grep --line-buffered "StuffToFind" '{}' \; | wc -l)
echo "PUTVAL \"$HOSTNAME/grep_log/gauge-stuff\" interval=$INTERVAL N:$RES"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment