erigones / ludolph Goto Github PK
View Code? Open in Web Editor NEWPython Jabber Bot
License: Other
Python Jabber Bot
License: Other
Create remind command that will send message at specified time.
listen
setting to configuration file and remove pipe_file
listen
config option use UNIX or INET socketpipe_mode
option to socket_mode
and use it with UNIX socketWith small changes and some testing we should be able to support Windows operating system.
Known problems:
Using default config and setting nick in config is not working...
We should implement "outage" command, which will disable alerting of hosts I am doing maintenance on. This should be done via the Zabbix API.
Create new Zabbix plugin from existing base plugin and make it as required dependency
Add ability to load 3rd party plugins available in python path
Zabbix plugin should support obtaining graphs via Zabbix API. It should have the following synopsis:
graph <hostgroup/host> [@period]
keyword is a regular expression or pattern, which matches the graph for specific host/hostgroup.
period represents time period, e.g 1h will show data for the last hour.
Some interesting URLs:
https://www.zabbix.com/documentation/2.2/manual/api/reference/graph/get
https://github.com/sorah/hubot-zabbix/blob/master/scripts/hubot-zabbix.coffee
Add ability to tell Ludolph to add user to his roster list. Only admin should be able to add users.
ALERTS works fine when none present, but with existing alert command fails:
2015-04-18 19:08:00,546 INFO ludolph.plugins.zabbix_api: [1429384080.55-00013] Calling Zabbix API method "event.get"
2015-04-18 19:08:02,436 INFO ludolph.plugins.zabbix_api: [1429384080.55-00014] Zabbix API method "event.get" finished in 1.89011 seconds
2015-04-18 19:08:02,448 ERROR sleekxmpp.xmlstream.xmlstream: Error processing event handler: <bound method LudolphBot.message of <ludolph.bot.LudolphBot object at 0x2700e70>>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1645, in _threaded_event_wrapper
func(*args)
File "/usr/local/lib/python2.7/dist-packages/ludolph/bot.py", line 414, in message
out = f_cmd(msg)
File "/usr/local/lib/python2.7/dist-packages/ludolph/plugins/zabbix.py", line 40, in wrap
return fun(obj, msg, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ludolph/command.py", line 82, in wrap
out = fun(obj, msg, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ludolph/plugins/zabbix.py", line 203, in alerts
dt = self.zapi.get_datetime(trigger['lastchange'])
KeyError: 'lastchange'
2015-04-18 19:08:02,505 ERROR sleekxmpp.stanza.rootstanza: Error handling {jabber:client}message stanza
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1645, in _threaded_event_wrapper
func(*args)
File "/usr/local/lib/python2.7/dist-packages/ludolph/bot.py", line 414, in message
out = f_cmd(msg)
File "/usr/local/lib/python2.7/dist-packages/ludolph/plugins/zabbix.py", line 40, in wrap
return fun(obj, msg, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ludolph/command.py", line 82, in wrap
out = fun(obj, msg, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ludolph/plugins/zabbix.py", line 203, in alerts
dt = self.zapi.get_datetime(trigger['lastchange'])
KeyError: 'lastchange'
2015-04-18 19:08:02,511 ERROR sleekxmpp.basexmpp: 'lastchange'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1645, in _threaded_event_wrapper
func(*args)
File "/usr/local/lib/python2.7/dist-packages/ludolph/bot.py", line 414, in message
out = f_cmd(msg)
File "/usr/local/lib/python2.7/dist-packages/ludolph/plugins/zabbix.py", line 40, in wrap
return fun(obj, msg, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ludolph/command.py", line 82, in wrap
out = fun(obj, msg, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ludolph/plugins/zabbix.py", line 203, in alerts
dt = self.zapi.get_datetime(trigger['lastchange'])
KeyError: 'lastchange'
OUTAGE add command does not works, I am unabe to set outage:
R: outage add CASE
TARS: ERROR: Integer required
R: outage add 192.168.82.70
TARS: ERROR: Integer required
R: outage add 10084
TARS: ERROR: Host/Group not found
Unfortunately there is no error in log. List outage works fine.
Since alerts is not working I am not able to test ack, other commands seems to work fine.
Add new settings, which will affect affiliations and roles of Ludolph bot and room members.
Create new ES plugin from existing base plugin, this shouldnt be installed by default
Add ability to set avatar.
When Ludolph receives command to broadcast message, he broacsat to everyone in the roster, eg. to himself as well... This causes to execute broadcasted message as command, Ludolph does not understad and send help, problem is that ludolph is communicating with himself which creates an infinite loop.
Register a package with PyPI so the package can be installed using pip
Add ability for version command to support parameter for plugin name and return plugin version number so 3rd party plugins doesnt have to implement version command and can used built in one.
Ludolph responds with an error when crontab is disabled and user is setting at command:
ERROR ludolph.utils: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
File "/Users/ricco/Erigones/Ludolph/ludolph/utils.py", line 49, in wrap
return fun(*args, **kwargs)
File "/Users/ricco/Erigones/Ludolph/ludolph/bot.py", line 199, in _db_load_item
data = self.db.get(name, None)
AttributeError: 'NoneType' object has no attribute 'get
We shouldn't show at command in help when cron is not enabled, and when user executes it anyway tell him to contact admin to enable cron option.
When cron is enabled at command works fine.
@users
, @admins
keywords in settings fileLudolphBot.roster_cleanup() is not properly removing users from bots roster.
Document usage of all Ludolph command, webhooks and cron decorators and user exceptions.
Ludolph should support reload command, which will restart him. Optionally, this could be combined with upgrade. The implementation should be simple:
Some of the functions doesnt work in zabbix 2.4 there were depricated functions removed. We need to update Ludolph so it works properly with Zabbix 2.4. Currently login to 2.4.4 doesnt works.
https://www.zabbix.com/documentation/2.4/manual/api/changes_2.2_-_2.4
CRITICAL ludolph.bot: Unhandled exception!
Traceback (most recent call last):
File "./bin/ludolph", line 10, in
ludolph.bot.main()
File "/home/rkellner/Projects/Ludolph/ludolph/bot.py", line 456, in main
if xmpp.connect(tuple(address), use_tls=use_tls, use_ssl=use_ssl):
File "/usr/lib/python2.7/site-packages/sleekxmpp/clientxmpp.py", line 159, in connect
reattempt=reattempt)
File "/usr/lib/python2.7/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 432, in connect
func=self._connect)
File "/usr/lib/python2.7/site-packages/sleekxmpp/thirdparty/statemachine.py", line 69, in transition
func=func, args=args, kwargs=kwargs)
File "/usr/lib/python2.7/site-packages/sleekxmpp/thirdparty/statemachine.py", line 107, in transition_any
return_val = func(_args,__kwargs) if func is not None else True
File "/usr/lib/python2.7/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 519, in _connect
self.socket.connect(self.address)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(_args)
File "/home/rkellner/Projects/Ludolph/ludolph/bot.py", line 175, in shutdown
return self.abort()
AttributeError: 'LudolphBot' object has no attribute 'abort'
Even though the alert is customizable in zabbix, sometimes user uses the Do not disturb status in the xmpp client. In this case, ludolph should not notify user.
A nice to have feature would be that the missed alerts and reminders will be shown after the person changes state from DND.
At the moment, we can set outage only on one host or host group. It should be possible to set outage on multiple hosts in one command, e.g "outage HostA HostB HostD 60".
Add ability for admin, that he can send broadcast message to all users in Ludolph roster.
New version of SleekXMPP (released a few week ago) breaks Ludolph.
The following traceback is returned:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1601, in _threaded_event_wrapper
func(*args)
File "/usr/lib/python2.6/site-packages/ludolph/bot.py", line 412, in message
out = f_cmd(msg)
File "/usr/lib/python2.6/site-packages/ludolph/plugins/zabbix.py", line 41, in wrap
return fun(obj, msg, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/ludolph/command.py", line 81, in wrap
out = fun(obj, msg, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/ludolph/plugins/zabbix.py", line 183, in alerts
if trigger['error'] or int(trigger['value_flags']):
KeyError: 'value_flags'
Uptime should return information about bot's uptime and not of the server, where it runs.
At the moment, I have to manually remove outage from the list. It would be nice, if it was removed automatically.
Another cool feature would be automatic notification of outage's end.
Maximum character limit of Zabbix API actions is limited to 128. This should be fixed somehow.
How to reproduce:
and it should output something like this:
ERROR: Zabbix API error ((u'Error -32500: Application error., Value "'Maintenance for _XXXX - 1398111039'" is too long for field "name" - 194 characters. Allowed length is 128 characters. while sending {"params": {"maintenance_type": 0, "description": "[email protected]", "timeperiods": [{"timeperiod_type": 0, "start_date": "1398111039", "period": 3600}], "active_till": "1398114639", "active_since": "1398111039", "hostids": ["10355", "10449", "10451", "10452"], "name": "Maintenance for XXXX - 1398111039"}, "jsonrpc": "2.0", "method": "maintenance.create", "auth": "***", "id": 74}', -32500))
This happens to me once in a while, resulting in disconnect of the bot from the xmpp server. Bot has to be restarted manually then.
sep 29 18:02:11 mon ludolph[11243]: 2017-09-29 18:02:11,670 INFO sleekxmpp.xmlstream.xmlstream: Waiting for </stream:stream> from server
sep 29 18:02:17 mon ludolph[11243]: 2017-09-29 18:02:17,758 ERROR sleekxmpp.xmlstream.xmlstream: Could not connect to ----omitted----. Socket Error #111: Connection refused
sep 29 18:02:29 mon ludolph[11243]: 2017-09-29 18:02:29,414 INFO sleekxmpp.xmlstream.xmlstream: Negotiating TLS
sep 29 18:02:29 mon ludolph[11243]: 2017-09-29 18:02:29,414 INFO sleekxmpp.xmlstream.xmlstream: Using SSL version: TLS 1.0
sep 29 18:02:29 mon ludolph[11243]: 2017-09-29 18:02:29,485 WARNING sleekxmpp.xmlstream.cert: Could not find pyasn1 and pyasn1_modules. SSL certificate COULD NOT BE VERIFIED.
sep 29 18:02:29 mon ludolph[11243]: 2017-09-29 18:02:29,662 INFO sleekxmpp.features.feature_bind.bind: JID set to: ludolph@----omitted----
sep 29 18:02:29 mon ludolph[11243]: 2017-09-29 18:02:29,671 WARNING sleekxmpp.xmlstream.cert: Could not find pyasn1 and pyasn1_modules. SSL certificate expiration COULD NOT BE VERIFIED.
sep 29 18:02:59 mon ludolph[11243]: 2017-09-29 18:02:59,681 WARNING sleekxmpp.xmlstream.handler.waiter: Timed out waiting for IqWait_ff00ec05-153b-47af-a778-ff8da3ba834c-22
sep 29 18:03:29 mon ludolph[11243]: 2017-09-29 18:03:29,695 WARNING sleekxmpp.xmlstream.handler.waiter: Timed out waiting for IqWait_ff00ec05-153b-47af-a778-ff8da3ba834c-23
sep 29 18:03:29 mon ludolph[11243]: 2017-09-29 18:03:29,696 ERROR sleekxmpp.xmlstream.xmlstream: Error processing event handler: <bound method LudolphBot._session_start of <ludolph.bot.LudolphBot object at
sep 29 18:03:29 mon ludolph[11243]: Traceback (most recent call last):
sep 29 18:03:29 mon ludolph[11243]: File "/usr/lib/python2.7/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1708, in _event_runner
sep 29 18:03:29 mon ludolph[11243]: func(*args)
sep 29 18:03:29 mon ludolph[11243]: File "/usr/lib/python2.7/site-packages/ludolph/bot.py", line 795, in _session_start
sep 29 18:03:29 mon ludolph[11243]: self.client.get_roster()
sep 29 18:03:29 mon ludolph[11243]: File "/usr/lib/python2.7/site-packages/sleekxmpp/clientxmpp.py", line 263, in get_roster
sep 29 18:03:29 mon ludolph[11243]: response = iq.send(block, timeout, callback)
sep 29 18:03:29 mon ludolph[11243]: File "/usr/lib/python2.7/site-packages/sleekxmpp/stanza/iq.py", line 233, in send
sep 29 18:03:29 mon ludolph[11243]: raise IqTimeout(self)
sep 29 18:03:29 mon ludolph[11243]: IqTimeout
sep 29 18:03:29 mon ludolph[11243]: 2017-09-29 18:03:29,697 ERROR sleekxmpp.basexmpp: Request timed out: <iq type="get" id="ff00ec05-153b-47af-a778-ff8da3ba834c-23"><query xmlns="jabber:iq:roster" /></iq>
sep 29 18:03:29 mon ludolph[11243]: 2017-09-29 18:03:29,698 WARNING sleekxmpp.basexmpp: You should catch IqTimeout exceptions
Separate muc command into separate MUC plugin. Keep this plugin as a part of ludolph base plugins, just have it in separate file as this has potential to grow....
Unable to use tabulate dependency as it has error when run in python3, reported bug in developers bugtracker:
https://bitbucket.org/astanin/python-tabulate/issue/3/python32-error
Add support for OTR
Currently commands are case sensitive, but on android mobile clients by default starts with capital letter which results in Ludolph not recognizing the command.
I think to improve UX commands should not be case sensitive:
ERROR sleekxmpp.xmlstream.xmlstream: Error processing event handler: <bound method LudolphBot.message of <main.LudolphBot object at 0xa4fb1cc>>
Traceback (most recent call last):
File "/home/rkellner/Projects/Ludolph/envs3/lib/python3.2/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1659, in _event_runner
func(*args)
File "bot.py", line 163, in message
return f(msg)
File "/home/rkellner/Projects/Ludolph/envs3/lib/python3.2/site-packages/ludolph-0.3.0-py3.2.egg/ludolph/command.py", line 44, in wrap
return msg.reply(out).send()
File "/home/rkellner/Projects/Ludolph/envs3/lib/python3.2/site-packages/sleekxmpp/xmlstream/stanzabase.py", line 1575, in send
self.stream.send(self, now=now)
File "/home/rkellner/Projects/Ludolph/envs3/lib/python3.2/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1240, in send
top_level=True)
File "/home/rkellner/Projects/Ludolph/envs3/lib/python3.2/site-packages/sleekxmpp/xmlstream/tostring.py", line 113, in tostring
output.append(tostring(child, tag_xmlns, stream))
File "/home/rkellner/Projects/Ludolph/envs3/lib/python3.2/site-packages/sleekxmpp/xmlstream/tostring.py", line 110, in tostring
output.append(escape(xml.text, use_cdata))
File "/home/rkellner/Projects/Ludolph/envs3/lib/python3.2/site-packages/sleekxmpp/xmlstream/tostring.py", line 147, in escape
return ''.join(text)
TypeError: sequence item 0: expected str instance, int found
The commands plugin will make it possible to create new commands associated with OS commands/scripts only by editing ludolph's configuration file.
It will allow us to create an update command, thus it will surpass the issue #22.
Wrong pid is save into pidfile in daemon mode because it is saved before calling daemonize()
.
This is a regression from #46
Create RPM package for the project and add it to the Fedora (possibly EPEL).
Implement at command, using the internal cron thread. It should work like the classic unix at command.
Tabulate is great, but works only with monospaced fonts. Adding colors to some messages (especially zabbix commands output) would improve readability and maybe we could get rid of tabulate (#5).
I have setup an standard reminder, that works and also executes fine. However when trying to list existing reminders it doesnt works:
(10:47:46) Richard: remind add +1 test
(10:47:46) dunajko: Scheduled job ID 2 scheduled at 2017-02-15T10:48:00
(10:47:54) Richard: remind
(10:47:54) dunajko: 0 jobs are scheduled
Add unit tests for ludolph
init()
method to LudolphBot and LudolphPlugin classes. Will be used for config loading and called on init and reloadreload
sub-command to init scriptsAt the moment, ack will process only one event ID at the time. ack should allow us to enter multiple event IDs (ack 87336 87337 will process alerts with ID 87336 and 873367) and should also support globbing, e.g 8736* for all events ID 8733*.
Setting path to PID file in config without running in daemon mode does not create PID file.
# PID file location. Required in daemon mode
pidfile = /run/ludolph/ludolph.pid
admin_required
and parameter_required
decoratorsCommandPermissions
to namedtuple
and remove AttrDict
Ludolph does not start when log is set to DEBUG mode.
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.