Replies: 6 comments 5 replies
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
It continues to say Results Pending Any suggestions?? |
Beta Was this translation helpful? Give feedback.
-
I think you are going about this the wrong way. Netbox is not a portal on collected monitoring information - in other words, it its not intended to collate or "pull" data in. Netbox is a source of truth, which can be used to "push" instructions to other systems and control automated processes. For more information, please read: With this view in mind, the right approach would be for Netbox to control LibreNMS (so when you add a device to Netbox, it automatically gets added to LibreNMS), not the other way round. You'd have to build that integration yourself, unless someone has already done it. Personally I use Prometheus for monitoring, and it collects the list of targets to monitor using netbox-plugin-prometheus-sd.
Which exact script, and which version of Netbox are you running? The Netbox models and internal APIs do change between versions, I suspect that the script you've found isn't compatible with the version of Netbox you're running. If the job stays in "Pending" indefinitely, make sure the "netbox-rq" worker process is running. |
Beta Was this translation helpful? Give feedback.
-
from django.utils.text import slugify
from dcim.choices import DeviceStatusChoices, SiteStatusChoices
from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Site
from extras.scripts import *
class NewBranchScript(Script):
class Meta:
name = "New Branch"
description = "Provision a new branch site"
field_order = ['switch_model', 'manufacturer', 'switch_count', 'site_name']
site_name = StringVar(
description="Name of the new site"
)
switch_count = IntegerVar(
description="Number of access switches to create"
)
manufacturer = ObjectVar(
model=Manufacturer,
required=False
)
switch_model = ObjectVar(
description="Access switch model",
model=DeviceType,
query_params={
'manufacturer_id': '$manufacturer'
}
)
def run(self, data, commit):
# Create the new site
site = Site(
name=data['site_name'],
slug=slugify(data['site_name']),
status=SiteStatusChoices.STATUS_PLANNED
)
site.save()
self.log_success(f"Created new site: {site}")
# Create access switches
switch_role = DeviceRole.objects.get(name='Access Switch')
for i in range(1, data['switch_count'] + 1):
switch = Device(
device_type=data['switch_model'],
name=f'{site.slug}-switch{i}',
site=site,
status=DeviceStatusChoices.STATUS_PLANNED,
device_role=switch_role
)
switch.save()
self.log_success(f"Created new switch: {switch}")
# Generate a CSV table of new devices
output = [
'name,make,model'
]
for switch in Device.objects.filter(site=site):
attrs = [
switch.name,
switch.device_type.manufacturer.name,
switch.device_type.model
]
output.append(','.join(attrs))
return '\n'.join(output) |
Beta Was this translation helpful? Give feedback.
-
I am new to this so i have installed " pip install netbox-plugin-prometheus-sd" Is there anything additional that i need to do Cause i do not see the the plugin |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Guys
I am net to network automation and would like some direction on home to integrate Netbox with LibreNMS being the source for the information that is provided to Netbox.
I have also tired creating Scripts such as the NewSiteScript however it does not seem to work....
Your assistance is highly Appreciated !!
Thanks in advance...
Beta Was this translation helpful? Give feedback.
All reactions