Perform actions based on changes in Kernel states

Hi

I am reading the HA functionality of the ctl(4) driver, i have created two nodes that have high availability on the LUN that I expose with iscsid(8) everything works as expected, when the primary node goes down the kernel of the secondary node reports that the state of kern.cam.ctl.ha_link changes to 1, indicating that the connection with the primary node has been lost.

So for the secondary node to take the role of primary I need to change the status of kern.cam.ctl.ha_role to 0 Then the data starts flowing again, but I have to make that change manually with sysctl(8).

Having this problem, my question is the following, is there a way to automate a process according to the changes in the kernel states? The only thing I can think of is to create a script that checks the status of kern.cam.ctl.ha_role and schedule it in cron every second for example.

I have a feeling that what I say is not correct and it is not the best way to do it. I have read a project called BeaST where implement a quorum disk, I assume that implementing that type of solution would be the most correct.

Thanks.
 
is there a way to automate a process according to the changes in the kernel states?

Do you want to automate a userland process?

1. Check kqueue.

2. devd() can run a command once a kernel event occurs.

3. Or create a file under /dev/. The userland process can read the event from it.

4. If it is a sysctl_proc, the sysctl could initiate an aforementioned kernel event each times it changes from 0 to 1 or vice versa.

Maybe this helps.
 
I am going to implement the option that you have proposed, on the other hand I think I will create a new thread in the Storage subforum with the complete procedure.
 
I'm trying to add the notification in devd.conf but I don't know how to implement it, according to the manual devd.con(5)

System Subsystem Type Description
CAM Events related to the cam(4) system.
CAM periph Events related to peripheral devices.
CAM periph error Generic errors.
CAM periph timeout Command timeouts.

I am intending to take action on kern.cam.ctl.ha_link I have the following:

notify 0 {
match "system" "CAM";
action "my action";
};

But I don't know how to specifically add it's kernel state, On the other hand, even if I managed to manipulate it, I have realized that it does not make sense for the implementation since it is not enough to determine if a node is down, but I will add that in the new thread, I could do it to resolve this thread and the doubt.
 
Back
Top