Advertisement
bionicmac

HOWTO Install and Configure Glances + InfluxDB + Grafana

Jan 25th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. HOWTO Install and Configure Glances + InfluxDB + Grafana
  2. ======
  3. Screenshots
  4.  
  5. [ https://imgur.com/a/9O9jzxP ]
  6. ======
  7.  
  8. 1) Install and Test Glances
  9.  
  10. There are several methods to Install Glances on your system. Choose your weapon!
  11.  
  12. GNU/Linux
  13.  
  14. Glances is available on many Linux distributions, so you should be able to
  15. install it using your favorite package manager. Be aware that when you use
  16. this method the operating system package for Glances may not be the latest
  17. version.
  18.  
  19. === Valuable resources to guide you through the Glances Install ===
  20.  
  21. * Glances PyPI Project :: https://pypi.org/project/Glances/
  22. * Glances Main Website :: https://nicolargo.github.io/glances/
  23. * Glances GitHub Repo :: https://github.com/nicolargo/glances
  24.  
  25.  
  26. * * * I prefer to Install Glances using pip * * *
  27.  
  28. $ pip install glances
  29.  
  30. * * * Install Optional Features * * *
  31.  
  32. Optionally Install the following libraries in order to
  33. use optional features (like the Web interface, exports modules...):
  34.  
  35. $ pip install 'glances[action,browser,cloud,cpuinfo,docker,export,folders,gpu,graph,ip,raid,snmp,web,wifi]'
  36.  
  37. Done Installing Glances and optional libraries.
  38.  
  39. Test Glances:
  40.  
  41. Run glances locally from terminal:
  42.  
  43. $ glances
  44.  
  45. Run glances in local web server mode:
  46.  
  47. $ glances -w
  48.  
  49. Glances Web User Interface started on http://0.0.0.0:61208/
  50.  
  51. You can stop right here if glances worked as expected.
  52.  
  53. You can also read on and learn some more...
  54.  
  55. Usage
  56.  
  57. For the standalone mode, run:
  58.  
  59. $ glances
  60.  
  61. For the Web server mode, run:
  62.  
  63. $ glances -w
  64.  
  65. and enter the URL http://<ip>:61208 in your favorite web browser.
  66.  
  67. NOTE: If you only plan on using Glances to monitor your local machine,
  68. from you local machine, on your local machine, like you would run
  69. conky, gkrellm, htop, top, or any sensor applet or gadget on your
  70. desktop on a single machine, you can *STOP RIGHT HERE*. =)
  71.  
  72. === If you want to monitor multiple remote machines then follow the white rabbit... ===
  73.  
  74. Glances client/server mode:
  75.  
  76. Port 61209/tcp needs to be open on the glances-server.
  77.  
  78. ie: The glances-server machine you run [ $ glances -s ] on.
  79.  
  80. NOTE: If you have a firewall running on the glances-server
  81. you need to open port [ 61209/tcp ] on the glances-server.
  82. The glances-server is the machine you want to be remotely monitored.
  83. The glances-server is the machine you will run [ $ glances -s ]
  84.  
  85. For a very clear, simple example, I will define the server and the client here.
  86.  
  87. glances-server (Machine you want to remotely monitor)
  88. glances-client (Machine that will monitor the remote Glances server machine)
  89.  
  90. On the glances-server, run...
  91.  
  92. $ glances -s
  93.  
  94. HINT: Don't forget to open Port 61209 on the glances-server machine.
  95.  
  96. On the glances-client (Machine that will do the monitoring), run...
  97.  
  98. $ glances -c <ip>
  99.  
  100. In other words: [ $ glances -c INSERT-glances-server-IP-HERE ]
  101.  
  102. If all went well, you are now monitoring glances-server from/on glances-client.
  103.  
  104. This concludes the Glances installation and basic usage testing.
  105.  
  106. Note: glances.conf and systemd service /etc/systemd/system/glances.service
  107.  
  108. A glances.conf is NOT NEEDED if you are only going to use glances
  109. on your local machine with no bells and whistles. In other words,
  110. if you are not going to use glances in conjunction with InfluxDB
  111. or Grafana, for example.
  112.  
  113. You can even use glances in server/client mode to monitor remote
  114. machines, as explained in detail above, without any need for a glances.conf.
  115. Open port (61209/tcp) in the firewall on the glances-server if you plan
  116. on monitoring a remote machine in server/client mode.
  117.  
  118. If you plan on using Grafana and InfluxDB for a full fledged
  119. System Monitoring solution there is a need for glances.conf as
  120. well as a systemd service for glances. ie: /etc/systemd/glances.service
  121.  
  122. *** THIS SPACE RESERVED FOR FUTURE INFORMATION REGARDING ***
  123. *** glances.conf and SystemD -- /etc/systemd/glances.service
  124.  
  125. ====== Everything Below Is Not Complete --- More to come... ======
  126. ......
  127.  
  128. Install Grafana
  129.  
  130. Start Grafana Using systemd:
  131.  
  132. If you're Logging in to Grafana for the first time:
  133.  
  134. To run Grafana open your browser and go to http://localhost:3000/.
  135. 3000 is the default http port that Grafana listens to if you haven’t
  136. configured a different port. -> [ http://docs.grafana.org/installation/configuration/#http-port ]
  137. Then follow the instructions here. -> [ http://docs.grafana.org/guides/getting_started/ ]
  138.  
  139. Default username: admin
  140. Default password: admin
  141.  
  142. When you log in for the first time you will be asked to change your password.
  143.  
  144. We strongly encourage you to follow Grafana’s best practices and change the
  145. default administrator password. You can later go to user preferences and
  146. change your user name.
  147.  
  148. Before you create your first dashboard you need to add your data source.
  149.  
  150. How to add a data source in Grafana
  151.  
  152. I will use InfluxDB for a data source.
  153.  
  154. How to install InfluxDB
  155.  
  156. Each major Linux Distribution should have a Influxdb package in the repos.
  157.  
  158. openSUSE InfluxDB Installation
  159.  
  160. $ zypper install influxdb
  161.  
  162. $ systemctl enable influxdb
  163.  
  164. $ systemctl start influxdb
  165.  
  166. Configure InfluxDB In Glances
  167.  
  168. https://glances.readthedocs.io/en/latest/gw/influxdb.html?highlight=influxdb
  169.  
  170. You can export statistics to an InfluxDB server (time series server).
  171. The connection should be defined in the Glances configuration file as following:
  172.  
  173. Create /etc/glances.conf (or ~/.local/glances/glances.conf -- more on this later)
  174. and insert the following text:
  175.  
  176. NOTE: DO NOT INCLUDE THE DOTS ...
  177.  
  178. ...
  179. [influxdb]
  180. host=localhost
  181. port=8086
  182. user=root
  183. password=root
  184. db=glances
  185. tags=foo:bar,spam:eggs
  186. ...
  187.  
  188. See this link for detailed information on Glances Configuration:
  189.  
  190. https://glances.readthedocs.io/en/latest/config.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement