Saturday, December 24, 2011

Set up bind (caching-nameserver) on OpenBSD 4.9

http://www.nohair.net/news/2011/set-up-dns-on-openbsd-4-9/

Friday, October 28, 2011

ruby installation with rvm on Ubuntu 10.04.3 LTS

:~# PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/rvm/bin"
:~# apt-get install git-core curl build-essential openssl libssl-dev libyaml-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev
:~# bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

#something was broken here during package management above, not sure...
echo "export PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/rvm/bin\"" > >> ./.bashrc

:~# rvm pkg install zlib
:~# rvm install 1.9.2
:~# rvm use 1.9.2
:~# rvm default 1.9.2
:~# rvm all do gem install eventmachine
:~# echo "[[ -s \"/usr/local/rvm/scripts/rvm\" ]] && . \"/usr/local/rvm/scripts/rvm\"" >> ./.profile

root@sssid1:~# ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
root@sssid1:~#

Tuesday, October 11, 2011

how to securely wipe a drive in linux

option 1
# shred -n 7 -z /dev/sdb

option 2
# dd if=/dev/urandom of=/dev/sdb bs=4096 count=7
# dd if=/dev/zero of=/dev/sdb bs=4096 count=7

Friday, September 30, 2011

clear postfix mail queue

for f in ` mailq |grep .com -B 2 |grep ^[A-Z0-9]|awk '{print $1}'` ; do postsuper -d $f; done

Also, fun times here:
http://www.postfix.org/docs.html

Wednesday, September 28, 2011

Comparison of Disk Encryption Software

http://en.wikipedia.org/wiki/Comparison_of_disk_encryption_software

Wednesday, August 31, 2011

Nagios - ERROR opening session: An empty privacy password was specified.

in Nagios® Core™ 3.2.3 i got this error when running checks with "check_snmp_load":
"ERROR opening session: An empty privacy password was specified."

on the command line, after executing this:
../libexec/snmp/check_snmp_load.pl -l readpriv -x xxxxxx -X xxxxxx -H hostname -w 3,3,2 -c 4,4,3 -T netsl

i got this:
Argument "v6.0.1" isn't numeric in numeric lt (<) at ./check_snmp_load.pl_old line 348.
Load : 0.00 0.00 0.00 : OK

I changed line 348 from:
my $resultat = (Net::SNMP->VERSION < 4) ?

 to:
my $resultat = (Net::SNMP->VERSION lt 4) ?


..works

Wednesday, August 17, 2011

automatically bring up the openvpn client

# /etc/rc.local
echo 0 > /proc/sys/net/ipv4/conf/tun0/rp_filter
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
echo 1 > /proc/sys/net/ipv4/ip_forward
/usr/local/sbin/openvpn --config /etc/openvpn/client.conf --daemon &

#i use this to do all kinds of stuff...

clearing a mail queue

for f in ` mailq |grep hostname.com -B 2 |grep ^[A-Z0-9]|awk '{print $1}'` ; do postsuper -d $f; done

Monday, August 15, 2011

mrepo

http://dag.wieers.com/home-made/mrepo/

Saturday, August 13, 2011

SMTP Codes


211 - A system status message.
214 - A help message for a human reader follows.
220 - SMTP Service ready.
221 - Service closing.
250 - Requested action taken and completed.
251 - The recipient is not local to the server, but the server will accept and forward the message.
252 - The recipient cannot be VRFYed, but the server accepts the message and attempts delivery.

354 - Start message input and end with .. This indicates that the server is ready to accept the message itself

421 - The service is not available and the connection will be closed.
450 - The requested command failed because the user’s mailbox was unavailable (such as being full). Try again later.
451 - The command has been aborted due to a server error. (on their side)
452 - The command has been aborted because the server has insufficient system storage.

500 - The server could not recognize the command due to a syntax error.
501 - A syntax error was encountered in command arguments.
502 - This command is not implemented.
503 - The server has encountered a bad sequence of commands.
504 - A command parameter is not implemented.
550 - The requested command failed because the user’s mailbox was unavailable (such as not found)
551 - The recipient is not local to the server.
552 - The action was aborted due to exceeded storage allocation.
553 - The command was aborted because the mailbox name is invalid.
554 - The transaction failed for some unstated reason

Friday, August 12, 2011

compare packages between two RHEL systems

#generate package list on hostname1
rpm -qa --qf "%{NAME}\n" > hostname1.rpm.txt
cat ./hostname1.rpm.txt | sort | uniq > ./hostname1_final.rpm.txt

#generate package list on hostname2
rpm -qa --qf "%{NAME}\n" > hostname2.rpm.txt
cat ./hostname2.rpm.txt | sort | uniq > ./hostname2_final.rpm.txt

#you want the difference between systems - show diffs on the right and trim leading whitespace
sdiff ./hostname1.rpm.txt ./hostname2.rpm.txt | grep '>' | sed -e 's/^[> \t]*//'


#you want the difference between systems - show diffs on the left and trim trailing whitespace
sdiff ./hostname1.rpm.txt ./hostname2.rpm.txt | grep '<' | sed -e 's/[ \t<]*$//'

Wednesday, August 3, 2011

clearing a mail queue

#sendmail
sendmail -qS -v subdomain.test.com

#postfix
for f in ` mailq |egrep subdomain.test.com -B 2 |grep ^[A-Z0-9]|awk '{print $1}'` ; do postsuper -d $f; done

Thursday, July 28, 2011

GPG key error when updating RHEL 5.x system

when running a `yum update -y`, i got:

--
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 897da07a


Public key for nash-5.1.19.6-71.el5.i386.rpm is not installed
--


I had to install:

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta

then run again.


also, check this:

rpm -qa |grep gpg

if you have multiple of the same gpg keys installed use the following:

rpm -e --allmatches gpg-pubkey*
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta

Monday, July 25, 2011

mdadm notes

mdadm --remove /dev/md0 /dev/sdb
#pull disk, replace with new one

# you have to fail a disk before you remove it
# however, if the system wont release the raid partner, you need to slide the offending disks out and boot off a good disk.

#here you can review the layout
[root@host~]# fdisk -l /dev/sda

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          16      128488+  fd  Linux raid autodetect
/dev/sdb2              17        1291    10241437+  fd  Linux raid autodetect
/dev/sdb3            1292        2566    10241437+  83  Linux
/dev/sdb4            2567       30401   223584637+   5  Extended
/dev/sdb5            2567        2827     2096451   fd  Linux raid autodetect
/dev/sdb6            2828        2860      265041   fd  Linux raid autodetect
/dev/sdb7            2861       30401   221223051   fd  Linux raid autodetect

#review the descriptions of the disks



-----------


[root@host ~]# sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=       63, size=   256977, Id=fd, bootable
/dev/sda2 : start=   257040, size= 20482875, Id=fd
/dev/sda3 : start= 20739915, size= 20482875, Id=83
/dev/sda4 : start= 41222790, size=449113140, Id= 5
/dev/sda5 : start= 41222853, size=  4192902, Id=fd
/dev/sda6 : start= 45415818, size=   530082, Id=fd
/dev/sda7 : start= 45945963, size=444389967, Id=fd
[root@host ~]# sfdisk -d /dev/sdb

sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/sdb: unrecognized partition table type
No partitions found
-----------


#this command is similar to `sfdisk -l`, but you can use it to copy the layout to the new replacement disk
#its destructive to sdb, be sure you know what you're doing. read man page, right?  :)


-----------

[root@host~]# sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 30522 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdb1   *        63    257039     256977  fd  Linux raid autodetect
/dev/sdb2        257040  20739914   20482875  fd  Linux raid autodetect
/dev/sdb3      20739915  41222789   20482875  83  Linux
/dev/sdb4      41222790 490335929  449113140   5  Extended
/dev/sdb5      41222853  45415754    4192902  fd  Linux raid autodetect
/dev/sdb6      45415818  45945899     530082  fd  Linux raid autodetect
/dev/sdb7      45945963 490335929  444389967  fd  Linux raid autodetect
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
[root@host~]# sfdisk -d /dev/sdb
# partition table of /dev/sdb
unit: sectors

/dev/sdb1 : start=       63, size=   256977, Id=fd, bootable
/dev/sdb2 : start=   257040, size= 20482875, Id=fd
/dev/sdb3 : start= 20739915, size= 20482875, Id=83
/dev/sdb4 : start= 41222790, size=449113140, Id= 5
/dev/sdb5 : start= 41222853, size=  4192902, Id=fd
/dev/sdb6 : start= 45415818, size=   530082, Id=fd
/dev/sdb7 : start= 45945963, size=444389967, Id=fd


-----------




#check the status of the set
cat /proc/mdstat

#now, add the partition slices back to the set
mdadm --add /dev/md0 /dev/sdb1
mdadm --add /dev/md1 /dev/sdb5
mdadm --add /dev/md3 /dev/sdb6
mdadm --add /dev/md4 /dev/sdb7
mdadm --add /dev/md2 /dev/sdb2


#review
mdadm --detail /dev/md0

#review progress
cat /proc/mdstat


healthy output:

[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0] sdb1[1]
      128384 blocks [2/2] [UU]
   
md1 : active raid1 sda5[0] sdb5[1]
      2096384 blocks [2/2] [UU]
   
md3 : active raid1 sda6[0] sdb6[1]
      264960 blocks [2/2] [UU]
   
md4 : active raid1 sda7[0] sdb7[1]
      221222976 blocks [2/2] [UU]
   
md2 : active raid1 sda2[0] sdb2[1]
      10241344 blocks [2/2] [UU]
   
unused devices:


UNhealthy output:

[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1]
      128384 blocks [2/2] [_U]
   
md1 : active raid1 sdb5[1]
      2096384 blocks [2/2] [_U]
   
md3 : active raid1 sdb6[1]
      264960 blocks [2/2] [_U]
   
md4 : active raid1 sdb7[1]
      221222976 blocks [2/2] [_U]
   
md2 : active raid1 sdb2[1]
      10241344 blocks [2/2] [_U]
   
unused devices:

#have a nice day



--------------------------------------------------------
[root@somehost ~]# mdadm --detail /dev/md0
/dev/md0:
Version : 00.90.03
Creation Time : Sat Oct 31 03:08:47 2009
Raid Level : raid1
Array Size : 128384 (125.40 MiB 131.47 MB)
Device Size : 128384 (125.40 MiB 131.47 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Mon Jul 25 04:48:26 2011
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

UUID : xxxxxx:xxxxxxxx:xxxxxxx:dd7a13a5
Events : 0.74

Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
--------------------------------------------------------

nagios check: check_by_ssh!"sudo /bin/cat /proc/mdstat | grep _ /proc/mdstat -c | grep 0 -c

Thursday, July 21, 2011

ethtool command

/sbin/ethtool -s eth0 speed 100 duplex full autoneg off

mail alert when script is finished

echo y | ./deploy.sh -s xxxx -f '/root/xxxxx.tgz' && mail -s "deployment complete on `hostname`" me@overthere.com < /dev/null

Monday, July 18, 2011

logrotate script

#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

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