AttributeError in shipped python-script for Mobilant (SMS-Delivery) after update to 2.3.0p11

CMK version: Checkmk Enterprise Edition 2.3.0p11
OS version: Debian 12

Error message: AttributeError: module ‘urllib’ has no attribute ‘urlencode’

Hello everybody,

today we updated our site to the most recent 2.3.0p11. Before our site was running some 2.2-version.

This topic gives a solution for people who have the same problem, and probably it is also interesting for the Checkmk-staff, as I think the adjustment I made should be delivered from checkmk directly, or at least noted as an “incompatible todo”-werk.

After the update, our notification-rules which are using the mobilant-plugin didn’t work anymore:

Seems like the script is now using python 3+. Before the update, it was running with python 2.7+ just fine.

In the Werks I saw some various changes about python. However, none of them are connected to this mobilant-plugin. Looking at the error AttributeError: module ‘urllib’ has no attribute ‘urlencode’, and the point that urlencode is found in urllib.parse towards Python 3+, I assume that the mobilant-pythonscript is now called with python3+.

So I think it is missing in the werk-list / missing as an “incompatible todo”-werk, or Checkmk forgot about updating the mobilant-pythonscript in omd/versions/2.3.0p11.cee/share/doc/check_mk/treasures/notifications/mobilant, so it runs under python 3+, without any manual adjustments.

The solution was changing some lines in the script:

  • Change the shebang from #!/usr/bin/env python to #!/usr/bin/env python3 (not important, but to make it clear which version is used)
  • Change the imports from import sys, os, urllib to import sys, os, urllib.parse, urllib.request
  • Change the usage of urlencode from urllib.urlencode to urllib.parse.urlencode
  • Change the usage of urlopen from urllib.urlopen to urllib.request.urlopen

Greetings, Julien

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.