-
-
Notifications
You must be signed in to change notification settings - Fork 233
Timescaledb #827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bdeferme
wants to merge
7
commits into
voxpupuli:master
Choose a base branch
from
bdeferme:timescaledb
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Timescaledb #827
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9d1791e
Import timescaledb sql file based on boolean
a948c97
Manage_database_timescale
f5cb0fd
Manage_database_timescale
743d0f3
manage_database_timescale
e8eebed
Correct param name & pass on
d1217a0
Add basic test for timescaledb
c55e23c
Update to add port number
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| # @param database_host Hostname to use to connect to the database | ||
| # @param database_port Database port to be used for the import process. | ||
| # @param database_path Path to the database executable | ||
| # @param manage_database_timescale Import the timescaledb sql file? | ||
| # @author Werner Dijkerman <[email protected]> | ||
| class zabbix::database::postgresql ( | ||
| $zabbix_type = '', | ||
|
|
@@ -20,6 +21,7 @@ | |
| $database_host = '', | ||
| Stdlib::Port::Unprivileged $database_port = 5432, | ||
| $database_path = $zabbix::params::database_path, | ||
| Boolean $manage_database_timescale = false, | ||
| ) inherits zabbix::params { | ||
| assert_private() | ||
|
|
||
|
|
@@ -108,6 +110,28 @@ | |
| provider => 'shell', | ||
| require => Exec['update_pgpass'], | ||
| } | ||
| if $manage_database_timescale { | ||
| # Enable timescaledb | ||
| $_timescaledb_sql = [ | ||
| "cd ${schema_path}", | ||
| "&& psql -h '${database_host}'", | ||
| "-U '${database_user}'", | ||
| "-p ${database_port}", | ||
| "-d '${database_name}'", | ||
| '-f timescaledb.sql', | ||
| '&& touch /etc/zabbix/.timescaledb.done', | ||
| ] | ||
| exec { 'zabbix_timescaledb.sql': | ||
| command => $_timescaledb_sql.join(' '), | ||
| path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}", | ||
| unless => 'test -f /etc/zabbix/.timescaledb.done', | ||
| provider => 'shell', | ||
| require => [ | ||
| Exec['update_pgpass'], | ||
| Exec['zabbix_server_data.sql'], | ||
| ], | ||
| } | ||
| } | ||
| } | ||
| default: { | ||
| fail 'We do not work.' | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -113,6 +113,53 @@ | |||||
| it { is_expected.to contain_class('zabbix::params') } | ||||||
| end | ||||||
|
|
||||||
| describe "when zabbix_type is server and version is #{zabbix_version} and manage_database_timescale is true" do | ||||||
| let :params do | ||||||
| { | ||||||
| database_name: 'zabbix-server', | ||||||
| database_user: 'zabbix-server', | ||||||
| database_password: 'zabbix-server', | ||||||
| database_host: 'node01.example.com', | ||||||
| zabbix_type: 'server', | ||||||
| zabbix_version: zabbix_version, | ||||||
| manage_database_timescale: true | ||||||
| } | ||||||
| end | ||||||
|
|
||||||
| it { is_expected.to compile.with_all_deps } | ||||||
| it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:6432:zabbix-server:zabbix-server:zabbix-server >> /root/.pgpass') } | ||||||
| it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f #{sql_server}.gz ]; then gunzip -f #{sql_server}.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -p 6432 -d 'zabbix-server' -f #{sql_server} && touch /etc/zabbix/.schema.done") } | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @bdeferme - just curious if you saw this. Asking because I came here looking for the timescaledb support |
||||||
| it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } | ||||||
| it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } | ||||||
| it { is_expected.to contain_file('/root/.pgpass') } | ||||||
| it { is_expected.to contain_class('zabbix::params') } | ||||||
| it { is_expected.to contain_exec('zabbix_timescaledb.sql').with_command("cd #{path} && psql -h 'node01.example.com' -U 'zabbix-server' -p 5432 -d 'zabbix-server' -f timescaledb.sql && touch /etc/zabbix/.timescaledb.done") } | ||||||
| end | ||||||
|
|
||||||
| describe "when zabbix_type is server and version is #{zabbix_version} and manage_database_timescale is true and custom port is defined" do | ||||||
| let :params do | ||||||
| { | ||||||
| database_name: 'zabbix-server', | ||||||
| database_user: 'zabbix-server', | ||||||
| database_password: 'zabbix-server', | ||||||
| database_host: 'node01.example.com', | ||||||
| database_port: 6432, | ||||||
| zabbix_type: 'server', | ||||||
| zabbix_version: zabbix_version, | ||||||
| manage_database_timescale: true | ||||||
| } | ||||||
| end | ||||||
|
|
||||||
| it { is_expected.to compile.with_all_deps } | ||||||
| it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:6432:zabbix-server:zabbix-server:zabbix-server >> /root/.pgpass') } | ||||||
| it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f #{sql_server}.gz ]; then gunzip -f #{sql_server}.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -p 6432 -d 'zabbix-server' -f #{sql_server} && touch /etc/zabbix/.schema.done") } | ||||||
| it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } | ||||||
| it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } | ||||||
| it { is_expected.to contain_file('/root/.pgpass') } | ||||||
| it { is_expected.to contain_class('zabbix::params') } | ||||||
| it { is_expected.to contain_exec('zabbix_timescaledb.sql').with_command("cd #{path} && psql -h 'node01.example.com' -U 'zabbix-server' -p 6432 -d 'zabbix-server' -f timescaledb.sql && touch /etc/zabbix/.timescaledb.done") } | ||||||
| end | ||||||
|
|
||||||
| describe "when zabbix_type is proxy and version is #{zabbix_version}" do | ||||||
| let :params do | ||||||
| { | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.