Compare commits
9 Commits
554da113e3
...
d82a83cca1
Author | SHA1 | Date | |
---|---|---|---|
d82a83cca1 | |||
09d4d305cd | |||
d4bc25fa59 | |||
fcce8f78b0 | |||
a417edcfed | |||
77d8153b43 | |||
28482d201d | |||
6294a2ea3a | |||
1e2a8fb6c7 |
@ -1,15 +1,17 @@
|
|||||||
services:
|
services:
|
||||||
zabbixagent:
|
onvif-agent:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: zabbixagent.dockerfile
|
dockerfile: zabbixagent.dockerfile
|
||||||
environment:
|
environment:
|
||||||
ZBX_HOSTNAME: OnvifAgent plugin
|
ZBX_HOSTNAME: ONVIF
|
||||||
ZBX_SERVER_HOST: server
|
ZBX_SERVER_HOST: server
|
||||||
ZBX_SERVER_PORT: 10051
|
ZBX_SERVER_PORT: 10051
|
||||||
volumes:
|
volumes:
|
||||||
- ./log:/var/log/onvif-agent
|
- ./log:/var/log/onvif-agent
|
||||||
- ./config.yaml:/etc/onvif-agent/config.yaml
|
- ./config.yaml:/etc/onvif-agent/config.yaml
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
networks:
|
networks:
|
||||||
- zabbix-network
|
- zabbix-network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
app:
|
app:
|
||||||
port: 8080
|
port: 8080
|
||||||
host: "localhost"
|
host: "0.0.0.0"
|
||||||
url: "http://localhost:8080"
|
url: "http://onvif-agent:8080"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package zabbixagent
|
package zabbixagent
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PluginName = "OnvifAgent"
|
PluginName = "ONVIF"
|
||||||
)
|
)
|
||||||
|
@ -76,9 +76,9 @@ func (p *zabbixAgentPlugin) registerMetrics() error {
|
|||||||
h := NewHandler()
|
h := NewHandler()
|
||||||
|
|
||||||
p.metrics = map[metricKey]*metricBinding{
|
p.metrics = map[metricKey]*metricBinding{
|
||||||
"onvif.version": {
|
"onvif.app.version": {
|
||||||
metric: metric.New(
|
metric: metric.New(
|
||||||
"ONVIF app version",
|
"App version",
|
||||||
nil,
|
nil,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
|
18
main.go
18
main.go
@ -19,8 +19,7 @@ func main() {
|
|||||||
/**
|
/**
|
||||||
* Logging
|
* Logging
|
||||||
*/
|
*/
|
||||||
date := time.Now().Format("2006-01-02")
|
logFile := fmt.Sprintf("%s.log", time.Now().Format("2006-01-02"))
|
||||||
logFile := fmt.Sprintf("%s.log", date)
|
|
||||||
var logFilePath string
|
var logFilePath string
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
logFilePath = fmt.Sprintf("/var/log/%s/%s", constant.AppName, logFile)
|
logFilePath = fmt.Sprintf("/var/log/%s/%s", constant.AppName, logFile)
|
||||||
@ -63,9 +62,16 @@ func main() {
|
|||||||
/**
|
/**
|
||||||
* Zabbix agent
|
* Zabbix agent
|
||||||
*/
|
*/
|
||||||
go func() {
|
//go func() {
|
||||||
zabbixagent.Run()
|
// zabbixagent.Run()
|
||||||
}()
|
//}()
|
||||||
|
//
|
||||||
|
//select {}
|
||||||
|
|
||||||
select {}
|
err = zabbixagent.Launch()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ FROM golang:1.23 AS builder
|
|||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY . ./
|
COPY . ./
|
||||||
RUN GOPROXY=https://goproxy.cn go mod download
|
RUN GOPROXY=https://goproxy.cn go mod download
|
||||||
RUN PROFILE=dev CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o out/app
|
RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o out/app
|
||||||
|
|
||||||
FROM zabbix/zabbix-agent2:ubuntu-7.0-latest
|
FROM zabbix/zabbix-agent2:ubuntu-7.0-latest
|
||||||
COPY --from=builder /build/out/app /usr/sbin/onvif-agent
|
COPY --from=builder /build/out/app /usr/sbin/zabbix-agent2-plugin/onvif-agent
|
||||||
RUN echo "Plugins.Onvif.System.Path=/usr/sbin/onvif-agent" >> /etc/zabbix/zabbix_agent2.d/plugins.d/onvif.conf
|
RUN echo "Plugins.ONVIF.System.Path=/usr/sbin/zabbix-agent2-plugin/onvif-agent" >> /etc/zabbix/zabbix_agent2.d/plugins.d/onvif.conf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user