[ZBX-17317] unable to create item prototype key without quote while using regsub Created: 2020 Feb 13 Updated: 2020 Feb 19 Resolved: 2020 Feb 19 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 4.0.16 |
Fix Version/s: | None |
Type: | Problem report | Priority: | Trivial |
Reporter: | Levent Karakaş | Assignee: | Zabbix Support Team |
Resolution: | Won't fix | Votes: | 0 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Description |
Steps to reproduce:
being 50060E80123CEA20 discovered item example is: Expected: x[VSP F700.415594.50060E80123CEA20] How to get rid of double quotes in the key? Tried many other unsuccessful formulas :
trial #2: (We don't put outer quotes, escaped inner quotes) x[{ {#SYSTEMNAME}.regsub(\"(.*)\.(\d+)\", \1)}.{#DEVICEID}]result #2: x[\{VSP F700.415594.2.regsub(\"(.*)\.(\d+)\", \1)}.50060E80123CEA62] trial #3: (We don't put outer quotes, put inner quotes) x[{{#SYSTEMNAME} .regsub("(.*)\.(\d+)", \1)}.{#DEVICEID}] result #3: x[\{VSP F700.415594.1.regsub("(.*)\.(\d+)", \1)}.50060E80123CEA61]
Trial #3 is inspired by example in the manual but it doesn't work. https://www.zabbix.com/documentation/4.0/manual/config/macros/macro_functions?s[]=regsub
trial #4: (We escaped outer quotes, put inner quotes) x[\"{ {#SYSTEMNAME}.regsub("(.*)\.(\d+)", \1)}.{#DEVICEID}\"]result #4: [\"\{VSP F700.415594.19.regsub("(.*)\.(\d+)", \1)}.50060E80123CEA13\"] trial #5: (We escaped outer quotes, escaped inner quotes) x[\"{{#SYSTEMNAME} .regsub(\"(.*)\.(\d+)\", \1)}.{#DEVICEID}\"] result #5: [\"\{VSP F700.415594.19.regsub(\"(.*)\.(\d+)\", \1)}.50060E80123CEA13\"]
Whatever we tried we couldn't get x[VSP F700.415594.50060E80123CEA20]
|
Comments |
Comment by Glebs Ivanovskis [ 2020 Feb 13 ] |
Keys x["VSP F700.415594.50060E80123CEA20"] and x[VSP F700.415594.50060E80123CEA20] are semantically the same. You can leave double quotes, they should not matter.
You can try this one: x[{{#SYSTEMNAME}.regsub("(.*)\.(\d+)", \1)}.{#DEVICEID}] P.S. Looks like you have already tried it (trial #3). If it doesn't work, I'd say it's a bug. |
Comment by Levent Karakaş [ 2020 Feb 14 ] |
It is a zabbix trapper item prototype, would it be the reason? Zabbix trapper item prototypes doesn't support {$MACRO} too. |
Comment by Levent Karakaş [ 2020 Feb 14 ] |
Jira changed the code put some \ so i am sending results again in code blocks: #1 x["{{#SYSTEMNAME}.regsub(\"(.*)\.(\d+)\", \1)}.{#DEVICEID}"] x["VSP F700.415594.50060E80123CEA20"] #2 x[{{#SYSTEMNAME}.regsub(\"(.*)\.(\d+)\", \1)}.{#DEVICEID}] x[{VSP F700.415594.2.regsub(\"(.*)\.(\d+)\", \1)}.50060E80123CEA62] #3 x[{{#SYSTEMNAME}.regsub("(.*)\.(\d+)", \1)}.{#DEVICEID}] x[{VSP F700.415594.1.regsub("(.*)\.(\d+)", \1)}.50060E80123CEA61] #4 x[\"{{#SYSTEMNAME}.regsub("(.*)\.(\d+)", \1)}.{#DEVICEID}\"] x[\"{VSP F700.415594.19.regsub("(.*)\.(\d+)", \1)}.50060E80123CEA13\"] #5 x[\"{{#SYSTEMNAME}.regsub(\"(.*)\.(\d+)\", \1)}.{#DEVICEID}\"] x[\"{VSP F700.415594.19.regsub(\"(.*)\.(\d+)\", 1)}.50060E80123CEA13\"]
|
Comment by Glebs Ivanovskis [ 2020 Feb 14 ] |
No, item type should not matter. |
Comment by Glebs Ivanovskis [ 2020 Feb 16 ] |
I was wrong, #3 will not work. This is an item key, first thing Zabbix does is parses it as an item key splitting it into individual item key parameters. After that it will resolve macros in every item key parameter independently. There can be no comma in unquoted item key parameter, therefore in case of #3 Zabbix thinks there are two parameters: x[{{#SYSTEMNAME}.regsub("(.*)\.(\d+)", \1)}.{#DEVICEID}] '----------- 1st param -----------' '- 2nd param --' and there is only {#SYSTEMNAME} macro to be resolved in the next step in the 1st parameter, no regsub() since it is not enclosed properly into second pair of braces. To get your macro + macro function in one piece through item key parsing step, you have to make it a quoted item key parameter like in #1. But then Zabbix will keep them after macro resolution. leventkarakas, I'm sorry to say, but seems there is no way to get rid of quotes in the final key. |
Comment by Igor Gorbach (Inactive) [ 2020 Feb 17 ] |
Hello, Levent! As Glebs said - you can't to use comma character in item key Please read this: I close this ZBX, because there are not some bugs or issues in Zabbix Functionality here. Regards, Igor |
Comment by Levent Karakaş [ 2020 Feb 18 ] |
Not that we want to use comma, but we have to use comma for regsub since it requires a comma. Now we know that we can't use regsub in item prototype without quotes. It might at least help someone that gets stuck with this. Thanks for the effort. |
Comment by Levent Karakaş [ 2020 Feb 18 ] |
Is there way to escape comma inside regsub? |
Comment by Glebs Ivanovskis [ 2020 Feb 19 ] |
No, quoting the whole parameter is the only option. |