This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 textwidth=79 autoindent | |
""" | |
Python source code | |
Last modified: 12 Dec 2013 - 14:43 | |
Last author: Laban Mwangi | |
Calculates the start of a process based on it's /proc/pid/stat file and | |
the system uptime from /proc/uptime. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conversion of unix timestamps to POSIXct | |
> as.POSIXct(1388512551, origin="1970-01-01 00:00:00") | |
[1] "2013-12-31 19:55:51 SAST" | |
# ggplot of POSIXct. | |
# pdt_time is of POSIXct type | |
> m <- ggplot(df, aes(pdt_time, some_count)) + geom_point(aes(colour=as.factor(some_factor))) | |
> m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while True: | |
self.logger.info("[Re]starting to read %s" % self.input_file) | |
with open(self.input_file, "rb") as f: | |
for line in f: | |
...do_stuff_with_line...(line) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pre-create the fifo | |
# mkfifo /tmp/example_fifo | |
# Save this to a file and strace it | |
# strace -fttt -o open_close python test.py | |
import time | |
fname = "/tmp/example_fifo" | |
with open(fname, "r") as f: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while True: | |
self.logger.info("[Re]starting to read %s" % self.input_file) | |
with open(self.input_file, "rb") as f: | |
f1 = open (fname, "w") # The dummy writer has to be opened after a reader, otherwise it would block | |
for line in f: | |
...do_stuff_with_line...(line) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swapper: page allocation failure. order:4, mode:0x20 | |
Pid: 0, comm: swapper Not tainted 2.6.32-gentoo-r7 #1 | |
Call Trace: | |
<IRQ> [<ffffffff8107f082>] 0xffffffff8107f082 | |
[<ffffffff810a29a4>] 0xffffffff810a29a4 | |
[<ffffffff810a2b9f>] 0xffffffff810a2b9f | |
[<ffffffff810a2d35>] 0xffffffff810a2d35 | |
[<ffffffff810a2de3>] 0xffffffff810a2de3 | |
[<ffffffff810a2e4e>] 0xffffffff810a2e4e | |
[<ffffffff813ed961>] 0xffffffff813ed961 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2014-03-15 23:34:32,352 - main - INFO - Starting.... | |
2014-03-15 23:34:32,352 - main - INFO - Parsed options: {'size': None} | |
<logging.Logger object at 0x1102cffd0> | |
2014-03-15 23:34:32,352 - main - DEBUG - Parsing line: Node 0, zone DMA 5 4 4 4 4 3 2 0 0 0 2 | |
2014-03-15 23:34:32,353 - main - DEBUG - Parsed line: {'numa_node': '0', 'zone': 'DMA', 'nr_free': '5 4 4 4 4 3 2 0 0 0 2'} | |
2014-03-15 23:34:32,353 - main - DEBUG - Parsing line: Node 0, zone DMA32 2 2 3 2 2 1 3 1 2 3 386 | |
2014-03-15 23:34:32,353 - main - DEBUG - Parsed line: {'numa_node': '0', 'zone': 'DMA32', 'nr_free': '2 2 3 2 2 1 3 1 2 3 386'} | |
2014-03-15 23:34:32,353 - main - DEBUG - Parsing line: Node 0, zone Normal 56332 12573 2212 959 448 179 35 5 0 0 35002 | |
2014-03-15 23:34:32,353 - main - DEBUG - Parsed l |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 textwidth=79 autoindent | |
""" | |
Python source code | |
Last modified: 15 Feb 2014 - 13:38 | |
Last author: lmwangi at gmail com | |
Displays the available memory fragments | |
by querying /proc/buddyinfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First 10 packets of the second TCP stream in the pcap | |
# Comman separated values with a header for the specified fields | |
$ tshark -ntu -r test.pcap -Y tcp.stream==1 -c 10 \ | |
-E header=y -Tfields -E separator="," \ | |
-e ip.src \ | |
-e tcp.srcport \ | |
-e "ip.dst" \ | |
-e tcp.dstport \ | |
-e tcp.flags.syn \ | |
-e tcp.flags.ack \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Viewing the tcp conversations in a pcap | |
tshark -qn -z conv,tcp -r test.pcap | |
================================================================================ | |
TCP Conversations | |
Filter:<No Filter> | |
| <- | | -> | | Total | Relative | Duration | | |
| Frames Bytes | | Frames Bytes | | Frames Bytes | Start | | | |
a.b.c.d:31822 <-> e.f.g.h:9999 553 91298 549 36234 1102 127532 0.000000000 5155.6751 | |
a.b.c.d:8645 <-> e.f.g.h:9999 402 66141 402 28210 804 94351 5162.869498000 3715.2102 |