Compare commits
9 Commits
554da113e3
...
d82a83cca1
Author | SHA1 | Date | |
---|---|---|---|
d82a83cca1 | |||
09d4d305cd | |||
d4bc25fa59 | |||
fcce8f78b0 | |||
a417edcfed | |||
77d8153b43 | |||
28482d201d | |||
6294a2ea3a | |||
1e2a8fb6c7 |
@ -1,15 +1,17 @@
|
||||
services:
|
||||
zabbixagent:
|
||||
onvif-agent:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: zabbixagent.dockerfile
|
||||
environment:
|
||||
ZBX_HOSTNAME: OnvifAgent plugin
|
||||
ZBX_HOSTNAME: ONVIF
|
||||
ZBX_SERVER_HOST: server
|
||||
ZBX_SERVER_PORT: 10051
|
||||
volumes:
|
||||
- ./log:/var/log/onvif-agent
|
||||
- ./config.yaml:/etc/onvif-agent/config.yaml
|
||||
ports:
|
||||
- "8080:8080"
|
||||
networks:
|
||||
- zabbix-network
|
||||
restart: unless-stopped
|
||||
|
@ -1,4 +1,4 @@
|
||||
app:
|
||||
port: 8080
|
||||
host: "localhost"
|
||||
url: "http://localhost:8080"
|
||||
host: "0.0.0.0"
|
||||
url: "http://onvif-agent:8080"
|
||||
|
@ -1,5 +1,5 @@
|
||||
package zabbixagent
|
||||
|
||||
const (
|
||||
PluginName = "OnvifAgent"
|
||||
PluginName = "ONVIF"
|
||||
)
|
||||
|
@ -76,9 +76,9 @@ func (p *zabbixAgentPlugin) registerMetrics() error {
|
||||
h := NewHandler()
|
||||
|
||||
p.metrics = map[metricKey]*metricBinding{
|
||||
"onvif.version": {
|
||||
"onvif.app.version": {
|
||||
metric: metric.New(
|
||||
"ONVIF app version",
|
||||
"App version",
|
||||
nil,
|
||||
false,
|
||||
),
|
||||
|
18
main.go
18
main.go
@ -19,8 +19,7 @@ func main() {
|
||||
/**
|
||||
* Logging
|
||||
*/
|
||||
date := time.Now().Format("2006-01-02")
|
||||
logFile := fmt.Sprintf("%s.log", date)
|
||||
logFile := fmt.Sprintf("%s.log", time.Now().Format("2006-01-02"))
|
||||
var logFilePath string
|
||||
if runtime.GOOS == "linux" {
|
||||
logFilePath = fmt.Sprintf("/var/log/%s/%s", constant.AppName, logFile)
|
||||
@ -63,9 +62,16 @@ func main() {
|
||||
/**
|
||||
* Zabbix agent
|
||||
*/
|
||||
go func() {
|
||||
zabbixagent.Run()
|
||||
}()
|
||||
//go func() {
|
||||
// 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
|
||||
COPY . ./
|
||||
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
|
||||
COPY --from=builder /build/out/app /usr/sbin/onvif-agent
|
||||
RUN echo "Plugins.Onvif.System.Path=/usr/sbin/onvif-agent" >> /etc/zabbix/zabbix_agent2.d/plugins.d/onvif.conf
|
||||
COPY --from=builder /build/out/app /usr/sbin/zabbix-agent2-plugin/onvif-agent
|
||||
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