Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
archutils
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
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
archlinux
archutils
Commits
1edbaf56
Commit
1edbaf56
authored
11 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
checkservices: more systemd informations
parent
86b1ed43
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
checkservices
+19
-9
19 additions, 9 deletions
checkservices
with
19 additions
and
9 deletions
checkservices
+
19
−
9
View file @
1edbaf56
...
@@ -33,10 +33,9 @@ usage() {
...
@@ -33,10 +33,9 @@ usage() {
echo
'options:'
echo
'options:'
echo
' -h: this help'
>
&2
echo
' -h: this help'
>
&2
echo
' -r: restart services'
>
&2
echo
' -r: restart services'
>
&2
echo
' -l: list systemd commands to execute'
>
&2
echo
' -R: reload services'
>
&2
echo
' -R: reload services'
>
&2
echo
" -n: don't call systemd daemon-reload"
>
&2
echo
" -n: don't call systemd daemon-reload"
>
&2
echo
" -N: don't display
failed units after
restart/reload"
>
&2
echo
" -N: don't display
status of
restart/reload
units
"
>
&2
echo
" -v: verbose mode"
>
&2
echo
" -v: verbose mode"
>
&2
exit
1
exit
1
}
}
...
@@ -45,8 +44,8 @@ while getopts 'hrlRnv' opt; do
...
@@ -45,8 +44,8 @@ while getopts 'hrlRnv' opt; do
case
$opt
in
case
$opt
in
r
)
systemd_cmd
=
'restart'
;;
r
)
systemd_cmd
=
'restart'
;;
R
)
systemd_cmd
=
'reload'
;;
R
)
systemd_cmd
=
'reload'
;;
n
)
daemo
n_reload
=
false
;;
n
)
n
o
_reload
=
1
;;
N
)
show_failed
=
false
;;
N
)
no_status
=
1
;;
l
)
list
=
true
;;
l
)
list
=
true
;;
v
)
verbose
=
true
;;
v
)
verbose
=
true
;;
*
)
usage
;;
*
)
usage
;;
...
@@ -55,18 +54,21 @@ done
...
@@ -55,18 +54,21 @@ done
shift
$((
OPTIND
-
1
))
;
shift
$((
OPTIND
-
1
))
;
((
$#
>
0
))
&&
usage
((
$#
>
0
))
&&
usage
[[
-n
"
$systemd_cmd
"
||
-n
"
$list
"
]]
||
usage
# reload units list
[[
-z
$no_reload
]]
&&
systemctl
--system
daemon-reload
[[
$daemon_reload
]]
||
systemctl
--system
daemon-reload
# list of running services
# list of running services
declare
-a
services
declare
-a
services
services
=(
$(
systemctl
-t
service
--full
|grep
\.
service|grep running|sed
-rn
's/^(.*\.service).*/\1/p'
)
)
services
=(
$(
systemctl
-t
service
--full
|grep
\.
service|grep running|sed
-rn
's/^(.*\.service).*/\1/p'
)
)
# beggar count
declare
-a
needy
=()
for
svc
in
"
${
services
[@]
}
"
;
do
for
svc
in
"
${
services
[@]
}
"
;
do
pid
=
$(
systemctl show
"
$svc
"
|sed
-nr
's/^MainPID=(.*)/\1/p'
)
pid
=
$(
systemctl show
"
$svc
"
|sed
-nr
's/^MainPID=(.*)/\1/p'
)
deleted
=
$(
grep
'(deleted)'
"/proc/
$pid
/maps"
|sed
-nr
's|^\S+ ..x. \S+ \S+ \S+ \s+||p'
|sort|uniq
)
deleted
=
$(
grep
'(deleted)'
"/proc/
$pid
/maps"
|sed
-nr
's|^\S+ ..x. \S+ \S+ \S+ \s+||p'
|sort|uniq
)
if
[[
-n
$deleted
]]
;
then
if
[[
-n
$deleted
]]
;
then
needy+
=(
"
$svc
"
)
if
[[
$verbose
]]
;
then
if
[[
$verbose
]]
;
then
echo
"
${
c_title
}
Service:
${
c_svc
}
$svc
${
c_rst
}
"
echo
"
${
c_title
}
Service:
${
c_svc
}
$svc
${
c_rst
}
"
echo
"
${
c_title
}
Pid:
${
c_rst
}
$pid
"
echo
"
${
c_title
}
Pid:
${
c_rst
}
$pid
"
...
@@ -84,7 +86,15 @@ for svc in "${services[@]}"; do
...
@@ -84,7 +86,15 @@ for svc in "${services[@]}"; do
done
done
wait
wait
# show failed units
# show units status
[[
$systemd_cmd
&&
$show_failed
]]
&&
systemctl
--failed
--all
if
[[
-z
$no_status
&&
$systemd_cmd
&&
${
needy
[*]
}
]]
;
then
systemctl
--lines
=
0 status
"
${
needy
[@]
}
"
fi
if
[[
$verbose
]]
;
then
systemctl
--failed
--all
--no-pager
--full
list-units
else
systemctl
--failed
--all
--no-pager
--no-legend
--full
list-units
fi
exit
0
exit
0
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