Skip to content

A monitor project for server resources basing on glances, influxdb 1.7 and grafana 8.

Notifications You must be signed in to change notification settings

jaywang98/cockpit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cockpit

A monitor project for server resources basing on glances, influxdb 1.7 and grafana 8.

Environment

Python 3.9.4
Glances 3.2.7
Influxdb 1.7.10
Grafana 8.5.9

Show

Major Monitored Objects:

  • CPU(%)
  • Disk
  • Memory
  • Network

Deploy

Attention

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

Glances is on PyPI, To install, simply use pip

pip install glances

After installing glances, we can use command glances to test it.

Influxdb1.7

install online

influxdata.com documents

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
EOF
sudo yum install influxdb
sudo service influxdb start

install offline

cd /PATH/TO/cockpit/pkg/
yum installlocal  influxdb-1.7.10.x86_64.rpm

start influx service

sudo 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

Grafana

install offline

# download grafana
cd /PATH/TO/cockpit/pkg/
yum installlocal grafana-8.5.9-1.x86_64.rpm

# start the grafana service
service grafana-service satrt

Combination

1. Create database

influx
create database glances
use database

2. Load glances data

# 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.service

Try 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 

3. Crate Grafana Dashboard

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.

Reference

  1. Grafana Office
  2. Glances Ofiice
  3. Influx 1.7 Office Doc
  4. Glances, InfluxDB, Glances

About

A monitor project for server resources basing on glances, influxdb 1.7 and grafana 8.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published