|
| 1 | +# Eaton UPS Standalone UCM (SNMP) |
| 2 | + |
| 3 | +This example describes the implementation of the [Standalone UCM](https://handbook.enapter.com/software/virtual_ucm/) concept using the opensource [Enapter python-sdk](https://github.com/Enapter/python-sdk) for monitoring Eaton UPS using SNMP protocol. |
| 4 | + |
| 5 | +In order to use this UCM you need to enable SNMPv1 protocol in the Web Interface of your UPS and set unique community name for the read only access. The default port for SNMP is 161 but also can be changed. |
| 6 | + |
| 7 | +As an example in this guide we will use the following dummy settings for configuration: |
| 8 | + |
| 9 | +UPS IP Address: 192.168.192.192 |
| 10 | + |
| 11 | +Community Name: public |
| 12 | + |
| 13 | +SNMP Port: 161 |
| 14 | + |
| 15 | +## Requirements |
| 16 | + |
| 17 | +It is recommended to run this UCM using Docker and Docker Compose. This will ensure that environment is correct. |
| 18 | + |
| 19 | +The UPS must be reachable from the computer where the Docker Container will be running. You can check availability and settings with `snmpget` command on Linux or Mac: |
| 20 | + |
| 21 | +```bash |
| 22 | +user@pc snmp-eaton-ups % snmpget -v1 -c public 192.168.192.192:161 1.3.6.1.2.1.33.1.1.1.0 |
| 23 | +SNMPv2-SMI::mib-2.33.1.1.1.0 = STRING: "EATON" |
| 24 | +``` |
| 25 | + |
| 26 | +## Step 1. Create Standalone UCM in Enapter Cloud |
| 27 | + |
| 28 | +Log in to the Enapter Cloud, navigate to the Site where you want to create Standalone UCM and click on `Add new` button in the Standalone Device section. |
| 29 | + |
| 30 | +After creating Standalone UCM, you need to Generate and save Configuration string also known as ENAPTER_VUCM_BLOB as well as save UCM ID which will be needed for the next step |
| 31 | + |
| 32 | +More information you can find on [this page](https://developers.enapter.com/docs/tutorial/software-ucms/standalone). |
| 33 | + |
| 34 | +## Step 2. Upload Blueprint into the Cloud |
| 35 | + |
| 36 | +The general case [Enapter Blueprint](https://marketplace.enapter.com/about) consists of two files - declaration in YAML format (manifest.yaml) and logic written in Lua. Howerver for this case the logic is written in Python as Lua implementation doesn't have SNMP integration. |
| 37 | + |
| 38 | +But for both cases we need to tell Enapter Cloud which telemetry we are going to send and store and how to name it. |
| 39 | + |
| 40 | +The easiest way to do that - using [Enapter CLI](https://github.com/Enapter/enapter-cli) to upload manifest.yaml into Cloud. The other option is to use [Web IDE](https://developers.enapter.com/docs/tutorial/uploading-blueprint). |
| 41 | + |
| 42 | +```bash |
| 43 | +user@pc snmp-eaton-ups % enapter devices upload --blueprint-dir . --hardware-id REAL_UCM_ID |
| 44 | +upload started with operation id 25721 |
| 45 | +[#25721] 2023-07-20T16:27:33Z [INFO] Started uploading blueprint[id=dcb05efe-1618-4b01-877b-6105960690bc] on device[hardware_id=REAL_UCM_ID] |
| 46 | +[#25721] 2023-07-20T16:27:33Z [INFO] Generating configuration for uploading |
| 47 | +[#25721] 2023-07-20T16:27:33Z [INFO] Updating configuration in the cloud platform |
| 48 | +[#25721] 2023-07-20T16:27:33Z [INFO] Updating configuration on the gateway |
| 49 | +[#25721] 2023-07-20T16:27:35Z [INFO] Uploading blueprint finished successfully |
| 50 | +Done! |
| 51 | +``` |
| 52 | +
|
| 53 | +## Step 3. Configuring Standalone UCM |
| 54 | +
|
| 55 | +Open `docker-compose.yaml` in any editor. |
| 56 | +
|
| 57 | +Set environment variables according to your configuration settings. With dummy settings your file will look like this: |
| 58 | +
|
| 59 | +```yaml |
| 60 | +version: "3" |
| 61 | +services: |
| 62 | + snmp-eaton-ups-ucm: |
| 63 | + build: . |
| 64 | + image: enapter-vucm-examples/snmp-eaton-ups:latest |
| 65 | + environment: |
| 66 | + ENAPTER_VUCM_BLOB: "REALENAPTERVUCMBLOBMUSTBEHERE=" |
| 67 | + ENAPTER_SNMP_HOST: "192.168.192.192" |
| 68 | + ENAPTER_SNMP_PORT: "161" |
| 69 | + ENAPTER_SNMP_COMMUNITY: "public" |
| 70 | +``` |
| 71 | +
|
| 72 | +## Step 4. Build Docker Image with Standalone UCM |
| 73 | +
|
| 74 | +> You can you can skip this step and go directly to th Step 5. |
| 75 | +> Docker Compose will automatically build your image before starting container. |
| 76 | +
|
| 77 | +Build your Docker image by running `bash docker_build.sh` command in directory with UCM. |
| 78 | +
|
| 79 | +```bash |
| 80 | +user@pc snmp-eaton-ups % bash docker_build.sh |
| 81 | +#0 building with "desktop-linux" instance using docker driver |
| 82 | + |
| 83 | +#1 [internal] load .dockerignore |
| 84 | +#1 transferring context: 2B done |
| 85 | +#1 DONE 0.0s |
| 86 | + |
| 87 | +#2 [internal] load build definition from Dockerfile |
| 88 | +#2 transferring dockerfile: 281B done |
| 89 | +#2 DONE 0.0s |
| 90 | + |
| 91 | +#3 [internal] load metadata for docker.io/library/python:3.10-alpine3.16 |
| 92 | +#3 DONE 2.0s |
| 93 | + |
| 94 | +#4 [1/7] FROM docker.io/library/python:3.10-alpine3.16@sha256:afe68972cc00883d70b3760ee0ffbb7375cf09706c122dda7063ffe64c5be21b |
| 95 | +#4 DONE 0.0s |
| 96 | + |
| 97 | +#5 [internal] load build context |
| 98 | +#5 transferring context: 66B done |
| 99 | +#5 DONE 0.0s |
| 100 | + |
| 101 | +#6 [3/7] RUN apk add build-base |
| 102 | +#6 CACHED |
| 103 | + |
| 104 | +#7 [2/7] WORKDIR /app |
| 105 | +#7 CACHED |
| 106 | + |
| 107 | +#8 [4/7] RUN python -m venv .venv |
| 108 | +#8 CACHED |
| 109 | + |
| 110 | +#9 [5/7] COPY requirements.txt requirements.txt |
| 111 | +#9 CACHED |
| 112 | + |
| 113 | +#10 [6/7] RUN .venv/bin/pip install -r requirements.txt |
| 114 | +#10 CACHED |
| 115 | + |
| 116 | +#11 [7/7] COPY script.py script.py |
| 117 | +#11 CACHED |
| 118 | + |
| 119 | +#12 exporting to image |
| 120 | +#12 exporting layers done |
| 121 | +#12 writing image sha256:92e1050debeabaff5837c6ca5bc26b0b966d09fc6f24e21b1d10cbb2f4d9aeec done |
| 122 | +#12 naming to docker.io/enapter-vucm-examples/snmp-eaton-ups:latest done |
| 123 | +#12 DONE 0.0s |
| 124 | +``` |
| 125 | +
|
| 126 | +Your `enapter-vucm-examples/snmp-eaton-ups` image is now built and you can see it by running `docker images` command: |
| 127 | +
|
| 128 | +```bash |
| 129 | +user@pc snmp-eaton-ups % docker images enapter-vucm-examples/snmp-eaton-ups |
| 130 | +REPOSITORY TAG IMAGE ID CREATED SIZE |
| 131 | +enapter-vucm-examples/snmp-eaton-ups latest 92e1050debea 5 hours ago 285MB |
| 132 | +``` |
| 133 | +
|
| 134 | +## Step 5. Run your Standalone UCM Docker Container |
| 135 | +
|
| 136 | +Finally run your Standalone UCM with `docker-compose up` command: |
| 137 | +
|
| 138 | +```bash |
| 139 | +user@pc snmp-eaton-ups % docker-compose up |
| 140 | +[+] Running 1/0 |
| 141 | + ✔ Container snmp-eaton-ups-snmp-eaton-ups-ucm-1 Created 0.0s |
| 142 | +Attaching to snmp-eaton-ups-snmp-eaton-ups-ucm-1 |
| 143 | +snmp-eaton-ups-snmp-eaton-ups-ucm-1 | {"time": "2023-07-20T15:50:01.570744", "level": "INFO", "name": "enapter.mqtt.client", "host": "10.1.1.47", "port": 8883, "message": "starting"} |
| 144 | +snmp-eaton-ups-snmp-eaton-ups-ucm-1 | {"time": "2023-07-20T15:50:21.776037", "level": "INFO", "name": "enapter.mqtt.client", "host": "10.1.1.47", "port": 8883, "message": "client ready"} |
| 145 | +``` |
| 146 | +
|
| 147 | +On this step you can check that your UCM is now Online in the Cloud. |
0 commit comments