Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

snmpd cookbook added

  • Loading branch information...
commit a85a8a0da040c491ff8c1e9e340360c2b4240cc0 1 parent f5334df
@mdxp authored
View
8 snmpd/README.rdoc
@@ -0,0 +1,8 @@
+= DESCRIPTION:
+
+= REQUIREMENTS:
+
+= ATTRIBUTES:
+
+= USAGE:
+
View
17 snmpd/attributes/default.rb
@@ -0,0 +1,17 @@
+default[:snmpd][:monitoring_ips] = ["127.0.0.1"]
+default[:snmpd][:interface] = "eth0"
+default[:snmpd][:community] = "public"
+default[:snmpd][:syslocation] = "here"
+default[:snmpd][:syscontact] = "root <root@#{node[:domain]}>"
+default[:snmpd][:disks] = node[:filesystem].keys.select { |k| k =~ /\A\/dev\// }.map { |d| node[:filesystem][d][:mount] }
+default[:snmpd][:execs] = []
+# default[:snmpd][:execs] = [
+# {
+# :name => "postfix_queue_size",
+# :command => "/usr/local/bin/postfix_queue_size"
+# },
+# {
+# :name => "sda_smart_errors",
+# :command => "/usr/local/bin/smart_errors /dev/sda"
+# }
+# ]
View
29 snmpd/metadata.json
@@ -0,0 +1,29 @@
+{
+ "conflicting": {
+ },
+ "long_description": "= DESCRIPTION:\n\n= REQUIREMENTS:\n\n= ATTRIBUTES: \n\n= USAGE:\n\n",
+ "recipes": {
+ },
+ "attributes": {
+ },
+ "providing": {
+ },
+ "dependencies": {
+ },
+ "maintainer": "Promet Solutions",
+ "replacing": {
+ },
+ "platforms": {
+ },
+ "license": "Apache 2.0",
+ "maintainer_email": "marius@promethost.com",
+ "version": "0.1.0",
+ "groupings": {
+ },
+ "recommendations": {
+ },
+ "name": "snmpd",
+ "suggestions": {
+ },
+ "description": "Installs/Configures snmpd"
+}
View
7 snmpd/metadata.rb
@@ -0,0 +1,7 @@
+maintainer "Promet Solutions"
+maintainer_email "marius@promethost.com"
+license "Apache 2.0"
+description "Installs/Configures snmpd"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
+version "0.1"
+
View
35 snmpd/recipes/default.rb
@@ -0,0 +1,35 @@
+package "snmp"
+package "snmpd"
+
+template "/etc/snmp/snmpd.conf" do
+ source "snmpd.conf.erb"
+ owner "root"
+ group "root"
+ mode "0644"
+ variables(
+ :monitoring_ips => [node[:snmpd][:monitoring_ips]].flatten,
+ :community => node[:snmpd][:community],
+ :syslocation => node[:snmpd][:syslocation],
+ :syscontact => node[:snmpd][:syscontact],
+ :execs => [node[:snmpd][:execs]].flatten,
+ :disks => [node[:snmpd][:disks]].flatten
+ )
+end
+
+template "/etc/default/snmpd" do
+ source "snmpd.default.erb"
+ owner "root"
+ group "root"
+ mode "0644"
+ variables(
+ :ip => node["network"]["interfaces"]["#{node[:snmpd][:interface]}"]["addresses"].find {|addr, addr_info| addr_info[:family] == "inet"}.first
+ )
+end
+
+service "snmpd" do
+ supports :status => false, :restart => true, :reload => true
+ action [:enable, :start]
+ subscribes :restart, resources(:template => "/etc/snmp/snmpd.conf")
+ subscribes :restart, resources(:template => "/etc/default/snmpd")
+ #subscribes :restart, resources(:package => "snmpd")
+end
View
26 snmpd/templates/default/snmpd.conf.erb
@@ -0,0 +1,26 @@
+<% @monitoring_ips.each do |ip| -%>
+com2sec local <%= sprintf("%-18s", ip + "/32") %> <%= @community %>
+<% end -%>
+
+group MyROGroup v1 local
+group MyROGroup v2c local
+group MyROGroup usm local
+
+view all included .1 80
+
+access MyROGroup "" any noauth exact all none none
+
+syslocation <%= @syslocation %>
+syscontact <%= @syscontact %>
+<% unless @execs.empty? -%>
+
+<% @execs.each do |e| -%>
+exec <%= e[:name] %> <%= e[:command] %>
+<% end -%>
+<% end -%>
+<% unless @disks.empty? -%>
+
+<% @disks.each do |d| -%>
+disk <%= d %>
+<% end -%>
+<% end -%>
View
22 snmpd/templates/default/snmpd.default.erb
@@ -0,0 +1,22 @@
+# This file controls the activity of snmpd and snmptrapd
+
+# MIB directories. /usr/share/snmp/mibs is the default, but
+# including it here avoids some strange problems.
+export MIBDIRS=/usr/share/snmp/mibs
+
+# snmpd control (yes means start daemon).
+SNMPDRUN=yes
+
+# snmpd options (use syslog, close stdin/out/err).
+SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid <%= @ip %>'
+
+# snmptrapd control (yes means start daemon). As of net-snmp version
+# 5.0, master agentx support must be enabled in snmpd before snmptrapd
+# can be run. See snmpd.conf(5) for how to do this.
+TRAPDRUN=no
+
+# snmptrapd options (use syslog).
+TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
+
+# create symlink on Debian legacy location to official RFC path
+SNMPDCOMPAT=yes
Please sign in to comment.
Something went wrong with that request. Please try again.