glances icon indicating copy to clipboard operation
glances copied to clipboard

Export while in server mode

Open mitar opened this issue 5 years ago • 10 comments

Description

It looks like it is not possible to export data when running in server mode? That is surprising because when I read it in documentation I though that is the main use case. That you can run a server daemon and configure it so that it exports everything recorded to a file for preservation. And then you can connect with a client to see current state.

It seems you have to connect with a client to export recorded data, but why couldn't just server do that as well? So then there would be no need for me to periodically connect and export.

Versions

  • Glances & psutil (glances -V): Glances v3.1.1 with psutil v5.6.3
  • Operating System (lsb_release -a): Ubuntu 18.04.2 LTS

mitar avatar Aug 05 '19 10:08 mitar

For the moment, export is only available in standalone or client mode...

nicolargo avatar Aug 07 '19 06:08 nicolargo

Where does server mode save recorded data? In memory?

mitar avatar Aug 07 '19 06:08 mitar

Yes in memory. You can configure the buffer size here: https://github.com/nicolargo/glances/blob/develop/conf/glances.conf#L8-L10

nicolargo avatar Aug 07 '19 07:08 nicolargo

Yes, I have seen that you can configure it.

I really thought that all integration with CSV and InfluxDB and stuff like that can work on the server, that you can export all this data in real-time into those and then use them.

mitar avatar Aug 07 '19 07:08 mitar

By design, Glances server has a very low CPU footprint because it grab data only when a client ask for it (not every 3 seconds). If we allows user to serve and export i have to change this behavior on server side.

But i hear your need. I am going to think to a new mode to mix server and export mode...

Any ideas are welcomes.

nicolargo avatar Aug 13 '19 08:08 nicolargo

Is it possible to create 2 systemd services, for example glances.webserver and glances.exporter and use each of them according to the respective examples on https://github.com/nicolargo/glances/wiki/Start-Glances-through-Systemd ?

Are there any limitations to potentially running two instances while one is the webserver?

Thanks!!

EDIT: Tried to run glances --export prometheus while webserver is running in background as daemon, and using "top" command I got 15-20% CPU usage per second from the export service. Anyone can replicate?

MetallicAchu avatar Jun 16 '21 18:06 MetallicAchu

@MetallicAchu Yes it is possible to run two Glances instances.

For the CPU consumption, it is strange, on my system i am around 7% not 20%.... Try to disable the sensors plugin.

nicolargo avatar Jun 20 '21 06:06 nicolargo

I made 2 services, one for web server and one for export to prometheus every 10 seconds I tested it with ps aux | grep glances --- because ps aux gives the average CPU consumption over the running time.

Tested for almost 20 minutes: 16060 10.2 1.5 1373528 62524 ? Ssl 12:10 18:57 /usr/bin/python3 /usr/bin/glances -t 10 --quiet --export prometheus

Where 10.2 is CPU % over time run.

I'll let it run for a while more and update again :)

EDIT: After 3 hours CPU is steady at 10% average. I’m running 2 x intel 2.5ghz

I wouldn’t consider it much of a problem if only Glances could act both as a webserver and an exporter at the same time

MetallicAchu avatar Jun 22 '21 12:06 MetallicAchu

I wanted to update that with glances v3.2.0 I'm experiencing 2.5% CPU on average, so the change is most welcomed! Thank you!

MetallicAchu avatar Jul 10 '21 07:07 MetallicAchu

Same use case here, I start the server and the client for the export. I think it do the job

glances --config glances.conf --server
glances --config glances.conf --client localhost --export csv --export-csv-file export.csv

However I noticed that with the option --quiet, glances use 100% of CPU load. The client use 70% and server instance use the rest.

So I replace the client command by :

glances --config glances.conf --client localhost --export csv --export-csv-file export.csv > /dev/null

I can't try with client instance on another machine.

Glances v3.2.3.1 with PsUtil v5.8.0

crile avatar Sep 17 '21 07:09 crile