DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 6th October 2021
plepps plepps is offline
New User
 
Join Date: Mar 2020
Posts: 5
Default Logging interface state changes

Hello,

i would like to track media/state changes on my interfaces. I only need up/down messages in my message log.

I did not found anything for syslog settings.
ifstated may be a possible solution and my config looks like:

Code:
/etc/ifstated.conf

init-state auto
if em0.link.up
	run "logger -st ifstated 'em0 is active'"
if em0.link.down
	run "logger -st ifstated 'em0 is down'"
if em1.link.up
	run "logger -st ifstated 'em1 is active'"
if em1.link.down
	run "logger -st ifstated 'em1 is down'"
if em2.link.up
	run "logger -st ifstated 'em2 is active'"
if em2.link.down
	run "logger -st ifstated 'em2 is down'"
if em3.link.up
	run "logger -st ifstated 'em3 is active'"
if em3.link.down
	run "logger -st ifstated 'em3 is down'"

so far, so good. but if one interfcace changed the state, the current state from all other will be printed to messages log too. How can I prevet this, so only the changed interface is logged?

Thx for any hints.

Thomas
Reply With Quote
  #2   (View Single Post)  
Old 6th October 2021
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

Hello, and welcome!

The ifstated(8) man page says, "Whenever the value of a test associated with the current state changes, an event is triggered and the state's body is processed." So on a state change for any one interface, each of your if statements is tested in sequence, and a run statement is executed for every matching if.

Since ifstated() can run something you define with every state change, you might use it as a trigger to simply execute a local script that you write, which compares the current state of the interfaces with a last-known state previously recorded somewhere, such as in /var/run/<some.tracking.file>.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging question cal70 OpenBSD General 1 5th June 2020 08:04 PM
URL logging beavers OpenBSD General 15 9th March 2019 01:54 AM
Doas has logging? cpaulette OpenBSD General 1 13th March 2016 10:24 AM
Changing Which Interface Is Assigned To Network Interface (physical) Port EverydayDiesel OpenBSD General 2 18th July 2014 10:25 AM
pflog not logging. bsdnewbie999 OpenBSD General 9 13th March 2009 11:19 PM


All times are GMT. The time now is 09:25 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick