Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
resmon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
mirrors
resmon
Commits
e038df46
Commit
e038df46
authored
4 years ago
by
Sergey Joseph Ivanov
Browse files
Options
Downloads
Patches
Plain Diff
option to keep unknown/absent as unknown in addition to OK and Critical
parent
5a70963e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
resources/check_resmon_metric
+16
-4
16 additions, 4 deletions
resources/check_resmon_metric
with
16 additions
and
4 deletions
resources/check_resmon_metric
+
16
−
4
View file @
e038df46
...
@@ -90,6 +90,14 @@ the check information can be fetched, but the metric itself isn't listed in
...
@@ -90,6 +90,14 @@ the check information can be fetched, but the metric itself isn't listed in
the XML output. If the check information cannot be fetched, then it is still a
the XML output. If the check information cannot be fetched, then it is still a
critical error.
critical error.
=item -k
Specify that an absence should be treated as an UNKNOWN value. By default, if a
metric is absent, it is treated as CRITICAL. A metric is considered absent if
the check information can be fetched, but the metric itself isn't listed in
the XML output. If the check information cannot be fetched, then it is still a
critical error.
=back
=back
=head1 THRESHOLDS
=head1 THRESHOLDS
...
@@ -188,8 +196,8 @@ use utils qw($TIMEOUT %ERRORS &print_revision &support);
...
@@ -188,8 +196,8 @@ use utils qw($TIMEOUT %ERRORS &print_revision &support);
delete
@ENV
{'
PATH
',
'
IFS
',
'
CDPATH
',
'
ENV
',
'
BASH_ENV
'};
delete
@ENV
{'
PATH
',
'
IFS
',
'
CDPATH
',
'
ENV
',
'
BASH_ENV
'};
my
(
$port
,
$host
,
$module
,
$check
,
$age
,
$warning
,
$critical
,
$equals
,
$regex
,
my
(
$port
,
$host
,
$module
,
$check
,
$age
,
$warning
,
$critical
,
$equals
,
$regex
,
$metric
,
$url
,
$allow_absent
)
=
(
81
,
undef
,
undef
,
undef
,
0
,
undef
,
undef
,
$metric
,
$url
,
$allow_absent
,
$keep_unknown
)
=
(
81
,
undef
,
undef
,
undef
,
0
,
undef
,
undef
,
undef
,
undef
,
0
);
undef
,
undef
,
0
,
0
);
sub
help
{
sub
help
{
print
"
Usage: $0 [options]
\n
";
print
"
Usage: $0 [options]
\n
";
...
@@ -205,6 +213,7 @@ sub help {
...
@@ -205,6 +213,7 @@ sub help {
print
"
-e | --equals metric must equal this value (numerical metrics only)
\n
";
print
"
-e | --equals metric must equal this value (numerical metrics only)
\n
";
print
"
-r | --regex regex match against the metric (string print metrics only)
\n
";
print
"
-r | --regex regex match against the metric (string print metrics only)
\n
";
print
"
-u | --url specify an alternate URL to fetch
\n
";
print
"
-u | --url specify an alternate URL to fetch
\n
";
print
"
-k | --keepunkown Treat absences as UNKNOWN (default: critical)
\n
";
print
"
-a | --allowabsent Treat absences as OK (default: critical)
\n
";
print
"
-a | --allowabsent Treat absences as OK (default: critical)
\n
";
exit
$ERRORS
{'
UNKNOWN
'};
exit
$ERRORS
{'
UNKNOWN
'};
}
}
...
@@ -294,6 +303,7 @@ GetOptions (
...
@@ -294,6 +303,7 @@ GetOptions (
"
e|equals=i
"
=>
\
$equals
,
"
e|equals=i
"
=>
\
$equals
,
"
r|regex=s
"
=>
\
$regex
,
"
r|regex=s
"
=>
\
$regex
,
"
u|url=s
"
=>
\
$url
,
"
u|url=s
"
=>
\
$url
,
"
k|keepunknown
"
=>
\
$keep_unknown
,
"
a|allowabsent
"
=>
\
$allow_absent
);
"
a|allowabsent
"
=>
\
$allow_absent
);
unless
(
defined
$host
&&
defined
$module
&&
defined
$check
)
{
unless
(
defined
$host
&&
defined
$module
&&
defined
$check
)
{
...
@@ -322,10 +332,10 @@ eval {
...
@@ -322,10 +332,10 @@ eval {
my
$res
=
$ua
->
request
(
$t
);
my
$res
=
$ua
->
request
(
$t
);
my
$now_after
=
Time::HiRes::
time
();
my
$now_after
=
Time::HiRes::
time
();
die
"
could not fetch http://
$host
:
$port$url
-
"
.
$res
->
status_line
.
"
\n
"
die
"
could not fetch http://
$host
:
$port$url
-
"
.
$res
->
status_line
.
"
\n
"
unless
(
$res
&&
$res
->
is_success
)
;
unless
(
$res
&&
(
$res
->
is_success
||
$keep_unknown
||
$allow_absent
)
)
;
# Parse the xml
# Parse the xml
eval
{
$ref
=
$xs
->
XMLin
(
$res
->
content
,
ForceArray
=>
1
);
};
eval
{
$ref
=
$xs
->
XMLin
(
$res
->
content
,
ForceArray
=>
1
);
};
die
"
error parsing XML
\n
"
if
(
$@
);
die
"
error parsing XML
\n
"
unless
(
!
(
$@
)
||
$keep_unknown
||
$allow_absent
);
# Debugging
# Debugging
# use Data::Dumper;
# use Data::Dumper;
...
@@ -361,6 +371,8 @@ eval {
...
@@ -361,6 +371,8 @@ eval {
if
(
!
defined
(
$metricval
))
{
if
(
!
defined
(
$metricval
))
{
if
(
$allow_absent
)
{
if
(
$allow_absent
)
{
$state
=
"
OK
";
$state
=
"
OK
";
}
elsif
(
$keep_unknown
)
{
$state
=
"
UNKNOWN
";
}
else
{
}
else
{
$state
=
"
CRITICAL
";
$state
=
"
CRITICAL
";
}
}
...
...
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