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

Issue: I have trouble in naemon while mounting or sharing it in Docker container #466

Open
Qaisarkhursheed opened this issue Jun 4, 2024 · 5 comments

Comments

@Qaisarkhursheed
Copy link

Qaisarkhursheed commented Jun 4, 2024

Hey,

I am having an issue while sharing Naemon with docker container. I have the error /opt/energy-monitor/naemon/naemon: error while loading shared libraries: libnaemon.so.0: cannot open shared object file: No such file or directory .

I have two containers Merlin, Ninja. Inside the Ninja I want o have naemon working from the host machine. But when I mount it it gives me error.

Here is my docker -compose.yml version: '3.9'

services:
  ninja-app:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      #- ./ninja:/opt/energy-monitor/ninja
      #- ./ninja/src/monitor:/usr/local/lib/php/monitor
      #- /usr/bin/mysql:/usr/bin/mysql # Map the MySQL binary from the host
      #- /usr/lib64/mysql:/usr/lib64/mysql # Map the MySQL libraries from the host (adjust path as needed)
     #- /var/lib/mysql:/var/lib/mysql
      - /var/lib/mysql:/var/lib/mysql
      - /usr/local/bin:/opt/energy-monitor/naemon
    ports:
      - "8080:80"
    networks:
      - ninja-network
    environment:
      DB_HOST: host.docker.internal # Or use the host IP if on Linux
      DB_PORT: 3306
      DB_NAME: your_ninja_db_name
      DB_USER: root
      DB_PASS: "" # Empty password since your MariaDB runs without a password

  merlin:
    build:
      context: ./merlin
      dockerfile: Dockerfile
    ports:
      - "8081:80"
    environment:
      db_type: mysql
      db_host: host.docker.internal # Or use the host IP if on Linux
      db_port: 3306
      db_name: merlin
      db_user: root
      db_pass: "" # Empty password since your MariaDB runs without a password
    volumes:
     #- /usr/bin/mysql:/usr/bin/mysql # Map the MySQL binary from the host
     #- /usr/lib64/mysql:/usr/lib64/mysql # Map the MySQL libraries from the host (adjust path as needed)
     #- /var/lib/mysql:/var/lib/mysql
     #- /var/lib/mysql/mysql.sock:/var/lib/mysql/mysql.sock:ro
      - /var/lib/mysql:/var/lib/mysql
    networks:
      - ninja-network

networks:
  ninja-network:
    driver: bridge` anyone can help me with this?  

Thanks

@nook24
Copy link
Member

nook24 commented Jun 6, 2024

I have modified your Markdown and put the compose.file into a code block.


I'm not sure how much I can help you with this as I have never used Ninja and barely even touched Merlin. In case you compile Naemon from source, you will find the libnaemon at <prefix>/lib/libnaemon.so.0
In case you are using the packages from http://www.naemon.io/download/, make sure you have installed the libnaemon package.

Due to you are mounting /usr/local/bin:/opt/energy-monitor/naemon I guess you have used the provided packages. Try to use the same path inside the container as the packages rely on the path.

I want o have naemon working from the host machine

What do you mean by working from the host machine? Is this so that Naemon will not loose it's state files such as retention.dat?
Or because of the check plugins?

I guess that's all I can assist you with this.
In case you do not need to go with Nina/Merlin you can take a look at the openITCOCKPIT Docker Setup, it uses Mod_Gearman and also supports a clean way to install custom plugins

@Qaisarkhursheed
Copy link
Author

Qaisarkhursheed commented Jun 6, 2024

Hey @nook24 Thank you of your response. Actually, For host machine meaning, I am trying to run the naemon inside a container. I don't wanna install Naemon inside the container. But when I try 'which naemon' on my host machine it gives me a path kind of 'usr/bin/naemon' but this path I am trying to mount on my docker container.

So when I try to run inside container it gives the above error 'libnaemon' must be there. I know there might be other dependencies also which are required by naemon to install. But my mission is not to install Naemon inside docker just wanna use inside that container.

Note: I tried the same path /usr/local/bin:/usr/local/bin but it still didn't worked as expected giving same error /opt/energy-monitor/naemon/naemon: error while loading shared libraries: libnaemon.so.0: cannot open shared object file: No such file or directory

Thanks

@nook24
Copy link
Member

nook24 commented Jun 6, 2024

Why do you not want to install Naemon inside of the Container?

@Qaisarkhursheed
Copy link
Author

Actually its not a requirments. Alot of things are dependent on naemon. Actually we were using Red Hat 8 before so we have some depricated stuff we need to make it work. NAemon working fine on EL9 but others not that's why. I must have tp make it work from Host machhin to the docker container.

@nook24
Copy link
Member

nook24 commented Jun 7, 2024

Alot of things are dependent on naemon.

I'm not sure how something can depend on the Naemon Binary itself, as Naemon do not provide any external APIs than status.dat.
How ever, compiling Naemon on EL8 and running it on EL9 might work but I do not recommend it.

With that said: steps to do:

  1. Compile Naemon from source into a custom prefix: https://statusengine.org/tutorials/install-naemon-centos8/
  2. Install the same dependencies in your docker container (using yum or dnf)
  3. Mount the prefix /opt/naemon (or what you have set) into the same location in the docker container so /opt/naemon:/opt/naemon
  4. Start Naemon in the Docker Container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants