Skip to content

Instantly share code, notes, and snippets.

View nmicic's full-sized avatar
😀
I may be slow to respond.

Nenad Micic nmicic

😀
I may be slow to respond.
View GitHub Profile
@nmicic
nmicic / fizzbuzz.awk
Created June 17, 2018 17:17
fizzbuzz in awk
'{for(i=1;i<=100;i++){a=i;if(i%3==0){a="Fizz"}if(i%5==0){a=gensub(/[0-9]+/,"","g",a);a=a"Buzz"}print a;}}'
@nmicic
nmicic / i40e_dump.sh
Last active March 13, 2020 11:30
i40e_dump.sh
#!/bin/sh
### nmicic@cisco.com
### https://gist.github.com/nmicic/c04a9400ef39576e2d284aacf68bf99b ###
function help_message {
echo
echo "NOTE1: Script may cause kernel panic or reboot of the host! High risk running in production!"
echo "NOTE2: Script will clear dmesg. Please be aware! "man dmesg" for more info!"
echo "NOTE3: To run script execute: $0 run"
echo
}
@nmicic
nmicic / ucad_proc.sh
Last active August 4, 2022 10:46
More info about ASR5500 crypto chip from /proc/ucad from all cards in copy/paste format for debug shell ( on MIO ) Raw
#!/bin/bash
# ver 0.3
###### Please always collect 2x SSD before/after running this script! ####
# additionally please collect: "cat /proc/ucad/ipsec/sa_table" from DPC card we investigate from all CPU's of that DPC
read -r -d '' HELP_README << README_BEGIN_END
# get to debug shell after cli test-commands password ...
To run:
cd /var/tmp
cat > /var/tmp/ucad_proc.sh
<copy/paste this script>
@nmicic
nmicic / UcadCryptoMon.sh
Last active October 19, 2022 13:32
UcadCryptoMon.sh
#!/bin/bash
### Ver 4.4 # 17th Oct 2022
###Contact: nmicic@cisco.com
### NOTE script monitor for the following errors on DPC only
### ucam_cavecreek_dh_p1_sync()[2995]: cpaCyDhKeyGenPhase1() Failed with Status: -2!
###
### NOTE: Please copy/paste script from begin #!/bin/bash to the ###END
### NOTE: Please copy/paste script from begin #!/bin/bash to the ###END
### NOTE: Please copy/paste script from begin #!/bin/bash to the ###END
read -r -d '' HELP_README << README_BEGIN_END
@nmicic
nmicic / CUSP.sh
Last active August 16, 2022 21:52
process_pcaps_vlan3000+vlan_2000_RTT_issue
#!/bin/sh
FILE=$1
tshark -nr $FILE -q -z io,stat,1,"COUNT(tcp)tcp","COUNT(tcp.analysis.retransmission)tcp.analysis.retransmission","COUNT(tcp.analysis.fast_retransmission)tcp.analysis.fast_retransmission","COUNT(tcp.analysis.spurious_retransmission)tcp.analysis.spurious_retransmission","COUNT(tcp.analysis.duplicate_ack)tcp.analysis.duplicate_ack","COUNT(tcp.analysis.lost_segment)tcp.analysis.lost_segment","COUNT(tcp.analysis.ack_lost_segment)tcp.analysis.ack_lost_segment","COUNT(tcp.analysis.rto)tcp.analysis.rto","COUNT(tcp.analysis.out_of_order)tcp.analysis.out_of_order","MIN(tcp.window_size)tcp.window_size","AVG(tcp.window_size)tcp.window_size","MAX(tcp.window_size)","COUNT(tcp.analysis.window_full)tcp.analysis.window_full","COUNT(tcp.analysis.zero_window)tcp.analysis.zero_window","MIN(tcp.analysis.ack_rtt)tcp.analysis.ack_rtt","AVG(tcp.analysis.ack_rtt)tcp.analysis.ack_rtt","MAX(tcp.analysis.ack_rtt)tcp.analysis.ack_rtt","MIN(tcp.analysis.initial_rtt)tcp.analysis.initial_rtt","AVG(tcp.analysis.initial_rt
#!/bin/bash
DEBUG=1
test $DEBUG -ne 0 && set -vx
trap "date;echo Got Signal;echo 3 > /proc/sys/vm/drop_caches&rm -rf /mnt/user/hd-raid/records/cdr/Tests/*;exit;" 0 1 2 3 13 15
mkdir -p /mnt/user/hd-raid/records/cdr/Tests/
test ! -d /mnt/user/hd-raid/records/cdr/Tests/ && echo "ERROR /mnt/user/hd-raid/records/cdr/Tests/ doesn't exist" && exit
cd /mnt/user/hd-raid/records/cdr/Tests/
DAY=`date +%d`
RNDDIR="$DAY"/"$RANDOM"
mkdir -p $RNDDIR
@nmicic
nmicic / ucad_buffers_delta_icp.sh
Created August 4, 2022 14:07
ucad_buffers_delta_icp.sh
#!/bin/bash
PREVALLOC1=0
PREVALLOC2=0
PREVALLOC3=0
PREVALLOC4=0
PREVFREE1=0
PREVFREE2=0
PREVFREE3=0
PREVFREE4=0
#while [ 1 ]; do
@nmicic
nmicic / ring_buffer.sh
Last active September 8, 2022 08:52
ring_buffer
#!/bin/bash
cat << DONT_REMOVE_THIS_LINE_BEGIN_END_M > /tmp/Intel_ring_dump.tgz.base64
H4sIAAAAAAACA+xcDXRTVZ5/SVsaoCYRqlZReWgrRSE0bSnho9iUFF7Z4jBQ1Bmo
aUhSyJAvk5dSRnbs2bSuj1in7jmuHs4cl9nZ4zozu37M6Aw6zrS1QMGPGWTOOMwy
syKKJBaxrHxUEbL//333tTeveSi7jmf32FuSe+/v/r/u/37mvvuoD4pevzPiC250
emKB8FzurxDKIMyfN4/EENQxSVsrK8qqKsqryudZuTJredX8eRw/769hjDrEoqIr
wvNcJBQSL0X3eeX/T0O9qv0DAU+k1bI59GXquHT7l1dY58ntX2Eth69KaP/KCoD4
sq/CAV/z9r+/rmGZXqcbyeu4JZwuC53NPJquod9F3FVcLqQK4ZMDn+V3rOUerpvK
hZ4dmvoc//bhla9ssaz/4N5mVs5aQTomxE+YBalpqEHyDicRFKRzDYknuzGV+IZZ
SLQaGhLLSxuko8KsU4Sgs1fqjxVIhxoS3mEh0TS0vx8LB/ZimbVX6DtaIAwMYIZQ
@nmicic
nmicic / disable
Last active September 8, 2022 19:56
Automatic collection of Sessmgr core when 1st symptom event occur ([sessmgr 10039 error] ... sessmgr_med.c:24635] ...MED RX SHORT PDU from MED rxlen 0 iplen 0. MED info: from BIA(s/m/p) 3/2/65533 sBia=0302fffd dBia=0303c0b4. Len dump 0 0
#NOTE: This just generate output. You have to paste back this into CLI and configure it!
cli test-commands password .....
debug shell
cli show task table facility sessmgr all | grep sessmgr | awk 'BEGIN{print "configure"} {if ($3<5000){print "no logging enable-debug facility sessmgr instance "$3 }} END{print "exit"}'
exit
#NOTE: This just generate output. You have to paste back this into CLI and configure it!
@nmicic
nmicic / detect_from_MIO_debug_shell.sh
Last active September 9, 2022 10:10
To_detect_which_card_cpu_has_crypto_chip_hang
#!/bin/bash
echo "Impacted card is one where you see the line: ERROR: Qat is not responding. Please restart the device"
ping bcast -c 2 -w 0.2 -b >& /dev/null
IpNeighShowReach=( $( ip neigh show | grep 172.16 | grep REACHABLE | awk '{print $1}' | sort -n ))
i=0;for IP in "${IpNeighShowReach[@]}";do i=$(( $i + 1 )); IPX[$i]=$IP;done;iLAST=$i;
for ((i=1;i<=$iLAST;i++)); do
IP=${IPX[$i]};
echo === $IP ===
grep $IP" " /etc/hosts
ssh $IP 'grep -e "ERROR" -e "Qat is not responding" -e "Please restart the device" /proc/icp*/qat* /proc/icp*/heartbeat*'