# Configuring FreeBSD to notify me when an interface is down



## sarashafek (Oct 25, 2022)

Hi!
I'm trying to configure my FreeBSD so that it notifies me when an interface goes down.
I've written this script in /etc/devd/interface.conf

```
notify 0 {
    match "system"        "IFNET";
    match "subsystem"     "(em0|em1)";
    match "type"          "LINK_DOWN";
    action "/usr/local/sbin/notifier.sh $subsystem"
}
```

Would this work? And if yes, what sort of response can I expect to see from FreeBSD when the interface goes down?

Thanks!


----------



## wolffnx (Oct 25, 2022)

sorry , I cant help you with devd , but you can write an script and put it in cron every x seconds or minutes to check the interface


----------



## SirDice (Oct 25, 2022)

Not sure if `subsystem` is correct. But the basic idea should work.

This is what I've used for a carp(4) connection. It automagically sends a notification to Zabbix about the state of the interface (BACKUP, MASTER) if it changes. Which allows me to keep track of which node is the active one. 


```
% cat /etc/devd/carp.conf
notify 0 {
        match "system"    "CARP";
        match "subsystem" "[0-9]+@[0-9a-z]+";
        match "type"      "(MASTER|BACKUP)";
        action "/root/bin/carpcontrol.sh $type $subsystem";
};
```


----------



## smithi (Oct 25, 2022)

sarashafek said:


> Hi!
> I'm trying to configure my FreeBSD so that it notifies me when an interface goes down.
> I've written this script in /etc/devd/interface.conf
> 
> ...



Semicolon needed after each line in notify 0 {...} including the last.

Whether and how it works will depend on your content in /usr/local/sbin/notifier.sh ?

From one I added years ago to monitor battery charge reports (ACPI CMBAT), write some stats to a log and a line to /var/log/messages:


```
#!/bin/sh
LOGGER="logger -t acpi_cmbat -p daemon.notice"
${LOGGER} "CMBAT notify = $1"
/root/bin/x200stat >> /root/acpi_cmbat_events.log
```

Or you could play a tune ...

cheers


----------

