-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from EncoreTechnologies/hotfix/fix-ci-errors
feature/zabbix-6-support-and-more-actions
- Loading branch information
Showing
13 changed files
with
245 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
description: "List all active triggers for a given host" | ||
enabled: true | ||
runner_type: orquesta | ||
entry_point: workflows/host_get_active_triggers.yaml | ||
name: host_get_active_triggers | ||
pack: zabbix | ||
parameters: | ||
host: | ||
type: string | ||
description: "Name of the Zabbix Host" | ||
required: True | ||
priority: | ||
type: array | ||
description: "List of priority numbers (severity) to get triggers for" | ||
required: False | ||
default: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
name: host_get_alerts | ||
pack: zabbix | ||
runner_type: python-script | ||
description: List all alerts for a given host ID in Zabbix | ||
enabled: true | ||
entry_point: call_api.py | ||
parameters: | ||
expandDescription: | ||
type: string | ||
description: "test flag" | ||
default: "" | ||
immutable: true | ||
filter: | ||
type: object | ||
description: Condition to filter the result | ||
token: | ||
type: string | ||
description: Encrypted access token to authenticate to ZabbixServer | ||
default: | | ||
{% if st2kv.user.zabbix.secret_token|string != '' %}{{ st2kv.user.zabbix.secret_token | decrypt_kv }}{% endif %} | ||
secret: true | ||
api_method: | ||
default: alert.get | ||
immutable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
name: host_get_events | ||
pack: zabbix | ||
runner_type: python-script | ||
description: List all events for a given host in Zabbix | ||
enabled: true | ||
entry_point: call_api.py | ||
parameters: | ||
expandDescription: | ||
type: string | ||
description: "test flag" | ||
default: "" | ||
immutable: true | ||
filter: | ||
type: object | ||
description: Condition to filter the result | ||
token: | ||
type: string | ||
description: Encrypted access token to authenticate to ZabbixServer | ||
default: | | ||
{% if st2kv.user.zabbix.secret_token|string != '' %}{{ st2kv.user.zabbix.secret_token | decrypt_kv }}{% endif %} | ||
secret: true | ||
api_method: | ||
default: event.get | ||
immutable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Licensed to the StackStorm, Inc ('StackStorm') under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from lib.actions import ZabbixBaseAction | ||
from pyzabbix.api import ZabbixAPIException | ||
|
||
|
||
class HostGetHostGroups(ZabbixBaseAction): | ||
|
||
def run(self, host_id, group_id): | ||
""" Gets the hostgroups of one or more Zabbix Hosts. | ||
""" | ||
self.connect() | ||
|
||
# Find hostgroups by host ids | ||
try: | ||
hostgroups = self.client.host.get( | ||
hostids=host_id, selectGroups='extend', output=['hostid', 'groups']) | ||
except ZabbixAPIException as e: | ||
raise ZabbixAPIException(("There was a problem searching for the host: " | ||
"{0}".format(e))) | ||
|
||
# if group ids are passed in we check to see if the host is a part of said groups | ||
if group_id: | ||
for group in hostgroups[0]["groups"]: | ||
if group["groupid"] == group_id: | ||
return hostgroups | ||
|
||
return (False, hostgroups) | ||
# otherwise just return the groups the host is in | ||
else: | ||
return hostgroups |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
name: host_get_hostgroups | ||
pack: zabbix | ||
runner_type: python-script | ||
description: Gets/Checks the hostgroups of one or more Zabbix Hosts | ||
enabled: true | ||
entry_point: host_get_hostgroups.py | ||
parameters: | ||
group_id: | ||
type: string | ||
description: "Optional Group ID to check if host is in" | ||
required: False | ||
host_id: | ||
type: string | ||
description: "Host ID to find hostgroups for" | ||
required: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
name: host_get_triggers | ||
pack: zabbix | ||
runner_type: python-script | ||
description: List all triggers for a given host in Zabbix | ||
enabled: true | ||
entry_point: call_api.py | ||
parameters: | ||
expandDescription: | ||
type: string | ||
description: "test flag" | ||
default: "" | ||
immutable: true | ||
filter: | ||
type: object | ||
description: Condition to filter the result | ||
token: | ||
type: string | ||
description: Encrypted access token to authenticate to ZabbixServer | ||
default: | | ||
{% if st2kv.user.zabbix.secret_token|string != '' %}{{ st2kv.user.zabbix.secret_token | decrypt_kv }}{% endif %} | ||
secret: true | ||
api_method: | ||
default: trigger.get | ||
immutable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
version: 1.0 | ||
|
||
description: List all active triggers for a given host | ||
|
||
input: | ||
- host | ||
- priority | ||
|
||
vars: | ||
- error: "" | ||
- triggers: [] | ||
- host_id: "" | ||
|
||
|
||
output: | ||
- triggers: "{{ ctx().triggers }}" | ||
|
||
tasks: | ||
get_zabbix_id: | ||
action: zabbix.host_get_id | ||
input: | ||
host: "{{ ctx().host }}" | ||
next: | ||
- when: "{{ succeeded() }}" | ||
publish: | ||
- host_id: "{{ result().result }}" | ||
do: | ||
- get_triggers | ||
- when: "{{ failed() }}" | ||
publish: | ||
- error: "{{ result().stderr }}" | ||
do: | ||
- fail | ||
|
||
get_triggers: | ||
action: zabbix.host_get_triggers | ||
input: | ||
filter: | ||
hostid: "{{ ctx().host_id }}" | ||
value: 1 | ||
priority: "{{ ctx().priority }}" | ||
next: | ||
- when: "{{ succeeded() }}" | ||
publish: | ||
- triggers: "{{ result().result }}" | ||
do: | ||
- noop | ||
- when: "{{ failed() }}" | ||
publish: | ||
- error: "{{ result().stderr }}" | ||
do: | ||
- fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ description: Zabbix Monitoring System | |
keywords: | ||
- zabbix | ||
- monitoring | ||
version: 1.0.0 | ||
version: 1.2.4 | ||
author: Hiroyasu OHYAMA | ||
email: [email protected] | ||
python_versions: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
py-zabbix==1.1.3 | ||
st2client | ||
git+https://github.com/EncoreTechnologies/py-zabbix.git | ||
pytz | ||
tzlocal |