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
feadda6f
You need to sign in or sign up before continuing.
Verified
Commit
feadda6f
authored
5 years ago
by
me5na7qbjqbrp
Browse files
Options
Downloads
Patches
Plain Diff
Patch prometheus APT collector
parent
cbd83f37
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
roles/prometheus-node-exporter/files/apt.sh
+44
-0
44 additions, 0 deletions
roles/prometheus-node-exporter/files/apt.sh
roles/prometheus-node-exporter/tasks/main.yml
+10
-0
10 additions, 0 deletions
roles/prometheus-node-exporter/tasks/main.yml
with
54 additions
and
0 deletions
roles/prometheus-node-exporter/files/apt.sh
0 → 100644
+
44
−
0
View file @
feadda6f
#!/bin/bash
#
# Description: Expose metrics from apt updates.
#
# Author: Ben Kochie <superq@gmail.com>
upgrades
=
"
$(
/usr/bin/apt-get
--just-print
dist-upgrade
\
| /usr/bin/awk
-F
'[()]'
\
'/^Inst/ { sub("^[^ ]+ ", "", $2); gsub(" ","",$2);
sub("\\[", " ", $2); sub("\\]", "", $2); print $2 }'
\
| /usr/bin/sort
\
| /usr/bin/uniq
-c
\
|
awk
'{ gsub(/\\\\/, "\\\\", $2); gsub(/\"/, "\\\"", $2);
gsub(/\[/, "", $3); gsub(/\]/, "", $3);
print "apt_upgrades_pending{origin=\"" $2 "\",arch=\"" $NF "\"} " $1}'
)
"
autoremove
=
"
$(
/usr/bin/apt-get
--just-print
autoremove
\
| /usr/bin/awk
'/^Remv/{a++}END{print "apt_autoremove_pending " a}'
)
"
echo
'# HELP apt_upgrades_pending Apt package pending updates by origin.'
echo
'# TYPE apt_upgrades_pending gauge'
if
[[
-n
"
${
upgrades
}
"
]]
;
then
echo
"
${
upgrades
}
"
else
echo
'apt_upgrades_pending{origin="",arch=""} 0'
fi
echo
'# HELP apt_autoremove_pending Apt package pending autoremove.'
echo
'# TYPE apt_autoremove_pending gauge'
if
[[
-n
"
${
autoremove
}
"
]]
;
then
echo
"
${
autoremove
}
"
else
echo
'apt_autoremove_pending 0'
fi
echo
'# HELP node_reboot_required Node reboot is required for software updates.'
echo
'# TYPE node_reboot_required gauge'
if
[[
-f
'/run/reboot-required'
]]
;
then
echo
'node_reboot_required 1'
else
echo
'node_reboot_required 0'
fi
This diff is collapsed.
Click to expand it.
roles/prometheus-node-exporter/tasks/main.yml
+
10
−
0
View file @
feadda6f
...
...
@@ -38,3 +38,13 @@
ARGS="--web.listen-address={{ ansible_hostname }}.adm.crans.org:9100"
notify
:
Restart prometheus-node-exporter
tags
:
restart-node-exporter
# Install new APT textfile collector, it might be upstreamed one day
# https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/pull/35
-
name
:
Patch APT textfile collector
copy
:
src
:
apt.sh
dest
:
/usr/share/prometheus-node-exporter/apt.sh
owner
:
root
group
:
root
mode
:
0755
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