Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zabbix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infra
ansible-shared
zabbix
Commits
af165749
Commit
af165749
authored
8 years ago
by
Lars Beckers
Browse files
Options
Downloads
Patches
Plain Diff
zabbix-server: add comment counts function
parent
7f936a04
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
zabbix-server/files/commentcounts.sql
+20
-0
20 additions, 0 deletions
zabbix-server/files/commentcounts.sql
zabbix-server/tasks/main.yml
+18
-0
18 additions, 0 deletions
zabbix-server/tasks/main.yml
with
38 additions
and
0 deletions
zabbix-server/files/commentcounts.sql
0 → 100644
+
20
−
0
View file @
af165749
CREATE
OR
REPLACE
FUNCTION
zbx_update_partition_table_comments
(
schema_arg
TEXT
DEFAULT
'partitions'
)
RETURNS
INT
AS
$$
DECLARE
r
RECORD
;
c
BIGINT
;
t
TEXT
;
BEGIN
RAISE
NOTICE
'Updating table comments in schema %'
,
schema_arg
;
FOR
r
IN
SELECT
tablename
FROM
pg_tables
WHERE
schemaname
=
schema_arg
-- AND tablename like 'history_str%'
LOOP
RAISE
NOTICE
'. updating comment for %.%'
,
schema_arg
,
r
.
tablename
;
EXECUTE
'SELECT count(1) FROM '
||
quote_ident
(
schema_arg
)
||
'.'
||
quote_ident
(
r
.
tablename
)
||
''
INTO
c
;
t
:
=
quote_literal
(
date_trunc
(
'second'
,
CURRENT_TIMESTAMP
)::
TEXT
||
' => '
||
to_char
(
c
,
'999G999G999G999'
)
||
' Rows'
);
RAISE
NOTICE
'.. got count % for %.%'
,
t
,
schema_arg
,
r
.
tablename
;
EXECUTE
'COMMENT ON TABLE '
||
quote_ident
(
schema_arg
)
||
'.'
||
quote_ident
(
r
.
tablename
)
||
' IS '
||
t
||
''
;
END
LOOP
;
RETURN
1
;
END
$$
LANGUAGE
plpgsql
;
This diff is collapsed.
Click to expand it.
zabbix-server/tasks/main.yml
+
18
−
0
View file @
af165749
...
...
@@ -36,6 +36,12 @@
-
database
-
zabbix
-
name
:
ensure there is the commentcounts sql file
copy
:
src=commentcounts.sql dest=/usr/share/doc/zabbix-server-pgsql/commentcounts.sql
tags
:
-
database
-
zabbix
-
name
:
ensure we have a user on the database server
postgresql_user
:
name="{{ zabbix_db_user }}" password="{{ zabbix_db_password }}" state=present role_attr_flags=NOSUPERUSER,NOCREATEDB
become
:
yes
...
...
@@ -107,6 +113,18 @@
-
database
-
zabbix
-
name
:
apply database commentcounts function
shell
:
psql -h {{ zabbix_db_host }} -U {{ zabbix_db_user }} -w -d {{ zabbix_db_name }} -f /usr/share/doc/zabbix-server-pgsql/commentcounts.sql && touch /var/lib/zabbix/.db_schema_countfunc
args
:
creates
:
/var/lib/zabbix/.db_schema_countfunc
become
:
yes
become_user
:
zabbix
notify
:
-
restart zabbix server
tags
:
-
database
-
zabbix
-
name
:
include snmp-features
include
:
snmp.yml
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment