Scheduled Report / Export of devices and Cables

982 views
Skip to first unread message

danny....@gmail.com

unread,
Jul 8, 2021, 8:47:52 AM7/8/21
to NetBox
Hello Folks,

I tried to get some information how to export all devices and cables into a csv or excel file, but I failed. Goal is to have an offline documation in case to a datacenter crash.

I want do schedule a report or an export (don't know which will be the right one) to automatically collect 
1. all device including its location, rack and position 
2. all cables including device A + port A and device B + port B

.. and put this information in a csv or excel file. After the job will copy the files into a share, where we mirrow the data to our local clients.

Does someone have such a report or can someone help me?

best regards
/Danny

Brian Candler

unread,
Jul 8, 2021, 9:08:50 AM7/8/21
to NetBox
A report is arbitrary python code and can do what you like, but normally only generates log messages (info / warning / fail) to highlight inconsistencies in your database.  Potentially it *could* write to one or more files as a side effect, but that's not how it's intended to be used.  You can run reports from a CLI script or the API.

An export template only iterates over one type of object at the top level (e.g. devices), but it can access information on related objects.  One export template for devices (giving location/rack/position) and one export template for cables (giving the terminations) sounds like what you want.  As for rendering export templates automatically, see #3665 - it looks like this will be available in upcoming Netbox 2.12.

Start with the device export, as that's really simple; there are examples in the documentation. For getting cable termination endpoints, I saw examples of this in in recent postings - search the group archive and also github discussions. "termination" should be a good keyword to search on.

Another option is to dump the entire postgres database periodically as described in "Replicating Netbox", and then restore it to some other instance e.g. in the cloud.

Brian Candler

unread,
Jul 8, 2021, 9:57:35 AM7/8/21
to NetBox
Custom Scripts can also generate arbitrary output like CSV - see the example given.

danny....@gmail.com

unread,
Jul 9, 2021, 9:35:50 AM7/9/21
to NetBox
Hello Brian,
thanks for quick reponse.

I already have an export template for devices and cables, yes this is a very simple way. But, as you said, I have to trigger it manually in the related sector in the UI.
Reply all
Reply to author
Forward
0 new messages