From c97b13dc0dc72f6d83a56ebf947abff351a524e5 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 15 Sep 2015 11:03:21 +0200 Subject: [PATCH] Add glances blog post --- ...g-with-glances-and-home-assistant.markdown | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 source/_posts/2015-09-18-monitoring-with-glances-and-home-assistant.markdown diff --git a/source/_posts/2015-09-18-monitoring-with-glances-and-home-assistant.markdown b/source/_posts/2015-09-18-monitoring-with-glances-and-home-assistant.markdown new file mode 100644 index 00000000000..d8e146a00c2 --- /dev/null +++ b/source/_posts/2015-09-18-monitoring-with-glances-and-home-assistant.markdown @@ -0,0 +1,78 @@ +--- +layout: post +title: "Monitoring with Glances and Home Assistant" +description: "This post describes the setup for monitoring remote hosts with Home Assistant." +date: 2015-09-18 11:00:00 +0200 +date_formatted: "September 18, 2015" +author: Fabian Affolter +comments: true +categories: how-to +og_image: /images/supported_brands/glances.png +--- + + +Inspried by a [feature requests](https://github.com/balloob/home-assistant/issues/310) I started looking into the available options to do monitoring of remote hosts. The feature request is about displaying system information in a similar way than the [systemmonitor](/components/sensor.systemmonitor.html) sensor does it for the local system. After a while I started to think that it would be a nice addition for a small home network where no full-blown system monitoring setup is present. + + + +The basic problem is to get the data from the remote host. Starting with [psutil](https://pypi.python.org/pypi/psutil) that is used by the systemmonitor sensor, a possible solution is only a click away and named [Glances](https://github.com/nicolargo/glances). Glances has a nice curses-based interface and a [RESTful API](https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API). + +The [Glances sensor](/components/sensor.glances.html) sensor uses that API to get all needed data. + +In this post a default Fedora 22 Workstation installation is used on the host that should be monitored. In fact, it doesn't matter if the system is the local one or a remote one as long as Glances is available. With some adjustments it should work on your own system too. The difference will be the package and the firewall management tools. + +First some extra packages are needed beside Glances, especially the [bootle](http://bottlepy.org/docs/dev/index.html) webserver. I guess that Glances is available for your distribution as well. Otherwise follow those [instructions](https://github.com/nicolargo/glances#installation). + +``` +sudo dnf -y install glances python-bottle +``` + +On Fedora the Firewall settings are strict. Let's open port 61208 to allow other hosts to connect to that port. This is not needed if you just want to observe your local machine. + +```bash +sudo firewall-cmd --permanent --add-port=61208/tcp +sudo firewall-cmd --reload +``` + +Launch `glances` and keep an eye on the output. + +```bash +glances -w +Glances web server started on http://0.0.0.0:61208/ +``` + +Now browse to http://IP_ADRRESS:61208/. You should see the webified view of Glances. + +

+ + Glances web interface +

+ +Another check is to access the API located at http://IP_ADRRESS:61208/api/2/mem/used and to confirm that a detail about your memory usage is provided as a JSON response. If so, you are good to proceed. + +```bash +curl -X GET http://IP_ADDRESS:61208/api/2/mem/used +{"used": 203943936} +``` + +Add the [glances sensor](/components/sensor.glances.html) entry to your `configuration.yaml` file and restart Home Assistant then. + +```yaml +# Example configuration.yaml entry + - platform: glances + name: NAS + host: IP_ADDRESS + resources: + - 'disk_use_percent' + - 'disk_use' + - 'disk_free' +``` + +If there are no error in the log file then you should see your new sensors. + +

+ + The Glances sensors +

+ +[Glances](https://github.com/nicolargo/glances) has a couple of optional dependencies which are extenting the range of provided information. This means that it would be possible to get details about the RAID system, HDD temperature, IP addresses, sensors, etc., please create a [Pull request](https://github.com/balloob/home-assistant/pulls) with your additions or a [Feature request](https://github.com/balloob/home-assistant/issues/new) if you want see more details in your Home Assistant frontend.