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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
dfc28ebf
Commit
dfc28ebf
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
no output on activity; update replication check
parent
ab85e881
Branches
Branches containing commit
No related tags found
1 merge request
!109
no output on activity; update replication check
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_psqlserver
+49
-9
49 additions, 9 deletions
check_psqlserver
with
49 additions
and
9 deletions
check_psqlserver
+
49
−
9
View file @
dfc28ebf
...
...
@@ -17,12 +17,13 @@
# 2023-06-08 v0.3 <axel.hahn@unibe.ch> show unknown if database connection fails
# 2023-06-08 v0.4 <axel.hahn@unibe.ch> get summary for cronflicts and problems
# 2023-06-09 v0.5 <axel.hahn@unibe.ch> deltaunit can be set as parameter
# 2023-06-13 v0.6 <axel.hahn@unibe.ch> no output on activity; update replication check
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPVERSION
=
0.
5
self_APPVERSION
=
0.
6
# --- other vars...
cfgfile
=
/etc/icingaclient/.psql.conf
...
...
@@ -232,11 +233,11 @@ case "${sMode}" in
typeset
-i
iQOther
;
iQOther
=
$iQTotal
-
$iQActive
-
$iQIdle
-
$iQFastpath
descr
=
"Running total:
$iQTotal
... active:
$iQActive
idle:
$iQIdle
fastpath:
$iQFastpath
other:
$iQOther
"
typeset
-i
iMax
;
iMax
=
20
out
=
$(
grep
"^.[a-z]"
<<<
"
${
_out
}
"
|
cut
-c
1-150 |
tr
'|'
':'
|
head
-
${
iMax
}
)
if
[
${
iQTotal
}
-gt
${
iMax
}
]
;
then
out+
=
"
${
NL
}
(showing
${
iMax
}
of
${
iQTotal
}
lines)
${
NL
}
"
fi
#
typeset -i iMax; iMax=20
#
out=$( grep "^.[a-z]" <<< "${_out}" | cut -c 1-150 | tr '|' ':' | head -${iMax} )
#
if [ ${iQTotal} -gt ${iMax} ]; then
#
out+="${NL}(showing ${iMax} of ${iQTotal} lines)${NL}"
#
fi
ph.perfadd
"running-total"
"
${
iQTotal
}
"
ph.perfadd
"running-active"
"
${
iQActive
}
"
ph.perfadd
"running-idle"
"
${
iQIdle
}
"
...
...
@@ -302,13 +303,52 @@ case "${sMode}" in
;;
"replication"
)
_out
=
$(
psql
-c
"select * from pg_stat_replication"
2>&1
)
||
_queryFailed
# _out=$( psql -c "select * from pg_stat_replication" 2>&1 ) || _queryFailed
_out
=
$(
psql
-c
"select application_name,client_addr,state,write_lag,flush_lag,replay_lag,GREATEST(write_lag,flush_lag,replay_lag) as max_lag,sync_state from pg_stat_replication"
2>&1
)
||
_queryFailed
if
tail
-1
<<<
"
$_out
"
|
grep
"(0 rows)"
>
/dev/null
;
then
descr
=
"No data in pg_stat_replication
= no replication here.
"
descr
=
"No
ne (no
data in pg_stat_replication
)
"
out
=
""
else
descr
=
"status (from pg_stat_replication)"
out
=
$(
echo
"
${
_out
}${
NL
}
"
|
tr
'|'
':'
)
data
=
$(
sed
-n
"3,
\$
p"
<<<
"
${
_out
}
"
|
tr
-d
' '
|
grep
-v
'^('
)
# --- check: state
typeset
-i
iTotal
;
iTotal
=
$(
wc
-l
<<<
"
${
data
}
"
)
typeset
-i
iStateStreaming
;
iStateStreaming
=
$(
cut
-f
3
-d
'|'
<<<
"
${
data
}
"
|
grep
-c
'streaming'
)
typeset
-i
iStateOther
;
iStateOther
=
$iTotal
-
$iStateStreaming
ph.perfadd
"total"
"
${
iTotal
}
"
ph.perfadd
"state-streaming"
"
${
iStateStreaming
}
"
ph.perfadd
"state-other"
"
${
iStateOther
}
"
if
[
$iStateOther
-gt
0
]
;
then
ph.setStatus
"warning"
descr+
=
" ... state warning"
out+
=
"WARNING: a replication doesn't have the state 'streaming'.
${
NL
}
"
out+
=
" - startup: This WAL sender is starting up.
${
NL
}
"
out+
=
" - catchup: This WAL sender's connected standby is catching up with the primary.
${
NL
}
"
out+
=
" - streaming: This WAL sender is streaming changes after its connected standby server has caught up with the primary.
${
NL
}
"
out+
=
" - backup: This WAL sender is sending a backup.
${
NL
}
"
out+
=
" - stopping: This WAL sender is stopping.
${
NL
}
"
out+
=
""
fi
# --- check: max_leg
# max_leg is the maximum value of write_lag,flush_lag,replay_lag
# value as sec + "." + millisec ... or empty
MaxLag
=
$(
cut
-f
7
-d
'|'
<<<
"
${
data
}
"
|
sort
|
tail
-1
|
awk
-F
:
'{ print ($1 * 3600) + ($2 * 60) + $3 }'
)
test
-z
"
$MaxLag
"
&&
MaxLag
=
"0"
ph.perfadd
"max-lag"
"
${
MaxLag
}
"
if
!
grep
"^0[
\.
]*"
<<<
"
$MaxLag
"
>
/dev/null
;
then
ph.setStatus
"warning"
descr+
=
" ... lag warning"
out+
=
"WARNING: !!! experimantal !!! a lag larger 1 sec was detected. Maybe a target server is out of sync.'.
${
NL
}
"
fi
out+
=
$(
echo
"
${
_out
}${
NL
}
"
|
tr
'|'
':'
)
fi
;;
...
...
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