-
Notifications
You must be signed in to change notification settings - Fork 390
Debug Tips
ajayhn edited this page Feb 13, 2015
·
23 revisions
- JSONViewer
- Github Wiki Search
- POSTMAN REST client
- Vim in TextArea with ctrl+enter - write more wiki!
- strace
strace -p <pid> -e trace=network
- lsof
lsof -p <pid>
- tcpdump
tcpdump -ni any port <portnum> -A -s 1500
- contrail-logs to gather details when UI access is not possible
- To view xml output with indentation
curl -sq http://localhost:8085/Snh_ItfReq? | python -c 'import sys;import xml.dom.minidom;s=sys.stdin.read();print xml.dom.minidom.parseString(s).toprettyxml()' | less
- To locate particular stanza based on child value
- (for e.g. interface stanza based on name of vhost0, port uuid or vm uuid)
(export KEY=name VAL=vhost0; curl -s -q http://localhost:8085/Snh_ItfReq? | python -c 'import sys, os;from lxml import etree as et;s=sys.stdin.read();root=et.fromstring(s); print et.tostring(root.xpath(".//%s[text()=\"%s\"]/.." %(os.environ["KEY"], os.environ["VAL"]))[0], pretty_print=True)')
(export KEY=uuid VAL=29ec90f1-c637-4cc8-8edb-125ce3dcc0f9; curl -s -q http://localhost:8085/Snh_ItfReq? | python -c 'import sys, os;from lxml import etree as et;s=sys.stdin.read();root=et.fromstring(s); print et.tostring(root.xpath(".//%s[text()=\"%s\"]/.." %(os.environ["KEY"], os.environ["VAL"]))[0], pretty_print=True)')
(export KEY=vm_uuid VAL=a607ec69-95e9-4f8a-9d29-f6632e66fd76; curl -s -q http://localhost:8085/Snh_ItfReq? | python -c 'import sys, os;from lxml import etree as et;s=sys.stdin.read();root=et.fromstring(s); print et.tostring(root.xpath(".//%s[text()=\"%s\"]/.." %(os.environ["KEY"], os.environ["VAL"]))[0], pretty_print=True)')
- Vim function to pretty print large XML. Put following in your .vimrc and type \x.
" XML formatter
function! DoFormatXML() range
" Save the file type
let l:origft = &ft
" Clean the file type
set ft=
" Add fake initial tag (so we can process multiple top-level elements)
exe ":let l:beforeFirstLine=" . a:firstline . "-1"
if l:beforeFirstLine < 0
let l:beforeFirstLine=0
endif
exe a:lastline . "put ='</PrettyXML>'"
exe l:beforeFirstLine . "put ='<PrettyXML>'"
exe ":let l:newLastLine=" . a:lastline . "+2"
if l:newLastLine > line('$')
let l:newLastLine=line('$')
endif
" Remove XML header
exe ":" . a:firstline . "," . a:lastline . "s/<\?xml\\_.*\?>\\_s*//e"
" Recalculate last line of the edited code
let l:newLastLine=search('</PrettyXML>')
" Execute external formatter
exe ":silent " . a:firstline . "," . l:newLastLine . "!xmllint --noblanks --format --recover -"
" Recalculate first and last lines of the edited code
let l:newFirstLine=search('<PrettyXML>')
let l:newLastLine=search('</PrettyXML>')
" Get inner range
let l:innerFirstLine=l:newFirstLine+1
let l:innerLastLine=l:newLastLine-1
" Remove extra unnecessary indentation
exe ":silent " . l:innerFirstLine . "," . l:innerLastLine "s/^ //e"
" Remove fake tag
exe l:newLastLine . "d"
exe l:newFirstLine . "d"
" Put the cursor at the first line of the edited code
exe ":" . l:newFirstLine
" Restore the file type
exe "set ft=" . l:origft
endfunction
command! -range=% FormatXML <line1>,<line2>call DoFormatXML()
nmap <silent> <leader>x :%FormatXML<CR>
vmap <silent> <leader>x :FormatXML<CR>
You can use access the VRouter management webpage on port 8085
Here is some useful webpages.
http://localhost:8085/Snh_VrfListReq?name=
http://localhost:8085/Snh_Inet4UcRouteReq?x=8
http://localhost:8085/Snh_SandeshMessageStatsReq?
You can use this script
https://gist.github.com/nati/8064561
ubuntu@contrail-01:~$ python cas.py virtual-network
default-domain:default-project:__link_local__ 3e072e3c-59a9-402e-b61f-3697b81a7274
default-domain:default-project:default-virtual-network 3795cb36-1338-4292-936a-5541fbd06ee6
default-domain:default-project:ip-fabric 8adc0fdd-674f-44cd-ac1b-87854dd0ec87
default-domain:demo:right 6884a3b2-cfbe-4fff-88bb-52ef36146e0e
Check ip for clients
curl "http://node_ip:5998/clients.json" | python -mjson.tool
-
Api Server
http://<config-node-ip>:8084/Snh_SandeshUVECacheReq?x=NodeStatus
-
Schema Transformer
http://<config-node-ip>:8087/Snh_SandeshUVECacheReq?x=NodeStatus