Add cacti host.

Change-Id: I67cc116ad8a2b2586856965ae1e341d735d69fd3
Reviewed-on: https://review.openstack.org/14582
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
James E. Blair 2012-10-20 23:53:20 +00:00 committed by Jenkins
parent cdbd0f6510
commit 8bb3ef831a
7 changed files with 7074 additions and 0 deletions

View File

@ -115,6 +115,12 @@ node 'jenkins-dev.openstack.org' {
}
}
node 'cacti.openstack.org' {
class { 'openstack_project::cacti':
sysadmins => hiera('sysadmins'),
}
}
node 'community.openstack.org' {
class { 'openstack_project::community':
sysadmins => hiera('sysadmins'),

View File

@ -13,6 +13,7 @@
-A openstack-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# SNMP from openstack cacti
-A openstack-INPUT -m udp -p udp --dport 161 -s 50.57.120.246 -j ACCEPT
-A openstack-INPUT -m udp -p udp --dport 161 -s 198.61.215.188 -j ACCEPT
# Public TCP ports
<% public_tcp_ports.each do |port| -%>
-A openstack-INPUT -m state --state NEW -m tcp -p tcp --dport <%= port %> -j ACCEPT

View File

@ -10,6 +10,8 @@
-A openstack-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# SSH from anywhere
-A openstack-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# SNMP from openstack cacti
-A openstack-INPUT -m udp -p udp --dport 161 -s 2001:4800:780d:0509:3bc3:d7f6:ff04:49de -j ACCEPT
# Public TCP ports
<% public_tcp_ports.each do |port| -%>
-A openstack-INPUT -m state --state NEW -m tcp -p tcp --dport <%= port %> -j ACCEPT

View File

@ -0,0 +1,81 @@
#!/bin/bash
cd /usr/share/cacti/cli
HOST_NAME=$1
HOST_TEMPLATE_ID=`php -q /usr/share/cacti/cli/add_device.php \
--list-host-templates |grep "Linux Host"|cut -f 1`
php -q add_device.php --description="$HOST_NAME" --ip="$HOST_NAME" \
--template=$HOST_TEMPLATE_ID --version=2 --community="public"
HOST_ID=`php -q add_graphs.php --list-hosts |grep $HOST_NAME|cut -f 1`
TREE_ID=`php -q add_tree.php --list-trees |grep "Default Tree"|cut -f 1`
php -q add_tree.php --type=node --node-type=host --tree-id=$TREE_ID \
--host-id=$HOST_ID
php -q add_graphs.php --list-graph-templates \
--host-template-id=$HOST_TEMPLATE_ID | \
while read line
do
if echo $line | grep "Known" >/dev/null || [ "$line" == "" ]
then
continue
fi
TEMPLATE_ID=`echo $line | cut -f 1 -d ' '`
php -q add_graphs.php --host-id=$HOST_ID --graph-type=cg \
--graph-template-id=$TEMPLATE_ID
done
function add_ds_graph {
TEMPLATE_NAME=$1
TYPE_NAME=$2
FIELD_NAME=$3
FIELD_VALUE=$4
TEMPLATE_ID=`php -q add_graphs.php --list-graph-templates | \
grep "$TEMPLATE_NAME"|cut -f 1`
TYPE_ID=`php -q add_graphs.php --snmp-query-id=$SNMP_QUERY_ID \
--list-query-types | grep "$TYPE_NAME"|cut -f 1`
php -q add_graphs.php --host-id=$HOST_ID --graph-type=ds \
--graph-template-id=$TEMPLATE_ID --snmp-query-id=$SNMP_QUERY_ID \
--snmp-query-type-id=$TYPE_ID --snmp-field=$FIELD_NAME \
--snmp-value=$FIELD_VALUE
}
# php -q add_graphs.php --list-graph-templates
# php -q add_graphs.php --snmp-query-id=$SNMP_QUERY_ID --list-query-types
SNMP_QUERY_ID=`php -q add_graphs.php --host-id=$HOST_ID --list-snmp-queries | \
grep "SNMP - Get Mounted Partitions"|cut -f 1`
add_ds_graph "Host MIB - Available Disk Space" "Available Disk Space" \
"hrStorageDescr" "/"
SNMP_QUERY_ID=`php -q add_graphs.php --host-id=$HOST_ID --list-snmp-queries | \
grep "SNMP - Interface Statistics"|cut -f 1`
add_ds_graph "Interface - Traffic (bits/sec)" "In/Out Bits (64-bit Counters)" \
"ifOperStatus" "Up"
add_ds_graph "Interface - Errors/Discards" "In/Out Errors/Discarded Packets" \
"ifOperStatus" "Up"
add_ds_graph "Interface - Unicast Packets" "In/Out Unicast Packets" \
"ifOperStatus" "Up"
add_ds_graph "Interface - Non-Unicast Packets" "In/Out Non-Unicast Packets" \
"ifOperStatus" "Up"
SNMP_QUERY_ID=`php -q add_graphs.php --host-id=$HOST_ID --list-snmp-queries | \
grep "ucd/net - Get IO Devices"|cut -f 1`
add_ds_graph "ucd/net - Device IO - Operations" "IO Operations" \
"diskIODevice" "xvda"
add_ds_graph "ucd/net - Device IO - Throughput" "IO Throughput" \
"diskIODevice" "xvda"
add_ds_graph "ucd/net - Device IO - Operations" "IO Operations" \
"diskIODevice" "xvdc"
add_ds_graph "ucd/net - Device IO - Throughput" "IO Throughput" \
"diskIODevice" "xvdc"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
<query>
<name>Get Disk I/O</name>
<description>Queries a net-snmp host for a device I/O listing</description>
<comment>Get more Cacti graphs at http://www.rodre.com</comment>
<oid_index>.1.3.6.1.4.1.2021.13.15.1.1.1</oid_index>
<index_order>diskIODevice:diskIOIndex</index_order>
<index_order_type>numeric</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>
<fields>
<diskIOIndex>
<name>Index</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.4.1.2021.13.15.1.1.1</oid>
</diskIOIndex>
<diskIODevice>
<name>Device</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<oid>.1.3.6.1.4.1.2021.13.15.1.1.2</oid>
</diskIODevice>
<diskIONRead>
<name>BytesRead</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2021.13.15.1.1.3</oid>
</diskIONRead>
<diskIONWritten>
<name>BytesWritten</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2021.13.15.1.1.4</oid>
</diskIONWritten>
<diskIOReads>
<name>DeviceReads</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2021.13.15.1.1.5</oid>
</diskIOReads>
<diskIOWrites>
<name>DeviceWrites</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2021.13.15.1.1.6</oid>
</diskIOWrites>
</fields>
</query>

View File

@ -0,0 +1,62 @@
class openstack_project::cacti (
$sysadmins = []
) {
class { 'openstack_project::server':
iptables_public_tcp_ports => [80, 443],
sysadmins => $sysadmins
}
include apache
package { 'cacti':
ensure => present
}
file { "/usr/local/share/cacti/resource/snmp_queries":
ensure => directory,
owner => "root",
}
file { "/usr/local/share/cacti/resource/snmp_queries/net-snmp_devio.xml":
source => "puppet:///modules/openstack_project/cacti/net-snmp_devio.xml",
mode => 644,
owner => "root",
group => "root",
require => File["/usr/local/share/cacti/resource/snmp_queries"],
}
file { "/var/lib/cacti/linux_host.xml":
source => "puppet:///modules/openstack_project/cacti/linux_host.xml",
mode => 644,
owner => "root",
group => "root",
require => File["/usr/local/share/cacti/resource/snmp_queries/net-snmp_devio.xml"],
}
file { "/usr/local/bin/create_graphs.sh":
source => "puppet:///modules/openstack_project/cacti/create_graphs.sh",
mode => 744,
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"],
}
class {'cacti_device': hostname=> "etherpad.openstack.org"}
}
class cacti_device(
$hostname
){
exec { "/var/lib/cacti/linux_host.xml":
command => "/usr/local/bin/create_graphs.sh $hostname",
require => Exec["cacti_import_xml"]
}
}