[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:
Jipan Yang 2018-03-27 13:39:04 -07:00 committed by lguohan
parent da42bd75a8
commit f74de8914b
20 changed files with 250 additions and 9 deletions

1
.gitignore vendored
View File

@ -57,6 +57,7 @@ dockers/docker-router-advertiser/Dockerfile
dockers/docker-snmp-sv2/Dockerfile dockers/docker-snmp-sv2/Dockerfile
dockers/docker-teamd/Dockerfile dockers/docker-teamd/Dockerfile
dockers/docker-sonic-mgmt/Dockerfile dockers/docker-sonic-mgmt/Dockerfile
dockers/docker-sonic-telemetry/Dockerfile
platform/*/docker-syncd-*/Dockerfile platform/*/docker-syncd-*/Dockerfile
platform/*/docker-syncd-*-rpc/Dockerfile platform/*/docker-syncd-*-rpc/Dockerfile
platform/vs/docker-sonic-vs/Dockerfile platform/vs/docker-sonic-vs/Dockerfile

View File

@ -70,7 +70,8 @@ SONIC_BUILD_INSTRUCTION := make \
USERNAME=$(USERNAME) \ USERNAME=$(USERNAME) \
SONIC_BUILD_JOBS=$(SONIC_BUILD_JOBS) \ SONIC_BUILD_JOBS=$(SONIC_BUILD_JOBS) \
HTTP_PROXY=$(http_proxy) \ 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 .PHONY: sonic-slave-build sonic-slave-bash init reset

View 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"]

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Start with default config
exec /usr/sbin/dialout_client_cli -insecure -logtostderr -v 2

View 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

View 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

View 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}

View 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

View File

@ -31,6 +31,7 @@
/var/log/cron.log /var/log/cron.log
/var/log/syslog /var/log/syslog
/var/log/teamd.log /var/log/teamd.log
/var/log/telemetry.log
/var/log/quagga/bgpd.log /var/log/quagga/bgpd.log
/var/log/quagga/zebra.log /var/log/quagga/zebra.log
/var/log/swss/sairedis.rec /var/log/swss/sairedis.rec

View File

@ -19,3 +19,9 @@ if $programname contains "teamd_" then {
/var/log/teamd.log /var/log/teamd.log
stop stop
} }
## telemetry rules
if $msg startswith " telemetry" or ($msg startswith " dialout" )then {
/var/log/telemetry.log
stop
}

View File

@ -27,12 +27,12 @@ DEFAULT_USERNAME = admin
DEFAULT_PASSWORD = YourPaSsWoRd DEFAULT_PASSWORD = YourPaSsWoRd
# ENABLE_DHCP_GRAPH_SERVICE - specify the source of minigraph to generate configuration file. # ENABLE_DHCP_GRAPH_SERVICE - specify the source of minigraph to generate configuration file.
# If set to y SONiC will get the minigraph from graph service. Graph service URL need to be # If set to y SONiC will get the minigraph from graph service. Graph service URL need to be
# passed through DHCP option 225. # passed through DHCP option 225.
# If not set (default behavior) the default minigraph built into the image will be used. # If not set (default behavior) the default minigraph built into the image will be used.
# ENABLE_DHCP_GRAPH_SERVICE = y # ENABLE_DHCP_GRAPH_SERVICE = y
# SHUTDOWN_BGP_ON_START - if set to y all bgp sessions will be in admin down state when # SHUTDOWN_BGP_ON_START - if set to y all bgp sessions will be in admin down state when
# bgp service starts. # bgp service starts.
# SHUTDOWN_BGP_ON_START = y # SHUTDOWN_BGP_ON_START = y
@ -52,6 +52,9 @@ SONIC_ROUTING_STACK = quagga
# ENABLE_SYNCD_RPC - build docker-syncd with rpc packages for testing purposes. # ENABLE_SYNCD_RPC - build docker-syncd with rpc packages for testing purposes.
# Uncomment to enable: # Uncomment to enable:
# ENABLE_SYNCD_RPC = y # ENABLE_SYNCD_RPC = y
# Enable Origanization Extensions - Specific to the deployment scenarios of the Organization # Enable Origanization Extensions - Specific to the deployment scenarios of the Organization
ENABLE_ORGANIZATION_EXTENSIONS = y 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
View 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
View 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)

View File

@ -12,8 +12,8 @@ GUID = $(shell id -g)
.SECONDEXPANSION: .SECONDEXPANSION:
SPACE := SPACE :=
SPACE += SPACE +=
############################################################################### ###############################################################################
## General definitions ## General definitions
@ -107,6 +107,7 @@ $(info "ENABLE_SYNCD_RPC" : "$(ENABLE_SYNCD_RPC)")
$(info "ENABLE_ORGANIZATION_EXTENSIONS" : "$(ENABLE_ORGANIZATION_EXTENSIONS)") $(info "ENABLE_ORGANIZATION_EXTENSIONS" : "$(ENABLE_ORGANIZATION_EXTENSIONS)")
$(info "HTTP_PROXY" : "$(HTTP_PROXY)") $(info "HTTP_PROXY" : "$(HTTP_PROXY)")
$(info "HTTPS_PROXY" : "$(HTTPS_PROXY)") $(info "HTTPS_PROXY" : "$(HTTPS_PROXY)")
$(info "ENABLE_SYSTEM_TELEMETRY" : "$(ENABLE_SYSTEM_TELEMETRY)")
$(info ) $(info )
############################################################################### ###############################################################################
@ -441,7 +442,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export image_type="$($*_IMAGE_TYPE)" export image_type="$($*_IMAGE_TYPE)"
export sonicadmin_user="$(USERNAME)" export sonicadmin_user="$(USERNAME)"
export sonic_asic_platform="$(CONFIGURED_PLATFORM)" export sonic_asic_platform="$(CONFIGURED_PLATFORM)"
export enable_organization_extensions="$(ENABLE_ORGANIZATION_EXTENSIONS)" export enable_organization_extensions="$(ENABLE_ORGANIZATION_EXTENSIONS)"
export enable_dhcp_graph_service="$(ENABLE_DHCP_GRAPH_SERVICE)" export enable_dhcp_graph_service="$(ENABLE_DHCP_GRAPH_SERVICE)"
export shutdown_bgp_on_start="$(SHUTDOWN_BGP_ON_START)" export shutdown_bgp_on_start="$(SHUTDOWN_BGP_ON_START)"
export enable_pfcwd_on_start="$(ENABLE_PFCWD_ON_START)" export enable_pfcwd_on_start="$(ENABLE_PFCWD_ON_START)"
@ -451,7 +452,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export config_engine_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CONFIG_ENGINE))" export config_engine_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CONFIG_ENGINE))"
export swsssdk_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SWSSSDK_PY2))" export swsssdk_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SWSSSDK_PY2))"
export platform_common_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY2))" export platform_common_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY2))"
$(foreach docker, $($*_DOCKERS),\ $(foreach docker, $($*_DOCKERS),\
export docker_image="$(docker)" export docker_image="$(docker)"
export docker_image_name="$(basename $(docker))" export docker_image_name="$(basename $(docker))"
@ -472,7 +473,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
j2 -f env files/initramfs-tools/union-mount.j2 onie-image.conf > files/initramfs-tools/union-mount j2 -f env files/initramfs-tools/union-mount.j2 onie-image.conf > files/initramfs-tools/union-mount
j2 -f env files/initramfs-tools/arista-convertfs.j2 onie-image.conf > files/initramfs-tools/arista-convertfs j2 -f env files/initramfs-tools/arista-convertfs.j2 onie-image.conf > files/initramfs-tools/arista-convertfs
$(if $($*_DOCKERS), $(if $($*_DOCKERS),
j2 files/build_templates/sonic_debian_extension.j2 > sonic_debian_extension.sh j2 files/build_templates/sonic_debian_extension.j2 > sonic_debian_extension.sh
chmod +x sonic_debian_extension.sh, chmod +x sonic_debian_extension.sh,
) )

20
src/telemetry/Makefile Normal file
View 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}

View 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

View File

@ -0,0 +1 @@
9

View 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

View File

@ -0,0 +1,3 @@
#!/usr/bin/make -f
%:
dh $@ --with systemd

View 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