Skip to content

Commit

Permalink
Merge pull request coderanger#10 from trobrock/centos
Browse files Browse the repository at this point in the history
Updating recipes for centos 6.3, update packages to install and add init.d script
  • Loading branch information
trobrock committed Dec 13, 2012
2 parents 6aadf0a + 99fea03 commit 82494bf
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
5 changes: 4 additions & 1 deletion recipes/_install_from_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
include_recipe "build-essential"
include_recipe "ark"

user_packages = %w(librrd2-dev libsnmp-dev)
user_packages = value_for_platform_family(
["rhel", "fedora", "suse"] => %w(rrdtool-devel net-snmp-devel perl-ExtUtils-MakeMaker),
"debian" => %w(librrd2-dev libsnmp-dev)
)
unless node['collectd']['build_prereq_pkgs'].nil?
node['collectd']['build_prereq_pkgs'].each { |pkgs| user_packages << pkgs }
end
Expand Down
7 changes: 7 additions & 0 deletions recipes/_server_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
# limitations under the License.
#

template "/etc/init.d/collectd" do
source "collectd-init.d.erb"
owner "root"
group "root"
mode 0755
end

service 'collectd' do
supports :restart => true, :status => true
action [:enable, :start]
Expand Down
70 changes: 70 additions & 0 deletions templates/default/collectd-init.d.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash
#
# collectd Startup script for the Collectd statistics gathering daemon
# chkconfig: - 99 01
# description: Collectd is a statistics gathering daemon used to collect \
# system information ie. cpu, memory, disk, network
# processname: collectd
# config: <%= node['collectd']['sysconf_dir'] %>/collectd.conf
# config: /etc/sysconfig/collectd
# pidfile: /var/run/collectd.pid

# Source function library.
. /etc/init.d/functions

RETVAL=0
ARGS=""
prog="collectdmon"
PATH="<%= node['collectd']['sbin_dir'] %>:$PATH"
service="collectd"
CONFIG=<%= node['collectd']['sysconf_dir'] %>/collectd.conf
COLLECTD=<%= node['collectd']['sbin_dir'] %>/collectd
COLLECTDMONPID=/var/run/collectdmon.pid

if [ -r /etc/default/$prog ]; then
. /etc/default/$prog
fi

start () {
echo -n $"Starting collectd: "
if [ -r "$CONFIG" ]
then
daemon $prog -P $COLLECTDMONPID -c $COLLECTD -- -C "$CONFIG"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$service
fi
}
stop () {
echo -n $"Stopping collectd: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$service
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
;;
restart|reload)
stop
start
;;
condrestart)
[ -f /var/lock/subsys/$prog ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac

exit $?

# vim:syntax=sh

0 comments on commit 82494bf

Please sign in to comment.