oxidized: Oxidized unable to parse/search multiple tags in http api call from PRTG
I’m not a seasoned programmer, nor am I a linux engineer. I’m a network engineer with a goal, and I’m motivated.
We are running PRTG with a myriad of devices. I’m running Oxidized and using the PRTG API to retrieve a list of devices containing certain tags like fortios, procurve, aoscx, etc. (Since I believe this is the only way Oxidized is able to figure out the type of device and what script to use for logging in and making a backup?)
I’ve configured it according to the documentation, and that works. As long as I only have 1 tag per device.
source:
default: http
http:
url: [Redacted]
hosts_location: devices
scheme: https
secure: false
map:
name: device
ip: host
model: tags
group: group
model_map:
juniper: junos
cisco: ios
fortinet: fortios
aoscx: aoscx
procuve: procurve
aossw: procurve
When I have more than 1 tag per device in PRTG the tag field in the API call is shown as a single string separated by spaces.
For example:
{
"device": "LAB-XXX-XXX-SW01",
"device_raw": "LAB-XXX-XXX-SW01",
"host": "xxx.xxx.xxx.xxx",
"host_raw": "xxx.xxx.xxx.xxx",
"tags": "procurve switch",
"tags_raw": "procurve switch",
"group": "LAB-Probe",
"group_raw": "LAB-Probe"
},
Oxidized then doesn’t show the device in the webUI and is not contained in the backup. I’ve seen someone (although commented out) use a ruby regex in the config file after model: tags. (https://github.com/ytti/oxidized/issues/1999)
model: tags !ruby/regexp /\bios|\bdnos|\bnxos|\bftos|\bfortios|\betherhaul|\bsonicos|\bairfiber/ig
I tried this, (added procurve to the regex ofcourse) and it doesn’t work. all devices are added as Junos (default in the config file)
We use multiple tags for other automation tasks and right now I’d have to break them in order to automatically back-up devices with the correct model in oxidized.
Is there a way to use a regex? and so, what would be the right one to use?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 38 (17 by maintainers)
Commits related to this issue
- Allow using regexp for model_map and group_map keys Use case is that the source returns string which has unrelated and variant data but the actual model is included somewhere in this data For exampl... — committed to ytti/oxidized by ytti 2 years ago
- Allow using regexp for model_map and group_map keys Use case is that the source returns string which has unrelated and variant data but the actual model is included somewhere in this data For exampl... — committed to ytti/oxidized by ytti 2 years ago
- Stop normalising config keys into string We want to retain regexp keys for #3360 — committed to ytti/oxidized by ytti 2 years ago
- Allow using regexp for model_map and group_map keys (#3362) * Allow using regexp for model_map and group_map keys Use case is that the source returns string which has unrelated and variant data b... — committed to ytti/oxidized by ytti 2 years ago
The problem is in config.rb line 13
The
key_to_s: trueturns the Regexp into string, therefore we never run the Regexp match.I’m not sure why it is like that, it’s been like that since day1, but I for life of me can’t recall the reason for it. Possibly I thought about integer keys.
Can you try to remove
key_to_s: true, it should default to false. Then the Regexp should be preserved, unless we break something else that I cannot recallI’m not ok with that, sorry. Either I can work with the actual issue or we just have to postpone this for now, maybe one of us gets bright idea what we are doing wrong.
I am out of ideas, if the source.rb file is correct as in https://ytti.fi/ I think it should work and I don’t think I can debug it further without seeing the actual issue myself.
So if you can provide access to the device API call even better ssh access to the lab device seeing this issue, I’m afraid I can’t help. I have some ideas, but it’s too much trouble to troubleshoot back and forth over mail/issue.
Not sure what other tell you, I wrote test for it, and test passes.
I think your config is right for the proposed code.
Unclear why you see the actual string returned, possibly the key.class is never Regexp for reasons that would need troubleshooting with real data.