Published under Uncategorized.

well many time ago
i was rouding with this idea in my head..

measure how many time took a host on reboot process , the following script is the most accurate way ,that i could craft, to perform that task…
this script was maded to test Rhel hosts but should work against almost any linux flavor’s , check the reboot command , if you plan to test it in other
plattaform.

beware of ssk unknown hosts and/or duplicate keys…. before to launch this script test if you could connect using ssh to the the root account…

#!/bin/bash
slp=”/bin/sleep”
expr=”/usr/bin/expr”
ssh=”/usr/bin/ssh”
rb=”/sbin/reboot”
oneMinuteInSeconds=”60″
oneHourInSeconds=”3600″
dateStart=”`date +%s`”
remoteUser=”root”
remoteHost=”someHost.Somedomain.tld” # should be know first the launch this script
$ssh $remoteUser@$remoteHost “$rb”
sleep 30
while true;
do
sleep 1
$ssh -q $remoteUser@$remoteHost “$slp 1 2>&1 > /dev/null” 2>&1 > /dev/null
if [ $? -eq 0 ];then
echo “host up”
break
fi
done
dateEnd=”`date +%s`”
totalTime=”`$expr $dateEnd – $dateStart`”
if [ "$totalTime" -eq 0 ];then
echo “the process probably doesn’t run or took less than one second”
elif [ "$totalTime" -gt 0 ] && [ "$totalTime" -lt "$oneMinuteInSeconds" ];then
echo “total time was $totalTime”
elif [ "$totalTime" -gt "$oneMinuteInSeconds" ] && [ "$totalTime" -lt "$oneHourInSeconds" ] ;then
howManyMins=”`$expr $totalTime \/ $oneMinuteInSeconds`”
howManyMinsInSecs=”`$expr $howManyMins \* $oneMinuteInSeconds`”
howManySecsOverMins=”`$expr $totalTime – $howManyMinsInSecs`”
echo “total was $howManyMins min(s), $howManySecsOverMins seconds”
else
echo “the process probably it’s stucked or never run”
fi

Dump All Mysql Databases On Some Host

Published under linux,mysql.

Well the idea is quite simple … extract all db’s on some mysql host and dump them in SEPARATE files… really useful , for FAST db recovery….

#!/bin/bash
mySqlDumpProgram=`which mysqldump`
if [ -z $mySqlDumpProgram ];then mySqlDumpProgram=”/usr/bin/mysqldump”;fi #if which doesn’t find the prog
mySqlDbaUser=”mysqldSuperDuperUser”
mySqlDbaPass=”superSecretPassword”
mySqlHost=”xxx.xxx.xxx.xxx”
backupDir=”/some/dir”
if [ -z $mySqlDumpProgram ];then mySqlDumpProgram=”/usr/bin/mysqldump”;fi #if which doesn’t find the prog
backupSuffix=”sql”
backupMaskFile=”${backupDir}/mysql_`hostname -f`_`date +%F`”
gzipCompressProgram=`which gzip`

getAnArrayOfDbsOnHost () {
dbs=`/usr/bin/mysql -u ${mySqlDbaUser} -p${mySqlDbaPass} -h ${mySqlHost} -B -N -e “show databases;”|xargs`
}

if [ -z $gzipCompressProgram ];then gzipCompressProgram=”/bin/gzip”;fi #if which doesn’t find the prog
getAnArrayOfDbsOnHost
#main
for db in $dbs;do
${mySqlDumpProgram} -u ${mySqlDbaUser} -p${mySqlDbaPass} -h ${mySqlHost} $db > ${backupMaskFile}-$db.$backupSuffix
done
if [ $? == '0' ];then #if backup end nice so compress them
for db in $dbs;do
$gzipCompressProgram -f ${backupMaskFile}-$db.$backupSuffix
done
else
echo “errors from backup process….see mysql logs or invoke $0 with bash -x prefix” > ${backupMaskFile}
fi

after execute this script, in your $backupDir should be many files as databes holds the machine , at least two,
mysql_localhost_1666-06-66-information_schema.sql.gz
mysql_localhost_1666-06-66-mysql.sql.gz

so you can restore each specific database with a command like this:

mysql -u $mySqlDbaUser -p$mySqlDbaPass -h $mySqlHost mysql < `zcat $backupDir/mysql_localhost_1666-06-66-information_schema.sql.gz`

refresh scsi devices

Published under things-that-should-not-bet-forged.

echo “- – -” > /sys/class/scsi_host/host0/scan

squid reverse with vhost

Published under linux.

well… many time ago i want to make this config… well here is !! upfront this website….

visible_hostname proxy.domain.tld
cache_effective_user proxy
hosts_file /etc/hosts
cache_mgr root@domain.tld
dns_testnames www.domain.tld www.google.com
http_port xxx.xxx.xxx.xxx:80 accel defaultsite=www.domain.tld vhost
cache_peer xxx.xxx.xxx.xx1 parent 80 0 no-query originserver name=someserver login=PASS
cache_peer xxx.xxx.xxx.xx2 parent 80 0 no-query originserver name=someotherserver login=PASS
cache_peer xxx.xxx.xxx.xx3 parent 8080 0 no-query originserver name=someotherserverextra login=PASS
forwarded_for on
maximum_object_size_in_memory 4 KB
cache_dir ufs /dev/shm/squid-cache 100 16 256
cache_mem 64 MB
memory_replacement_policy lru
cache_replacement_policy lru
store_dir_select_algorithm least-load
max_open_disk_fds 1024
minimum_object_size 1 KB
maximum_object_size 20480 KB
forwarded_for on
maximum_object_size_in_memory 4 KB
cache_mem 64 MB
memory_replacement_policy lru
cache_replacement_policy lru
store_dir_select_algorithm least-load
max_open_disk_fds 1024
minimum_object_size 1 KB
maximum_object_size 20480 KB
forwarded_for on
maximum_object_size_in_memory 4 KB
cache_mem 64 MB
memory_replacement_policy lru
cache_replacement_policy lru
store_dir_select_algorithm least-load
max_open_disk_fds 1024
minimum_object_size 1 KB
maximum_object_size 20480 KB
dead_peer_timeout 1 seconds
cache_swap_low 90
cache_swap_high 95
access_log /var/log/squid/access.log
useragent_log /var/log/squid/user-agent.log
referer_log /var/log/squid/referer.log
emulate_httpd_log on
coredump_dir /var/log/squid
log_ip_on_direct on
client_netmask 255.255.255.255
acl safe_ports port 80 21 443 563 70 210 1025-65535
http_access deny !safe_ports
acl all src 0.0.0.0/0
http_access allow all
acl someserver_sites dstdomain www.domain.tld syslog.domain.tld localhost.domain.tld some.domain.tld
acl someotherserver_sites dstdomain someotherserver.domain.tld
acl someotherserverextra dstdomain someotherserverextra.domain.tld
http_access allow someserver_sites
cache_peer_access someserver allow someserver_sites
cache_peer_access someserver deny all
http_access allow someotherserver_sites
cache_peer_access someotherserver allow someotherserver_sites
cache_peer_access someotherserver deny all
http_access allow someotherserverextra
cache_peer_access someotherserverextra allow someotherserverextra
cache_peer_access someotherserverextra deny all

be carefull with resolution of the names used over the vhosts, they MUST be resoluble by dns

~

cron’s mail

Published under linux,things-that-should-not-bet-forged.

run once per user crontab …

crontab -l > existing.cron;echo MAILTO=”you@domain.tld” > mailto.cron;cat existing.cron >> mailto.cron;crontab < mailto.cron; rm -rf existing.cron mailto.cron

/etc/mail.rc (zimbra’s localmail)

Published under things-that-should-not-bet-forged.

alias root some@domain.tld
alias zimbra some@domain.tld

sed !!

Published under things-that-should-not-bet-forged.

zmlocalconfig -s | sed -e “s/ = \(.*\)/=\’\1\’/”

Los Hijos De Eva

Published under Poemas.

del baùl de los recuerdos, un trabajo de al menos 10 años atràs…


Maldigo a los hijos de eva
deshonro a todos sin pena
ejecuto a Cain Y Abel
dándoles condena

Hijos inmaduros
Pero sin igual los torturo
Odioso futuro
Sin ningun laburo

Modestos niños molestos
Breves razocinios funestos
Que por milagro algo logran
Quizá, como última capacidad

Incapacidad de observar
Imbecilidad de obrar
Intencionalidad de pensar
Pero sólo por un minuto

Esperanza sin semblanza
Añoranza sin extravagancia
Lamentaciones sin cavilaciones
Segregaciones a montes !!

searching ips using grep

Published under linux.

grep -o “[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*” someFile.log

zmmta hardconfig

Published under things-that-should-not-bet-forged.

zmlocalconfig -e setting=value