Monday, July 18, 2011

create a list of all packages

#!/bin/sh

/bin/rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}.rpm\n' 2>&1 \
| /bin/sort > /var/log/rpmpkgs

The idea would be to take a sha1 hash of this file and then check it periodically to be sure that the package list has not changed.

Wednesday, June 22, 2011

oracle linux links

http://www.oracle.com/us/technologies/linux/index.htm
http://www.oracle.com/us/technologies/linux/unbreakable-enterprise-kernel-ds-173416.pdf
http://www.oracle.com/us/technologies/linux/ubl-edison-066204.pdf
http://public-yum.oracle.com/

Tuesday, June 14, 2011

sending logs to splunk

#* * * * * root lockfile -l5 -s5 /tmp/mysql_error_log.lock && /usr/sbin/logtail /dbhost2_logs/dbhost2.err | /usr/bin/nc -w2 -v dblogs1 10001 && rm -rf /tmp/mysql_error_log.lock > /dev/null 2>&1

#* * * * * root lockfile -l5 -s5 /tmp/messages_log.lock && /usr/sbin/logtail /var/log/messages | /usr/bin/nc -w2 -v dblogs1 10002 && rm -rf /tmp/messages_log.lock > /dev/null 2>&1

Monday, June 13, 2011

top 10 memory hogs

ps -eo pmem,pid,comm --no-headers | sort -k1 -rn | head -10

Wednesday, March 23, 2011

unable to build ports in OpenBSD 4.8 - SOLVED

From root's .profile, comment this out:

...

if [ -x /usr/bin/tset ]; then
if [ X"$XTERM_VERSION" = X"" ]; then
eval `/usr/bin/tset -sQ '-munknown:?vt220' $TERM`
else
eval `/usr/bin/tset -IsQ '-munknown:?vt220' $TERM`
fi
fi

...

and add this:

export TERM=vt100

reinstall openbsd ports

tar -xvzpf base48.tgz -C/
tar -xvzpf comp48.tgz -C/
tar -xvzpf xbase48.tgz -C/

Friday, March 11, 2011

unix time coolness

[root@elcap ~]# date
Fri Mar 11 11:26:52 PST 2011

[root@elcap ~]# date +%s
1299871617

[root@elcap ~]# date -R -d @1300000000
Sat, 12 Mar 2011 23:06:40 -0800
[root@elcap ~]#

Saturday, February 26, 2011

how many InnoDB rows are read per second in mysql

mysqladmin extended-status -i 1 -r -p -uroot | grep -e "Com_select"

Thursday, February 17, 2011

how to help out heartbeat

/sbin/arping -q -A -c 1 -I eth0 -s 10.6.1.10 10.6.1.10

Thursday, January 6, 2011

quick check of top current process

top -b -n1 -d 3 | sed 1,7d |head -1

Friday, October 8, 2010

ctrap script

#!/bin/bash
ctrap(){
echo -ne "\033]0;"puppet"\007"
}
if [ $# -eq 1 ];then
trap ctrap SIGINT
echo -ne "\033]0;"$1"\007"
ssh $1
ctrap
exit 0
fi
ssh $*

Monday, September 20, 2010

mount ntfs in *bsd

http://lordhendrix.wordpress.com/2008/01/13/mounting-ntfs-to-freebsd-or-unix/

Friday, July 30, 2010

symon/symux/syweb installation on openbsd 4.4


mkdir /mnt/cdrom
mount /dev/cd0c /mnt/cdrom/
cd /
tar -zxvf /mnt/cdrom/4.4/i386/xbase44.tgz
ldconfig /usr/X11R6/lib /usr/local/lib
pkg_add -v http://ftp.openbsd.org/pub/OpenBSD/4.4/packages/i386/libart-2.3.20p0.tgz
pkg_add -v http://ftp.openbsd.org/pub/OpenBSD/4.4/packages/i386/png-1.2.28.tgz
pkg_add -v http://ftp.openbsd.org/pub/OpenBSD/4.4/packages/i386/rrdtool-1.2.23p0.tgz
pkg_add -v http://ftp.openbsd.org/pub/OpenBSD/4.4/packages/i386/wget-1.11.3.tgz
pkg_add -v http://ftp.openbsd.org/pub/OpenBSD/4.4/packages/i386/pcre-7.7p0.tgz
pkg_add -v http://ftp.openbsd.org/pub/OpenBSD/4.4/packages/i386/php5-fastcgi-5.2.6.tgz
pkg_add -v http://ftp.openbsd.org/pub/OpenBSD/4.4/packages/i386/php5-mbstring-5.2.6.tgz
echo "env -i PHP_FCGI_CHILDREN=5 PHP_FCGI_MAX_REQUESTS=1000 /usr/local/bin/php-fastcgi -q -c /var/www/conf/ -b 127.0.0.1:8888 &" > /root/run_php-fastcgi.sh && chmod 700 /root/run_php-fastcgi.sh
ln -s /var/www/conf/modules.sample/php5.conf /var/www/conf/modules
ln -fs /var/www/conf/php5.sample/mbstring.ini /var/www/conf/php5/mbstring.ini
mkdir /var/www/tmp

tar zxvf ./syweb-0.59.tar.gz
tar zxvf ./symon-2.80.tar.gz
cd symon
make && make install
cp ./symon/symon.conf /etc/symon.conf
cp ./symux/symux.conf /etc/symux.conf
cp ./symon/hifn_test.layout /var/www/symon/
useradd -d /var/empty -L daemon -c 'symon Account' -s /sbin/nologin _symon
/usr/local/libexec/symon
mkdir /var/www/symon /var/www/symon/rrds /var/www/symon/rrds/localhost
#fix up symux.conf here
./symux/c_smrrds.sh all


echo > /etc/symon.conf <#
# Demo configuration for symon. See symon(8) for BNF.
#

monitor { cpu(0), mem,
if(lo0),
pf,
mbuf,
# sensor(0),
proc(sshd),
if(em0),
io(wd0)
} stream to 127.0.0.1 2100
EOF


echo > /etc/symux.conf <#
mux 127.0.0.1 2100
source 127.0.0.1 {
accept { cpu(0), mem, pf,
if(em0),
if(lo0),
io(wd0),
df(sd0a) }

datadir "/var/www/symon/rrds/localhost"
}
EOF

Thursday, June 17, 2010

regex for IP addresses

ifconfig | sed -n ‘/^[A-Za-z0-9]/ {N;/dr:/{;s/.*dr://;s/ .*//;p;}}’

Tuesday, May 25, 2010

Tuesday, May 18, 2010

convert vmdk from thick to thin

vmkfstools -i /vmfs/volumes/datastore1/somehost/somehost.vmdk /vmfs/volumes/datastore1/somehost/somehost-thin.vmdk -d 'thin' -a lsilogic

# adjust vmx and away you go.

Monday, May 10, 2010

my fave prompt

PS1='[\t][\u@\h:\w]$ '

Saturday, April 24, 2010

backup your failing system hard drive and mount it under ubuntu

i heard some clicking coming from the hard drive of my openbsd firewall the other day. i have put a lot of time into this thing and i dont want to lose it. I have more hard drives, but i dont want to lose everything on this one. this system run on an an old Dell b733r, PIII w/256MB RAM. I love it. Its Perfect.


#on failing host, do not skip this critical step
disklabel -v wd0c > failing_host_disklabel.info && scp ./failing_host_disklabel.info root@stable_host:.

#on stable host
nc -p 2222 -l | bzip2 -d | dd of=/root/failing_host.img

#on failing host
bzip2 -c /dev/wd0c | nc stable_host 2222

#wait for completion ...

#on stable host

#test to see if image is good
sfdisk -l failing_host.img
sfdisk -d failing_host.img
fdisk -l -u failing_host.img

#take offset from disklabel.info: offset * bytes/sector = [value]
#default value for dd block size (bytes/sector) is 512, adjust as necessary

mount -v -o ro,loop,offset=[value],ufstype=44bsd -t ufs ./failing_host.img /mnt/failing_host

#if it fails and you get a message in dmesg that says:
#
#[some.date] ufs_read_super: bad magic number
#
# it means you have the wrong offset value

Wednesday, April 14, 2010

loop-aes-utils, smbfs and Ubuntu

The following was experienced on Ubuntu Desktop 9.10

if you install loop-aes-utils, and then install smbfs, the cryptoloop.ko is removed from the kernel.

`mount` will give you errors like:

ioctl: LOOP_SET_STATUS: Invalid argument, requested cipher or key length (256 bits) not supported by kernel


`modprobe loop` will give you:

FATAL: Module loop not found


well, not sure what the whole story is, but the following fixes it.

`modprobe cryptoloop`

Monday, April 5, 2010

resolve IP's of established connections using pfctl


pfctl -s state | grep 'EST' | grep -v '<-' | awk '{print $6}' | cut -d":" -f1 | xargs dig +short -x