How to automate adding custom OIDs to specific servers?

Let me first explain what I’m doing, maybe there is a better way to do it.

On a linux server, I need to log ping response times from different interfaces on that server.

serverA-int0 ping 30ms
sererrA-int1 ping 120ms
and so on

I added a bash script that takes care of this and then added some snmpd extends.

I then went to the server and added the custom OID. Data shows up correctly and the graphs are good. The issue is that I need to replicate adding the custom OIDs to several other servers. I would do this with the API but I didn’t see any end points that would allow for this.

  1. Can I do this with the API?
  2. Is there another way to automate this?
  3. Should I rework what I’m doing?

I was looking at the POST data that’s sent when I add a custom OID. I’m guessing I can automate that but that makes me feel that I’m going about this the wrong way.

Does anyone have any insight on this?

I ended up capturing the POST data when I added the OID via the web GUI.

I took that and then made a python script with requests.

It seems to have worked.

@clovehitch: I am not using the API, but I suppose that it is not implemented right now. So as you guessed, doing the same POST as the webGUI is a way to acheive it. A better way would be to implement it into the API, of course.
LibreNMS is made by us, users. So if you feel extending the API, go for it, start a pull request in github and you’ll receive the help you need.

Is all of the API code in:

I don’t work with php at all but maybe I can copy and paste what needs to change.

I have no clue about it. Never played neither with the feature, nor with the code