ionice does not work with software raid

test ionice with dd and found out that it does nothing.

rsyslog omprog (run a shell script on a filtered message)

rsyslog.conf
 
$ModLoad omprog
$actionomprogbinary /opt/omprog.py
:msg, contains, "sometext"  :omprog:;RSYSLOG_TraditionalFileFormat
omprog.py
line = sys.stdin.readline()
if line:
    check(line)

Linux multiple default route

http://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/

Cisco Routing Process

http://ciscorouterswitch.over-blog.com/article-cisco-ios-order-of-operation-114424332.html

perl Devel::Trace

Install
cpan> o conf make /usr/bin/make
    make               /usr/bin/make

cpan> o conf commit
commit: wrote /etc/perl/CPAN/Config.pm

perl -MCPAN -e 'install Devel::Trace'

Run
perl -d:Trace my.pl

CentOS 7: Grub2 does not find Windows partition

need to install ntfs-3g, then rerun grub2-config

bash call trace

http://www.skybert.net/unix/bash/serious-programming-in-bash/

Sata Drive Issue

http://lime-technology.com/wiki/index.php/The_Analysis_of_Drive_Issues#Drive_interface_issue_.232 https://ata.wiki.kernel.org/index.php/Libata_error_messages

Low Kernel Entropy

http://www.lincvz.info/2013/09/22/linux-low-entropy-pool-for-devrandom-after-system-upgrade/

PAM

http://www.linuxforums.org/articles/linux-basics-pluggable-authentication-modules-pam-_1491.html

Cisco EEM

Samples
  1.  https://supportforums.cisco.com/document/117596/cisco-eem-basic-overview-and-sample-configurations
  2. https://supportforums.cisco.com/document/117596/cisco-eem-basic-overview-and-sample-configurations 
  3. http://www.cisco.com/c/en/us/td/docs/switches/datacenter/sw/5_x/nx-os/system_management/configuration/guide/sm_nx_os_cg/sm_eem_events_and_examples.html 
  4. http://wiki.nil.com/Executing_IOS_commands_from_Tcl_shell  

Other Resources

  1. Cisco Best Practice 
  2. white Paper 
  3. Writing EEM Policies Using Tcl

Tcl


Documentation


Basics


~ $ tclsh
% set a 2
2
% expr 1 + 2
3
% puts $a
2
% set c [expr $a + 1]  # result of cmd in [ ] is substituted
3
% set d "$a $c"        # var $a and $c is substituted
2 3
% set e {$a $c}        # var $a and $c is not substituted.
$a $c
% set x y
y
% set $x 0
0
% puts $y
0
% while {$c > 1} {set c [expr $c - 1]; puts $c}
2
1
% 

Note that
set c 3; while "$c > 1" {set c [expr $c - 1]; puts $c}
is the same as
set c 3; while "3  > 1" {set c [expr $c - 1]; puts $c}

List


% set x {a b c d}
a b c d
% set y "a b c d"
a b c d
% llength $x
4
% lindex $x 2
c
% lappend x e
a b c d e
% puts $x 
a b c d e

% set x "$x f"
a b c d e f

% foreach i $x {
   puts $i 
}
a
b
c
d
e
f
% foreach {i j} $x {
   puts "$i $j"
}
a b
c d
e f

Array/Hash

~ $ tclsh
% set a(2) 4
4
% set a(1) 2
2
% set a(1000) 2000
2000
% set b(ftp) 21
21
% set b(http) 80
80
% set b(ssh) 22
22
% set a(zero) 0
0
% array name b
http ssh ftp
% array name *p
% array get b
http 80 ssh 22 ftp 21
% foreach {key value} [array get b] {
  puts "$key uses port $value"
}
http uses port 80
ssh uses port 22
ftp uses port 21

Control Structure

% while {$c > 1} {set c [expr $c - 1]; puts $c}
2
1
% for {set x 0} {$x < 10} {incr x} {
  puts $x
}
0
1
2
3
4
5
6
7
8
9
% set x 10
10
% incr x 2
12
% incr x -3
9
% incr x 0.3
expected integer but got "0.3"
% if {$x > 0} {puts "postive"} elseif {$x < 0} {puts "negative"} else {puts "zero"}
postive
% 
% 
% 
% proc factorial {n} {
   set product 1
   for {set i 1} {$i <= $n} {incr i} {
     set product [expr $product*$i]
   }
   return $product
}
% factorial 3
6
% factorial 0
1
% 
% 
% proc callonetime {x} {
   puts $x
   proc callonetime {x} {
     puts "you can only call this proc once!"
   }
}
% callonetime 10
10
% callonetime 10
you can only call this proc once!
% 

Global Variable


% global x
% set x 1
1
% proc foo {} {
  global x
  puts $x
}
% foo
1
% 

Regexp


set VAR "This is a test string"
if {[regexp -nocase [subst -nocommands -nobackslashes {something here:[\s\w]+:$VAR}]} then {
...
}

Windows PCItree vs RWEverything

http://www.pcitree.de/userguide.html (does not work with 64bit).  

RWEverything works great can change BARs and PCI config space

Django Cheat Sheet

http://www.mercurytide.co.uk/news/article/django-15-cheat-sheet/ http://web-developing.reading-now.org/book/11 http://driveactivated.com/files/ftpupload/djangobook/djangobook-1-0.pdf

Error: no module named taggit

I had this problem on a ubuntu. It turns I installed pip using easy-install3 which is for python3. So pip installed taggit for Phython3 and the default python is 2.7.

iptables (Flow)

incoming - packet from outside to this host
outgoing - packet from this host to outside
forwarding - host acting as a router, packet passthrough this  host from one interface to another.

https://www.digitalocean.com/community/tutorials/a-deep-dive-into-iptables-and-netfilter-architecture
http://content.hccfl.edu/pollock/AUnixSec/IptablesOverview.htm
http://www.adminsehow.com/2011/09/iptables-packet-traverse-map/
http://stuffphilwrites.com/wp-content/uploads/2014/09/FW-IDS-iptables-Flowchart-2014-09-25.png
ftp://ftp.shorewall.net/pub/shorewall/misc/netfilterflow.pdf

Fake Mac Address with macchanger


service NetworkManager stop
macchanger interface --mac=aa:bb:cc:dd:ee:ff
service NetworkManager start

ip dhcp snooping

http://packetlife.net/blog/2010/aug/18/dhcp-snooping-and-dynamic-arp-inspection/

Cisco Catalyst Port Mirroring

no monitor session 1

monitor session 1 source interface gi0/5
monitor session 1 destination interface gi0/8 ingress dot1q vlan 30

 #show mon
Session 1
---------
Type                   : Local Session
Source Ports           :
    Both               : Gi0/5
Destination Ports      : Gi0/8
    Encapsulation      : Native
          Ingress      : Enabled, default VLAN = 30
    Ingress encap : DOT1Q




 # ! or... untagged
 no monitor session 1
monitor session 1 source interface gi0/5
monitor session 1 destination interface gi0/8 ingress vlan 30

#do show mon                                                  
Session 1
---------
Type                   : Local Session
Source Ports           :
    Both               : Gi0/5
Destination Ports      : Gi0/8
    Encapsulation      : Native
          Ingress      : Enabled, default VLAN = 30
    Ingress encap : Untagged