Commit 1827c0f0 authored by Rousseau Vincent's avatar Rousseau Vincent
Browse files

Update for multi sensors

parent e5378cb8
No related merge requests found
Showing with 15 additions and 189 deletions
+15 -189
......@@ -30,11 +30,11 @@ http://docs.grafana.org/installation/debian/
`git clone`
`cd influxdb/sensor`
`cd influxdb/sensors/sensor_driver`
`python3 -m pip install -r requirements.txt`
`python3 cpu_influx.py`
`python3 sensor_driver.py`
# Connect to Grafana
......@@ -42,5 +42,5 @@ http://docs.grafana.org/installation/debian/
* user : admin
* pwd : admin
* Ajouter une source de donnée influxdb avec comme nom de base de donnée "cpu-sense"
* Ajouter un graphique pour afficher usage CPU dans le temps
\ No newline at end of file
* Ajouter une source de donnée influxdb avec comme nom de base de donnée "multi-sense"
* Ajouter un graphique pour afficher les données dans le temps
\ No newline at end of file
......@@ -16,7 +16,7 @@ services:
env_file:
- ./grafana/config.monitoring
sensor:
build: ./sensor
build: ./sensors/cpu_load
restart: always
environment:
- INFLUX_HOST=influxdb
......
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 1,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Influxdb",
"fill": 1,
"gridPos": {
"h": 15,
"w": 18,
"x": 0,
"y": 0
},
"id": 2,
"legend": {
"avg": true,
"current": false,
"max": true,
"min": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"groupBy": [
{
"params": [
"10s"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "CPU Usage",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Panel Title",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"schemaVersion": 16,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "",
"title": "CPU Usage",
"uid": "OwisVIuiz",
"version": 3
}
......@@ -69,7 +69,7 @@
"type": "fill"
}
],
"measurement": "CPU Usage",
"measurement": "cpu_load",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
......@@ -169,7 +169,7 @@
]
},
"timezone": "",
"title": "CPU Usage",
"title": "CPU Load",
"uid": "OwisVIuiz",
"version": 3
}
apiVersion: 1
providers:
- name: 'CPU usage'
- name: 'CPU load'
orgId: 1
folder: ''
type: file
......
......@@ -3,7 +3,7 @@ datasources:
- name: Influxdb
type: influxdb
access: proxy
database: cpu-sense
database: multi-sense
user: root
password: root
url: http://influxdb:8086
......
FROM python:3
RUN mkdir -p /usr/src/app
COPY cpu_influx.py /usr/src/app
COPY cpu_load.py /usr/src/app
COPY requirements.txt /usr/src/app
WORKDIR /usr/src/app
RUN python3 -m pip install -r requirements.txt
CMD ["python3", "/usr/src/app/cpu_influx.py"]
\ No newline at end of file
CMD ["python3", "/usr/src/app/cpu_load.py"]
\ No newline at end of file
......@@ -4,13 +4,14 @@ import psutil
from influxdb import InfluxDBClient
influx_host = os.getenv('INFLUX_HOST', 'localhost')
influx_client = InfluxDBClient(host=influx_host, database='cpu-sense')
influx_client.create_database('cpu-sense')
influx_dbname = os.getenv('INFLUX_DBNAME', 'multi-sense')
influx_client = InfluxDBClient(host=influx_host, database=influx_dbname)
influx_client.create_database(influx_dbname)
while True:
measurement = [
{
'measurement': 'CPU Usage',
'measurement': 'cpu_load',
'fields': {
'value': float(psutil.cpu_percent(0))
}
......
File moved
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment