38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/cloudstack-nagios/commands/snmpd_config.rb', line 38
def enable(*vms)
apt = options[:apt]
if vms.size == 0
say 'Get a list of all routers from Cloudstack..', :yellow
vms = router_ips
end
hosts = vms.map do |router|
host = SSHKit::Host.new("root@#{router}")
host.ssh_options = sshoptions(options[:ssh_key])
host.port = options[:port]
host
end
say 'Connect to router and enable snmpd...', :yellow
on hosts, in: :sequence, wait: 10 do
begin
execute 'apt-get', 'update'
execute 'apt-get', '-y', 'install', 'snmpd'
upload! File.join(File.dirname(__FILE__), '..', 'files', 'snmpd.conf'), '/etc/snmp/snmpd.conf'
execute 'service', 'snmpd', 'restart'
execute 'iptables', '-A INPUT -p tcp -m tcp --dport 161 -j ACCEPT'
rescue StandardError => e
puts 'configuration failed!'
puts e.message
puts e.backtrace
end
end
end
|