Skip to content

Instantly share code, notes, and snippets.

@jessereynolds
Created June 6, 2012 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessereynolds/2878994 to your computer and use it in GitHub Desktop.
Save jessereynolds/2878994 to your computer and use it in GitHub Desktop.
collectd exec plugin fork freeze
#!/bin/bash
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
INTERVAL="${COLLECTD_INTERVAL:-10}"
while sleep "$INTERVAL"; do
VALUE=1.23
echo "PUTVAL \"$HOSTNAME/exec-magic/gauge-magic_level\" interval=$INTERVAL N:$VALUE"
done
root@jesse-precise-desktop:~# bin/test_collectd_exec.sh
Wed Jun 6 09:39:24 CST 2012: starting collectd
Starting statistics collection and monitoring daemon: collectd,,.
Wed Jun 6 09:39:24 CST 2012: exec started?
2461 pts/2 S+ 0:00 \_ /bin/bash bin/test_collectd_exec.sh
2470 pts/2 S+ 0:00 \_ grep collect
2466 ? Ss 0:00 /usr/sbin/collectdmon -P /var/run/collectdmon.pid -- -C /etc/collectd/collectd.conf
2468 ? SLl 0:00 \_ collectd -C /etc/collectd/collectd.conf -f
Wed Jun 6 09:39:26 CST 2012: stopping collectd
Stopping statistics collection and monitoring daemon: collectd.
collectd is stopped.
collectd is stopped.
collectd is stopped.
collectd is stopped.
Wed Jun 6 09:39:30 CST 2012: killing any remaining processes
collectd: no process found
Wed Jun 6 09:39:31 CST 2012: starting collectd
Starting statistics collection and monitoring daemon: collectd,,.
Wed Jun 6 09:39:31 CST 2012: exec started?
2461 pts/2 S+ 0:00 \_ /bin/bash bin/test_collectd_exec.sh
2520 pts/2 S+ 0:00 \_ grep collect
2516 ? Ss 0:00 /usr/sbin/collectdmon -P /var/run/collectdmon.pid -- -C /etc/collectd/collectd.conf
2518 ? RLl 0:00 \_ collectd -C /etc/collectd/collectd.conf -f
Wed Jun 6 09:39:33 CST 2012: stopping collectd
Stopping statistics collection and monitoring daemon: collectd.
collectd (2531) is running.
collectd (2531) is running.
^C
root@jesse-precise-desktop:~# ps afx | grep collectd
2531 ? S 0:00 collectd -C /etc/collectd/collectd.conf -f
root@jesse-precise-desktop:~# strace -p 2531
Process 2531 attached - interrupt to quit
futex(0x7fa983a9edb0, FUTEX_WAIT_PRIVATE, 2, NULL^C <unfinished ...>
Process 2531 detached
#!/bin/bash
# this starts and stops collectd and looks to see if any collectd processes remain
while true ; do
echo "`date`: starting collectd"
/etc/init.d/collectd start
echo "`date`: exec started?"
ps afx | grep collect
sleep 2
echo "`date`: stopping collectd"
/etc/init.d/collectd stop
/etc/init.d/collectd status
sleep 1
/etc/init.d/collectd status
sleep 1
/etc/init.d/collectd status
sleep 1
/etc/init.d/collectd status
echo "`date`: killing any remaining processes"
killall -9 collectd
sleep 1
done
@jessereynolds
Copy link
Author

I've raised a bug report here: collectd/collectd#89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment