add chassis_name and slot_name for sonic chassis
This commit is contained in:
parent
337a9dbcf4
commit
b2757b14c0
52
1
Normal file
52
1
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
||||||
|
# Initialization code that may require console input (password prompts, [y/n]
|
||||||
|
# confirmations, etc.) must go above this block; everything else may go below.
|
||||||
|
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||||
|
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
source ~/tools/powerlevel10k/powerlevel10k.zsh-theme
|
||||||
|
|
||||||
|
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||||
|
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||||
|
|
||||||
|
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||||
|
|
||||||
|
export HISTFILE=~/.zsh_history
|
||||||
|
export HISTSIZE=100000
|
||||||
|
export HISTFILESIZE=100000
|
||||||
|
SAVEHIST=1000
|
||||||
|
|
||||||
|
alias ta="tmux attach-session -t"
|
||||||
|
alias ts="tmux new-session -A -s"
|
||||||
|
|
||||||
|
__tmux_fzf_get_session__() {
|
||||||
|
session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null |
|
||||||
|
fzf --exit-0 --preview='~/bin/tmux_tree {}')
|
||||||
|
echo "$session"
|
||||||
|
}
|
||||||
|
# Tmux session switcher (`tms foo` attaches to `foo` if exists, else creates
|
||||||
|
# it)
|
||||||
|
tms() {
|
||||||
|
[[ -n "$TMUX" ]] && change="switch-client" || change="attach-session"
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
if [[ "$1" == "-ask" ]]; then
|
||||||
|
read -r -p "New tmux session name: " session_name
|
||||||
|
else
|
||||||
|
session_name="$1"
|
||||||
|
fi
|
||||||
|
tmux $change -t "$session_name" 2>/dev/null || \
|
||||||
|
(tmux -f "$HOME/.tmux/tmux.conf" new-session -d -s "$session_name" && \
|
||||||
|
tmux $change -t "$session_name");
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
session=$(eval __tmux_fzf_get_session__)
|
||||||
|
tmux $change -t "$session" || echo "No sessions found."
|
||||||
|
}
|
||||||
|
|
||||||
|
export PATH="$HOME/bin:$HOME/.tmux/plugins/tmuxifier/bin:$PATH"
|
||||||
|
eval "$(tmuxifier init -)"
|
||||||
|
|
||||||
|
alias brcm_configure="smake configure PLATFORM=broadcom"
|
||||||
|
alias vs_configure="smake configure PLATFORM=vs"
|
||||||
|
alias smake_cfg_engine=""
|
@ -1,6 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
||||||
|
CHASSIS_NAME=`sonic-cfggen -d -v DEVICE_METADATA.localhost.chassis_name`
|
||||||
|
SLOT_ID=`sonic-cfggen -d -v DEVICE_METADATA.localhost.slot_id`
|
||||||
|
|
||||||
# Parse the device specific asic conf file, if it exists
|
# Parse the device specific asic conf file, if it exists
|
||||||
ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf
|
ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf
|
||||||
@ -19,8 +21,15 @@ else
|
|||||||
fi
|
fi
|
||||||
hostname=$(hostname)
|
hostname=$(hostname)
|
||||||
|
|
||||||
sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 \
|
template="\"udp_server_ip\": \"$udp_server_ip\", \"hostname\": \"$hostname\""
|
||||||
-a "{\"udp_server_ip\": \"$udp_server_ip\", \"hostname\": \"$hostname\"}" \
|
echo $template
|
||||||
> /etc/rsyslog.conf
|
if [ -n "$CHASSIS_NAME" ]; then
|
||||||
|
template="$template, \"chassis_name_marker\": \"CHASSIS_NAME:\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$SLOT_ID" ]; then
|
||||||
|
template="$template, \"slot_id_marker\": \"SLOT_ID:\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 -a "{$template}" >/etc/rsyslog.conf
|
||||||
systemctl restart rsyslog
|
systemctl restart rsyslog
|
@ -14,7 +14,6 @@
|
|||||||
#################
|
#################
|
||||||
|
|
||||||
$ModLoad imuxsock # provides support for local system logging
|
$ModLoad imuxsock # provides support for local system logging
|
||||||
|
|
||||||
{% set gconf = (SYSLOG_CONFIG | d({})).get('GLOBAL', {}) -%}
|
{% set gconf = (SYSLOG_CONFIG | d({})).get('GLOBAL', {}) -%}
|
||||||
{% set rate_limit_interval = gconf.get('rate_limit_interval') %}
|
{% set rate_limit_interval = gconf.get('rate_limit_interval') %}
|
||||||
{% set rate_limit_burst = gconf.get('rate_limit_burst') %}
|
{% set rate_limit_burst = gconf.get('rate_limit_burst') %}
|
||||||
@ -51,7 +50,7 @@ $UDPServerRun 514
|
|||||||
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
|
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
|
||||||
|
|
||||||
# Define a custom template
|
# Define a custom template
|
||||||
$template SONiCFileFormat,"%timegenerated%.%timegenerated:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
|
$template SONiCFileFormat,"%timegenerated%.%timegenerated:::date-subseconds% %HOSTNAME% {{chassis_name_marker}}{{DEVICE_METADATA['localhost']['chassis_name']}} {{slot_id_marker}}{{DEVICE_METADATA.localhost.slot_id}} %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
|
||||||
$ActionFileDefaultTemplate SONiCFileFormat
|
$ActionFileDefaultTemplate SONiCFileFormat
|
||||||
|
|
||||||
template(name="WelfRemoteFormat" type="string" string="%TIMESTAMP% id=firewall time=\"%timereported\
|
template(name="WelfRemoteFormat" type="string" string="%TIMESTAMP% id=firewall time=\"%timereported\
|
||||||
|
Reference in New Issue
Block a user