A monitor project for server resources basing on glances, influxdb 1.7 and grafana 8.
Python 3.9.4
Glances 3.2.7
Influxdb 1.7.10
Grafana 8.5.9
Major Monitored Objects:
- CPU(%)
- Disk
- Memory
- Network
There existed a dependence between influxdb and grafana and it's significant to choose the suitable version.
The instructions in this guide require Grafana Cloud or Grafana v7.1+. For information about using InfluxDB with other versions of Grafana, see the Grafana documentation.
Glances is on PyPI, To install, simply use pip
pip install glancesAfter installing glances, we can use command glances to test it.
cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOFsudo yum install influxdb
sudo service influxdb startcd /PATH/TO/cockpit/pkg/
yum installlocal influxdb-1.7.10.x86_64.rpmsudo service influxdb start
# start, status, stop
sudo systemctl start influxdb.service
sudo systemctl status influxdb.service
sudo systemctl stop influxdb.service
## check the influx service log
# real-time
journalctl -f -u influxdb.service
# latest 100 lines
journalctl -n 100 -u influxdb.service# download grafana
cd /PATH/TO/cockpit/pkg/
yum installlocal grafana-8.5.9-1.x86_64.rpm
# start the grafana service
service grafana-service satrtinflux
create database glances
use database# single command
glances --export influxdb
# service
vi /etc/systemd/system/glances.service
## service config, and focus on ExecStart
[Unit]
Description=Glances
After=network.target influxd.service
[Service]
ExecStart=/usr/local/bin/glances --config /etc/glances/glances.conf --quiet --export influxdb
Restart=on-failure
RestartSec=30s
TimeoutSec=30s
[Install]
WantedBy=multi-user.target
# reload the systemctl
systemctl daemon-reload
systemctl start glances.service
# auto start glance service when server start
systemctl enable glances.serviceTry to select data from influxdb glances databases or read glances log to ensuring data loaded.
# select database data, new tables will be created if data loaded successfully.
influx
use glances
show merasurements
# use journalctl to check influxdb log
# real-time
journalctl -f -u influxdb.service
# latest 100 log line
journalctl -n 100 -u influxdb.service Open http://localhost:3000 in the local browser.
The datasource was created, and then we need to import the dashboard.
Finally, click the import to finish creating the monitor program.








