forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from t-8ch/typesdb
Typesdb
- Loading branch information
Showing
6 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
define collectd::type ( | ||
$target, | ||
$ds_type, | ||
$ds = $title, | ||
$min = 'U', | ||
$max = 'U', | ||
$ds_name = 'value', | ||
) { | ||
validate_string($ds_name) | ||
$upper_ds_type = upcase($ds_type) | ||
|
||
validate_re($upper_ds_type, | ||
['^ABSOLUTE$', '^COUNTER$', '^DERIVE$', '^GAUGE$']) | ||
|
||
if $min != 'U' { | ||
validate_numeric($min) | ||
} | ||
|
||
if $max != 'U' { | ||
validate_numeric($max) | ||
} | ||
|
||
$content = "${ds}\t${ds_name}:${upper_ds_type}:${min}:${max}" | ||
|
||
concat::fragment { "${target}/${ds}": | ||
content => $content, | ||
target => $target, | ||
order => $ds, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
define collectd::typesdb ( | ||
$path = $title, | ||
) { | ||
include collectd::params | ||
|
||
|
||
concat { $path: | ||
ensure => present, | ||
owner => 'root', | ||
group => $collectd::params::root_group, | ||
mode => '0640', | ||
ensure_newline => true, | ||
force => true, | ||
notify => Service['collectd'], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::type', :type => :define do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:id => 'root', | ||
:concat_basedir => tmpfilename('collectd-type'), | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
} | ||
end | ||
|
||
context 'define a type' do | ||
let(:title) { 'index' } | ||
let :params do | ||
{ | ||
:target => '/etc/collectd/types.db', | ||
:ds_type => 'ABSOLUTE', | ||
:min => 4, | ||
:max => 5, | ||
:ds_name => 'some_name', | ||
} | ||
end | ||
|
||
it 'creates an entry' do | ||
should contain_concat__fragment('/etc/collectd/types.db/index').with({ | ||
:target => '/etc/collectd/types.db', | ||
:content => "index\tsome_name:ABSOLUTE:4:5", | ||
}) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::typesdb', :type => :define do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:id => 'root', | ||
:concat_basedir => tmpfilename('collectd-typesdb'), | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
} | ||
end | ||
|
||
context 'without any types' do | ||
let(:title) { '/etc/collectd/types.db' } | ||
|
||
it 'should contain empty types.db' do | ||
should contain_concat('/etc/collectd/types.db') | ||
should contain_file('/etc/collectd/types.db') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
$typesdb = '/etc/collectd/types.db' | ||
|
||
class { 'collectd': | ||
typesdb => [ | ||
$typesdb, | ||
], | ||
} | ||
|
||
collectd::typesdb { $typesdb: } | ||
collectd::type { | ||
'bytes': | ||
target => $typesdb, | ||
ds_type => 'GAUGE', | ||
min => 0; | ||
'absolute': | ||
target => $typesdb, | ||
ds => 'absolute', | ||
ds_type => 'ABSOLUTE', | ||
ds_name => 'value', | ||
min => '0', | ||
max => 'U'; | ||
} |