Skip to content
Discussion options

You must be logged in to vote

The issue is that Netbox's data for the hook only provides IPs in CIDR form, and Nagios does not like that.

Do you mean, you just want the plain IP address without prefix length? nbshell is a good way to exercise that, because even though jinja2 is not Python, all the properties and methods of objects are available.

# /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py nbshell
...
>>> i = IPAddress.objects.first()
>>> i
<IPAddress: 1.2.3.4/32>
>>> i.address
IPNetwork('1.2.3.4/32')
>>> i.address.ip
IPAddress('1.2.3.4')
>>> str(i.address.ip)
'1.2.3.4'
>>> print(i.address.ip)
1.2.3.4

Hence {{ foo.address.ip }} is just a trick you have to know for Netbox IPAddress objects, e.g. {{ dev…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@candlerb
Comment options

@j4w8n
Comment options

@j4w8n
Comment options

@candlerb
Comment options

@j4w8n
Comment options

Answer selected by j4w8n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants