{"id":13885,"date":"2019-04-06T13:36:25","date_gmt":"2019-04-06T13:36:25","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13885"},"modified":"2019-04-06T13:36:25","modified_gmt":"2019-04-06T13:36:25","slug":"use-glances-to-monitor-remote-linux-in-web-server-mode","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/use-glances-to-monitor-remote-linux-in-web-server-mode\/","title":{"rendered":"Use Glances to Monitor Remote Linux in Web Server Mode"},"content":{"rendered":"<p><a href=\"https:\/\/www.tecmint.com\/glances-an-advanced-real-time-system-monitoring-tool-for-linux\/\" target=\"_blank\" rel=\"noopener\">Glances<\/a>\u00a0is a free open source, modern, cross-platform, real-time\u00a0<a href=\"https:\/\/www.tecmint.com\/12-top-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">top<\/a>\u00a0and\u00a0<a href=\"https:\/\/www.tecmint.com\/install-htop-linux-process-monitoring-for-rhel-centos-fedora\/\" target=\"_blank\" rel=\"noopener\">htop<\/a>\u00a0like system monitoring tool. It offers advanced features compared to its counterparts, and can run in different modes: as a standalone, in client\/server mode and in web server mode.<\/p>\n<p>Considering the web server mode, you do not necessarily need to log into your remote server via SSH to run glances, you can run it in web server mode and access it via a web browser to remotely monitor your Linux server, as explained below.<\/p>\n<p>To run\u00a0<strong>glances<\/strong>\u00a0in web server mode, you need to install it together with the\u00a0<strong>Python bottle<\/strong>\u00a0module, a fast, simple and lightweight\u00a0<strong>WSGI<\/strong>\u00a0micro web-framework, using the appropriate command for your Linux distribution.<\/p>\n<pre>$ sudo apt install glances python-bottle\t#Debian\/Ubuntu\r\n$ sudo yum install glances python-bottle\t#RHEL\/CentOS\r\n$ sudo dnf install glancespython-bottle\t        #Fedora 22+\r\n<\/pre>\n<p>Alternatively, install it using\u00a0<a href=\"https:\/\/www.tecmint.com\/install-pip-in-linux\/\" target=\"_blank\" rel=\"noopener\">PIP command<\/a>\u00a0like shown.<\/p>\n<pre>$ sudo pip install bottle\r\n<\/pre>\n<p>Once you have installed the above packages, launch\u00a0<strong>glances<\/strong>\u00a0with the\u00a0<code>-w<\/code>\u00a0flag to run it in web server mode. By default, it will listen on port\u00a0<strong>61208<\/strong>.<\/p>\n<pre>$ glances -w \r\nOR\r\n$ glances -w &amp;\r\n<\/pre>\n<p>If you are running\u00a0<strong>firewalld<\/strong>\u00a0services, then you should open port\u00a0<strong>61208<\/strong>\u00a0to allow inbound traffic to that port.<\/p>\n<pre>$ sudo firewall-cmd --permanent --add-port=61208\/tcp\r\n$ sudo firewall-cmd --reload\r\n<\/pre>\n<p>For\u00a0<strong>UFW<\/strong>\u00a0firewall, run these commands.<\/p>\n<pre>$ sudo  ufw  allow 61208\/tcp\r\n$ sudo  ufw  allow reload\r\n<\/pre>\n<p>After that, from a web browser, use the URL\u00a0<code>http:\/\/SERVER_IP:61208\/<\/code>\u00a0to access the glances UI.<\/p>\n<p>If you are using\u00a0<strong>systemd<\/strong>\u00a0system and services manager, you can run\u00a0<strong>glances<\/strong>\u00a0in web server mode as a service for efficient management, as explained in the next section. I actually prefer this method to running it as a background process.<\/p>\n<h3>Run Glances in Web Server Mode as a Service<\/h3>\n<p>Start by creating your service unit file (which I have preferred to name as\u00a0<strong>glancesweb.service<\/strong>) under\u00a0<strong>\/usr\/lib\/systemd\/system\/glancesweb.service<\/strong>.<\/p>\n<pre>$ sudo vim \/usr\/lib\/systemd\/system\/glancesweb.service\r\n<\/pre>\n<p>Then copy and paste the unit file configuration below in it.<\/p>\n<pre>[Unit]\r\nDescription = Glances in Web Server Mode\r\nAfter = network.target\r\n\r\n[Service]\r\nExecStart = \/usr\/bin\/glances  -w  -t  5\r\n\r\n[Install]\r\nWantedBy = multi-user.target\r\n<\/pre>\n<p>The above configuration tells systemd that this is a unit of type service, it should be loaded after the\u00a0<strong>network.target<\/strong>.<\/p>\n<p>And once the system is in the network target, systemd will invoke the command \u201c<strong>\/usr\/bin\/glances -w -t 5<\/strong>\u201d as a service. The\u00a0<code>-t<\/code>\u00a0specifies an interval for live updates in seconds.<\/p>\n<p>The\u00a0<code>[install]<\/code>\u00a0section informs systemd that this service is wanted by \u201c<strong>multi-user.target<\/strong>\u201d. Therefore, when you enable it, a symbolic link is created from the\u00a0<strong>\/etc\/systemd\/system\/multi-user.target.wants\/glancesweb.service<\/strong>\u00a0to\u00a0<strong>\/usr\/lib\/systemd\/system\/glancesweb.service<\/strong>. Disabling it will delete this symbolic link.<\/p>\n<p>Next, enable your new systemd service, start and view its status as follows.<\/p>\n<pre>$ sudo systemctl enable connection.service\r\n$ sudo systemctl start connection.service\r\n$ sudo systemctl status connection.service\r\n<\/pre>\n<p>Finally, from your web browser, use the URL\u00a0<code>http:\/\/SERVER_IP:61208\/<\/code>\u00a0to remotely monitor your Linux servers via the glances UI, on any device (smart phone, tablet or computer).<\/p>\n<div id=\"attachment_28434\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/Monitor-Remote-Linux-Server-Under-Glances.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28434\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/Monitor-Remote-Linux-Server-Under-Glances.png\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/Monitor-Remote-Linux-Server-Under-Glances.png 1920w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/Monitor-Remote-Linux-Server-Under-Glances-768x432.png 768w\" alt=\"Monitor Remote Linux Server Under Glances\" width=\"1920\" height=\"1080\" aria-describedby=\"caption-attachment-28434\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28434\" class=\"wp-caption-text\">Monitor Remote Linux Server Under Glances<\/p>\n<\/div>\n<div id=\"attachment_28433\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/Monitor-Remote-Linux-Processes-Under-Glances.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28433\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/Monitor-Remote-Linux-Processes-Under-Glances.png\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/Monitor-Remote-Linux-Processes-Under-Glances.png 1920w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/Monitor-Remote-Linux-Processes-Under-Glances-768x432.png 768w\" alt=\"Monitor Remote Linux Processes Under Glances\" width=\"1920\" height=\"1080\" aria-describedby=\"caption-attachment-28433\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28433\" class=\"wp-caption-text\">Monitor Remote Linux Processes Under Glances<\/p>\n<\/div>\n<p>You can change the refresh rate of the page, simply add the period in seconds at the end of the URL, this sets the refresh rate to\u00a0<strong>8<\/strong>\u00a0seconds.<\/p>\n<pre>http:\/\/SERVERI_P:61208\/8\t\r\n<\/pre>\n<p>One downside of running glances in web server mode is that, if the Internet connection is poor the client tends to easily disconnect from the server.<\/p>\n<p>You can learn how to create new systemd services from this guide:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/create-new-service-units-in-systemd\/\" target=\"_blank\" rel=\"noopener\">How to Create and Run New Service Units in Systemd Using Shell Script<\/a><\/li>\n<\/ol>\n<p>That\u2019s all! If you have any questions or additional information to add, use the comment from below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/glances-monitor-remote-linux-in-web-server-mode\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Glances\u00a0is a free open source, modern, cross-platform, real-time\u00a0top\u00a0and\u00a0htop\u00a0like system monitoring tool. It offers advanced features compared to its counterparts, and can run in different modes: as a standalone, in client\/server mode and in web server mode. Considering the web server mode, you do not necessarily need to log into your remote server via SSH to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/use-glances-to-monitor-remote-linux-in-web-server-mode\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Use Glances to Monitor Remote Linux in Web Server Mode&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13885","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13885"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13885\/revisions"}],"predecessor-version":[{"id":13886,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13885\/revisions\/13886"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}