Skip to main content

Developer tools, tricks

 Developer Tips

------------ create cscope and tags to source code --------------

Create CTAGS, CREATE FILE LIST [cscope.files], start cscope where the cscope.file exist.

cscope steps - ctags -R . ; find . -name *.[CchH] > cscope.files ; cscope # ready to start using cscope.


Using Ctrl+] Ctril+T for moving forward/ backwards.

----------------------------------------------------------

Setting up messages file log rotation on linux

1. # su - $ change to root account

2. # go to /etc/logrotate.d

   # delete the line (/var/log/messages) from file syslog

sed "/message/d" /etc/logrotate.d/syslog > /tmp/tmpsyslog && mv /tmp/tmpsyslog /etc/logrotate.d/syslog OR

grep -v "message" /etc/logrotate.d/syslog > /tmp/tmpsyslog && mv /tmp/tmpsyslog /etc/logrotate.d/syslog

3. #create new file and add below content to limit the file rotate on 20M file size or weekly once which is satisfied

cat <<EOF > /etc/logrotate.d/messageslog

/var/log/messages

{

    weekly

    rotate 13

    size 20M

    missingok

    dateext

    dateformat -%Y%m%d-%s

    notifempty

}

EOF


4. #Make entry to file /etc/cron.d/0hourly - run the logrotate for messages every 4 hrs at 2 min time

02 */4 * * * root logrotate /etc/logrotate.d/messageslog

OR

add above entry to crontab using command

crontab -e


to run the script at 5th min of each hour

05 * * * * root logrotate /etc/logrotate.d/messageslog


For running every few seconds (running lesser than 1 min duration) As the cron allows the granularity set upto 1 min only, below is the example to run the log rotation every 30 sec (2 times) or 15 secs (3 times)

* * * * * root logrotate /etc/logrotate.d/messageslog && sleep 30; logrotate /etc/logrotate.d/messageslog

* * * * * root for i in 0 1 2; do logrotate /etc/logrotate.d/messageslog & sleep 15; done;

-----------------------------

# script to fill up the messages file under /var/log folder

create a file with 777 permissions in /tmp

touch /tmp/nonstop.txt

# execute logger command to start dumping content of this file into the /var/log/messages file

logger -f /tmp/nonstop.txt


# run the script to write into /tmp/nonstop.txt file

test it by executing - sudo echo "Hello Test" > /tmp/nonstop.txt

================notstop.sh START ================

#!/bin/bash

counter=0

while true

do

sudo echo "$counter - testing non stop logs to messages file" >  /tmp/nonstop.txt

counter=$(( counter + 1 ))

sleep 1

# -n option, omits the new line after echo

echo -n '.'

done

================notstop.sh END================

linux kernel source

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/net/ipv4/tcp_input.c?h=linux-4.0.y

file - /net/ipv4/tcp_input.c

RFC - https://tools.ietf.org/html/rfc5827#section-3

https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt

-----------------------------


Comments

Popular posts from this blog

Cloud based Frameworks/ Kubernetes environment

Cloud based microservice frameworks Some of open source platforms available are Swarm (Docker), Kubernetes (google), mesos, The most popular in communities and internet industry seems to be kubernetes and picking steam in telecom front as well for upcoming 5G Service based architecture. The kubernetes has the default container solution based on Rket ? but the most popular combinations are using Docker as container. Kubernetes/ an Cloud orachastrator !! Deployment automation of scaling in (zooming in/ increasing) and out (zooming out, decreasing) Network plugin available such as flannel (popular, support only IPv4), calico (support IPv4, IPv6), weavenet Kubernetes currently does not support dual stack IPv4, IPv6 inter-working etc capabilities till version 1.13 (dec 2018). Another limitation, it does not recognize the multiple interfaces in case enable to POD's for configuring services exposure and external communication till version 1.13 (dec 2018) Will be adding more...

SCTP - A new transport protocol

SCTP is a new transport protocol, also used for LTE Signalling S1-MME interface between eNB and MME (core network) and MME -HSS (Diameter / SCTP). 1 SCTP Protocol SCTP Packet is located after the MAC/ IP header. The basic SCTP Header consist of Source / Destination Ports (16 bits each), Verification Tag (32 bits) and check sum (32 bits) Verification Tag is used by the receiver to validate the senders authenticity, this get published by each endpoint to remote end duing the 4 way handshake done initially for setting up SCTP association. 1.1 4-Way handshake Msgs 1.1.1 INIT - Contains Initiate Tag, receiver window, in/out bound streams, initial TSN 1.1.2 INIT-ACK - Contains all params same as INIT msg also contains the State Cookie 1.1.3 COOKIE-ECHO - Contains Cookie same as received in INIT-ACK 1.1.4 COOKIE-ACK - Contains nothing, used to acknowledge receipt of COOKIE-ECHO Completion of above 4 SCTP msgs bring the SCTP association to an established stat...