Help with Alert for a specific port on a network switch

Hi,

I have a network switch that I’d like to monitor a specific port. Alerts/Transports are working as I get an Alert when I unplug the switch from the network (test switch).

I’d like to monitor a specific port (where I have a network printer attached). If this port is unplugged/goes down/etc I’d like to receive an alert.

Navigating to the interface graph for the specific port (4) and showing the ‘rrd graph command’ I see that the port has an ID of 933.

I’ve created a specific rule for this device and the rule is set as ‘ports.ifName equal id933’ or ‘ports.ifName equal 933’ as I’m not sure which is correct (maybe they are both wrong)?

I set Max alerts to 1 with a Delay of 5m and an Interval of 0. I only want to receive an alert when the port drops and if/when the port is back up.

When I unplug the device from port 4 and give librenms enough time to update polling, I see that the interface is showing as down in librenms, but the alert never arrives. I am not physically unplugging the device, I’m simply using the CLI command to shutdown the port, I don’t know if this matters.

Is ports.ifName the correct option to use or should I be using something else? Do I need to make any adjustments in any other settings on the device within LibreNMS?

Thanks.

Edit- I do believe that administrative down is different from a device being unplugged from the port, so I’ve edited my rule to include a port that I am physically able to unplug. I still can’t get the rule to work. I must be missing something simple because monitoring and alerting on a single port seems like it should be something very simple to configure.

Also, I found this in the librenms documentation, but it is for Any port and not a specific port.

Examples
Alert when:
Any port changes: ports.ifOperStatus != ‘up’

Try creating alert rule like below
for multiple ports, you can group them and write rule for port group

1 Like

This worked exactly like I want it to work. Maybe I didn’t get the correct combination when I was trying last week (I tried several). How do you know when to use macro.port_down vs another macro specifically when it seems that another macro would work?

I know I tried macro.port_down, but maybe the second/sub option was not correct.

Thanks.

you can check macro query from the built in rule collection.

regarding second option, ifname value contains gi0/2, eth2/3 etc, its not unique . port_id is unique value ( incremental ) assigned by librenms for each port

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.