Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant hostaddress #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions mattermost.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def parse():
parser.add_argument('--hostalias', help='Host Alias', required=True)
parser.add_argument('--hostaddress', help='Host Address', required=True)
parser.add_argument('--hoststate', help='Host State')
parser.add_argument('--hostoutput', help='Host Output')
parser.add_argument('--hostoutput', help='Host Output', default='')
parser.add_argument('--servicedesc', help='Service Description')
parser.add_argument('--servicestate', help='Service State')
parser.add_argument('--serviceoutput', help='Service Output')
parser.add_argument('--serviceoutput', help='Service Output', default='')
parser.add_argument('--cgiurl', help='Link to extinfo.cgi on your Nagios instance')
parser.add_argument('--version', action='version',
version='% (prog)s {version}'.format(version=VERSION))
Expand All @@ -68,7 +68,10 @@ def emoji(notificationtype):

def text(args):
template_host = "__{notificationtype}__ {hostalias} is {hoststate}\n{hostoutput}" # noqa
template_service = "__{notificationtype}__ {hostalias} at {hostaddress}/{servicedesc} is {servicestate}\n{serviceoutput}" # noqa
template_service_with_alias = "__{notificationtype}__ {hostalias} at {hostaddress}/{servicedesc} is {servicestate}\n{serviceoutput}" # noqa
template_service_without_alias = "__{notificationtype}__ {hostaddress}/{servicedesc} is {servicestate}\n{serviceoutput}" # noqa
template_service = template_service_without_alias if args.hostalias == args.hostaddress else template_service_with_alias

if args.hoststate is not None:
template_cgiurl = " [View :link:]({cgiurl}?type=1&host={hostalias})"
elif args.servicestate is not None:
Expand Down