
The current process to udpate cacti hosts is fairly chatty. It basically goes in and just tries to update every host there and if they exist that generates a bunch of output which is then emailed to infra roots. This information is potentially useful for debugging so keep it around in local cacti host logs. These logs will then be rotated with a week of retention. This should help make our inboxes happier. Change-Id: Ib03ef7b22083a2a2454715bd5229313b19b84ae9
104 lines
2.6 KiB
Puppet
104 lines
2.6 KiB
Puppet
# Class to configure cacti on a node.
|
|
class openstack_project::cacti (
|
|
$sysadmins = [],
|
|
$cacti_hosts = [],
|
|
$vhost_name = '',
|
|
) {
|
|
|
|
if $::osfamily != 'Debian' {
|
|
fail("${::osfamily} is not supported.")
|
|
}
|
|
|
|
class { 'openstack_project::server':
|
|
iptables_public_tcp_ports => [80, 443],
|
|
sysadmins => $sysadmins,
|
|
}
|
|
|
|
class { '::apache':
|
|
default_vhost => false,
|
|
mpm_module => 'prefork',
|
|
}
|
|
class { '::apache::mod::rewrite': }
|
|
class { '::apache::mod::php': }
|
|
|
|
package { 'cacti':
|
|
ensure => present,
|
|
}
|
|
|
|
::apache::listen { '80': }
|
|
::apache::listen { '443': }
|
|
|
|
::apache::vhost::custom { $::fqdn:
|
|
ensure => present,
|
|
content => template('openstack_project/cacti.vhost.erb'),
|
|
}
|
|
|
|
file { '/usr/local/share/cacti/resource/snmp_queries':
|
|
ensure => directory,
|
|
owner => 'root',
|
|
}
|
|
|
|
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'],
|
|
}
|
|
|
|
file { '/var/lib/cacti/linux_host.xml':
|
|
ensure => present,
|
|
source => 'puppet:///modules/openstack_project/cacti/linux_host.xml',
|
|
mode => '0644',
|
|
owner => 'root',
|
|
group => 'root',
|
|
require => File[
|
|
'/usr/local/share/cacti/resource/snmp_queries/net-snmp_devio.xml'
|
|
],
|
|
}
|
|
|
|
file { '/usr/local/bin/create_graphs.sh':
|
|
ensure => present,
|
|
source => 'puppet:///modules/openstack_project/cacti/create_graphs.sh',
|
|
mode => '0744',
|
|
owner => 'root',
|
|
group => 'root',
|
|
}
|
|
|
|
exec { 'cacti_import_xml':
|
|
command => '/usr/bin/php -q /usr/share/cacti/cli/import_template.php --filename=/var/lib/cacti/linux_host.xml --with-template-rras',
|
|
cwd => '/usr/share/cacti/cli',
|
|
require => File['/var/lib/cacti/linux_host.xml'],
|
|
}
|
|
|
|
file { '/var/lib/cacti/devices':
|
|
ensure => present,
|
|
content => join($cacti_hosts, " "),
|
|
mode => '0744',
|
|
owner => 'root',
|
|
group => 'root',
|
|
}
|
|
|
|
cron { 'add cacti hosts':
|
|
ensure => present,
|
|
user => root,
|
|
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',
|
|
minute => '0',
|
|
}
|
|
|
|
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'],
|
|
}
|
|
}
|