A 1 Cool Commands

download A 1 Cool Commands

If you can't read please download the document

description

c

Transcript of A 1 Cool Commands

tcpdump -i lo udp port 7781 -A //L4 to DB UMTStcpdump -i lo udp port 7780 -A //L4 to DB CDMAtcpdump -i lo udp port 7779 -A //L4 to DB GSMtcpdump -i lo udp port 7778 -A //L4 to DB LTEtcpdump -i lo udp port 14448 -A //DB to L5 UMTStcpdump -i lo udp port 14447 -A //DB to L5 CDMAtcpdump -i lo udp port 14446 -A //DB to L5 GSMtcpdump -i lo udp port 14445 -A //DB tx side to L5 LTEtcpdump -i lo udp port 13337 -A //L5 rx side from DB LTEtcpdump -i lo udp port 13345 -A //ptt_scan output to the alertHandlertcpdump -i lo udp port 13346 -A //PTT alertHandler output to the Brain tcpdump -i eth0 tcp port 8617 -w /tmp/ndr308.pcap //talking to the ndr308 tunerCtrl from the ndr308srvr backend//ubuntu command line image viewereog image-filename//pdf viewereveince pdf-filename//gdb attach to running processgdb -pid 23067//or just issue the gdb command and once you are at the gdb prompt typeattach pid //note that this stops the program and you will need to type continue to keep runninginfo threads //to see all threads (the * is the current thread being monitoredthread n //to switch to a specified threadcntrl x cntr a //to see a source window in gdb, use this to also to toggle it offdirectory "path to source files" //to let gdb know where the code to debug isb filename:linum //to set a break point also look into watch points//to parse rover csv and get all the uniq decoded cells usecat TSR_GSM_8-14-20150827T103606.gns | awk -F, '{ print $9 " " $10 " " $11 " " $12 }' | sort | uniq -d//To see database performance use, then use the ? menu to set the meas interval and//watch the qps queries per secondinnotop -uroot -ppassword //to see device info for usb devices use lsusb//To see what ports and files the ptt_scan program is usinglsof -p `pgrep ptt_scan`//To see what ports and files the ptt_scan program is usinglsof -p `pgrep alertHandler`//list only hidden filesls -ld .?*//To see the send and the return of a brain task in the brain logtail -f UmtsBrain.log | grep 'Buff=UMTS_\|Completed taskType'//to see cpu infolscpu//to list only files that are 2 chars longfind . -name "??"//To see duplicates in a file, create a sorted file then rununiq -d file.txt//for loop thru all files in a folder and do something to themfor i in *.iq; do md5sum $i; done > tt//To see which udp ports are listening and the process name using that port usess -lnupss -lnup | head to see the column namesss -lnup | grep v49 //to see a specific process name//A top like tool to something similar isnetstat -c --udp -an//To access another machine use this command (as user not root)ssh [email protected] logged onto the other machine as user you can sudo su//To delete files of type *.tif smaller than 160kfind -name "*.tif" -size -160k -delete//To delete files greater than 160k use find -name "*.tif" -size +160k -delete//To delete files exactly 160k use find -name "*.tif" -size 160k -delete//Save make output to a file so you can grep for errors also displays it to std outmake clean all install 2>&1 | tee output.log//To reset the dhcpd leases remove the following file. This allows you to change tuners connected to a backendrm /var/lib/dhcp/dhcpd.leasesThen issue this command to restart the dhcp service//back end dhcp server restart/etc/init.d/isc-dhcp-server restart//networking restart/etc/init.d/networking restart//To get an address via dhcp issuedhclient eth1//to toggle an interface up or down (ifup ifdown)ifconfig eth1 up//To see the bridge info issue pan1 pan0brctl show//path to the interfaces file /etc/network/interfaces//path to the usb network udev rule/etc/udev.rules.d/70-persistent-net.rules//To run the reset scriptmysql -uroot -ppassword < tableCreationText.sqlmysql -uroot -ppassword mrtDBmysql> SHOW COLUMNS FROM mytable FROM mydb;//restart udev rules variation 1 which didnt work for the gpssudo service udev restart//dmesg human readable timestampsdmesg -T//Use this to reload the udev rules udevadm control --reload//To watch what happens when devicesudevadm monitor//or try unbuffer udevadm monitor --environment//To increase the logging of udev rules use this command //The default log level for udev rules is "err" see file /etc/udev/udev.conf//Then you will see all logs in your system log via syslogudevadm control --log-priority=info//display info about the portstty -a -F /dev/gps//set the port speed to 4800stty -F /dev/gps ispeed 4800//ouputs gps datacat /dev/gps//set 115200 8N1 for dev gps for the firefly gpsstty -F /dev/gps ispeed 115200 cs8 -cstopb -parenb//gpsd commands (on my laptop)lsof | grep ttyUSB0 // to see who owns this port//To set the gps in nmea mode and 4800 baud and use gpsctl in low level modegpsctl -f /dev/ttyUSB0 -n -s 4800gpsmon /dev/ttyUSB0//serial port dump with timestampsjpnevulator --ascii --timing-print --read --tty /dev/gps//To see info about the serial portssetserial -ga /dev/ttyS*setserial -g /dev/ttyS*//recursive searches that skip svn and cscope and tags filesgrep -ri --exclude=*.{tags,svn} --exclude=tags --exclude=tt getGps *grep -r --exclude=*.{tags,svn*} --exclude=tags --exclude=cscope* l3parse *//To grep for pn=3 or pn=xxx,3,rrr or pn=xxx,uuu,3grep -n pn= EvdoBrain.log | grep -P 'pn=3,[0-9]{3}'\|'pn=[0-9]{3},3,'\|'pn=[0-9]{3},[0-9]{3},3,'\|'pn=[0-9]{3},[0-9]{3},[0-9]{3},3'//This will test for 5 pns at oncegrep -P 'pn=[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3}' EvdoBrain.log//This will test for 6 pns at oncegrep -P 'pn=[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},' EvdoBrain.log//to check out from the new svn usesvn co https://subversion.npnj.g3ti.local/MRT/trunk trunkNew//To simulate a merge of a branch back to the trunk use this command to see how many conflicts there will be//Even after building the clean latest trunk I had to do an svn update to get rid of the following error//about the file named corestat getting restored//Issue this command from inside the trunk foldersvn merge --dry-run --reintegrate https://subversion.npnj.g3ti.local/MRT/branches/ptt > ttt//To fix local conflictssvn resolve --accept=working *//this version can be run at the top level and it will recurse the folders fixing conflictssvn resolve -R --accept=working *//To see which files have changed between 2 revs usesvn diff -r 5000:6001 --summarizesvn diff -r 13447:HEAD --summarize//To actually diff those files remove the --summarize option//Build stand alone gpsgcc CEventHandler.cpp NMEA.c NmeaParser.cpp SGPS.cpp -o sgpsTest2 -L . -l G3_Compat_2 -lpthread -lm -lrtgdb --args commandname args for command name//this command will set multiple delimeters for -F in this case ( and ) awk -F'[()]' '{ print $2 }'//This command skips the Rover header lines and then takes the timestamp and converts it to secondsawk -F [T,:' '] 'NR>6 { secs=$3*3600+$4*60+$5; print secs " " $0; }' | head//PTT to find duplicate search freqs in the l5 loggrep PTT_search PttBrain.log | awk -F'[= ]' '{ print $13 }' | sort | uniq -d//This command will test for the issue where the wrong center freq was reported for a frequencycat PttBrain.log | grep -i buff= | awk -F'[= ]' 'BEGIN{result="PASS";} { delta=$13-$15; if(delta>10 || delta2){print y[i]} } '}//to see directories in svnsvn list https://subversion.g3np.org///to see total search/scan/decode tasks awaiting L4/L3 processing after the grab is completed //Note that this is assuming the log file is tech specificgrep push_q2 tsControl-umts.log | grep search | wc -lgrep push_q2 tsControl-umts.log | grep scan | wc -lgrep push_q2 tsControl-umts.log | grep decode | wc -l//Verifies how often we write to Rover (Should be every second)cat LteBrain.log | grep -i "Wrote to rover" | awk -F [T:' '] '{ x[NR]=$3*3600+$4*60+$5;} END { for(i=1; i 0) print sum / n; }'//Does max and avggrep "LTE Processing time for taskType=2" dblog.log | awk 'BEGIN {max = 0} { if ($NF>max) max=$NF; sum += $NF; n++; } END { if (n > 0) print "AVG="sum / n; print "MAX=" max }'//To grep for a floating point number 1935.0grep -w "1935[\.]0" LteBrain_2014_1119_230005.log | grep LTE_search//To grep for a negative floating point value -98.6grep -w "\-98[\.]6" LteBrain_2014_1119_230005.log | grep LTE_search//removes carls colorcodessed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" output.log > output.log2mysqldump -uroot -ppassword --no-create-info --complete-insert mrtDB MissionHistory > /tmp/missionHistorySave.sqlmysql -uroot -ppassword < /var/www/ts/data/tableCreationText.sqlmysql -uroot -ppassword mrtDB < /tmp/missionHistorySave.sqlmysql -uroot -ppassword < /var/www/ts/data/fillMccMncTableText.sqlmysql -uroot -ppassword < /var/www/ts/data/TSAK.sqlmysql -uroot -ppassword < /var/www/ts/data/TSAK_SID.sqlmysql -uroot -ppassword < /var/www/ts/data/fillBandsTable.sql//TO count rows inside mysqlselect count(*) from DecodeTable;//To see how many times a cell was dropped from the brain issue the following grep command:grep -i badfscount=5 LteBrain.log//For new jackson labs firefly gpsKERNEL=="ttyUSB*", ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0109", NAME="gps", RUN+="/Virtuoso/master/kickGPS.sh", OPTIONS+="last_rule"//Mike D's incomplete and lame way to do a grab at some unknown freqtrunk/NDR308# ./bps.308 eth2 //channelizer per data streamtrunk/NDR308# ./bps.308 eth3 //all IF datatrunk/NDR308# ./ndr308_grab --port 14001 -n 20000 //does an lte grab and saves a xxx.v49 file to same folder //Agam way that works to do a grab at a known freq//Step 1 start ndr308 server using appropriate ip addressndr308_Server -host 192.168.1.20 -cfg /usr/local/bin/ndr308.cfgndr308_Server -host 10.211.160.20 -cfg /usr/local/bin/ndr308.cfg//Step 2 do the grab note the path name trunk vs trunkNew etc ... //The v49 grab file is put in public/mrt/logs. Below are some examples/home/user/workspace/trunkNew/wcdma/CellSearch/udpTunerCmdClient 'grab tech=lte to=10000 freq='$FREQ' blocks=85 name='outputfilename bw=1.4'/home/user/workspace/trunkNew/wcdma/CellSearch/udpTunerCmdClient 'grab tech=cdma to=10000 freq=1951.25 blocks=10000 name=tttEvdo.v49 bw=1.2288'/home/user/workspace/trunk/wcdma/CellSearch/udpTunerCmdClient 'snapshot freq=2120 blocks=1024 name=/public/rssi/iq/snap.2120.v49'udpTunerCmdClient 'snapshot freq=1950 blocks=10000 name=/public/rssi/iq/snapshot_1950M_308_qam16d_n100.v49'udpTunerCmdClient 'grab tech=evdo to=10000 freq=1951.25 blocks=10000 name=EvdoGrab1951-25-n60.v49'//Step 3 if necessary convert v49 to 16 bit iqcat evdoGrab.v49 | v49_ndr308 -bin16 > evdoGrab.iq//Step 4 evdo decode must be run from cdma2/evdo folder./evdoTestMain -f /home/user/tttEvdo.iq -t 16 --decode --flip_iq 2>&1 | grep -i -A10 "CC hdr" > badSectorParamsParse//To run the g3lte proc as a udp server issue the following commandg3lte -l 1//Then run udp_send --portnum and hit return//Then in the udp_send terminal paste the following command"id=2408 type=decode f=1935.0000 name=/public/mrt/logs/mikedbag4 out=/public/mrt/logs/mikedout pci=291"//The g3lte logging goes to file mikedout//To grep whole words use the -w option//To pretty print shell output pipe the output throughcommand bla bla bla | column -t//Counts the number of commas in each sendTask line which is used to count the number of brain sendTasks that //are multiple scans or decodesgrep sendTask CdmaBrain.log | awk -F, '/,/{sum+=(NF-1); print NR,NF-1,sum $0}'//just the sumgrep sendTask CdmaBrain.log | awk -F, '/,/{sum+=(NF-1);} END {print sum} '//Start ndr308 server. This is in usr/local/bin and doesnt require the ./ndr308_Server -host 192.168.1.20 -snapwait 3000 &> /public/mrt/logs/ndr308_Server.log &//Start tsControl for EVDOtsControl --evdo --num_proc 2 --q1-depth 30 --q2-depth 20 --grab-depth 4 &> /public/mrt/logs/tsControl-evdo.log &//Start dbmrtdbProxy -d DEBUG4 &//Switch to vim, and use :set hlsearch//You can then use :highlight Search ctermfg=yellow to customize; where:cterm is for formatingctermfg is for foreground colorctermbg is for background color//see :help highlight link//You can then use :noh to temporarily hide the last search highlight.//to close the quickfix list :ccl//This is a line from the tsControl log for CDMA. This is how you determine if PN 0 is a problem. The value in parenthesis (0.018s) is what you need to focus on. //If its bigger than 10 seconds than PN0 will be unreliable because searches are not occurring often enough to keep it updated. ***WARNING***: G3NJ_ERR: cdma_cell_search: samp_num= 1309991452 pn0_samp_num= 1309969948 diff= 21504 (0.018s) PN= 244 peakIndex= 6582 Ec/Io= -5.06 PN0= 16082 PN0_avg= 16084.73 stream_id= 6//Use this command to awk out that PN0 related time value. This command will sort the values from smallest to largest. //NOTE THAT THE FIRST VALUE in the beginning of the log should be ignored. It will be a very large value.grep -i pn0 tsControl-cdma.log | awk -F'[()]' '{ print $2 }' | sort -n//to see how many channelizers are being used use this command (CDMA example)grep CDMA- ndr308_Server.log//to use non promiscuous modetcpdump -p -i eth2 If you want the app to always run as root1) Pin the application to the launcher as normal.2) Locate the applications .desktop file which will be in either:/usr/share/applications/APPNAME.desktop~/.local/share/applications/APPNAME.desktopor somewhere else, use locate .desktop|grep APPAME3) Open with gedit:gksudo gedit /usr/share/applications/APPNAME.desktop 4 ) Change then lineExec=APP_COMMANDtoExec=gksudo -k -u root APP_COMMAND5) SaveThis command will also keep your environment which is very usefull if you need to connect to others servers and use your private key.To add a quicklist option to 'Run as root'Follow steps 1, 2 and 3 aboveIf the launcher currently doesn't have any other quicklist options, just append this to the end of the documentX-Ayatana-Desktop-Shortcuts=Runroot[Runroot Shortcut Group]Name=Run as rootExec=gksudo -k -u root APP_COMMANDTargetEnvironment=UnityPTT compile steps-----------------cd /home/user/workspace/ptt/G3_Core; make clean all installcd /home/user/workspace/ptt/NDR308; make clean all v49_ndr308.o # need this .ocd /home/user/workspace/ptt/ptt; make v49_main ptt_scancd /home/user/workspace/ptt/ptt/WF; make allPTT run these programs (see /root/bin/setupPtt.sh )---------------------- cd /home/user/workspace/ptt/NDR308; ./lab.dip; //You may have to run this from the trunk locally ndr308_Server -host tunerCtrl //You may have to run this from the trunk locally # from another terminal do a grab at 145MHz to set tuner freq. If it works you will see "uuusnd(): resp is ok" fn=/tmp/xx-lte.v49; rm $fn; uuusnd -p 5555 "grab tech=lte freq=145 blocks=900 name=$fn bw=20" OKcd /home/user/workspace/ptt/ptt; ./v49_main -p 14001 # 14001-4 or 14023 ./ptt_scan -T 15 -N 2048 -F 0.00 -C -S 30.72 # thresh, fftLen, fC, conj, sRcd /home/ptt/ptt/WF; ./pumpit.shrun seahorse to delete gnome keyring passwords like default or...rm ~/.gnome2/keyrings/login.keyringTo fix errors about dbus when opening vi or coolcommands via cool use this commandeval `dbus-launch`ps aux | grep -e "ndr\|v49\|ptt\|PttBrain\|tsControl\^Crtdb\|alertHandler" | awk '{ print $2 }' | xargs -I{} kill -9 {}//This will change your ip scheme without changing your tuners ip address//Use it if your back end is 192.168. based but the tuner is 10.211 based.//To see this comand issue: ifedit -hifedit oldTuner=192.168.1.20 newTuner=10.211.160.20 oldWifiSubnet=10.42.43 newWifiSubnet=10.211.43 \ oldList="192.168.1.10 192.168.150.3 192.168.140.3 192.168.1.20 192.168.150.2 192.168.140.2" \ newList="10.211.160.10 10.211.150.3 10.211.140.3 10.211.160.20 10.211.150.2 10.211.140.2" -noTunerChange//Start TS, then start process monitoring like this ...nohup atop -p 60 6000 &> atop.out & //where 60 = interval in sec, 6000 = num intervals, Option "-p" accumulates process activity per program (i.e. process name).... then run mkplot-atop. Work files are written to "/dev/shm/mkplot-atop".cat evdoGapsQxdm.txt | awk '{if($1=="LOG") {time=$8;} if(substr($0,1,26)=="Active Set\[0\]\.Pilot Energy") print time " " $5 }' > plot1cat plot1 | awk -F'[:. ]' '{print $1*3600000 + $2*60000 + $3*1000 + $4 " " $5 }' > plot2cat plot2 | sort -unk1 > plot3grep -n 'Active Set\[0\]\.Pilot Energy = 0' evdoGapsQxdm.txt//Counting multple PN jobs//First save the output of the 2 lines below to a file ttgrep 'UMTS_decode\|UMTS_scan\|UMTS_decode' UmtsBrain.log | awk -Fsc '{ print $NF }' > umtsPSCsgrep 'CDMA_decode\|CDMA_scan\|CDMA_decode' CdmaBrain.log | awk -Fpn '{ print $NF }' > cdmaPNs//Then use this awk cmd to count the multiple pns per grab and total themawk -F, 'BEGIN {MAX=0; SUM=0} { if(NF>MAX)MAX=NF; SUM+=NF; print $0 " --- "NF} END {print "------"; print "MAX PNS PER SINGLE GRAB="MAX; print"TOTAL PNs="SUM; print "AVG PNS PER GRAB=" SUM/NR }' cdmaPNs//To do a taskid analysis on a brain log do the following.//Get the task ids of all the task types you are interested ingrep EVDO_decode EvdoBrain.log | awk -F'[ =]' '{ print $13 }' > taskidFileNamegrep EVDO_searchEvdoBrain.log | awk -F'[ =]' '{ print $13 }' > taskidFileNamegrep EVDO_scan EvdoBrain.log | awk -F'[ =]' '{ print $13 }' > taskidFileName//Then use xargs to search for each taskidcat evdoDecodes | xargs -l1 -i grep {} EvdoBrain.log > evdoPerDecode//OR BETTER YET RUN THIS SHELL SCRIPTidParser on my Desktop//and there is a script called cirParser also cirParser//To upgrade to g++ 5 I usedsudo add-apt-repository ppa:ubuntu-toolchain-r/testsudo apt-get updatesudo apt-get install gcc-4.7//byte buffer printing use this printf format otherwise the print doesnt show 0f it shows f but memory actually contains a 0f for(unsigned int i=0; i