Using web monitor within LXC to monitor core server?
Is there a way to expose the core server to an LXC container for a system monitor? I want to be able to have Nginx inside of a container, but use ezservermonitor (web based real-time monitor) to see the main system stats and not the container it's running in.
I'm trying to prevent installing Nginx on the server and use LXC as much as possible, but I don't think LXC can do this since it's kind of like a VM. I haven't used Docker much, but I've seen netdata docker image so do I need to use Docker Nginx/PHP and that would allow me to use ezservermonitor to see the core system? I'd like to stick to LXC if can, but will do Docker if can't. |
You can have netdata monitor the host, while running inside an lxc container.
To do this, create the directories /host, /host/proc, /host/sys, /host/dev inside the container and use lxc configuration to mount /proc /sys /dev from the host to the container. This is usually done with lxc configs like this: Code:
lxc.mount.entry = /path/in/host/mount_point mount_point_in_container none bind 0 0 Code:
lxc.mount.entry = /proc host/proc none bind 0 0 Check the lxc docs for correct usage of this and additional information. Then, in netdata.conf inside the container, set: Code:
[global] Now netdata should monitor the host. Keep in mind that certain data collection features of netdata many not work as expected when running netdata inside a container, since netdata does not have full visibility of the host system. If you want to get the full of it, install netdata at the host (this is also the suggested way). netdata has binary packages that install it in /opt/netdata to avoid installing from source. |
Thanks a lot. Was able to get ezservermonitor to pull up the core server stats using your examples for netdata.
|
Monitor Proxmox Host with ezservermonitor in LXC
Create Ubuntu 18.04 LXC with YOUR_IP_ADDR
========================================= sudo nano /etc/pve/lxc/10x.conf mp0: /proc,mp=/host/proc mp1: /sys,mp=/host/sys mp2: /dev,mp=/host/dev mp3: /mnt/Share/Drive1,mp=/mnt/Drive1,size=800G mp4: /mnt/Share/Drive2,mp=/mnt/Drive2 install lighttpd web server =========================== sudo -i apt update && apt upgrade apt install lighttpd -y systemctl enable lighttpd systemctl start lighttpd install PHP =========== visit http://YOUR_IP_ADDR -> if all goes well see placeholder page apt install -y php7.2 php7.2-fpm php7.2-mysql php7.2-cli php7.2-curl php7.2-xml nano /etc/php/7.2/fpm/php.ini uncomment cgi.fix_pathinfo=1 nano /etc/php/7.2/fpm/pool.d/www.conf Change listen = /run/php/php7.2-fpm.sock to listen = 127.0.0.1:9000 systemctl restart php7.2-fpm nano /etc/lighttpd/conf-available/15-fastcgi-php.conf FROM: "bin-path" => "/usr/bin/php-cgi", TO "host" => "127.0.0.1", FROM: "socket" => "/var/run/lighttpd/php.socket", TO: "port" => "9000", apt install cpanminus lighty-enable-mod fastcgi lighty-enable-mod fastcgi-php systemctl restart lighttpd nano /var/www/html/index.php <?php phpinfo(); ?> chown -R www-data:www-data /var/www/html/ systemctl restart lighttpd systemctl restart php7.2-fpm visit http://YOUR_IP_ADDR -> if all goes well see PHP info page download and unzip ezservermonitor apt install curl apt install unzip apt install net-tools curl -L h_t_t_p_s://ezservermonitor.com/esm-web/downloads/version/2.5 -o ezservermonitor-web_v2.5.zip unzip ezservermonitor-web_v2.5.zip cp -R eZServerMonitor-2.5 /var/www/html/ visit: http://YOUR_IP_ADDR/eZServerMonitor-2.5/ -> if all goes well will see eZServerMonitor page Modify eZServerMonitor to show Proxmox host info, not LXC info ============================================================== config: nano /var/www/html/eZServerMonitor-2.5/conf/esm.config.json => "auto_refresh": 60, "theme": "dark", Misc.php: nano /var/www/html/eZServerMonitor-2.5/libs/Utils/Misc.php /proc/cpuinfo => /host/proc/cpuinfo cpu.php: nano /var/www/html/eZServerMonitor-2.5/libs/cpu.php /proc/cpuinfo => /host/proc/cpuinfo memory.php: nano /var/www/html/eZServerMonitor-2.5/libs/memory.php /proc/meminfo => /host/proc/meminfo swap.php: nano /var/www/html/eZServerMonitor-2.5/libs/swap.php /proc/meminfo => /host/proc/meminfo disk.php: OK as-is load_average.php: nano /var/www/html/eZServerMonitor-2.5/libs/load_average.php /proc/loadavg => /host/proc/loadavg services.php: OK as-is network.php: OK as-is system.php: nano /var/www/html/eZServerMonitor-2.5/libs/system.php /proc/uptime => /host/proc/uptime nano /var/www/html/eZServerMonitor-2.5/index.php <td>Hostname</td> => <td>LXC Hostname</td> <td>OS</td> => <td>LXC OS</td> Enjoy! |
All times are GMT -5. The time now is 08:03 AM. |