Skip to content

Commit

Permalink
infomaniak-*: Add new parameters --insecure --no-proxy --timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
markuslf committed Mar 14, 2024
1 parent bfa5487 commit cdac278
Show file tree
Hide file tree
Showing 12 changed files with 565 additions and 99 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Monitoring Plugins:
* grassfish-\*: Add new parameters `--insecure` `--no-proxy` `--timeout`
* haproxy-status: Add new parameters `--insecure` `--no-proxy`
* huawei-dorado-\*: Add new parameter `--insecure`
* infomaniak-\*: Add new parameters `--insecure` `--no-proxy` `--timeout`
* infomaniak-swiss-backup-products: Improve output
* journald-query: Remove hard-coded `--boot` parameter from query
* logfile: Add new parameters `--insecure` `--no-proxy` `--timeout`
Expand Down
9 changes: 7 additions & 2 deletions check-plugins/infomaniak-events/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,23 @@ Help

.. code-block:: text
usage: infomaniak-events [-h] [-V] [--always-ok] [--service SERVICE] --token
TOKEN [--test TEST]
usage: infomaniak-events [-h] [-V] [--always-ok] [--insecure] [--no-proxy]
[--service SERVICE] [--timeout TIMEOUT] --token TOKEN
[--test TEST]
Informs you about open events at Infomaniak.
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
--always-ok Always returns OK.
--insecure This option explicitly allows to perform "insecure" SSL
connections. Default: False
--no-proxy Do not use a proxy. Default: False
--service SERVICE Only report this service category (repeating). Example:
`--service=swiss_backup --service=public_cloud`. Default:
none (so report all)
--timeout TIMEOUT Network timeout in seconds. Default: 8 (seconds)
--token TOKEN Infomaniak API token
--test TEST For unit tests. Needs "path-to-stdout-file,path-to-
stderr-file,expected-retc".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
"--always-ok": {
"set_if": "$infomaniak_events_always_ok$"
},
"--insecure": {
"set_if": "$infomaniak_events_insecure$"
},
"--no-proxy": {
"set_if": "$infomaniak_events_no_proxy$"
},
"--service": {
"value": "$infomaniak_events_service$",
"repeat_key": true
},
"--timeout": {
"value": "$infomaniak_events_timeout$"
},
"--token": {
"value": "$infomaniak_events_token$"
}
Expand All @@ -28,6 +37,21 @@
},
{
"datafield_id": 3,
"is_required": "n",
"var_filter": null
},
{
"datafield_id": 4,
"is_required": "n",
"var_filter": null
},
{
"datafield_id": 5,
"is_required": "n",
"var_filter": null
},
{
"datafield_id": 6,
"is_required": "y",
"var_filter": null
}
Expand All @@ -47,10 +71,19 @@
"--always-ok": {
"set_if": "$infomaniak_events_windows_always_ok$"
},
"--insecure": {
"set_if": "$infomaniak_events_windows_insecure$"
},
"--no-proxy": {
"set_if": "$infomaniak_events_windows_no_proxy$"
},
"--service": {
"value": "$infomaniak_events_windows_service$",
"repeat_key": true
},
"--timeout": {
"value": "$infomaniak_events_windows_timeout$"
},
"--token": {
"value": "$infomaniak_events_windows_token$"
}
Expand All @@ -59,17 +92,32 @@
"disabled": false,
"fields": [
{
"datafield_id": 4,
"datafield_id": 7,
"is_required": "n",
"var_filter": null
},
{
"datafield_id": 5,
"datafield_id": 8,
"is_required": "n",
"var_filter": null
},
{
"datafield_id": 6,
"datafield_id": 9,
"is_required": "n",
"var_filter": null
},
{
"datafield_id": 10,
"is_required": "n",
"var_filter": null
},
{
"datafield_id": 11,
"is_required": "n",
"var_filter": null
},
{
"datafield_id": 12,
"is_required": "y",
"var_filter": null
}
Expand Down Expand Up @@ -143,7 +191,10 @@
"use_var_overrides": null,
"vars": {
"criticality": "A",
"infomaniak_events_always_ok": false
"infomaniak_events_always_ok": false,
"infomaniak_events_insecure": false,
"infomaniak_events_no_proxy": false,
"infomaniak_events_timeout": 8
},
"volatile": null,
"zone": null,
Expand Down Expand Up @@ -189,7 +240,10 @@
"use_var_overrides": null,
"vars": {
"criticality": "C",
"infomaniak_events_windows_always_ok": false
"infomaniak_events_windows_always_ok": false,
"infomaniak_events_windows_insecure": false,
"infomaniak_events_windows_no_proxy": false,
"infomaniak_events_windows_timeout": 8
},
"volatile": null,
"zone": null,
Expand All @@ -207,6 +261,24 @@
"uuid": "4e98a980-eff7-4d71-9afb-71817f460e82"
},
"2": {
"varname": "infomaniak_events_insecure",
"caption": "Infomaniak Events: Insecure?",
"description": "This option explicitly allows to perform \"insecure\" SSL connections.",
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean",
"format": null,
"settings": {},
"uuid": "9b7d00e9-065b-460e-9c73-94f63e501977"
},
"3": {
"varname": "infomaniak_events_no_proxy",
"caption": "Infomaniak Events: No Proxy?",
"description": "Do not use a proxy.",
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean",
"format": null,
"settings": {},
"uuid": "a8038cc2-3cd7-42a3-8457-f8288307f0f2"
},
"4": {
"varname": "infomaniak_events_service",
"caption": "Infomaniak Events: Service",
"description": "Only report this service category (repeating). Example: `--service=swiss_backup --service=public_cloud`. Default: none (so report all)",
Expand All @@ -217,7 +289,18 @@
},
"uuid": "9a649d44-1c9c-43d1-9c5f-e0b5eb15da9e"
},
"3": {
"5": {
"varname": "infomaniak_events_timeout",
"caption": "Infomaniak Events: Timeout",
"description": "Network timeout in seconds.",
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
"format": null,
"settings": {
"visibility": "visible"
},
"uuid": "a363e2d8-d2f9-4cdf-9d05-9e58c6ffb20c"
},
"6": {
"varname": "infomaniak_events_token",
"caption": "Infomaniak Events: Token",
"description": "Infomaniak API token",
Expand All @@ -228,7 +311,7 @@
},
"uuid": "8e095449-0ffc-427e-9353-49ea5fab4fde"
},
"4": {
"7": {
"varname": "infomaniak_events_windows_always_ok",
"caption": "Infomaniak Events: Always OK?",
"description": "Always returns OK.",
Expand All @@ -237,7 +320,25 @@
"settings": {},
"uuid": "4eb625e5-7da0-4d67-81cf-bf7718d50022"
},
"5": {
"8": {
"varname": "infomaniak_events_windows_insecure",
"caption": "Infomaniak Events: Insecure?",
"description": "This option explicitly allows to perform \"insecure\" SSL connections.",
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean",
"format": null,
"settings": {},
"uuid": "dc34616a-8434-4f39-936b-a0a43464e422"
},
"9": {
"varname": "infomaniak_events_windows_no_proxy",
"caption": "Infomaniak Events: No Proxy?",
"description": "Do not use a proxy.",
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean",
"format": null,
"settings": {},
"uuid": "77b6badb-9505-4166-af71-c9c21f71bbd8"
},
"10": {
"varname": "infomaniak_events_windows_service",
"caption": "Infomaniak Events: Service",
"description": "Only report this service category (repeating). Example: `--service=swiss_backup --service=public_cloud`. Default: none (so report all)",
Expand All @@ -248,7 +349,18 @@
},
"uuid": "a1cbcead-df18-46aa-ad90-16ad5c389b08"
},
"6": {
"11": {
"varname": "infomaniak_events_windows_timeout",
"caption": "Infomaniak Events: Timeout",
"description": "Network timeout in seconds.",
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
"format": null,
"settings": {
"visibility": "visible"
},
"uuid": "dac8584d-ef4a-42e1-bbb9-f00ca7ee260a"
},
"12": {
"varname": "infomaniak_events_windows_token",
"caption": "Infomaniak Events: Token",
"description": "Infomaniak API token",
Expand Down
40 changes: 38 additions & 2 deletions check-plugins/infomaniak-events/infomaniak-events
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ from lib.globals import (STATE_OK, STATE_UNKNOWN, # pylint: disable=C0413
STATE_WARN)

__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
__version__ = '2023120601'
__version__ = '2024031401'

DESCRIPTION = """Informs you about open events at Infomaniak."""

DEFAULT_INSECURE = False
DEFAULT_NO_PROXY = False
DEFAULT_TIMEOUT = 8


def parse_args():
"""Parse command line arguments using argparse.
Expand All @@ -50,6 +54,24 @@ def parse_args():
default=False,
)

parser.add_argument(
'--insecure',
help='This option explicitly allows to perform "insecure" SSL connections. '
'Default: %(default)s',
dest='INSECURE',
action='store_true',
default=DEFAULT_INSECURE,
)

parser.add_argument(
'--no-proxy',
help='Do not use a proxy. '
'Default: %(default)s',
dest='NO_PROXY',
action='store_true',
default=DEFAULT_NO_PROXY,
)

parser.add_argument(
'--service',
help='Only report this service category (repeating). '
Expand All @@ -60,6 +82,15 @@ def parse_args():
default=None,
)

parser.add_argument(
'--timeout',
help='Network timeout in seconds. '
'Default: %(default)s (seconds)',
dest='TIMEOUT',
type=int,
default=DEFAULT_TIMEOUT,
)

parser.add_argument(
'--token',
help='Infomaniak API token',
Expand Down Expand Up @@ -89,7 +120,12 @@ def main():

# fetch data
if args.TEST is None:
result = lib.base.coe(lib.infomaniak.get_events(args.TOKEN))
result = lib.base.coe(lib.infomaniak.get_events(
args.TOKEN,
insecure=args.INSECURE,
no_proxy=args.NO_PROXY,
timeout=args.TIMEOUT,
))
else:
# do not call the command, put in test data
stdout, stderr, retc = lib.test.test(args.TEST)
Expand Down
9 changes: 7 additions & 2 deletions check-plugins/infomaniak-swiss-backup-devices/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ Help
.. code-block:: text
usage: infomaniak-swiss-backup-devices [-h] [-V] --account-id ACCOUNT_ID
[--always-ok] [-c CRIT]
[--severity {warn,crit}] --token TOKEN
[--always-ok] [-c CRIT] [--insecure]
[--no-proxy] [--severity {warn,crit}]
[--timeout TIMEOUT] --token TOKEN
[--test TEST] [-w WARN]
Checks each device / slot of all your Infomaniak Swiss backup products via the
Expand All @@ -53,8 +54,12 @@ Help
--always-ok Always returns OK.
-c CRIT, --critical CRIT
Set the CRIT threshold as a percentage. Default: >= 95
--insecure This option explicitly allows to perform "insecure"
SSL connections. Default: False
--no-proxy Do not use a proxy. Default: False
--severity {warn,crit}
Severity for alerting other values. Default: warn
--timeout TIMEOUT Network timeout in seconds. Default: 8 (seconds)
--token TOKEN Infomaniak API token
--test TEST For unit tests. Needs "path-to-stdout-file,path-to-
stderr-file,expected-retc".
Expand Down
Loading

0 comments on commit cdac278

Please sign in to comment.