[telemetry]: SONiC system telemetry Support (#1526)
* SONiC system telemetry Support Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com> * Update package name from telemetry to sonic-telemetry Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
This commit is contained in:
parent
da42bd75a8
commit
f74de8914b
1
.gitignore
vendored
1
.gitignore
vendored
@ -57,6 +57,7 @@ dockers/docker-router-advertiser/Dockerfile
|
||||
dockers/docker-snmp-sv2/Dockerfile
|
||||
dockers/docker-teamd/Dockerfile
|
||||
dockers/docker-sonic-mgmt/Dockerfile
|
||||
dockers/docker-sonic-telemetry/Dockerfile
|
||||
platform/*/docker-syncd-*/Dockerfile
|
||||
platform/*/docker-syncd-*-rpc/Dockerfile
|
||||
platform/vs/docker-sonic-vs/Dockerfile
|
||||
|
3
Makefile
3
Makefile
@ -70,7 +70,8 @@ SONIC_BUILD_INSTRUCTION := make \
|
||||
USERNAME=$(USERNAME) \
|
||||
SONIC_BUILD_JOBS=$(SONIC_BUILD_JOBS) \
|
||||
HTTP_PROXY=$(http_proxy) \
|
||||
HTTPS_PROXY=$(https_proxy)
|
||||
HTTPS_PROXY=$(https_proxy) \
|
||||
ENABLE_SYSTEM_TELEMETRY=$(ENABLE_SYSTEM_TELEMETRY)
|
||||
|
||||
.PHONY: sonic-slave-build sonic-slave-bash init reset
|
||||
|
||||
|
31
dockers/docker-sonic-telemetry/Dockerfile.j2
Normal file
31
dockers/docker-sonic-telemetry/Dockerfile.j2
Normal file
@ -0,0 +1,31 @@
|
||||
FROM docker-config-engine
|
||||
|
||||
## Make apt-get non-interactive
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
RUN apt-get install -f -y libdbus-1-3 libdaemon0 libjansson4
|
||||
|
||||
## Install redis-tools dependencies
|
||||
## TODO: implicitly install dependencies
|
||||
RUN apt-get -y install libjemalloc1
|
||||
|
||||
COPY \
|
||||
{% for deb in docker_sonic_telemetry_debs.split(' ') -%}
|
||||
debs/{{ deb }}{{' '}}
|
||||
{%- endfor -%}
|
||||
debs/
|
||||
|
||||
RUN dpkg -i \
|
||||
{% for deb in docker_sonic_telemetry_debs.split(' ') -%}
|
||||
debs/{{ deb }}{{' '}}
|
||||
{%- endfor %}
|
||||
|
||||
COPY ["start.sh", "telemetry.sh", "dialout.sh", "/usr/bin/"]
|
||||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
||||
|
||||
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
|
||||
RUN rm -rf /debs
|
||||
|
||||
ENTRYPOINT ["/usr/bin/supervisord"]
|
6
dockers/docker-sonic-telemetry/dialout.sh
Executable file
6
dockers/docker-sonic-telemetry/dialout.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Start with default config
|
||||
|
||||
exec /usr/sbin/dialout_client_cli -insecure -logtostderr -v 2
|
||||
|
11
dockers/docker-sonic-telemetry/start.sh
Executable file
11
dockers/docker-sonic-telemetry/start.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
mkdir -p /var/sonic
|
||||
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
|
||||
|
||||
rm -f /var/run/rsyslogd.pid
|
||||
|
||||
supervisorctl start rsyslogd
|
||||
|
||||
supervisorctl start telemetry
|
||||
supervisorctl start dialout
|
36
dockers/docker-sonic-telemetry/supervisord.conf
Normal file
36
dockers/docker-sonic-telemetry/supervisord.conf
Normal file
@ -0,0 +1,36 @@
|
||||
[supervisord]
|
||||
logfile_maxbytes=1MB
|
||||
logfile_backups=2
|
||||
nodaemon=true
|
||||
|
||||
[program:start.sh]
|
||||
command=/usr/bin/start.sh
|
||||
priority=1
|
||||
autostart=true
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
|
||||
[program:rsyslogd]
|
||||
command=/usr/sbin/rsyslogd -n
|
||||
priority=2
|
||||
autostart=false
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
|
||||
[program:telemetry]
|
||||
command=/usr/bin/telemetry.sh
|
||||
priority=3
|
||||
autostart=false
|
||||
autorestart=true
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
|
||||
[program:dialout]
|
||||
command=/usr/bin/dialout.sh
|
||||
priority=4
|
||||
autostart=false
|
||||
autorestart=true
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
51
dockers/docker-sonic-telemetry/telemetry.sh
Executable file
51
dockers/docker-sonic-telemetry/telemetry.sh
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Try to read telemetry and x509 config from ConfigDB.
|
||||
# Use default value if no valid config exists
|
||||
X509=`sonic-cfggen -d -v "DEVICE_METADATA['x509']"`
|
||||
TELEMETRY=`sonic-cfggen -d -v 'TELEMETRY.keys() | join(" ") if TELEMETRY'`
|
||||
|
||||
TELEMETRY_ARGS=" -logtostderr"
|
||||
|
||||
if [ ! -z $X509 ]; then
|
||||
SERVER_CRT=`sonic-cfggen -d -v "DEVICE_METADATA['x509']['server_crt']"`
|
||||
SERVER_KEY=`sonic-cfggen -d -v "DEVICE_METADATA['x509']['server_key']"`
|
||||
if [ -z $SERVER_CRT ] || [ -z $SERVER_KEY ]; then
|
||||
TELEMETRY_ARGS+=" --insecure"
|
||||
else
|
||||
TELEMETRY_ARGS+=" --server_crt $SERVER_CRT --server_key $SERVER_KEY "
|
||||
fi
|
||||
else
|
||||
TELEMETRY_ARGS+=" --insecure"
|
||||
fi
|
||||
|
||||
if [ ! -z $X509 ]; then
|
||||
CA_CRT=`sonic-cfggen -d -v "DEVICE_METADATA['x509']['ca_crt']"`
|
||||
if [ ! -z $CA_CRT ]; then
|
||||
TELEMETRY_ARGS+=" --ca_crt $CA_CRT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If no configuration entry exists for TELEMETRY, create one default port
|
||||
if [ -z $TELEMETRY ]; then
|
||||
redis-cli -n 4 hset "TELEMETRY|gnmi" port 8080
|
||||
fi
|
||||
|
||||
PORT=`sonic-cfggen -d -v "TELEMETRY['gnmi']['port']"`
|
||||
TELEMETRY_ARGS+=" --port $PORT"
|
||||
|
||||
CLIENT_AUTH=`sonic-cfggen -d -v "TELEMETRY['gnmi']['client_auth']"`
|
||||
if [ -z $CLIENT_AUTH ] || [ $CLIENT_AUTH == "false" ]; then
|
||||
TELEMETRY_ARGS+=" --allow_no_client_auth"
|
||||
fi
|
||||
|
||||
LOG_LEVEL=`sonic-cfggen -d -v "TELEMETRY['gnmi']['log_level']"`
|
||||
if [ ! -z $LOG_LEVEL ]; then
|
||||
TELEMETRY_ARGS+=" -v=$LOG_LEVEL"
|
||||
else
|
||||
TELEMETRY_ARGS+=" -v=2"
|
||||
fi
|
||||
|
||||
exec /usr/sbin/telemetry ${TELEMETRY_ARGS}
|
||||
|
||||
|
13
files/build_templates/telemetry.service.j2
Normal file
13
files/build_templates/telemetry.service.j2
Normal file
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Telemetry container
|
||||
Requires=swss.service
|
||||
After=swss.service
|
||||
|
||||
[Service]
|
||||
User={{ sonicadmin_user }}
|
||||
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
|
||||
ExecStart=/usr/bin/{{docker_container_name}}.sh attach
|
||||
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -31,6 +31,7 @@
|
||||
/var/log/cron.log
|
||||
/var/log/syslog
|
||||
/var/log/teamd.log
|
||||
/var/log/telemetry.log
|
||||
/var/log/quagga/bgpd.log
|
||||
/var/log/quagga/zebra.log
|
||||
/var/log/swss/sairedis.rec
|
||||
|
@ -19,3 +19,9 @@ if $programname contains "teamd_" then {
|
||||
/var/log/teamd.log
|
||||
stop
|
||||
}
|
||||
|
||||
## telemetry rules
|
||||
if $msg startswith " telemetry" or ($msg startswith " dialout" )then {
|
||||
/var/log/telemetry.log
|
||||
stop
|
||||
}
|
@ -55,3 +55,6 @@ SONIC_ROUTING_STACK = quagga
|
||||
|
||||
# Enable Origanization Extensions - Specific to the deployment scenarios of the Organization
|
||||
ENABLE_ORGANIZATION_EXTENSIONS = y
|
||||
|
||||
# ENABLE_SYSTEM_TELEMETRY - build docker-sonic-telemetry for system telemetry support
|
||||
# ENABLE_SYSTEM_TELEMETRY = y
|
||||
|
15
rules/docker-telemetry.mk
Normal file
15
rules/docker-telemetry.mk
Normal file
@ -0,0 +1,15 @@
|
||||
# docker image for telemetry agent
|
||||
|
||||
DOCKER_TELEMETRY = docker-sonic-telemetry.gz
|
||||
$(DOCKER_TELEMETRY)_PATH = $(DOCKERS_PATH)/docker-sonic-telemetry
|
||||
$(DOCKER_TELEMETRY)_DEPENDS += $(REDIS_TOOLS) $(SONIC_TELEMETRY)
|
||||
$(DOCKER_TELEMETRY)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE)
|
||||
SONIC_DOCKER_IMAGES += $(DOCKER_TELEMETRY)
|
||||
ifeq ($(ENABLE_SYSTEM_TELEMETRY), y)
|
||||
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_TELEMETRY)
|
||||
endif
|
||||
|
||||
$(DOCKER_TELEMETRY)_CONTAINER_NAME = telemetry
|
||||
$(DOCKER_TELEMETRY)_RUN_OPT += --net=host --privileged -t
|
||||
$(DOCKER_TELEMETRY)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
|
||||
|
5
rules/telemetry.mk
Normal file
5
rules/telemetry.mk
Normal file
@ -0,0 +1,5 @@
|
||||
# SONiC telemetry package
|
||||
|
||||
SONIC_TELEMETRY = sonic-telemetry_0.1_amd64.deb
|
||||
$(SONIC_TELEMETRY)_SRC_PATH = $(SRC_PATH)/telemetry
|
||||
SONIC_DPKG_DEBS += $(SONIC_TELEMETRY)
|
1
slave.mk
1
slave.mk
@ -107,6 +107,7 @@ $(info "ENABLE_SYNCD_RPC" : "$(ENABLE_SYNCD_RPC)")
|
||||
$(info "ENABLE_ORGANIZATION_EXTENSIONS" : "$(ENABLE_ORGANIZATION_EXTENSIONS)")
|
||||
$(info "HTTP_PROXY" : "$(HTTP_PROXY)")
|
||||
$(info "HTTPS_PROXY" : "$(HTTPS_PROXY)")
|
||||
$(info "ENABLE_SYSTEM_TELEMETRY" : "$(ENABLE_SYSTEM_TELEMETRY)")
|
||||
$(info )
|
||||
|
||||
###############################################################################
|
||||
|
20
src/telemetry/Makefile
Normal file
20
src/telemetry/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
export GOPATH=/tmp/go
|
||||
|
||||
INSTALL := /usr/bin/install
|
||||
|
||||
all: sonic-telemetry
|
||||
|
||||
sonic-telemetry:
|
||||
/usr/local/go/bin/go get -v github.com/Azure/sonic-telemetry/telemetry
|
||||
/usr/local/go/bin/go get -v github.com/Azure/sonic-telemetry/dialout/dialout_client_cli
|
||||
|
||||
install:
|
||||
$(INSTALL) -D ${GOPATH}/bin/telemetry $(DESTDIR)/usr/sbin/telemetry
|
||||
$(INSTALL) -D ${GOPATH}/bin/dialout_client_cli $(DESTDIR)/usr/sbin/dialout_client_cli
|
||||
|
||||
deinstall:
|
||||
rm $(DESTDIR)/usr/sbin/telemetry
|
||||
rm $(DESTDIR)/usr/sbin/dialout_client_cli
|
||||
|
||||
clean:
|
||||
rm -fr ${GOPATH}
|
5
src/telemetry/debian/changelog
Normal file
5
src/telemetry/debian/changelog
Normal file
@ -0,0 +1,5 @@
|
||||
sonic-telemetry (0.1) UNRELEASED; urgency=medium
|
||||
|
||||
* Initial release.
|
||||
|
||||
-- Jipan Yang <jipan.yang@alibaba-inc.com> Sat, 24 Mar 2018 12:48:22 -0700
|
1
src/telemetry/debian/compat
Normal file
1
src/telemetry/debian/compat
Normal file
@ -0,0 +1 @@
|
||||
9
|
17
src/telemetry/debian/control
Normal file
17
src/telemetry/debian/control
Normal file
@ -0,0 +1,17 @@
|
||||
Source: sonic-telemetry
|
||||
Section: devel
|
||||
Priority: optional
|
||||
Maintainer: Jipan Yang <jipan.yang@alibaba-inc.com>
|
||||
Build-Depends: debhelper (>= 8.0.0),
|
||||
dh-systemd
|
||||
Standards-Version: 3.9.3
|
||||
Homepage: https://github.com/Azure/sonic-telemetry
|
||||
XS-Go-Import-Path: github.com/Azure/sonic-telemetry
|
||||
|
||||
Package: sonic-telemetry
|
||||
Architecture: any
|
||||
Built-Using: ${misc:Built-Using}
|
||||
Depends: ${misc:Depends},
|
||||
${shlibs:Depends}
|
||||
Description: SONiC telemetry
|
||||
sonic-telemetry
|
3
src/telemetry/debian/rules
Normal file
3
src/telemetry/debian/rules
Normal file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/make -f
|
||||
%:
|
||||
dh $@ --with systemd
|
14
src/telemetry/debian/telemetry.init.d
Normal file
14
src/telemetry/debian/telemetry.init.d
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: sonic-telemetry
|
||||
# Required-Start: $local_fs $network $remote_fs $syslog
|
||||
# Required-Stop: $local_fs $network $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: start and stop the telemetry
|
||||
# Description: sonic-telemetry is an implementation of sonic telemetry daemon in Go
|
||||
### END INIT INFO
|
||||
#
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user