I use some python-scenario for rabbitMQ on my zabbix-server.
https://github.com/jasonmcintosh/rabbitmq-zabbix/blob/master/scripts/rabbitmq/api.py
And on my rabbitMQ-server i have too long queues names, more than 128 symbols, and my zabbix-server says me that the name is too long.
So I want to change the python-scenario, but i'm not a python developer.
I need help, how can i limit length string to 126 symbols?
I've added '%.126s' %
to line key = key.format(queue['vhost'], item, queue['name'])
, but it's not working.
Asked
Active
Viewed 73 times
0

perrfect
- 15
- 3
-
you can use string slicing, try: `key = key.format(queue['vhost'], item, queue['name'])[:126]` – Adam.Er8 Feb 10 '20 at 15:37
-
Does this answer your question? [Python truncate a long string](https://stackoverflow.com/questions/2872512/python-truncate-a-long-string) – Adam.Er8 Feb 10 '20 at 15:38
-
This decision set limit on the variable 'key', but i want to limit only on value the 'name' – perrfect Feb 10 '20 at 15:48