Thatbytes

Mostly Interesting

Find Your Ip With Bash

I only wanted to run a script if the machine had a specific network access so i constructed this below.

How to find the machines ip address

1
ifconfig eth0 | grep "inet addr" | awk -F: '{ print $2 }' | awk '{ print $1 }'

Then find out if its on a network we care about

1
ifconfig eth0 | grep "inet addr" | awk -F: '{ print $2 }' | awk '{ print $1 }' |  grep -qE '172\.24|25\.[0-9]{1,3}\.[0-9]{1,3}' ; echo $?

Another option would be to use facter to get your IP address.

Reading Stdin Bash Style

Have you ever had the need to read standard input in a bash script, for example

1
cat /var/log/message | mycoolbashscript.sh

Imapfilter + Offilineimap + Mutt + New Script = Even Less Pain

My last article covered by original mail setup after some usage i have tweaked it even more so i have to do even less.
I have now introduced imapfilter that can move messages to the correct mail folder before i run offlineimap.

First you need to setup ~.imapfilter/config.lua

Offlineimap + Mutt = Less Pain

I receive a lot of email as im a system administrator in order to handle this i prefer to use Mutt. One problem, Mutt sucks when using imap connections. In order to over come this you can use a nice little util called offlineimap that with sync a imap server to a local folder in mail dir format.

Sun Java Plugin Firefox and Lucid

After upgrading i noticed the sun plugin no longer works in firefox after so poking i got it working using this hack

1
2
3
4
sudo rm /etc/alternatives/mozilla-javaplugin.so  
sudo ln -s /usr/lib/jvm/java-6-sun/jre/lib/amd64/libnpjp2.so /etc/alternatives/mozilla-javaplugin.so  
sudo rm /usr/lib/mozilla/plugins/libjavaplugin.so  
sudo ln -s /etc/alternatives/mozilla-javaplugin.so /usr/lib/mozilla/plugins/libjavaplugin.so

Lucid Windows Control Layout

After upgrading to lucid i noticed that they decided to go for the mac layout on windows controls to fix this.
Run gconf-editor, then apps > metacity > general > button layout > menu:minimize,maximize,close

Fixed thank god.

Powertop

PowerTOP is a software utility designed to measure, explain and minimize a computers power consumption. It works for both Intel and AMD processors. It analyses the programs, devices and kernel options running Linux or Solaris. It estimates the power consumption for any computer.

Irq Fun

Hardware interrupts were introduced as a way to avoid wasting the processor’s valuable time in polling loops, waiting for external events. They may be implemented in hardware as a distinct system with control lines, or they may be integrated into the memory subsystem.Read More

1
2
3
4
5
6
7
8
9
[[email protected] ~]# cat /proc/interrupts
           CPU0       CPU1
 <items removed>
30: 1543015844         70   IO-APIC-level  eth0
33:        982 1125222804   IO-APIC-level  eth1
NMI:          0          0
LOC:  312789123  312790125
ERR:          0
MIS:          0

As you can see from the list above the interrupts for the network card has been balanced betwen the Cores. How Irqbalance works is rather complex and i suggest you read more.

The Most Useful Command Ever

How many times have you run a command and then thought, ooo crap i now need to leave work, i really should have nohupped it or run it in screen session well welcome to.