Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Service sensor and VM Service sensor don't detect running services #36

Closed
ond000 opened this issue Dec 29, 2024 · 39 comments
Closed
Labels
bug Something isn't working

Comments

@ond000
Copy link
Contributor

ond000 commented Dec 29, 2024

Describe the bug
Docker Service sensor is off even if I have running Docker containers and VM Service sensor is off too, even if I have running VM service. This behavior start from update of integration to version 2024.12.28.

From that time I can see in HA Core logs error "Command failed: open failed" from Unraid integration, but without more details in log, so I don't know if there is any connection between that.

Expected behavior
Sensors should be in on state

Screenshots

Unraid (please complete the following information):

  • Versions 6.12.13 and 6.2.14

Home Assistant (please complete the following information):

  • Version 2024.12.5

Home Assistant installation type (please complete the following information):

  • Docker / Container
  • Virtual Machine
  • Raspberry Pi

Priority of Request

  • High
  • Medium
  • Low

Additional context

@ond000 ond000 added the bug Something isn't working label Dec 29, 2024
@domalab
Copy link
Owner

domalab commented Dec 29, 2024

Due to the scope of this update, you may need to reinstall the integration and clear your browser cache for everything to work smoothly. There is a high chance that your existing entities will not be migrated across and any automations will be affected.

If you enable debug logging in the integration, reload the integration and then check the logs you should see if anything failed or loaded successfully

@mcolli31
Copy link

I'm having the same issue with The VM and Docker services not being recognised as running. Integration completely removed, deleted and re installed from HACS cache cleared in multiple browsers. Debug log doesn't seem to help as far as I can see, just has:

2024-12-30 19:33:28.773 DEBUG (MainThread) [custom_components.unraid.api.vm_operations] Checking VM service status
2024-12-30 19:33:28.790 DEBUG (MainThread) [custom_components.unraid.api.vm_operations] VM service is not running

and similar for the docker.

If I roll back to the previous integration version they are all detected and controllable it's only 2024.12.28 that is not detecting the VM or docker service.

I run HASS on a VM on my unraid server.

@domalab
Copy link
Owner

domalab commented Dec 30, 2024

That's weird!

Im running it from my HA dev container on laptop and production HA container on Unraid. No issues.

@artifactdev

This comment has been minimized.

@alasta
Copy link

alasta commented Dec 31, 2024

Hi,

I have the same issue and disk:
2024-12-31 14:38:01.098 DEBUG (MainThread) [custom_components.unraid.api.docker_operations] Docker service is not running, no containers available 2024-12-31 14:38:01.119 DEBUG (MainThread) [custom_components.unraid.helpers] No disk information found in system stats
Same after reinstall.

@domalab

This comment was marked as off-topic.

@domalab
Copy link
Owner

domalab commented Jan 1, 2025

@ond000 @mcolli31 I'm stumped about this issue

I fired up my raspberry pi running latest HA version, installed the latest unraid release and works without issues.
Screenshot 2025-01-01 at 11 08 03 am

Screenshot 2025-01-01 at 11 29 13 am

Screenshot 2025-01-01 at 11 08 46 am

All controls are visible
Screenshot 2025-01-01 at 10 51 39 am
Screenshot 2025-01-01 at 10 59 07 am

Docker and VM Services are running fine
Screenshot 2025-01-01 at 11 00 47 am

When I delete the VM and reload the integration it shows the entity is not available and can be removed which is fine and working as expected.
Screenshot 2025-01-01 at 11 02 27 am

VM Service then shows Not Running which is normal as no VMs are available or deployed.
Screenshot 2025-01-01 at 11 03 21 am

@alasta
Copy link

alasta commented Jan 1, 2025

Hi,
I have the same version of HA and plugin :
image
image
I have add installed "dockersocket" but not activate "Docker insights beta".
The dockers don't show in HA :
image
image
image
The plugin shows the docker service stopped.

@domalab
Copy link
Owner

domalab commented Jan 1, 2025

Can you enable debug logging in the integration, reload it and send the debug log please?

@alasta
Copy link

alasta commented Jan 1, 2025

Hi,
i have grep "unraid" in my debug log. I also have one stopped VM.
Thank you !
unraid.log

@domalab
Copy link
Owner

domalab commented Jan 1, 2025

Hi, i have grep "unraid" in my debug log. I also have one stopped VM. Thank you ! unraid.log

Can you please run this diagnostic command from unraid terminal console?

echo "=== VM Service Status ==="
/etc/rc.d/rc.libvirt status
echo
echo "=== Docker Service Status ==="
/etc/rc.d/rc.docker status
echo
echo "=== Service Processes ==="
ps aux | grep -E 'docker|libvirt' | grep -v grep
echo
echo "=== Docker Container List ==="
docker ps -a

And also these commands

# Test VM command
virsh list --all --name

# Test Docker command
docker ps -a --format '{{.Names}}|{{.State}}|{{.ID}}|{{.Image}}'

Please provide the outputs

@alasta
Copy link

alasta commented Jan 2, 2025

Yes, this is the outputs commands.
unraid-cmd1.log

@mcolli31
Copy link

mcolli31 commented Jan 2, 2025

@domalab I'm not a programmer, I blunder my through most things, so I wish I could help more. I wonder if there is some issue with integration when HA is run as a VM on the unraid server? I note that both OP and I have it set up this way while you have it on a separate device.
Otherwise as far as I can tell (and I'm just guessing here) looking through the code I assume the VM part starts by running "/etc/rc.d/rc.libvirt status" and expecting a response. If I run that command in the the unraid terminal I get no response. I don't see that command in the previous versions. Could that be part of the issue? Although running the same for the docker does return a service running message so I'm clutching at straws.

Happy to help hunt down the issue but not sure how much help I can be.

@ond000
Copy link
Contributor Author

ond000 commented Jan 2, 2025

@domalab I'm not a programmer, I blunder my through most things, so I wish I could help more. I wonder if there is some issue with integration when HA is run as a VM on the unraid server? I note that both OP and I have it set up this way while you have it on a separate device. Otherwise as far as I can tell (and I'm just guessing here) looking through the code I assume the VM part starts by running "/etc/rc.d/rc.libvirt status" and expecting a response. If I run that command in the the unraid terminal I get no response. I don't see that command in the previous versions. Could that be part of the issue? Although running the same for the docker does return a service running message so I'm clutching at straws.

Happy to help hunt down the issue but not sure how much help I can be.

It's probably not because you have it on the same device, I have HA installed on an Rpi4 and I'm monitoring two Unraid servers.

@domalab
Copy link
Owner

domalab commented Jan 3, 2025

@domalab I'm not a programmer, I blunder my through most things, so I wish I could help more. I wonder if there is some issue with integration when HA is run as a VM on the unraid server? I note that both OP and I have it set up this way while you have it on a separate device. Otherwise as far as I can tell (and I'm just guessing here) looking through the code I assume the VM part starts by running "/etc/rc.d/rc.libvirt status" and expecting a response. If I run that command in the the unraid terminal I get no response. I don't see that command in the previous versions. Could that be part of the issue? Although running the same for the docker does return a service running message so I'm clutching at straws.

Happy to help hunt down the issue but not sure how much help I can be.

Shouldn't matter if you are running HA in docker, VM or bare metal. I'm running my HA instance on UNRAID in docker container. The integration connects to UNRAID via SSH and executes the commands on UNRAID, gets the return status and updates the integration sensors, switches, etc.

The updated code basically does a validation if you use VM service or not.

  1. First check if VM system is enabled via libvirt y running /etc/rc.d/rc.libvirt status
root@Cube:~# /etc/rc.d/rc.libvirt status
libvirt daemon is currently running.
root@Cube:~# /etc/rc.d/rc.libvirt status
libvirt daemon is not running.
  1. If service check fails or service isn't running, VMs are disabled
  2. And then only proceed with VM checks if service is running and enabled

Previous code didn't have this and issues were logged by users that dont use VM and service was stopped then it logged errors in HA

@domalab
Copy link
Owner

domalab commented Jan 3, 2025

@domalab I'm not a programmer, I blunder my through most things, so I wish I could help more. I wonder if there is some issue with integration when HA is run as a VM on the unraid server? I note that both OP and I have it set up this way while you have it on a separate device. Otherwise as far as I can tell (and I'm just guessing here) looking through the code I assume the VM part starts by running "/etc/rc.d/rc.libvirt status" and expecting a response. If I run that command in the the unraid terminal I get no response. I don't see that command in the previous versions. Could that be part of the issue? Although running the same for the docker does return a service running message so I'm clutching at straws.

Happy to help hunt down the issue but not sure how much help I can be.

For my own sanity I tested this today from a HA VM running on UNRAID using latest source code

Screenshot 2025-01-03 at 1 39 26 pm

VM is using Network Source br0 to get its own IP from the network.

Screenshot 2025-01-03 at 1 37 44 pm

I can see container switches

Screenshot 2025-01-03 at 1 41 44 pm

And the Home Assistant VM container switch

Screenshot 2025-01-03 at 1 42 25 pm

Diagnostics is also showing Containers and VM service running

Screenshot 2025-01-03 at 1 45 04 pm

@ond000
Copy link
Contributor Author

ond000 commented Jan 3, 2025

It's strange.

I used latest code, VM service is enabled.

Snímek obrazovky 2025-01-03 v 11 24 25

VM use network br0 to and is enabled.

Snímek obrazovky 2025-01-03 v 11 26 57

But I don't see VM switch and VM service sensor is in off state.

Snímek obrazovky 2025-01-03 v 11 28 32

Same situation for docker.

For sure, I just tried to run command "/etc/rc.d/rc.libvirt status" and I don't got any response.

Snímek obrazovky 2025-01-03 v 11 29 49

Same situation is at both servers.

@ElVit

This comment has been minimized.

@ond000
Copy link
Contributor Author

ond000 commented Jan 3, 2025

Hi, I have the same issue. In the home assitant log I can see some warnings when /boot/config/parity-checks.log is read. Could this be the cause?

Hi @ElVit , probably not, that warnings regarding reading parsing parity check history are covered in issues #38 and #39 😊

@domalab
Copy link
Owner

domalab commented Jan 3, 2025

It's strange.

I used latest code, VM service is enabled.

Snímek obrazovky 2025-01-03 v 11 24 25

VM use network br0 to and is enabled.

Snímek obrazovky 2025-01-03 v 11 26 57

But I don't see VM switch and VM service sensor is in off state.

Snímek obrazovky 2025-01-03 v 11 28 32

Same situation for docker.

For sure, I just tried to run command "/etc/rc.d/rc.libvirt status" and I don't got any response.

Snímek obrazovky 2025-01-03 v 11 29 49

Same situation is at both servers.

Ok so I just noticed you are running unraid versions 6.12.13 and 6.12.14

I'm running version 7.0.0.rc2

So I'm wondering if there's a bug with 6.12.13 and 6.12.14 that it doesn't show the status of /etc/rc.d/rc.libvirt status command like it does with 7.0.0.rc2

If it's the case then I will need to enhance the validation check in the code

Can you run these commands to see what it returns please

Basic Service Status:

# Check rc.d script status
/etc/rc.d/rc.libvirt status

# Check running processes
ps -ef | grep libvirtd
pgrep -f libvirtd

Socket and Port Validation:

# Check listening ports
netstat -tuln | grep 16509
# or
ss -tuln | grep 16509

# Check Unix socket
ls -l /var/run/libvirt/libvirt-sock

VM Functionality:

# List all VMs
virsh --connect qemu:///system list --all

# Check libvirt daemon functionality
virsh version

# Test connection to hypervisor
virsh -c qemu:///system sysinfo

Process Details:

# Check detailed process info
ps aux | grep -E 'libvirtd|virtlogd|virtqemud'

# Check libvirt-related services
ls -l /var/run/libvirt/

Log Inspection:

# Check libvirt logs
tail -f /var/log/libvirt/libvirtd.log

# Check for any errors
grep -i error /var/log/libvirt/libvirtd.log

If all these commands:

Show libvirtd process running
Show the socket file exists
Show port 16509 listening
Allow virsh commands to work
Show no critical errors in logs

Then the service should be properly detected

Updated validation check code will look something like this

async def _check_libvirt_running(self) -> bool:
    """Check if libvirt is running using multiple methods."""
    try:
        # Method 1: Traditional rc.d script check
        service_check = await self.execute_command("/etc/rc.d/rc.libvirt status")
        if service_check.exit_status == 0 and "is currently running" in service_check.stdout:
            return True

        # Method 2: Process check
        process_check = await self.execute_command("pgrep -f libvirtd")
        if process_check.exit_status == 0:
            # Method 3: Socket file check
            sock_check = await self.execute_command("[ -S /var/run/libvirt/libvirt-sock ]")
            if sock_check.exit_status == 0:
                _LOGGER.debug("Libvirt validated through process and socket checks")
                return True

        _LOGGER.debug("Libvirt service checks failed")
        return False

    except Exception as err:
        _LOGGER.debug("Error checking libvirt status: %s", str(err))
        return False

@domalab
Copy link
Owner

domalab commented Jan 4, 2025

@ond000 @alasta

Docker and VM Diagnostic script you can run from User Scripts plugin

I just shows report if VM and Docker services are running and will help me to enhance the above validation check code.

#!/bin/bash

# Debug script for Unraid Docker and libvirt service validation

echo "=== Unraid Service Validation Script ==="
echo "Date: $(date)"
echo "Unraid Version: $(cat /etc/unraid-version)"

# Docker Checks
echo -e "\n=== Docker Service Checks ==="
echo "RC Script Status:"
/etc/rc.d/rc.docker status

echo -e "\nDocker Process:"
pgrep -fa dockerd

echo -e "\nDocker Socket:"
ls -l /var/run/docker.sock

echo -e "\nDocker Info:"
docker info

# VM Checks
echo -e "\n=== VM Service Checks ==="
echo "RC Script Status:"
/etc/rc.d/rc.libvirt status

echo -e "\nLibvirt Process:"
pgrep -fa libvirtd

echo -e "\nLibvirt Socket:"
ls -l /var/run/libvirt/libvirt-sock

echo -e "\nVirsh List:"
virsh list --all

echo -e "\nLibvirt Port:"
netstat -tuln | grep 16509 || ss -tuln | grep 16509

echo -e "\nSystem Info:"
uname -a

@ond000
Copy link
Contributor Author

ond000 commented Jan 4, 2025

Output from diagnostic script:

=== Unraid Service Validation Script ===
Date: Sat Jan 4 14:47:56 CET 2025
Unraid Version: version="6.12.14"

=== Docker Service Checks ===
RC Script Status:
status of dockerd: running
running containers: GLANCES HANDBRAKE TORRENT PLEX JDOWN MONOCKER PROMTAIL YT KRUSADER TELEGRAF

Docker Process:
26232 /usr/bin/dockerd -p /var/run/dockerd.pid --log-opt max-size=50m --log-opt max-file=1 --log-level=fatal --storage-driver=btrfs -H unix:///var/run/docker.sock -H tcp://192.168.200.200:2375 --storage-driver=btrfs

Docker Socket:
srw-rw---- 1 root docker 0 Dec 31 08:25 /var/run/docker.sock

Docker Info:
Client:
Version: 24.0.9
Context: default
Debug Mode: false

Server:
Containers: 12
Running: 10
Paused: 0
Stopped: 2
Images: 12
Server Version: 24.0.9
Storage Driver: btrfs
Btrfs:
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7c3aca7a610df76212171d200ca3811ff6096eb8
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.1.118-Unraid
Operating System: Slackware 15.0 x86_64 (post 15.0 -current)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 31.24GiB
Name: OK-USSTR
ID: c8c8e086-24f3-4b74-94b9-2faa6d412364
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

=== VM Service Checks ===
RC Script Status:

Libvirt Process:
27980 /usr/sbin/libvirtd -d -l -f /etc/libvirt/libvirtd.conf -p /var/run/libvirt/libvirtd.pid

Libvirt Socket:
srwxrwx--- 1 root users 0 Dec 31 08:25 /var/run/libvirt/libvirt-sock

Virsh List:
Id Name State
-----------------------
2 RSYNC running


Libvirt Port:
tcp 0 0 127.0.0.1:16509 0.0.0.0:* LISTEN

System Info:
Linux OK-USSTR 6.1.118-Unraid #1 SMP PREEMPT_DYNAMIC Thu Nov 21 15:54:38 PST 2024 x86_64 Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz GenuineIntel GNU/Linux

@ond000
Copy link
Contributor Author

ond000 commented Jan 4, 2025

Ok so I just noticed you are running unraid versions 6.12.13 and 6.12.14

I'm running version 7.0.0.rc2

So I'm wondering if there's a bug with 6.12.13 and 6.12.14 that it doesn't show the status of /etc/rc.d/rc.libvirt status command like it does with 7.0.0.rc2

Yeah, that can be root cause.

Basic Service Status:

# Check rc.d script status
/etc/rc.d/rc.libvirt status

# Check running processes
ps -ef | grep libvirtd
pgrep -f libvirtd

First didn't return anything.

Second:

root     21913 20143  0 15:01 pts/2    00:00:00 grep libvirtd
root     27980     1  0  2024 ?        00:00:05 /usr/sbin/libvirtd -d -l -f /etc/libvirt/libvirtd.conf -p /var/run/libvirt/libvirtd.pid

Third:
27980

Socket and Port Validation:

# Check listening ports
netstat -tuln | grep 16509
# or
ss -tuln | grep 16509

# Check Unix socket
ls -l /var/run/libvirt/libvirt-sock

First:
tcp 0 0 127.0.0.1:16509 0.0.0.0:* LISTEN

Second:
tcp LISTEN 0 1000 127.0.0.1:16509 0.0.0.0:*

Third:
srwxrwx--- 1 root users 0 Dec 31 08:25 /var/run/libvirt/libvirt-sock=

VM Functionality:

# List all VMs
virsh --connect qemu:///system list --all

# Check libvirt daemon functionality
virsh version

# Test connection to hypervisor
virsh -c qemu:///system sysinfo

First:

 Id   Name    State
-----------------------
 2    RSYNC   running

Second:

Compiled against library: libvirt 8.7.0
Using library: libvirt 8.7.0
Using API: QEMU 8.7.0
Running hypervisor: QEMU 7.2.0

Third:

<sysinfo type='smbios'>
  <bios>
    <entry name='vendor'>American Megatrends Inc.</entry>
    <entry name='version'>1205</entry>
    <entry name='date'>05/11/2018</entry>
    <entry name='release'>5.12</entry>
  </bios>
  <system>
    <entry name='manufacturer'>System manufacturer</entry>
    <entry name='product'>System Product Name</entry>
    <entry name='version'>System Version</entry>
    <entry name='serial'>System Serial Number</entry>
    <entry name='uuid'>d65d81f9-6a98-f668-f5db-107b4416ba71</entry>
    <entry name='sku'>SKU</entry>
    <entry name='family'>To be filled by O.E.M.</entry>
  </system>
  <baseBoard>
    <entry name='manufacturer'>ASUSTeK COMPUTER INC.</entry>
    <entry name='product'>PRIME B250-PRO</entry>
    <entry name='version'>Rev X.0x</entry>
    <entry name='serial'>170502630300603</entry>
    <entry name='asset'>Default string</entry>
    <entry name='location'>Default string</entry>
  </baseBoard>
  <chassis>
    <entry name='manufacturer'>Default string</entry>
    <entry name='version'>Default string</entry>
    <entry name='serial'>Default string</entry>
    <entry name='asset'>Default string</entry>
    <entry name='sku'>Default string</entry>
  </chassis>
  <processor>
    <entry name='socket_destination'>LGA1151</entry>
    <entry name='type'>Central Processor</entry>
    <entry name='family'>Core i5</entry>
    <entry name='manufacturer'>Intel(R) Corporation</entry>
    <entry name='signature'>Type 0, Family 6, Model 158, Stepping 9</entry>
    <entry name='version'>Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz</entry>
    <entry name='external_clock'>100 MHz</entry>
    <entry name='max_speed'>8300 MHz</entry>
    <entry name='status'>Populated, Enabled</entry>
    <entry name='serial_number'>To Be Filled By O.E.M.</entry>
    <entry name='part_number'>To Be Filled By O.E.M.</entry>
  </processor>
  <memory_device>
    <entry name='size'>16 GB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>ChannelA-DIMM1</entry>
    <entry name='bank_locator'>BANK 0</entry>
    <entry name='type'>DDR4</entry>
    <entry name='type_detail'>Synchronous Unbuffered (Unregistered)</entry>
    <entry name='speed'>2400 MT/s</entry>
    <entry name='manufacturer'>Patriot</entry>
    <entry name='serial_number'>00000000</entry>
    <entry name='part_number'>PSD416G26662</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>16 GB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>ChannelB-DIMM1</entry>
    <entry name='bank_locator'>BANK 2</entry>
    <entry name='type'>DDR4</entry>
    <entry name='type_detail'>Synchronous Unbuffered (Unregistered)</entry>
    <entry name='speed'>2400 MT/s</entry>
    <entry name='manufacturer'>Patriot</entry>
    <entry name='serial_number'>00000000</entry>
    <entry name='part_number'>PSD416G26662</entry>
  </memory_device>
  <oemStrings>
    <entry>Default string</entry>
    <entry>Default string</entry>
    <entry>Carrot</entry>
    <entry>Default string</entry>
    <entry>FFFFFFFFFFFFF</entry>
    <entry>FFFFFFFFFFFFF</entry>
    <entry>FFFFFFFFFFFFF</entry>
    <entry>Default string</entry>
  </oemStrings>
</sysinfo>

Process Details:

# Check detailed process info
ps aux | grep -E 'libvirtd|virtlogd|virtqemud'

# Check libvirt-related services
ls -l /var/run/libvirt/

First:

root      7587  0.0  0.0   4060  2284 pts/2    S+   15:05   0:00 grep -E libvirtd|virtlogd|virtqemud
root     27904  0.0  0.0  32512 10172 ?        S     2024   0:00 /usr/sbin/virtlogd -d -f /etc/libvirt/virtlogd.conf -p /var/run/libvirt/virtlogd.pid
root     27980  0.0  0.0 1527136 23436 ?       Sl    2024   0:05 /usr/sbin/libvirtd -d -l -f /etc/libvirt/libvirtd.conf -p /var/run/libvirt/libvirtd.pid

Second:

total 12
drwx------ 2 root root   60 Dec 31 08:25 common/
drwxr-xr-x 2 root root   40 Dec 30 19:50 hostdevmgr/
drwx------ 2 root root   60 Dec 31 08:25 interface/
srwx------ 1 root users   0 Dec 31 08:25 libvirt-admin-sock=
srwxrwx--- 1 root users   0 Dec 31 08:25 libvirt-sock=
srwxrwxrwx 1 root users   0 Dec 31 08:25 libvirt-sock-ro=
-rw-r--r-- 1 root root    5 Dec 31 08:25 libvirtd.pid
drwxr-xr-x 2 root root  140 Dec 31 08:25 network/
drwx------ 2 root root   60 Dec 31 08:25 nodedev/
drwx------ 2 root root   60 Dec 31 08:25 nwfilter/
drwx------ 2 root root   40 Dec 30 19:50 nwfilter-binding/
drwxr-xr-x 4 root root  160 Jan  3 11:15 qemu/
drwx------ 2 root root   60 Dec 31 08:25 secrets/
drwxr-xr-x 2 root root   80 Dec 31 08:25 storage/
srwx------ 1 root root    0 Dec 31 08:25 virtlockd-admin-sock=
srwx------ 1 root root    0 Dec 31 08:25 virtlockd-sock=
-rw-r--r-- 1 root root    5 Dec 31 08:25 virtlockd.pid
srwx------ 1 root root    0 Dec 31 08:25 virtlogd-admin-sock=
srwx------ 1 root root    0 Dec 31 08:25 virtlogd-sock=
-rw-r--r-- 1 root root    5 Dec 31 08:25 virtlogd.pid

Log Inspection:

# Check libvirt logs
tail -f /var/log/libvirt/libvirtd.log

# Check for any errors
grep -i error /var/log/libvirt/libvirtd.log

Both are empty

@Guruleenyc
Copy link

Guruleenyc commented Jan 5, 2025

I have the same issue after uninstalling and then installing the new version of unraid integration, I lost all the Docker entities.
Aside from only one entity 'binary_sensor.unraid_server_tower_tower_docker_service', I have no entities for my Docker resource and it shows my Docker service as not running, which is invalid because it is.
I am on unread 6. 12.14.
This appears to be a known issue as also discussed in the associated home assistant forum post. Let me know if I can help with testing or anything.

@domalab
Copy link
Owner

domalab commented Jan 6, 2025

@ond000 @Guruleenyc I added extra validation checks to the code to check if VM and Docker services are running or not to see if I can get around the 6.12.x bug with not showing /etc/rc.d/rc.libvirt status.

Here's the specific flow:
For Unraid 6.12.x:

  1. If /etc/rc.d/rc.libvirt status or /etc/rc.d/rc.docker status fails or returns nothing:
  • It doesn't immediately give up
  • Instead moves to the next validation method
  1. Process Check:
  • Checks if the actual process is running using pgrep
  • For VMs: pgrep -f libvirtd
  • For Docker: pgrep -f dockerd
  1. If process is found running:
  • Final Socket Check
  • For VMs: Checks /var/run/libvirt/libvirt-sock
  • For Docker: Checks /var/run/docker.sock

So even if the rc.d script check fails on 6.12.x:

  • If the service is actually running
  • And the process exists
  • And the socket exists
  • It will still create the switches

This makes the integration much more robust across different Unraid versions, as it doesn't rely solely on the rc.d script output which can vary between versions.

When you get time please download latest source code by manually copying updated unraid folder to home assistant custom_components and restarting HA.

@ond000
Copy link
Contributor Author

ond000 commented Jan 6, 2025

@domalab it helps, now I can see both services in state running and I have again switches for each docker container and VM, thanks for that.

@Iceman248
Copy link

I'm having same issue. Does this feature also work on 6.11.x systems?

@krasty633
Copy link

krasty633 commented Jan 6, 2025

@domalab I can also confirm that it is working again, thanks!

Unraid 6.12.14
HA Core 2025.1.0

@domalab
Copy link
Owner

domalab commented Jan 6, 2025

I'm having same issue. Does this feature also work on 6.11.x systems?

No idea! You need to try out the updated code.

@Iceman248
Copy link

I'm having same issue. Does this feature also work on 6.11.x systems?

No idea! You need to try out the updated code.

Is the updated code the 2024.12.28 version?

@domalab
Copy link
Owner

domalab commented Jan 6, 2025

I'm having same issue. Does this feature also work on 6.11.x systems?

No idea! You need to try out the updated code.

Is the updated code the 2024.12.28 version?

You need to download the source code and not the release version.

Screenshot 2025-01-07 at 9 05 32 am

You need the source code from the unraid folder and overwrite it in HA custom_components\unraid. After doing that restart HA

Screenshot 2025-01-07 at 9 05 59 am

@Iceman248
Copy link

Thanks, thought it was probably that. It worked.

@Iceman248

This comment was marked as off-topic.

@domalab

This comment was marked as off-topic.

@mcolli31
Copy link

mcolli31 commented Jan 7, 2025

Works for me as well. Although it doesn't recognise my windows 11 VM, this was an issue previously so that's a separate problem.

@domalab
Copy link
Owner

domalab commented Jan 7, 2025

Works for me as well. Although it doesn't recognise my windows 11 VM, this was an issue previously so that's a separate problem.

Please log the VM issue as a bug. 👍🏻

@alasta
Copy link

alasta commented Jan 7, 2025

Hello @domalab ,
this is the commands outputs:

=== Unraid Service Validation Script ===
Date: Tue Jan  7 18:28:14 CET 2025
Unraid Version: version="6.12.14"

=== Docker Service Checks ===
RC Script Status:
status of dockerd: running
running containers: Glances dockersocket Unraid-API Nginx-Proxy-Manager-Official immich nextcloud PostgreSQL_Immich

Docker Process:
7117 /usr/bin/dockerd -p /var/run/dockerd.pid --log-opt max-size=50m --log-opt max-file=1 --log-level=fatal --storage-driver=btrfs

Docker Socket:
srw-rw---- 1 root docker 0 Jan  7 18:26 /var/run/docker.sock

Docker Info:
Client:
 Version:    24.0.9
 Context:    default
 Debug Mode: false

Server:
 Containers: 14
  Running: 7
  Paused: 0
  Stopped: 7
 Images: 14
 Server Version: 24.0.9
 Storage Driver: btrfs
  Btrfs: 
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7c3aca7a610df76212171d200ca3811ff6096eb8
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.1.118-Unraid
 Operating System: Slackware 15.0 x86_64 (post 15.0 -current)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.53GiB
 Name: tower
 ID: 7ff6c9e5-b10a-4849-a3e8-8e5c1c40ec18
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

WARNING: No swap limit support

=== VM Service Checks ===
RC Script Status:

Libvirt Process:
8224 /usr/sbin/libvirtd -d -l -f /etc/libvirt/libvirtd.conf -p /var/run/libvirt/libvirtd.pid

Libvirt Socket:
srwxrwx--- 1 root users 0 Jan  7 18:26 /var/run/libvirt/libvirt-sock

Virsh List:
 Id   Name     State
-------------------------
 -    Ubuntu   shut off


Libvirt Port:
tcp        0      0 127.0.0.1:16509         0.0.0.0:*               LISTEN     

System Info:
Linux tower 6.1.118-Unraid #1 SMP PREEMPT_DYNAMIC Thu Nov 21 15:54:38 PST 2024 x86_64 Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz GenuineIntel GNU/Linux

Thank you for your help.
And happy new year !

@ond000
Copy link
Contributor Author

ond000 commented Jan 8, 2025

@Iceman248 I have available actions, but I'm not sure which entity I can use in action as target for test...

@alasta
Copy link

alasta commented Jan 11, 2025

The issue is resolve for me, I think after upgrade HA Unraid to 2025.01.08.
Thank You @domalab

@domalab domalab closed this as completed Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants