Problem:Univention-join failed - TYPE_OR_VALUE_EXISTS value #1 provided more than once

Problem

It looks like you’re encountering an LDAP error during the modification of a Univention object related to monitoring. The specific error is ldap.TYPE_OR_VALUE_EXISTS with the message Type or value exists: univentionMonitoringAlertHosts: value #1 provided more than once.

This error typically indicates that you are trying to add a value to an attribute that already exists or is not allowed to have multiple values. In your case, it seems to be related to the univentionMonitoringAlertHosts attribute.

Object exists: cn=UNIVENTION_LISTENER_MDB_MAXSIZE_METRIC_MISSING,cn=monitoring,dc=univention,dc=local
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/univention/admin/uldap.py", line 797, in modify
    return self.lo.modify(dn, changes, serverctrls=serverctrls, response=response, rename_callback=rename_callback)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 212, in _decorated
    return func(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 765, in modify
    self.modify_ext_s(dn, ml, serverctrls=serverctrls, response=response)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 212, in _decorated
    return func(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 824, in modify_ext_s
    rtype, rdata, rmsgid, resp_ctrls = self.lo.modify_ext_s(dn, ml, serverctrls=serverctrls)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 1253, in modify_ext_s
    return self._apply_method_s(SimpleLDAPObject.modify_ext_s,*args,**kwargs)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 1197, in _apply_method_s
    return func(self,*args,**kwargs)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 602, in modify_ext_s
    resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all=1,timeout=self.timeout)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 749, in result3
    resp_ctrl_classes=resp_ctrl_classes
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 756, in result4
    ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 329, in _ldap_call
    reraise(exc_type, exc_value, exc_traceback)
  File "/usr/lib/python3/dist-packages/ldap/compat.py", line 44, in reraise
    raise exc_value
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 313, in _ldap_call
    result = func(*args,**kwargs)
ldap.TYPE_OR_VALUE_EXISTS: {'desc': 'Type or value exists', 'info': 'univentionMonitoringAlertHosts: value #1 provided more than once'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 201, in save
    self.dn = self._orig_udm_object.modify()
  File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 650, in modify
    dn = self._modify(modify_childs, ignore_license=ignore_license, response=response, serverctrls=serverctrls)
  File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 1370, in _modify
    self.dn = self.lo.modify(self.dn, ml, ignore_license=ignore_license, serverctrls=serverctrls, response=response, rename_callback=wouldRe
name.on_rename)
  File "/usr/lib/python3/dist-packages/univention/admin/uldap.py", line 808, in modify
    raise univention.admin.uexceptions.ldapError(_err2str(msg), original_exception=msg)
univention.admin.uexceptions.ldapError: LDAP Error: Type or value exists: univentionMonitoringAlertHosts: value #1 provided more than once.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/share/univention-monitoring-client/migrate-nagios-services-to-alerts", line 121, in <module>
    main()
  File "/usr/share/univention-monitoring-client/migrate-nagios-services-to-alerts", line 116, in main
    obj.save()
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 207, in save
    ), sys.exc_info()[2])
  File "/usr/lib/python3/dist-packages/six.py", line 692, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 201, in save
    self.dn = self._orig_udm_object.modify()
  File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 650, in modify
    dn = self._modify(modify_childs, ignore_license=ignore_license, response=response, serverctrls=serverctrls)
  File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 1370, in _modify
    self.dn = self.lo.modify(self.dn, ml, ignore_license=ignore_license, serverctrls=serverctrls, response=response, rename_callback=wouldRe
name.on_rename)
  File "/usr/lib/python3/dist-packages/univention/admin/uldap.py", line 808, in modify
    raise univention.admin.uexceptions.ldapError(_err2str(msg), original_exception=msg)
univention.udm.exceptions.ModifyError: Error saving 'monitoring/alert' object at 'cn=UNIVENTION_DISK_ROOT,cn=monitoring,dc=univention,dc=local': 
LDAP Error: Type or value exists: univentionMonitoringAlertHosts: value #1 provided more than once.
30univention-monitoring-client.inst: Could not migrate nagios service to alerts

Solution

  1. Verify Correct DN: Ensure that the DN (Distinguished Name) provided to the udm monitoring/alert modify command is correct and corresponds to the entry you intend to modify. Double-check the DN to avoid any typos or mistakes.
 univention-ldapsearch -LLLb 'cn=UNIVENTION_DISK_ROOT_METRIC_MISSING,cn=monitoring,dc=univention,dc=local' univentionMonitoringAlertHosts
dn: cn=UNIVENTION_DISK_ROOT_METRIC_MISSING,cn=monitoring,dc=univention,dc=local                                                                                              
univentionMonitoringAlertHosts: cn=ucs5primary,cn=dc,cn=computers,dc=univention,dc=local
univentionMonitoringAlertHosts: cn=ucs5member,cn=memberserver,cn=computers,dc=univention,dc=local
univentionMonitoringAlertHosts: cn=ucs5member,ou=Mitgliedsserver,ou=Univention GmbH,dc=univention,dc=local
  1. Step-by-Step Approach: Instead of using a loop to modify multiple entries at once, try modifying one entry at a time. This can help isolate and address any issues with a specific entry.
udm monitoring/alert modify --dn 'cn=UNIVENTION_DISK_ROOT_METRIC_MISSING,cn=monitoring,dc=univention,dc=local' --remove 'assignedHosts=cn=ucs5member,ou=Mitgliedsserver,ou=Univention GmbH,dc=univention,dc=local'
  1. Loop: This loop is helpful for obtaining a list of DNs for further processing.If you have specific tasks or modifications you want to perform on each monitoring alert, you can include those actions within the loop.
for i in $(udm monitoring/alert list | grep DN: | sed 's/DN: //p'); do
    echo "Processing $i"
    # Add your additional commands or operations here
done
  1. Remove over loop: To remove the values from all the object under monitoring/alerts.
for i in $(udm monitoring/alert list | grep DN: | sed 's/DN: //p'); do
    echo "Processing $i"
    udm monitoring/alert modify --dn "$i" --remove 'assignedHosts=cn=ucs5member,ou=Mitgliedsserver,ou=Univention GmbH,dc=univention,dc=local' --remove 'assignedHosts=cn=ucs5member,cn=memberserver,cn=computers,dc=univention,dc=local' --remove 'assignedHosts=cn=ucs5member,cn=computers,dc=univention,dc=local'
done
Mastodon