Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
My Nagios Plugin Wrapper
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
shore
My Nagios Plugin Wrapper
Commits
f5410600
Commit
f5410600
authored
3 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Allow for plugin handling chaining.
So you can insert mnpw between some other system and the plugin.
parent
06ea95db
No related branches found
No related tags found
No related merge requests found
Pipeline
#2024
failed
3 years ago
Stage: .pre
Stage: build
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.rst
+4
-1
4 additions, 1 deletion
README.rst
mnpw/__init__.py
+12
-0
12 additions, 0 deletions
mnpw/__init__.py
with
16 additions
and
1 deletion
README.rst
+
4
−
1
View file @
f5410600
...
@@ -19,7 +19,8 @@ Usage
...
@@ -19,7 +19,8 @@ Usage
.. code:: shell
.. code:: shell
usage: mnpw [-h] [-v] [-V] [-d] [-q] [-w] [-u] [-e] [-t TIMEOUT] command [arguments ...]
usage: mnpw [-h] [-v] [-V] [-c] [-d] [-q] [-w] [-u] [-e] [-t TIMEOUT]
command [arguments ...]
My Nagios plugin wrapper.
My Nagios plugin wrapper.
...
@@ -31,6 +32,8 @@ Usage
...
@@ -31,6 +32,8 @@ Usage
-h, --help show this help message and exit
-h, --help show this help message and exit
-v, --verbose Verbose output
-v, --verbose Verbose output
-V, --version show program's version number and exit
-V, --version show program's version number and exit
-c, --chain Echo the check output and exit with the same exit
code, allow for chaining with plugin handlers.
-d, --dry-run Dry-run, don't notify
-d, --dry-run Dry-run, don't notify
-q, --quiet, --silent
-q, --quiet, --silent
No output, except for errors.
No output, except for errors.
...
...
This diff is collapsed.
Click to expand it.
mnpw/__init__.py
+
12
−
0
View file @
f5410600
...
@@ -5,6 +5,7 @@ __version__ = "0.1.2"
...
@@ -5,6 +5,7 @@ __version__ = "0.1.2"
import
argparse
import
argparse
import
logging
import
logging
import
socket
import
socket
import
sys
import
requests
import
requests
...
@@ -41,6 +42,12 @@ def main(): # noqa: MC0001
...
@@ -41,6 +42,12 @@ def main(): # noqa: MC0001
action
=
"
version
"
,
action
=
"
version
"
,
version
=
f
"
mnpw version
{
__version__
}
"
,
version
=
f
"
mnpw version
{
__version__
}
"
,
)
)
parser
.
add_argument
(
"
-c
"
,
"
--chain
"
,
help
=
"
Echo the check output and exit with the same exit code, allow for chaining with plugin handlers.
"
,
# noqa: E501
action
=
"
store_true
"
,
)
parser
.
add_argument
(
parser
.
add_argument
(
"
-d
"
,
"
--dry-run
"
,
help
=
"
Dry-run, don
'
t notify
"
,
action
=
"
store_true
"
"
-d
"
,
"
--dry-run
"
,
help
=
"
Dry-run, don
'
t notify
"
,
action
=
"
store_true
"
)
)
...
@@ -77,6 +84,7 @@ def main(): # noqa: MC0001
...
@@ -77,6 +84,7 @@ def main(): # noqa: MC0001
default
=
nagios
.
DEFAULT_TIMEOUT
,
default
=
nagios
.
DEFAULT_TIMEOUT
,
)
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
log_level
=
logging
.
WARNING
# Default level.
log_level
=
logging
.
WARNING
# Default level.
if
args
.
verbose
and
args
.
quiet
:
if
args
.
verbose
and
args
.
quiet
:
parser
.
error
(
"
Can
'
t specify verbose and quiet output together.
"
)
parser
.
error
(
"
Can
'
t specify verbose and quiet output together.
"
)
...
@@ -115,6 +123,10 @@ def main(): # noqa: MC0001
...
@@ -115,6 +123,10 @@ def main(): # noqa: MC0001
if
args
.
errors
:
if
args
.
errors
:
notify
(
f
"
Check
{
args
.
command
}
on
{
HOSTNAME
}
status is invalid.
"
)
notify
(
f
"
Check
{
args
.
command
}
on
{
HOSTNAME
}
status is invalid.
"
)
if
args
.
chain
:
print
(
check
.
_stdout
)
# pylint: disable=protected-access
sys
.
exit
(
check
.
ExitCode
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
main
()
main
()
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