3 Commits

4 changed files with 81 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
build
.DS_Store
snmp-mqtt

29
.woodpecker.yml Normal file
View File

@ -0,0 +1,29 @@
steps:
build:
image: plugins/kaniko
settings:
repo: gitea.hottis.de/wn/snmp-mqtt
registry:
from_secret: container_registry
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
username:
from_secret: container_registry_username
password:
from_secret: container_registry_password
dockerfile: Dockerfile
when:
- event: [push, tag]
deploy:
image: portainer/kubectl-shell:latest
secrets:
- source: kube_config
target: KUBE_CONFIG_CONTENT
- source: image_name
target: IMAGE_NAME
commands:
- printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig
- export KUBECONFIG=/tmp/kubeconfig
- cat $CI_WORKSPACE/deployment/deploy-yml.tmpl | sed -e 's,%IMAGE%,'$IMAGE_NAME':'$CI_COMMIT_TAG',' | kubectl apply -f -
when:
- event: tag

21
Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM golang:1.21-alpine as builder
RUN mkdir -p /go/src /go/src/snmp /go/src/config
COPY ./snmp-mqtt.go /go/src
COPY ./snmp/ /go/src/snmp
COPY ./config/ /go/src/config
COPY ./go.mod /go/src
COPY ./go.sum /go/src
WORKDIR /go/src
RUN go mod tidy && go build -a -installsuffix nocgo -o snmp-mqtt github.com/dchote/snmp-mqtt
FROM scratch
ENV SNMP_MQTT_CONF ""
COPY --from=builder /go/src/snmp-mqtt ./
ENTRYPOINT ["./snmp-mqtt"]

View File

@ -87,6 +87,36 @@
"topic": "power/printerUPS/batteryTemperature"
}
]
},
{
"endpoint": "172.18.0.53",
"community": "public",
"oidTopics": [
{
"oid": ".1.3.6.1.4.1.318.1.1.1.3.2.1.0",
"topic": "power/dansDesk/lineVoltage"
},
{
"oid": ".1.3.6.1.4.1.318.1.1.1.4.2.4.0",
"topic": "power/dansDesk/outputCurrent"
},
{
"oid": ".1.3.6.1.4.1.318.1.1.1.2.2.1.0",
"topic": "power/dansDesk/batteryCapacity"
},
{
"oid": ".1.3.6.1.4.1.318.1.1.1.2.2.3.0",
"topic": "power/dansDesk/batteryRuntime"
},
{
"oid": ".1.3.6.1.4.1.318.1.1.1.2.2.2.0",
"topic": "power/dansDesk/batteryTemperature"
},
{
"oid": ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1",
"topic": "power/dansDesk/temperatureProbe"
}
]
}
]
}