Replace a failed disk on a 3ware RAID

I had an old Debian GNU/Linux system with a 3ware RAID controller. Having to figure out how to properly replace the failed disk was a pain. You can manipulate the RAID array, without rebooting to the controller bios, with the 3waretwi_cli command line tool.

For this example, we will assume that port6 on the first controller has failed. Tell the controller to remove the disk, then physically remove the disk:
# ./tw_cli /c0/p6 remove

Now physically insert your replacement disk and scan for it:
# ./tw_cli /c0 show
# ./tw_cli /c0 rescan

Issue the command to start rebuilding the array onto the new disk in port6:
# ./tw_cli /c0/u0 start rebuild disk=p6 ignoreECC

If you need to, pause and resume the rebuild:
# ./tw_cli /c0/u0 pause rebuild
# ./tw_cli /c0/u0 resume rebuild

Check the rebuild progress and RAID health:
# ./tw_cli /c0 show

##### FOR WINDOWS #####

./tw_cli maint rebuild c1 u0 p2

Mailq Check

<pre class=”brush:shell”>#!/bin/sh

fila_post=`postqueue -p |grep -e “^[A-Z,0-9]” | grep -v “Mail” |wc -l`
crit=30
warn=25

if [ $fila_post -gt $warn ]; then
if [ $fila_post -le $crit ]; then
echo “WARNING: postqueue -p -> $fila_post”
exit 1
fi
fi
if [ $fila_post -gt $crit ]; then
echo “CRITICAL: postqueue -p > $fila_post”
exit 2
fi
if [ $fila_post -le $warn ]; then

echo “OK: postqueue -p -> $fila_post”
exit 0
fi</pre>
<div style=”clear: both;”></div>

<!– PAGES LKINKS –>
<div class=”pages_navigation”>
</div>

 

Tips and Tricks from Pesho

mount -t msdosfs -o large,-M=755 /dev/da0s1 temp/
tr -d \r < dosfile > newfile ===premahva bad charovete ot dos file
tr -d ‘”‘ <filename >newfilename — premahva ”
while IFS= read -r file; do rm — “$file”; done < filelist
sed ‘/define hostgroup/{N;N;N;d;}’ $i>$i.new && mv $i.new $i — namira i iztriva 3 reda sled tova 🙂
root@Microknoppix:~# ssh pstankov@hosting dd if=/dev/sdb2 |dd of=/dev/sda2
mailq |grep -i 0-|cut -f 1 -d “*”|postsuper -d –
dns hitrini za load balance
http://www.zytrax.com/books/dns/ch7/queries.html#rrset-order
check and repair all tables
mysqlcheck –all-databases -u root -p
mdconfig -a -t vnode -f /usr/space/work/proxmox-ve_1.9-6542-7.iso -u 1
[root@darksun ~]# mount -t cd9660 /dev/md1 /mnt/temp/
import -window root screenshot1.png – printscreena
find . -name ‘spam-*’ | xargs rm

freeBSD
pw lock vivek
pw unlock vivek
karmic ubuntu
http://azerdark.wordpress.com/2009/12/04/ubuntu-9-10-repository-list/

 

ipfw + fail2ban – FreeBSD

Fail2ban + ipfw = Джилязо

Вери много важно – f2b на freebsd има бъг с името на затворите, ако има “-” в името примерно ssh-ipfw, не работи :), затова sshipfw, да ти е мирна главицата!

Install fail2ban on freebsd

cd /usr/ports/security/py-fail2ban
make install clean
echo ‘fail2ban_enable=”YES”‘ >> /etc/rc.conf

Create table in ipfw for F2B

ipfw table 10 add 127.0.0.2
ipfw add 1 deny ip from table(10) to me

Must create action for ipfw in f2b action.d/ipfw.con to know how to deal with the spammers

actionban = ipfw table 10 add
actionunban = ipfw table 10 delete

jail.conf setting

ignoreip = 127.0.0.1/8
bantime = 35600

[sshipfw]
enabled = true
filter = ipfw-ssh
action = ipfw-ssh[localhost=127.0.0.1]
sendmail-whois[name=”SSH,IPFW”, dest=netadmin@powernet.bg]
logpath = /var/log/auth.log
maxretry = 3

[postfix]
enabled = true
filter = postfix
action = mail[localhost=127.0.0.1]
sendmail-whois[name=”Postfix jail”, dest=netadmin@powernet.bg]
logpath = /var/log/maillog
maxretry = 4

[dovecot]
enabled = true
filter = dovecot
action = mail[localhost=127.0.0.1]
sendmail-whois[name=”Dovecot mail jail”, dest=netadmin@powernet.bg]
logpath = /var/log/maillog
maxretry = 4