linux

tcpdump tip

As I was debugging an issue at work related to http headers being forwarded by haproxy I used a couple tcpdump commands that was great, storing here for future reference .

tcpdump -s 1024 -l -A | grep X-Forwarded-For

tcpdump -s 1024 -l -A src 192.168.9.56 or dst 192.168.9.56

First one will print lines containing X-Forwarded-For, second one let you filter on src and/or destination .
Note that tcpdump by default does not include 127.0.0.1 or ::1 ( lo ) .

dmesg timestamp

[518950.884021] usb 2-4: new low speed USB device number 23 using ohci_hcd
[518951.108559] input: Trust GM-4200 Gamer Optical Mouse as /devices/pci0000:00/0000:00:0b.0/usb2/2-4/2-4:1.0/input/input24
[518951.108681] generic-usb 0003:145F:011A.0016: input,hidraw1: USB HID v1.11 Mouse [Trust GM-4200 Gamer Optical Mouse] on usb-0000:00:0b.0-4/input0

It’s kind of frustrating with dmesg timestamps. It basically show [seconds.nanoseconds] since last boot … that’s really accurate, and totally useless for humans that can’t do that math in their heads .
This guy at code.saghul.net wrote a great python script as a solution.
With reference to one of the comments at that blog, an even more elegant solution would be to simply use /var/log/kern.log , it’s already there 🙂

How much ram in my graphics card ?

Nice command to find how much ram my graphics card has. Use ‘lspci’ to get the pci id and throw it back to lspci like this:

joar@juno:~$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 09)
joar@juno:~$ lspci -v -s 00:02.0
00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 09)
	Subsystem: Lenovo Device 3a02
	Flags: bus master, fast devsel, latency 0, IRQ 30
	Memory at f4000000 (64-bit, non-prefetchable) [size=4M]
	Memory at d0000000 (64-bit, prefetchable) [size=256M]
	I/O ports at 1800 [size=8]
	Capabilities: <access denied>
	Kernel driver in use: i915
	Kernel modules: i915

joar@juno:~$