How to test if a console session is active?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I use libvirt to manage a container based environment. Is there an efficient method for testing if someone has a console session open for a given container? The approach I'm using at the moment is to use lsof and check if there is an entry for the container's console pts device. For example, I can determine a container's console device from its xml definition:

# virsh dumpxml vm-00|grep -A 4 pty
    <console type='pty' tty='/dev/pts/3'>
      <source path='/dev/pts/3'/>
      <target type='lxc' port='0'/>
      <alias name='console0'/>
    </console>

Once I have pts device, I can do something like

# if lsof /dev/pts/3; then echo "Container vm-00 has an active console session"; fi

This all works fine but we've found that lsof is very expensive. Is there a more efficient means to make this active console check?

Peter


_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users



[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux