Skip to content

Commit

Permalink
Setup syslog logging and logrotate.
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed Jan 31, 2014
1 parent 08d5146 commit ad16fcd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions attributes/logrotate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default[:mongodb][:logrotate][:path] = "/var/log/mongodb/mongodb.log"
default[:mongodb][:logrotate][:frequency] = "daily"
default[:mongodb][:logrotate][:rotate] = 30
3 changes: 3 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
depends "runit", ">= 1.1.6"
depends "yum"

depends "logrotate"
depends "rsyslog"

%w{ ubuntu debian freebsd centos redhat fedora amazon scientific}.each do |os|
supports os
end
Expand Down
17 changes: 17 additions & 0 deletions recipes/logrotate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
include_recipe "logrotate"
include_recipe "rsyslog"

template "/etc/rsyslog.d/mongodb.conf" do
source "rsyslog.conf.erb"
owner "root"
group "root"
mode "0644"
notifies :restart, "service[rsyslog]"
end

logrotate_app "mongodb" do
path [node[:mongodb][:logrotate][:path]]
frequency "daily"
frequency node[:mongodb][:logrotate][:frequency]
rotate node[:mongodb][:logrotate][:rotate]
end
8 changes: 8 additions & 0 deletions recipes/syslog.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
template "/etc/rsyslog.d/mongodb.conf" do
source "rsyslog.conf.erb"
owner "root"
group "root"
mode "0644"
notifies :restart, "service[rsyslog]"
end

7 changes: 7 additions & 0 deletions templates/default/rsyslog.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Log mongo messages
:programname, startswith, "mongod." <%= node[:mongodb][:logrotate][:path] %>
:programname, startswith, "mongos." <%= node[:mongodb][:logrotate][:path] %>

# Now discard mongo messages so they don't appear in /var/log/messages
:programname, startswith, "mongod." ~
:programname, startswith, "mongos." ~

0 comments on commit ad16fcd

Please sign in to comment.