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
6507d7d3
Commit
6507d7d3
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
remove special chars from systemd status
parent
dde54092
No related branches found
No related tags found
1 merge request
!191
remove special chars from systemd status
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
check_systemdunit
+7
-3
7 additions, 3 deletions
check_systemdunit
docs/20_Checks/check_systemdunit.md
+9
-9
9 additions, 9 deletions
docs/20_Checks/check_systemdunit.md
with
16 additions
and
12 deletions
check_systemdunit
+
7
−
3
View file @
6507d7d3
...
...
@@ -9,11 +9,12 @@
# 2020-09-06 v1.2 <axel.hahn@unibe.ch> add param -r to use a regex
# 2020-09-18 v1.3 <axel.hahn@unibe.ch> fix: list units --all to show all stopped units
# 2020-09-18 v1.4 <axel.hahn@unibe.ch> replace pipes in systemctl status output
# 2020-10-20 v1.5 <axel.hahn@unibe.ch> remove special chars from systemd status
# ================================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
export
self_APPVERSION
=
1.
4
export
self_APPVERSION
=
1.
5
# ----------------------------------------------------------------------
# FUNCTIONS
...
...
@@ -127,13 +128,16 @@ fi
# --- check given unit
_
status
=
$(
systemctl
--no-pager
-l
status
"
${
_unit
}
"
2>&1 |
tr
'|'
':'
)
_
data
=
$(
systemctl
--no-pager
-l
status
"
${
_unit
}
"
2>&1 |
tr
'|'
':'
)
if
!
grep
"Active: active (running) "
<<<
"
${
_status
}
"
>
/dev/null
;
then
_status
=
$(
echo
"
$_data
"
|
head
-1
|
sed
"s#^[^a-zA-Z]*##g"
)
if
!
grep
"Active: active (running) "
<<<
"
${
_data
}
"
>
/dev/null
;
then
ph.setStatus critical
fi
ph.status
"
${
_status
}
"
echo
"
$_data
"
|
sed
-n
"2,
\$
p"
|
tr
-d
'└├'
|
tr
'─'
'-'
ph.exit
# ----------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
docs/20_Checks/check_systemdunit.md
+
9
−
9
View file @
6507d7d3
...
...
@@ -16,7 +16,7 @@ A unit is everything listed by systemctl command - services, timers, targets, ..
______________________________________________________________________
CHECK_SYSTEMDUNIT
v1.
4
v1.
5
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
...
...
@@ -89,17 +89,17 @@ To check a single service you need to add the unit name in the 1st column.
``$ ./check_systemdunit nginx``
returns
```
txt
OK:
●
nginx.service - A high performance web server and a reverse proxy server
OK: nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
Active: active (running) since
Tue
2023-
09-05
08:04:
4
5 CEST;
8h
ago
Process:
577
ExecStart=/usr/bin/nginx
-g pid /run/nginx.pid; error_log stderr;
(code=exited, status=0/SUCCESS)
Main PID:
612
(nginx)
Active: active (running) since
Fri
2023-
10-20
08:04:
3
5 CEST;
3h 14min
ago
Process:
783
ExecStart=/usr/bin/nginx (code=exited, status=0/SUCCESS)
Main PID:
787
(nginx)
Tasks: 2 (limit: 18881)
Memory: 3.
0
M
CPU: 3
8
ms
Memory: 3.
8
M
CPU: 3
9
ms
CGroup: /system.slice/nginx.service
├─612
"nginx: master process /usr/bin/nginx
-g pid /run/nginx.pid; error_log stderr;
"
└─613
"nginx: worker process"
-787
"nginx: master process /usr/bin/nginx"
-788
"nginx: worker process"
...
```
...
...
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