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
42f9adf3
Commit
42f9adf3
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
fix iPkg2Update on empty package list
parent
05b8d8f9
Branches
Branches containing commit
No related tags found
1 merge request
!20
add sudo when calling yum
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_packages2install
+19
-12
19 additions, 12 deletions
check_packages2install
with
19 additions
and
12 deletions
check_packages2install
+
19
−
12
View file @
42f9adf3
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
# 2021-12-17 v1.7 <axel.hahn@iml.unibe.ch> show non matching packages in section "other"
# 2021-12-17 v1.7 <axel.hahn@iml.unibe.ch> show non matching packages in section "other"
# 2021-12-20 v1.8 <axel.hahn@iml.unibe.ch> show all packages if no filter matched
# 2021-12-20 v1.8 <axel.hahn@iml.unibe.ch> show all packages if no filter matched
# 2022-06-03 v1.9 <axel.hahn@iml.unibe.ch> call yum with path; shellcheck updates; plugin like package managers
# 2022-06-03 v1.9 <axel.hahn@iml.unibe.ch> call yum with path; shellcheck updates; plugin like package managers
# 2022-06-07 v1.10 <axel.hahn@iml.unibe.ch> fix iPkg2Update on empty package list
# rename package manager functions
# ======================================================================
# ======================================================================
...
@@ -88,11 +90,17 @@ Get packages that must be updated on this system
...
@@ -88,11 +90,17 @@ Get packages that must be updated on this system
Licence: GNU GPL 3
Licence: GNU GPL 3
______________________________________________________________________
______________________________________________________________________
Get packages that must be updated on this system an
s
show found
Get packages that must be updated on this system an
d
show found
packages in groups.
packages in groups.
For groups and their search filters see files in subdir
RELATED FILES:
check_packages2install-data.
1) For groups and their search filters see files in subdir
check_packages2install-data.
2) In the subdir check_packages2install-pkgmanager are scripts
for supported package managers (with aded ".sh").
OUTPUT:
It returns UNKNOWN if package manager is not supported.
It returns OK if the system is up to date.
It returns OK if the system is up to date.
It returns WARNING or ERROR if count of found pakackes is greater than
It returns WARNING or ERROR if count of found pakackes is greater than
...
@@ -111,13 +119,12 @@ $_self [options]
...
@@ -111,13 +119,12 @@ $_self [options]
OPTIONS:
OPTIONS:
-h show this help
-w custom warning level; default:
$iWarnDefault
-w custom warning level; default:
$iWarnDefault
-c custom critical level; default:
$iCriticalDefault
-c custom critical level; default:
$iCriticalDefault
PARAMETERS:
PARAMETERS:
None.
-h show this help
EOF
EOF
}
}
...
@@ -153,7 +160,7 @@ function _detectPkgManager(){
...
@@ -153,7 +160,7 @@ function _detectPkgManager(){
function
showFilteredPackages
(){
function
showFilteredPackages
(){
# filtered package view
# filtered package view
if
[
!
-z
"
$packages2install
"
]
;
then
if
[
-n
"
$packages2install
"
]
;
then
typeset
-i
iTotal
typeset
-i
iTotal
iTotal
=
$(
echo
"
$packages2install
"
|
wc
-l
)
iTotal
=
$(
echo
"
$packages2install
"
|
wc
-l
)
typeset
-i
iFound
=
0
typeset
-i
iFound
=
0
...
@@ -194,7 +201,6 @@ function showFilteredPackages(){
...
@@ -194,7 +201,6 @@ function showFilteredPackages(){
# total packages
# total packages
echo
Total packages to
install
:
$iTotal
echo
Total packages to
install
:
$iTotal
ph.perfadd
"updates-available"
"
$iTotal
"
${
iWarnLimit
}
${
iCriticalLimit
}
fi
fi
...
@@ -224,7 +230,7 @@ fi
...
@@ -224,7 +230,7 @@ fi
# load functions for the detected package manager
# load functions for the detected package manager
.
"
${
dir_pkg
}
/
${
pkgmanager
}
.sh"
||
exit
2
.
"
${
dir_pkg
}
/
${
pkgmanager
}
.sh"
||
exit
2
packagemanOut
=
$(
${
pkgmanager
}
GetUpdates
)
packagemanOut
=
$(
${
pkgmanager
}
.
GetUpdates
)
if
[
-z
"
$packagemanOut
"
]
;
then
if
[
-z
"
$packagemanOut
"
]
;
then
ph.setStatus
"critical"
ph.setStatus
"critical"
...
@@ -232,9 +238,9 @@ if [ -z "$packagemanOut" ]; then
...
@@ -232,9 +238,9 @@ if [ -z "$packagemanOut" ]; then
else
else
# generated function names - package manager is prefix
# generated function names - package manager is prefix
function2install
=
"
${
pkgmanager
}
Package
s
"
function2install
=
"
${
pkgmanager
}
.get
Package
List
"
_functionExists
"
${
pkgmanager
}
Status"
&&
functionStatus
=
"
${
pkgmanager
}
Status"
_functionExists
"
${
pkgmanager
}
.get
Status
Line
"
&&
functionStatus
=
"
${
pkgmanager
}
.get
Status
Line
"
_functionExists
"
${
pkgmanager
}
Critical"
&&
functionCritical
=
"
${
pkgmanager
}
Critical"
_functionExists
"
${
pkgmanager
}
.get
Critical
List
"
&&
functionCritical
=
"
${
pkgmanager
}
.get
Critical
List
"
# count of packages ... to install ... critical (centos only)
# count of packages ... to install ... critical (centos only)
typeset
-i
iPkg2Update
=
0
typeset
-i
iPkg2Update
=
0
...
@@ -242,7 +248,7 @@ else
...
@@ -242,7 +248,7 @@ else
# get list of packages 2 install
# get list of packages 2 install
packages2install
=
$(
$function2install
)
packages2install
=
$(
$function2install
)
iPkg2Update
=
$(
echo
"
$packages2install
"
|
wc
-l
)
iPkg2Update
=
$(
test
-n
"
$packages2install
"
&&
echo
"
$packages2install
"
|
wc
-l
)
# custom: status text
# custom: status text
test
-n
"
$functionStatus
"
&&
statusLabel
=
"[
$pkgmanager
]
$(
$functionStatus
)
"
test
-n
"
$functionStatus
"
&&
statusLabel
=
"[
$pkgmanager
]
$(
$functionStatus
)
"
...
@@ -259,6 +265,7 @@ else
...
@@ -259,6 +265,7 @@ else
else
else
ph.setStatusByLimit
${
iPkg2Update
}
${
iWarnLimit
}
${
iCriticalLimit
}
ph.setStatusByLimit
${
iPkg2Update
}
${
iWarnLimit
}
${
iCriticalLimit
}
fi
fi
ph.perfadd
"updates-available"
"
${
iPkg2Update
}
"
"
${
iWarnLimit
}
"
"
${
iCriticalLimit
}
"
# set label for status line
# set label for status line
if
[
-z
"
$statusLabel
"
]
;
then
if
[
-z
"
$statusLabel
"
]
;
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