Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
686ea6f6
Commit
686ea6f6
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Plain Diff
Merge branch '6010-check-pqsql' into 'master'
add activity counters See merge request
!91
parents
f172f162
e2340f2a
No related branches found
No related tags found
1 merge request
!91
add activity counters
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_psqlserver
+16
-10
16 additions, 10 deletions
check_psqlserver
with
16 additions
and
10 deletions
check_psqlserver
+
16
−
10
View file @
686ea6f6
...
@@ -143,7 +143,7 @@ EOH
...
@@ -143,7 +143,7 @@ EOH
# param string database query
# param string database query
function
renderCounters
(){
function
renderCounters
(){
local
_query
;
_query
=
"
$1
"
local
_query
;
_query
=
"
$1
"
local
_out
;
_out
=
$(
psql
-c
"
${
_query
}
2>&1
"
)
||
_queryFailed
local
_out
;
_out
=
$(
psql
-c
"
${
_query
}
"
2>&1
)
||
_queryFailed
local
_iCounter
;
typeset
-i
_iCounter
=
0
local
_iCounter
;
typeset
-i
_iCounter
=
0
local
_header
;
_header
=
$(
echo
"
${
_out
}
"
|
head
-1
|
tr
-d
' '
)
local
_header
;
_header
=
$(
echo
"
${
_out
}
"
|
head
-1
|
tr
-d
' '
)
local
_data
;
_data
=
$(
echo
"
${
_out
}
"
|
head
-3
|
tail
-1
|
tr
-d
' '
)
local
_data
;
_data
=
$(
echo
"
${
_out
}
"
|
head
-3
|
tail
-1
|
tr
-d
' '
)
...
@@ -220,14 +220,20 @@ sMode=$(ph.getValueWithParam '' m "$@")
...
@@ -220,14 +220,20 @@ sMode=$(ph.getValueWithParam '' m "$@")
case
"
${
sMode
}
"
in
case
"
${
sMode
}
"
in
"activity"
)
"activity"
)
_out
=
$(
psql
-c
"select
pid,usename,state,query,backend_type,backend_start
from pg_stat_activity"
)
||
_queryFailed
_out
=
$(
psql
-c
"select
backend_type,state,query
from pg_stat_activity"
2>&1
)
||
_queryFailed
typeset
-i
iQTotal
;
iQTotal
=
$(
tail
-1
<<<
"
$_out
"
|
cut
-f
1
-d
' '
|
tr
-d
'('
)
typeset
-i
iQTotal
;
iQTotal
=
$(
tail
-1
<<<
"
$_out
"
|
cut
-f
1
-d
' '
|
tr
-d
'('
)
typeset
-i
iQActive
;
iQActive
=
$(
awk
'{ print $5 }'
<<<
"
$_out
"
|
grep
-c
"active"
)
typeset
-i
iQActive
;
iQActive
=
$(
awk
'{ print $4 }'
<<<
"
$_out
"
|
grep
-c
"active"
)
typeset
-i
iQIdle
;
iQIdle
=
$(
awk
'{ print $4 }'
<<<
"
$_out
"
|
grep
-c
"idle"
)
typeset
-i
iQFastpath
;
iQFastpath
=
$(
awk
'{ print $4 }'
<<<
"
$_out
"
|
grep
-c
"fastpath"
)
typeset
-i
iQOther
;
iQOther
=
$iQTotal
-
$iQActive
-
$iQIdle
-
$iQFastpath
descr
=
"Running total:
$iQTotal
... active:
$iQActive
"
descr
=
"Running total:
$iQTotal
... active:
$iQActive
idle:
$iQIdle
fastpath:
$iQFastpath
other:
$iQOther
"
out
=
"
${
_out
}${
NL
}
"
out
=
$(
grep
"^.[a-z]"
<<<
"
${
_out
}
"
|
cut
-c
1-150
)
ph.perfadd
"running-total"
"
${
iQTotal
}
"
ph.perfadd
"running-total"
"
${
iQTotal
}
"
ph.perfadd
"running-active"
"
${
iQActive
}
"
ph.perfadd
"running-active"
"
${
iQActive
}
"
ph.perfadd
"running-idle"
"
${
iQIdle
}
"
ph.perfadd
"running-fastpath"
"
${
iQFastpath
}
"
ph.perfadd
"running-other"
"
${
iQOther
}
"
;;
;;
"conflicts"
)
"conflicts"
)
descr
=
"Detected conflicts (from pg_stat_database_conflicts)"
descr
=
"Detected conflicts (from pg_stat_database_conflicts)"
...
@@ -267,7 +273,7 @@ case "${sMode}" in
...
@@ -267,7 +273,7 @@ case "${sMode}" in
from pg_stat_database "
from pg_stat_database "
;;
;;
"replication"
)
"replication"
)
_out
=
$(
psql
-c
"select * from pg_stat_replication"
)
||
_queryFailed
_out
=
$(
psql
-c
"select * from pg_stat_replication"
2>&1
)
||
_queryFailed
if
tail
-1
<<<
"
$_out
"
|
grep
"(0 rows)"
>
/dev/null
;
then
if
tail
-1
<<<
"
$_out
"
|
grep
"(0 rows)"
>
/dev/null
;
then
descr
=
"No data in pg_stat_replication - this is no slave."
descr
=
"No data in pg_stat_replication - this is no slave."
out
=
""
out
=
""
...
...
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