2012-10-25 14:25:39 -07:00
|
|
|
# Class to configure cacti on a node.
|
2012-10-20 23:53:20 +00:00
|
|
|
class openstack_project::cacti (
|
2015-12-30 14:43:25 -08:00
|
|
|
$sysadmins = [],
|
|
|
|
$cacti_hosts = [],
|
2016-05-25 12:05:24 -07:00
|
|
|
$vhost_name = '',
|
2012-10-20 23:53:20 +00:00
|
|
|
) {
|
2014-06-19 19:24:31 -07:00
|
|
|
|
|
|
|
if $::osfamily != 'Debian' {
|
|
|
|
fail("${::osfamily} is not supported.")
|
|
|
|
}
|
|
|
|
|
2012-10-20 23:53:20 +00:00
|
|
|
class { 'openstack_project::server':
|
|
|
|
iptables_public_tcp_ports => [80, 443],
|
2012-10-25 14:25:39 -07:00
|
|
|
sysadmins => $sysadmins,
|
2012-10-20 23:53:20 +00:00
|
|
|
}
|
|
|
|
|
2016-02-25 12:33:52 -05:00
|
|
|
class { '::apache':
|
2016-05-26 14:54:01 +10:00
|
|
|
default_vhost => false,
|
2016-02-25 12:33:52 -05:00
|
|
|
mpm_module => 'prefork',
|
2014-01-12 18:29:25 +11:00
|
|
|
}
|
2016-02-25 12:33:52 -05:00
|
|
|
class { '::apache::mod::rewrite': }
|
|
|
|
class { '::apache::mod::php': }
|
2014-01-12 18:29:25 +11:00
|
|
|
|
2012-10-20 23:53:20 +00:00
|
|
|
package { 'cacti':
|
2012-10-25 14:25:39 -07:00
|
|
|
ensure => present,
|
2012-10-20 23:53:20 +00:00
|
|
|
}
|
|
|
|
|
2016-07-19 16:42:30 +10:00
|
|
|
::apache::listen { '80': }
|
|
|
|
::apache::listen { '443': }
|
|
|
|
|
2016-02-25 12:33:52 -05:00
|
|
|
::apache::vhost::custom { $::fqdn:
|
2014-01-12 18:29:25 +11:00
|
|
|
ensure => present,
|
2016-02-25 12:33:52 -05:00
|
|
|
content => template('openstack_project/cacti.vhost.erb'),
|
2014-01-12 18:29:25 +11:00
|
|
|
}
|
|
|
|
|
2012-10-25 14:25:39 -07:00
|
|
|
file { '/usr/local/share/cacti/resource/snmp_queries':
|
2017-12-14 11:32:54 -05:00
|
|
|
ensure => directory,
|
|
|
|
owner => 'root',
|
|
|
|
require => Package['cacti'],
|
2012-10-25 14:25:39 -07:00
|
|
|
}
|
2012-10-20 23:53:20 +00:00
|
|
|
|
2012-10-25 14:25:39 -07:00
|
|
|
file { '/usr/local/share/cacti/resource/snmp_queries/net-snmp_devio.xml':
|
|
|
|
ensure => present,
|
|
|
|
source => 'puppet:///modules/openstack_project/cacti/net-snmp_devio.xml',
|
|
|
|
mode => '0644',
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
require => File['/usr/local/share/cacti/resource/snmp_queries'],
|
2012-10-20 23:53:20 +00:00
|
|
|
}
|
|
|
|
|
2017-12-14 13:47:41 -05:00
|
|
|
file { '/var/lib/cacti':
|
|
|
|
ensure => directory,
|
|
|
|
require => Package['cacti'],
|
|
|
|
}
|
|
|
|
|
2012-10-25 14:25:39 -07:00
|
|
|
file { '/var/lib/cacti/linux_host.xml':
|
|
|
|
ensure => present,
|
|
|
|
source => 'puppet:///modules/openstack_project/cacti/linux_host.xml',
|
|
|
|
mode => '0644',
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2017-12-14 13:47:41 -05:00
|
|
|
require => [
|
|
|
|
File['/usr/local/share/cacti/resource/snmp_queries/net-snmp_devio.xml'],
|
|
|
|
File['/var/lib/cacti'],
|
|
|
|
],
|
2012-10-20 23:53:20 +00:00
|
|
|
}
|
|
|
|
|
2012-10-25 14:25:39 -07:00
|
|
|
file { '/usr/local/bin/create_graphs.sh':
|
|
|
|
ensure => present,
|
|
|
|
source => 'puppet:///modules/openstack_project/cacti/create_graphs.sh',
|
|
|
|
mode => '0744',
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2012-10-20 23:53:20 +00:00
|
|
|
}
|
|
|
|
|
2012-10-25 14:25:39 -07:00
|
|
|
exec { 'cacti_import_xml':
|
2012-11-11 04:57:19 +00:00
|
|
|
command => '/usr/bin/php -q /usr/share/cacti/cli/import_template.php --filename=/var/lib/cacti/linux_host.xml --with-template-rras',
|
2012-10-31 09:32:58 -07:00
|
|
|
cwd => '/usr/share/cacti/cli',
|
2012-10-25 14:25:39 -07:00
|
|
|
require => File['/var/lib/cacti/linux_host.xml'],
|
2012-10-20 23:53:20 +00:00
|
|
|
}
|
|
|
|
|
2016-02-24 15:28:30 -08:00
|
|
|
file { '/var/lib/cacti/devices':
|
|
|
|
ensure => present,
|
|
|
|
content => join($cacti_hosts, " "),
|
|
|
|
mode => '0744',
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2017-12-14 13:47:41 -05:00
|
|
|
require => File['/var/lib/cacti'],
|
2016-02-24 15:28:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
cron { 'add cacti hosts':
|
|
|
|
ensure => present,
|
|
|
|
user => root,
|
2017-12-12 14:00:08 -08:00
|
|
|
command => 'for host in $(cat /var/lib/cacti/devices); do /usr/local/bin/create_graphs.sh $host >> /var/log/cacti_update.log 2>&1; done',
|
2016-02-24 15:28:30 -08:00
|
|
|
minute => '0',
|
|
|
|
}
|
|
|
|
|
2017-12-12 14:00:08 -08:00
|
|
|
include logrotate
|
|
|
|
logrotate::file { 'cacti_update.log':
|
|
|
|
log => '/var/log/cacti_update.log',
|
|
|
|
options => [
|
|
|
|
'compress',
|
|
|
|
'missingok',
|
|
|
|
'rotate 7',
|
|
|
|
'daily',
|
|
|
|
'notifempty',
|
|
|
|
'copytruncate',
|
|
|
|
],
|
|
|
|
require => Cron['add cacti hosts'],
|
|
|
|
}
|
2012-10-20 23:53:20 +00:00
|
|
|
}
|