Comments (4)
So hacking at the code I managed to get first issue to work. The issue is within zabbixconn.py.
Line 115 in get_mediatype_id reads:
result = self.conn.mediatype.get(filter={'description': description})
I changed to:
result = self.conn.mediatype.get(filter={'name': description})
Before I did that I did try setting the description of the media types to match the names but it still always found the wrong one.
from zabbix-ldap-sync.
Ok so that this may help someone else gonna paste this here. It is messy but it works. The second issue is because when you update a user you have to pass ALL of the media types for that user or it will remove any that you are not passing. I changed the code to pull the current media types that dont match the one we are changing and append that to the update.
Here is what I changed in zabbixconn.py to fix the second issue:
def update_media(self, user, description, sendto, media_opt):
"""
Adds media to an existing Zabbix user
Args:
user (dict): A dict containing the user details
description (str): A string containing Zabbix media description
sendto (str): A string containing address, phone number, etc...
media_opt (dict): Media options
"""
userid = self.get_user_id(user)
mediatypeid = self.get_mediatype_id(description)
if mediatypeid:
media_temp = {
'mediatypeid': mediatypeid,
'sendto': sendto,
'active': '0',
'severity': '63',
'period': '1-7,00:00-24:00'
}
media_temp.update(media_opt)
currmediatemp = self.conn.user.get(selectMedias=['mediatypeid','sendto','active','severity','period'],userids=userid,output='medias')
self.logger.debug('update_media - currmediatemp %s' % (currmediatemp))
currmedia = currmediatemp[0]['medias']
self.logger.debug('update_media - currmedia %s' % (currmedia))
media_defaults = [media_temp]
for m in currmedia:
if m['mediatypeid'] != mediatypeid:
media_defaults.append(m)
self.logger.debug('update_media - userid %s - mediatypeid %s - media_defaults %s' % (userid, mediatypeid, media_defaults))
if self.conn.api_version() >= "3.4":
result = self.conn.user.update(userid=str(userid), user_medias=media_defaults)
else:
self.delete_media_by_description(user, description)
result = self.conn.user.updatemedia(users=[{"userid": str(userid)}], medias=media_defaults)
else:
result = None
return result
from zabbix-ldap-sync.
Thank you.
Can you send your contribution as a pull request?
from zabbix-ldap-sync.
solved
from zabbix-ldap-sync.
Related Issues (20)
- Not able to delete users HOT 3
- hardcoded .lower() for usernames in zabbixconn.py HOT 1
- Script adds users to random group HOT 1
- [Feature] Add role lookups HOT 1
- --deleteorphans does not work without alldirusergroup HOT 5
- wildcard groups and zabbix 4.4 HOT 5
- Multiple media HOT 1
- Issue with Zabbix 6.0 HOT 3
- zabbix version check problem HOT 1
- zabbix version value (ValueError) HOT 1
- requests.exceptions.SSLError HOT 5
- problem with zabbix 4.0,4.4 - script tries to use role instead type HOT 2
- Exception: Ambiguous media 'Email' found, 7 different medias HOT 5
- Correct LDAP Credentials and Validated but getting error ldap.INVALID_CREDENTIALS HOT 1
- Not working with zabbix 6.0 HOT 6
- Unable to delete users from group if 'alldirusergroup' option isn't set. HOT 2
- KeyError during update of media
- Problem with Zabbix 6.4 HOT 1
- Add option to trim full DN HOT 1
- Debian packaging: new release expected soon? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zabbix-ldap-sync.