Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ansible
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
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
Nounous
Ansible
Commits
e55bef00
Verified
Commit
e55bef00
authored
5 years ago
by
me5na7qbjqbrp
Browse files
Options
Downloads
Patches
Plain Diff
Add orphans apt packages metric
parent
3c2f218a
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
roles/prometheus-node-exporter/files/apt.sh
+11
-0
11 additions, 0 deletions
roles/prometheus-node-exporter/files/apt.sh
with
11 additions
and
0 deletions
roles/prometheus-node-exporter/files/apt.sh
100644 → 100755
+
11
−
0
View file @
e55bef00
...
...
@@ -19,6 +19,13 @@ autoremove="$(/usr/bin/apt-get --just-print autoremove \
| /usr/bin/awk
'/^Remv/{a++}END{printf "apt_autoremove_pending %d", a}'
)
"
orphans
=
"
$(
comm
-23
\
<
(
dpkg-query
-W
-f
'${db:Status-Abbrev}\t${Package}\n'
\
|
grep
'^.[^nc]'
|
cut
-f2
|
sort
)
\
<
(
apt-cache dumpavail |
sed
-rn
's/^Package: (.*)/\1/p'
|
sort
-u
)
\
|
awk
'END{printf "apt_orphans %d", NR}'
)
"
echo
'# HELP apt_upgrades_pending Apt package pending updates by origin.'
echo
'# TYPE apt_upgrades_pending gauge'
if
[[
-n
"
${
upgrades
}
"
]]
;
then
...
...
@@ -31,6 +38,10 @@ echo '# HELP apt_autoremove_pending Apt package pending autoremove.'
echo
'# TYPE apt_autoremove_pending gauge'
echo
"
${
autoremove
}
"
echo
'# HELP apt_orphans Orphan apt package.'
echo
'# TYPE apt_orphans gauge'
echo
"
${
orphans
}
"
echo
'# HELP node_reboot_required Node reboot is required for software updates.'
echo
'# TYPE node_reboot_required gauge'
if
[[
-f
'/run/reboot-required'
]]
;
then
...
...
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