Every time I restart my OpenVPN tunnel it increments interface's number and breaks MRTG graph for the interface.
IF-MIB::ifName.76 = STRING: tun_w
IF-MIB::ifName.77 = STRING: tun_w
Any way to fix it?
Write a script that regenerates your MRTG configuration whenever the interface is restarted. Also, adjust your MRTG configuration to target an interface based on the IP address. Specifcally if you use
In your main configuration file you have created by hand use the include directive to include another configuration file. Something like
Since you are using OpenVPN your might use the OpenVPN options
Compose your script that runs whenever the interface
When you create your MRTG cfg file, do not identify the interface by number. Instead, identify it by ifName or similar.
For example this identifies the device by ifName,
If the ifName is not unique, then try by ifDescr (use a backstroke to escape any spaces or colons in the description):
Alternatively, use ifType (prefix with %) or Ethernet address (prefix with !)
One of these should allow you to uniquely identify the interface despite its ifIndex changing frequently.