Compare commits
No commits in common. "master" and "0.0.8" have entirely different histories.
@ -1,56 +1,8 @@
|
|||||||
steps:
|
steps:
|
||||||
build:
|
build:
|
||||||
image: golang:1.22.5-alpine3.20
|
|
||||||
commands:
|
|
||||||
- GOPATH=/woodpecker/go
|
|
||||||
- ls -l
|
|
||||||
- cd src/smq
|
|
||||||
- go mod tidy
|
|
||||||
- go build -a -installsuffix nocgo -o smq snmp-mqtt.go
|
|
||||||
- cp smq ../..
|
|
||||||
when:
|
|
||||||
- event: [push, tag]
|
|
||||||
|
|
||||||
scan:
|
|
||||||
image: quay.io/wollud1969/woodpecker-helper:0.5.1
|
|
||||||
environment:
|
|
||||||
TRIVY_TOKEN:
|
|
||||||
from_secret: trivy_token
|
|
||||||
TRIVY_URL:
|
|
||||||
from_secret: trivy_url
|
|
||||||
DTRACK_API_KEY:
|
|
||||||
from_secret: dtrack_api_key
|
|
||||||
DTRACK_API_URL:
|
|
||||||
from_secret: dtrack_api_url
|
|
||||||
commands:
|
|
||||||
- export GOPATH=/woodpecker/go # the export is required, otherwise trivy will not consider the variable
|
|
||||||
- HOME=/home/`id -nu`
|
|
||||||
- TAG="${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
|
|
||||||
- |
|
|
||||||
trivy fs \
|
|
||||||
--server $TRIVY_URL \
|
|
||||||
--token $TRIVY_TOKEN \
|
|
||||||
--format cyclonedx \
|
|
||||||
--scanners license \
|
|
||||||
--output /tmp/sbom.xml \
|
|
||||||
.
|
|
||||||
- cat /tmp/sbom.xml
|
|
||||||
- |
|
|
||||||
curl -X "POST" \
|
|
||||||
-H "Content-Type: multipart/form-data" \
|
|
||||||
-H "X-Api-Key: $DTRACK_API_KEY" \
|
|
||||||
-F "autoCreate=true" \
|
|
||||||
-F "projectName=$CI_REPO" \
|
|
||||||
-F "projectVersion=$TAG" \
|
|
||||||
-F "bom=@/tmp/sbom.xml"\
|
|
||||||
"$DTRACK_API_URL/api/v1/bom"
|
|
||||||
when:
|
|
||||||
- event: [push, tag]
|
|
||||||
|
|
||||||
dockerize:
|
|
||||||
image: plugins/kaniko
|
image: plugins/kaniko
|
||||||
settings:
|
settings:
|
||||||
repo: ${FORGE_NAME}/${CI_REPO}
|
repo: gitea.hottis.de/wn/snmp-mqtt
|
||||||
registry:
|
registry:
|
||||||
from_secret: container_registry
|
from_secret: container_registry
|
||||||
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
|
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
|
||||||
@ -63,10 +15,10 @@ steps:
|
|||||||
- event: [push, tag]
|
- event: [push, tag]
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
image: quay.io/wollud1969/woodpecker-helper:0.5.1
|
image: portainer/kubectl-shell:latest
|
||||||
environment:
|
secrets:
|
||||||
KUBE_CONFIG_CONTENT:
|
- source: kube_config
|
||||||
from_secret: kube_config
|
target: KUBE_CONFIG_CONTENT
|
||||||
commands:
|
commands:
|
||||||
- export IMAGE_TAG=$CI_COMMIT_TAG
|
- export IMAGE_TAG=$CI_COMMIT_TAG
|
||||||
- printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig
|
- printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig
|
||||||
@ -74,4 +26,3 @@ steps:
|
|||||||
- ./deployment/deploy.sh
|
- ./deployment/deploy.sh
|
||||||
when:
|
when:
|
||||||
- event: tag
|
- event: tag
|
||||||
|
|
||||||
|
10
Dockerfile
10
Dockerfile
@ -1,8 +1,16 @@
|
|||||||
|
FROM golang:1.21-alpine as builder
|
||||||
|
|
||||||
|
RUN mkdir -p /go/src
|
||||||
|
COPY ./src /go/src
|
||||||
|
WORKDIR /go/src/smq
|
||||||
|
RUN go build -a -installsuffix nocgo -o smq snmp-mqtt.go
|
||||||
|
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
ENV SNMP_MQTT_CONF ""
|
ENV SNMP_MQTT_CONF ""
|
||||||
|
|
||||||
COPY smq ./
|
COPY --from=builder /go/src/smq ./
|
||||||
ENTRYPOINT ["./smq"]
|
ENTRYPOINT ["./smq"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,97 +4,8 @@
|
|||||||
"tlsEnable": "false",
|
"tlsEnable": "false",
|
||||||
"topic": "snmp"
|
"topic": "snmp"
|
||||||
},
|
},
|
||||||
"interval": 60,
|
"interval": 10,
|
||||||
"snmpEndpoints": [
|
"snmpEndpoints": [
|
||||||
{
|
|
||||||
"endpoint": "172.16.13.10",
|
|
||||||
"label": "david",
|
|
||||||
"community": "public",
|
|
||||||
"oidTopics": [
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.4.1.2021.10.1.3.1",
|
|
||||||
"label": "load1",
|
|
||||||
"diff": "false"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.6.2",
|
|
||||||
"label": "lan-in",
|
|
||||||
"diff": "true"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.7.2",
|
|
||||||
"label": "lan-in-pkts",
|
|
||||||
"diff": "true"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.10.2",
|
|
||||||
"label": "lan-out",
|
|
||||||
"diff": "true"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.11.2",
|
|
||||||
"label": "lan-out-pkts",
|
|
||||||
"diff": "true"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.4.1.9676.1",
|
|
||||||
"label": "time-req-pkts",
|
|
||||||
"diff": "true"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"endpoint": "172.16.13.11",
|
|
||||||
"label": "harrison",
|
|
||||||
"community": "public",
|
|
||||||
"oidTopics": [
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.4.1.2021.10.1.3.1",
|
|
||||||
"label": "load1",
|
|
||||||
"diff": "false"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.4.1.9676.123.1.4",
|
|
||||||
"label": "stratum",
|
|
||||||
"diff": "false"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.4.1.9676.123.1.7",
|
|
||||||
"label": "rootdisp",
|
|
||||||
"diff": "false"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.4.1.9676.123.2.3",
|
|
||||||
"label": "ss-reset",
|
|
||||||
"diff": "false"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.4.1.9676.123.2.10",
|
|
||||||
"label": "processed-pkts",
|
|
||||||
"diff": "true"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.6.2",
|
|
||||||
"label": "lan-in",
|
|
||||||
"diff": "true"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.7.2",
|
|
||||||
"label": "lan-in-pkts",
|
|
||||||
"diff": "true"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.10.2",
|
|
||||||
"label": "lan-out",
|
|
||||||
"diff": "true"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"oid": ".1.3.6.1.2.1.31.1.1.1.11.2",
|
|
||||||
"label": "lan-out-pkts",
|
|
||||||
"diff": "true"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"endpoint": "172.16.3.1",
|
"endpoint": "172.16.3.1",
|
||||||
"label": "router",
|
"label": "router",
|
||||||
@ -111,6 +22,23 @@
|
|||||||
"diff": "true"
|
"diff": "true"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"endpoint": "172.16.3.3",
|
||||||
|
"label": "switch-cluster",
|
||||||
|
"community": "public",
|
||||||
|
"oidTopics": [
|
||||||
|
{
|
||||||
|
"oid": ".1.3.6.1.2.1.31.1.1.1.6.1",
|
||||||
|
"label": "uplink-in",
|
||||||
|
"diff": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"oid": ".1.3.6.1.2.1.31.1.1.1.10.1",
|
||||||
|
"label": "uplink-out",
|
||||||
|
"diff": "true"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module smq
|
module smq
|
||||||
|
|
||||||
go 1.22.5
|
go 1.21.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/eclipse/paho.mqtt.golang v1.4.3
|
github.com/eclipse/paho.mqtt.golang v1.4.3
|
||||||
@ -10,6 +10,6 @@ require (
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gorilla/websocket v1.5.0 // indirect
|
github.com/gorilla/websocket v1.5.0 // indirect
|
||||||
golang.org/x/net v0.34.0 // indirect
|
golang.org/x/net v0.15.0 // indirect
|
||||||
golang.org/x/sync v0.1.0 // indirect
|
golang.org/x/sync v0.1.0 // indirect
|
||||||
)
|
)
|
||||||
|
@ -18,8 +18,6 @@ type variable_t struct {
|
|||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Variable string `json:"variable"`
|
Variable string `json:"variable"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
Unit string `json:"unit"`
|
|
||||||
Status string `json:"status"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type message_t struct {
|
type message_t struct {
|
||||||
@ -132,8 +130,6 @@ func Start() {
|
|||||||
Label: oidTopic.Label,
|
Label: oidTopic.Label,
|
||||||
Variable: oidTopic.OID,
|
Variable: oidTopic.OID,
|
||||||
Value: convertedValue,
|
Value: convertedValue,
|
||||||
Unit: "",
|
|
||||||
Status: "",
|
|
||||||
}
|
}
|
||||||
message.Variables[oidTopic.Label] = v
|
message.Variables[oidTopic.Label] = v
|
||||||
|
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
COMMUNITY=""
|
|
||||||
HOST=""
|
|
||||||
BASE_OID=""
|
|
||||||
|
|
||||||
while getopts "c:h:b:" option; do
|
|
||||||
case $option in
|
|
||||||
c) COMMUNITY=$OPTARG
|
|
||||||
;;
|
|
||||||
h) HOST=$OPTARG
|
|
||||||
;;
|
|
||||||
b) BASE_OID=$OPTARG
|
|
||||||
;;
|
|
||||||
?)
|
|
||||||
echo "Usage $0 -c COMMUNITY -h HOST -b BASE_OID"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$COMMUNITY" = "" ]; then
|
|
||||||
echo "Set a community using -c"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$HOST" = "" ]; then
|
|
||||||
echo "Set a host using -h"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$BASE_OID" = "" ]; then
|
|
||||||
echo "Set a base oid using -b"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
snmpwalk -v 2c -c $COMMUNITY -On $HOST $BASE_OID | while read -r line; do
|
|
||||||
oid=`echo $line | awk '{print $1}'`
|
|
||||||
textoid=`snmptranslate $oid`
|
|
||||||
value=`echo $line | cut -d ' ' -f 3-`
|
|
||||||
echo "$oid ($textoid): $value"
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user