Skip to content

Commit 45e3b53

Browse files
authored
Allow ignoring specific workloads (#40)
1 parent 166a6c5 commit 45e3b53

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

check_rancher2.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# You should have received a copy of the GNU General Public License along with this #
1919
# program; if not, see <https://www.gnu.org/licenses/>. #
2020
# #
21-
# Copyright 2018-2022 Claudio Kuenzler #
21+
# Copyright 2018-2023 Claudio Kuenzler #
2222
# Copyright 2020 Matthias Kneer #
2323
# Copyright 2021,2022 Steffen Eichler #
2424
# Copyright 2021 lopf #
@@ -51,6 +51,7 @@
5151
# 20220729 1.9.0 Output improvements (#32), show workload namespace (#33) #
5252
# 20220909 1.10.0 Fix ComponentStatus (#35), show K8s version in single cluster check #
5353
# 20220909 1.10.0 Allow ignoring statuses on workload checks (#29) #
54+
# 20230106 1.11.0 Allow ignoring workload names, TBD...
5455
##########################################################################################
5556
# (Pre-)Define some fixed variables
5657
STATE_OK=0 # define the exit code if status is OK
@@ -59,7 +60,7 @@ STATE_CRITICAL=2 # define the exit code if status is Critical
5960
STATE_UNKNOWN=3 # define the exit code if status is Unknown
6061
export PATH=/usr/local/bin:/usr/bin:/bin:$PATH # Set path
6162
proto=http # Protocol to use, default is http, can be overwritten with -S parameter
62-
version=1.10.0
63+
version=1.11.0
6364
##########################################################################################
6465
# functions
6566

@@ -164,7 +165,7 @@ Options:
164165
\t[ -n | --namespacename ] Namespace name (needed for specific workload or pod checks)
165166
\t[ -w | --workloadname ] Workload name (for specific workload check)
166167
\t[ -o | --podname ] Pod name (for specific pod check, this makes only sense if you use static pods)
167-
\t[ -i | --ignore ] Comma-separated list of status(es) to ignore (currently only supported in node check type)
168+
\t[ -i | --ignore ] Comma-separated list of status(es) to ignore (on node and workload check type) or list of workload name(s) to ignore (on workload check type)
168169
\t[ --cpu-warn ] Exit with WARNING status if more than PERCENT of cpu capacity is used (currently only supported in cluster specific node and cluster check type)
169170
\t[ --cpu-crit ] Exit with CRITICAL status if more than PERCENT of cpu capacity is used (currently only supported in cluster specific node and cluster check type)
170171
\t[ --memory-warn ] Exit with WARNING status if more than PERCENT of mem capacity is used (currently only supported in cluster specific node and cluster check type)
@@ -1001,6 +1002,10 @@ if [[ -z $workloadname ]]; then
10011002
i=0
10021003
for workload in ${workload_names[*]}; do
10031004
for status in ${healthstatus[$i]}; do
1005+
if [[ "${ignore}" =~ "${workload}" ]]; then
1006+
workloadignored[$i]="Workload ${workload} is ignored -"
1007+
continue
1008+
fi
10041009
if [[ ${status} = updating ]]; then
10051010
if [[ -n $(echo ${ignore} | grep -i ${status}) ]]; then
10061011
workloadignored[$i]="Workload ${workload} is ${status} but ignored -"

0 commit comments

Comments
 (0)