ndrive / nagios-mattermost Goto Github PK
View Code? Open in Web Editor NEWSends Nagios notifications to Mattermost Chat.
License: MIT License
Sends Nagios notifications to Mattermost Chat.
License: MIT License
Hello guys,
./mattermost.py --url https://mattermostserver.local:8065/hooks/3wjtktky7jgk8gp6wtgmx5apay --username Nagios --iconurl http://mattermostserver.local/nagios.png --notificationtype PROBLEM --hostalias myserver --hostaddress 10.10.10.10 --hoststate DOWN
Returns that (not working) :
Traceback (most recent call last): File "./mattermost.py", line 100, in <module> response = request(args.url, data) File "./mattermost.py", line 93, in request response = urllib2.urlopen(req) File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 429, in open response = self._open(req, data) File "/usr/lib/python2.7/urllib2.py", line 447, in _open '_open', req) File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 1241, in https_open context=self._context) File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open raise URLError(err) urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
/usr/bin/curl -i -X POST -d 'payload={"icon_url": "mattermostserver.local/nagios.png", "username": "Nagios", "text": "$NOTIFICATIONTYPE$ $HOSTNAME$ $HOSTADDRESS$ $HOSTSTATE$ $HOSTOUTPUT$"}' https://mattermostserver.local:8065/hooks/3wjtktky7jgk8gp6wtgmx5apay --insecure
Returns that (working) :
HTTP/1.1 200 OK Content-Type: text/plain X-Request-Id: nq4uub5cm3yeif19h6x1u9539c X-Version-Id: 5.15.0.5.15.0.ebede62880690e623d77fb106dea2ce3.false Date: Thu, 31 Oct 2019 13:45:13 GMT Content-Length: 2
I read that using HTTPS trought proxy with urllib2 may cause issues... But my nagios server and my mattermost server are on the same subnet (no proxy conf).
Regards,
Tom
Please let me know if you need further information. Thank you.
VERSIONS:
python -c "import sys;print sys.executable; import urllib2; print urllib2.__version__" /usr/bin/python 2.7
ERROR:
[1555410523] wproc: NOTIFY job 74314 from worker Core Worker 27615 is a non-check helper but exited with return code 1 [1555410523] wproc: host=pr-glb-gal-leo-db-01; service=DB Files; contact=mattermost [1555410523] wproc: early_timeout=0; exited_ok=1; wait_status=256; error_code=0; [1555410523] wproc: stderr line 01: Traceback (most recent call last): [1555410523] wproc: stderr line 02: File "/usr/local/nagios/libexec/mattermost.py", line 108, in <module> [1555410523] wproc: stderr line 03: response = request(args.url, payload(args)) [1555410523] wproc: stderr line 04: File "/usr/local/nagios/libexec/mattermost.py", line 102, in request [1555410523] wproc: stderr line 05: response = urllib2.urlopen(req) [1555410523] wproc: stderr line 06: File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen [1555410523] wproc: stderr line 07: return opener.open(url, data, timeout) [1555410523] wproc: stderr line 08: File "/usr/lib/python2.7/urllib2.py", line 431, in open [1555410523] wproc: stderr line 09: response = self._open(req, data) [1555410523] wproc: stderr line 10: File "/usr/lib/python2.7/urllib2.py", line 454, in _open [1555410523] wproc: stderr line 11: 'unknown_open', req) [1555410523] wproc: stderr line 12: File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain [1555410523] wproc: stderr line 13: result = func(*args) [1555410523] wproc: stderr line 14: File "/usr/lib/python2.7/urllib2.py", line 1265, in unknown_open [1555410523] wproc: stderr line 15: raise URLError('unknown url type: %s' % type) [1555410523] wproc: stderr line 16: urllib2.URLError: <urlopen error unknown url type: [http>
Hey @andrefreitas @hugopeixoto and others!
First, hugely appreciate you sharing this project back with the world. Fantastic work!
I wanted to let you know about our plans moving to API v4:
To make the Mattermost API web service easier to use and to offer more powerful options for these integrations, Mattermost will be moving to a new API version soon. Highlights include:
We plan to release API version 4 on March 16th, with Mattermost server 3.7. While the current API version 3 will be supported until September 16th, we recommend you begin using API version 4 soon after its release.
API version 4 is an active and on-going project. If you're interested in helping contribute, please join our Mattermost community instance and the APIv4 channel.
We've prepared a contribution process for APIv4 and a progress tracker for new APIv4 enpoints to help you get started.
We're also open for suggestions on adding new API endpoints to help with your integration.
Thanks for sharing this project! We have earlier added your integration in the Mattermost App Directory.
Would you consider adding a license, such as a MIT or an Apache 2.0 license?
To do so, in GitHub you can click "Create new file" and name a file LICENSE.txt.
This will prompt GitHub to offer a license template.
If you use a license it would make it easy to add your work to other open source projects, and we'd love to include your work in ours.
Thanks kindly for your consideration and let me know if you have any questions!
[2017-11-13 06:31:33 +0100] warning/PluginNotificationTask: Notification command for object 'blahblahhostname!disk /mnt/backup' (PID: 24573, arguments: '/usr/lib/nagios/plugins/mattermost.py' '--channel' 'monit' '--hostalias' 'blahblahhostname' '--notificationtype' 'PROBLEM' '--servicedesc' 'disk /mnt/backup' '--serviceoutput' 'DISK CRITICAL - free space: /mnt/backup 41212 MB (3% inode=-)];' '--servicestate' 'CRITICAL' '--url' '(valid webhook)') terminated with exit code 1, output: Traceback (most recent call last):
File "/usr/lib/nagios/plugins/mattermost.py", line 107, in
response = request(args.url, payload(args))
File "/usr/lib/nagios/plugins/mattermost.py", line 101, in request
response = urllib2.urlopen(req)
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 475, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 558, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request
works after removing semicolon of output.
standard plugin output below:
# /usr/lib/nagios/plugins/check_disk /home DISK OK - free space: / 937211 MB (53% inode=96%);| /=798526MB;;;0;1828650 #
import urllib2
ModuleNotFoundError: No module named 'urllib2'
Thanks for this !!
How you define the url where Mattermost is located and the channel to notify the alerts?
Thanks ;)
hi @andrefreitas ,
thanks for your script anyway.
kindly need your suggestion.
im quite struggling with your script.
i try by execute :
python matternag.py --url http://chat.abc.io/abc/channels/trial- --hostalias server1 --notificationtype Problem --serviceoutput "Service Apache Down!"
the last line output are :
`
<script>
window.setup_login_page({"TeamDisplayName":"abc","TeamName":"abc","Title":"abc-group Chat Line - Login"});
</script>
since our mattermost server are working well, is there anything else i need to do ?
do i need to put my username and password inside the script ?
looking forward for your information.
many thanks
cheers,
henry
Hi,
I am running Nagios and Mattermost on Ubuntu 14.04 and i am new to Ubuntu. Can you guys please help me to integrate Nagios with MM.?
I am successful on enabling webhook URL in MM. However i am facing difficulties on NDrive/nagios-mattermost plugin installation with Nagios. So Please provide me the detailed steps on plugin installation.
Appreciate your responses.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.