Skip to content

Commit

Permalink
Merge pull request #17 from lux4rd0/2.0.06
Browse files Browse the repository at this point in the history
2.0.06
  • Loading branch information
lux4rd0 authored Jun 25, 2024
2 parents c9f0cd8 + f490e03 commit d0519da
Show file tree
Hide file tree
Showing 7 changed files with 1,292 additions and 435 deletions.
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
# Use an official Python runtime as a parent image
FROM python:3.10.8-slim
FROM python:3.12.3-slim

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /usr/src/app
# Copy the current directory contents into the container at /app
COPY sense-collector.py .
COPY storage.py .
COPY requirements.txt .

# Install any needed packages specified in requirements.txt

RUN apt-get update && \
apt-get install -y gcc python3-dev python3-pip && \
rm -rf /var/lib/apt/lists/*

# Install pip and the Python packages
RUN python3 -m pip install --no-cache-dir --upgrade pip \
&& python3 -m pip install --no-cache-dir -r /app/requirements.txt
&& python3 -m pip install --no-cache-dir -r requirements.txt

# Run script.py when the container launches
# Run sense-collector.py when the container launches
CMD ["python3", "./sense-collector.py"]
862 changes: 661 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

88 changes: 66 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The project is deployed as a Docker container.

Use the following [Docker container](https://hub.docker.com/r/lux4rd0/sense-collector):

lux4rd0/sense-collector:2.0.03
lux4rd0/sense-collector:2.0.06
lux4rd0/sense-collector:latest

Correct environmental variables are required for the container to function.
Expand All @@ -47,55 +47,40 @@ To start the docker container, simply update this example compose.yaml file:
container_name: sense-collector-53997
environment:
SENSE_COLLECTOR_API_PASSWORD: CHANGEME
SENSE_COLLECTOR_API_USERNAME: dave@pulpfree.org
SENSE_COLLECTOR_API_USERNAME: dave@lux4rd0.com
SENSE_COLLECTOR_HOST_HOSTNAME: sense-collector.lux4rd0.com
SENSE_COLLECTOR_INFLUXDB_BUCKET: sense
SENSE_COLLECTOR_INFLUXDB_ORG: Tylephony
SENSE_COLLECTOR_INFLUXDB_ORG: Lux4rd0
SENSE_COLLECTOR_INFLUXDB_TOKEN: TOKEN
SENSE_COLLECTOR_INFLUXDB_URL: http://sense-collector.lux4rd0.com:8086
SENSE_COLLECTOR_LOG_LEVEL_API: CRITICAL
SENSE_COLLECTOR_LOG_LEVEL_GENERAL: INFO
SENSE_COLLECTOR_LOG_LEVEL_STORAGE: CRITICAL
SENSE_COLLECTOR_SENSE_API_RECEIVE_DATA_OUTPUT: "False"
TZ: America/Chicago
image: lux4rd0/sense-collector:latest
restart: always
volumes:
- type: bind
source: /mnt/docker/sense-collector/export
target: /app/export
bind:
create_host_path: true

If you don't want to use docker-compose, an example docker run command will be displayed on the screen.

docker run --rm \
--name=sense-collector-53997 \
-e SENSE_COLLECTOR_API_PASSWORD=CHANGEME \
-e SENSE_COLLECTOR_API_USERNAME=dave@pulpfree.org \
-e SENSE_COLLECTOR_API_USERNAME=dave@lux4rd0.com \
-e SENSE_COLLECTOR_HOST_HOSTNAME=sense-collector.lux4rd0.com \
-e SENSE_COLLECTOR_INFLUXDB_BUCKET=sense \
-e SENSE_COLLECTOR_INFLUXDB_ORG=Tylephony \
-e SENSE_COLLECTOR_INFLUXDB_TOKEN=TOKEN \
-e SENSE_COLLECTOR_INFLUXDB_URL=http://sense-collector.lux4rd0.com:8086 \
-e SENSE_COLLECTOR_LOG_LEVEL_API=CRITICAL \
-e SENSE_COLLECTOR_LOG_LEVEL_GENERAL=INFO \
-e SENSE_COLLECTOR_LOG_LEVEL_STORAGE=CRITICAL \
-e SENSE_COLLECTOR_SENSE_API_RECEIVE_DATA_OUTPUT="False" \
-e TZ=America/Chicago \
-v /mnt/docker/sense-collector/export:/app/export \
--restart always \
lux4rd0/sense-collector:latest

Running `docker-compose up -d' or the `docker-run` command will download and start up the sense-collector container.

## Environmental Flags:

The Docker contain can be configured with additional environment flags to control collector behaviors. They are descript below:
The Docker contain can be configured with additional environment flags to control collector behaviors. They are described below:

# Sense Collector Environmental Variables

This document provides a detailed explanation of the environmental variables used to configure the Sense Collector Docker container. Each variable is classified as required or optional, along with its default value and possible options.
This document provides a detailed explanation of the environmental variables used to configure the Sense Collector Docker container. Each variable is classified as required or optional, with its default value and possible options.

## Environmental Variables

Expand Down Expand Up @@ -159,12 +144,71 @@ This document provides a detailed explanation of the environmental variables use
- **Default**: INFO
- **Options**: DEBUG, INFO, WARNING, ERROR, CRITICAL

### SENSE_COLLECTOR_SENSE_API_RECEIVE_DATA_OUTPUT
### SENSE_COLLECTOR_OUTPUT_RECEIVED_DATA
- **Description**: Enables or disables the output of received Sense API data to a file.
- **Required**: No
- **Default**: false
- **Options**: true, false

### SENSE_COLLECTOR_WS_HEARTBEAT_INTERVAL
- **Description**: Interval (in seconds) between heartbeat messages to keep the WebSocket connection alive.
- **Required**: No
- **Default**: 10
- **Options**: Integer value representing seconds

### SENSE_COLLECTOR_WS_HEARTBEAT_TIMEOUT
- **Description**: Timeout (in seconds) to wait for a heartbeat response before considering the WebSocket connection as dead.
- **Required**: No
- **Default**: 30
- **Options**: Integer value representing seconds

### SENSE_COLLECTOR_WS_RECONNECT_DELAY_INITIAL
- **Description**: Initial delay (in seconds) before attempting to reconnect the WebSocket after a connection loss.
- **Required**: No
- **Default**: 5
- **Options**: Integer value representing seconds

### SENSE_COLLECTOR_WS_RECONNECT_DELAY_CAP
- **Description**: Maximum delay (in seconds) between reconnection attempts.
- **Required**: No
- **Default**: 60
- **Options**: Integer value representing seconds

### SENSE_COLLECTOR_WS_MAX_RETRIES
- **Description**: Maximum number of retries for reconnecting the WebSocket before giving up.
- **Required**: No
- **Default**: 3
- **Options**: Integer value

### SENSE_COLLECTOR_WS_BACKOFF_FACTOR
- **Description**: Factor for exponential backoff between reconnection attempts.
- **Required**: No
- **Default**: 1
- **Options**: Integer value

### SENSE_COLLECTOR_WS_RECONNECT_INTERVAL
- **Description**: Interval (in seconds) between forced WebSocket reconnections to maintain a fresh connection.
- **Required**: No
- **Default**: 840
- **Options**: Integer value representing seconds

### SENSE_COLLECTOR_DEVICE_CACHE_EXPIRY_SECONDS
- **Description**: Duration (in seconds) for which the device data should be cached before it expires.
- **Required**: No
- **Default**: 120
- **Options**: Integer value representing seconds

### SENSE_COLLECTOR_DEVICE_MAX_CONCURRENT_LOOKUPS
- **Description**: Maximum number of concurrent lookups that can be performed for device data.
- **Required**: No
- **Default**: 4
- **Options**: Integer value

### SENSE_COLLECTOR_DEVICE_LOOKUP_DELAY_SECONDS
- **Description**: Delay (in seconds) between consecutive device data lookup requests.
- **Required**: No
- **Default**: 0.5
- **Options**: Float value representing seconds

## Collector Details

Expand Down
27 changes: 8 additions & 19 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
name: sense-collector
name: sense-collector-53997
services:
sense-collector:
container_name: sense-collector
sense-collector-53997:
container_name: sense-collector-53997
environment:
SENSE_COLLECTOR_API_PASSWORD: adkajsdlnaisdjasidamlisdmald
SENSE_COLLECTOR_API_USERNAME: [email protected]
SENSE_COLLECTOR_HOST_HOSTNAME: app20.tylephony.com
SENSE_COLLECTOR_API_PASSWORD: CHANGEME
SENSE_COLLECTOR_API_USERNAME: [email protected]
SENSE_COLLECTOR_INFLUXDB_BUCKET: sense
SENSE_COLLECTOR_INFLUXDB_ORG: Tylephony
SENSE_COLLECTOR_INFLUXDB_TOKEN: lkjijdalisdjoanisdnalisdjlamisdjm==
SENSE_COLLECTOR_INFLUXDB_URL: http://influxdb.lux4rd0.com:8086
SENSE_COLLECTOR_LOG_LEVEL_API: CRITICAL
SENSE_COLLECTOR_LOG_LEVEL_GENERAL: INFO
SENSE_COLLECTOR_LOG_LEVEL_STORAGE: CRITICAL
SENSE_COLLECTOR_SENSE_API_RECEIVE_DATA_OUTPUT: "False"
SENSE_COLLECTOR_INFLUXDB_ORG: Lux4rd0
SENSE_COLLECTOR_INFLUXDB_TOKEN: TOKEN
SENSE_COLLECTOR_INFLUXDB_URL: http://sense.lux4rd0.com:8086
TZ: America/Chicago
image: lux4rd0/sense-collector:latest
restart: always
volumes:
- type: bind
source: /mnt/docker/sense-collector/export
target: /app/export
bind:
create_host_path: true
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
aiohttp==3.9.1
influxdb_client==1.39.0
psutil==5.9.5
python_dateutil==2.8.2
pytz==2024.1
Requests==2.32.3
Expand Down
Loading

0 comments on commit d0519da

Please sign in to comment.