Grafana 探索

安装与配置

实验环境 Centos 地址:101.6.163.52 密码:icenter /sudo用户 :saturn securitytnc
安装

Redhat & Centos(64 Bit)SHA256: a6c71fcebf26591e9ee76b7685f2e38c4c9f9968613e3e83cbb76a29b236abd4

wget https://dl.grafana.com/oss/release/grafana-5.4.3-1.x86_64.rpm 
sudo yum localinstall grafana-5.4.3-1.x86_64.rpm
配置文件路径 /usr/share/grafana/conf
另一套实验环境:以上环境不能启动服务。
换到Debian系列linux系统,地址:101.6.161.59 服务端口:3000 用户名:admin 密码:icenter

Ubuntu & Debian(64 Bit)SHA256: e9da6413b416f8cb9f733db39f685b64a82a425a3932bf09ae3cb8d5bc1e0494

wget https://dl.grafana.com/oss/release/grafana_5.4.3_amd64.deb 
sudo dpkg -i grafana_5.4.3_amd64.deb 
sudo systemctl start grafana-server      (启动服务,然后可以从浏览器访问)
docker方法安装 https://juejin.im/entry/58561a87ac502e0067eb0113
docker下载地址:https://hub.docker.com/r/samuelebistoletti/docker-statsd-influxdb-grafana/
2021年安装方法及数据: influxdb安装参考文件https://docs.influxdata.com/influxdb/v2.0/install/
    开放端口influxdb:101.6.160.22:5786   admin/adminadmin
            grafana:101.6.160.22:5730   admin/admin

应用1:光强感知检测

Grafana+influxdb+Pynq实时显示环境光感强度

硬件方面:使用Pynq z1芯片+PmodALS光传感器

这里需要注意一下几点:

  1. Pynq与主机连接方式不能直接用网线连接,这会导致Pynq板上的系统无法联网和更新,故应该将Pynq和控制主机连接到同一路由上。
  2. 这时候需要通过路由管理来获取Pynq板的IP,如果没有路由权限,可以通过局域网端口扫描的方法来获取Pynq的IP,具体需使用nmap软件(linux下,yum/apt-get install nmap安装)。
  3. Pynq和主机能成功通信后,第一步是改系统时间(使用date -s命令),否则会导致Pynq上的软件无法安装或更新。
  4. Pynq板需要更新或安装的软件:influxdb的python包。

实验步骤:

  1. 连接好Pynq硬件,按如上要求更新板上软件;软件方向,将grafana的后端数据库设置为fluxdb
  2. 使用Jupyter Notebook 每间隔1s获取一次当前环境光强度值,并将数据写入fluxdb数据库

最终使用grafana host主机的ip+port的方式来访问。

代码参考:

import time
from time import sleep
from influxdb import InfluxDBClient
#change localhost to IP of Pynq, user+passwd+influxdb_name are required
client = InfluxDBClient('localhost', 8086, 'datasource', 'datasource', 'test') 
while True:
   light_value = get_value(...) #using pynq to get the return value of Pmod_ALS
   json_body = [
           {
               "measurement": "test",
               "tags": {
                   "nio": "ens4"
               },
      "fields": {
                   "value": light_value,
               }
           }
       ]
       client.write_points(json_body) #写入influxdb数据库
    sleep(1)

应用2:智能视频监控

硬件:Jetson TX1

系统:Ubuntu 16.04

软件:YOLO,目前有 YOLO-v2和Yolo-v3。

启动InfluxDB
sudo influxd
启动grafana
sudo service grafana-server start
启动YOLO
./darknet detector demo cfg/coco.data cfg/yolov2.cfg yolov2.weights -c 0

参考

https://www.influxdata.com/blog/visualizing-time-series-data-with-dygraphs/

最后修改于2021年9月28日 (星期二) 04:40