Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
checkmk-formula
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
salt
checkmk-formula
Commits
23d2642a
Commit
23d2642a
authored
2 years ago
by
Fynn Becker
Browse files
Options
Downloads
Patches
Plain Diff
Add monitor-postgrest local check
parent
555c96ef
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
checkmk/custom-files/local/monitor-postgrest
+81
-0
81 additions, 0 deletions
checkmk/custom-files/local/monitor-postgrest
checkmk/debian/monitor_postgrest.sls
+12
-0
12 additions, 0 deletions
checkmk/debian/monitor_postgrest.sls
with
93 additions
and
0 deletions
checkmk/custom-files/local/monitor-postgrest
0 → 100644
+
81
−
0
View file @
23d2642a
#!/usr/bin/env bash
instance_names
=()
instance_admin_ports
=()
{
%
for
instance_name, instance_conf
in
instances.items
()
%
}
instance_names+
=(
"{{ instance_name }}"
)
instance_admin_ports+
=(
"{{ instance_conf['config']['admin-server-port'] }}"
)
{
% endfor %
}
function
check_endpoint
()
{
admin_port
=
"
$1
"
endpoint
=
"
$2
"
url
=
"127.0.0.1:
$admin_port
/
$endpoint
"
response
=
$(
wget
--quiet
--spider
--server-response
--output-document
-
"
$url
"
2>&1
)
wget_exit_code
=
$?
if
[
$wget_exit_code
-ne
0
]
;
then
return
$wget_exit_code
fi
status_code
=
$(
awk
'NR==1{print $2}'
<<<
"
$response
"
)
echo
"
$status_code
"
}
function
get_status_detail
()
{
status_code
=
"
$1
"
good
=
"
$2
"
bad
=
"
$3
"
if
[
"
$status_code
"
=
200
]
;
then
echo
"
$good
"
else
echo
"
$bad
"
fi
}
function
get_checkmk_status
()
{
status_codes
=(
"
$@
"
)
for
code
in
"
${
status_codes
[@]
}
"
;
do
if
[
"
$code
"
!=
200
]
;
then
echo
2
return
fi
done
echo
0
}
function
crit_on_non_zero
()
{
instance_name
=
"
$1
"
exit_code
=
"
$2
"
if
[
"
$exit_code
"
!=
0
]
;
then
echo
"2
\"
$instance_name
PostgREST Status
\"
- Failed to connect (wget exit code:
$exit_code
)"
exit
0
fi
}
function
check_instance
()
{
instance_name
=
"
$1
"
instance_port
=
"
$2
"
live_status_code
=
$(
check_endpoint
"
$instance_port
"
"live"
)
crit_on_non_zero
"
$instance_name
"
$?
ready_status_code
=
$(
check_endpoint
"
$instance_port
"
"ready"
)
crit_on_non_zero
"
$instance_name
"
$?
status_codes
=(
"
$live_status_code
"
"
$ready_status_code
"
)
checkmk_status
=
$(
get_checkmk_status
"
${
status_codes
[@]
}
"
)
live_status_detail
=
$(
get_status_detail
"
$live_status_code
"
"running"
"dead"
)
ready_status_detail
=
$(
get_status_detail
"
$ready_status_code
"
"correct"
"invalid"
)
checkmk_status_detail
=
"PostgREST
$live_status_detail
(status:
$live_status_code
)"
checkmk_status_detail+
=
", internal state
$ready_status_detail
(status:
$ready_status_code
)"
echo
"
$checkmk_status
\"
$instance_name
PostgREST Status
\"
-
$checkmk_status_detail
"
}
for
i
in
"
${
!instance_names[@]
}
"
;
do
check_instance
"
${
instance_names
[
$i
]
}
"
"
${
instance_admin_ports
[
$i
]
}
"
done
This diff is collapsed.
Click to expand it.
checkmk/debian/monitor_postgrest.sls
0 → 100644
+
12
−
0
View file @
23d2642a
{% set instances = salt['pillar.get']("postgrest:instances") %}
hsh_checkmk_monitor_postgrest_plugin:
file.managed:
- name: /usr/lib/check_mk_agent/local/monitor-postgrest
- source: salt://checkmk/custom-files/local/monitor-postgrest
- template: jinja
- context:
instances: {{ instances }}
- mode: 755
- user: root
- group: root
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