Monday, November 05, 2007

mdb display options (64-bit vs 32-bit) [42]

To see whether to use the \D or \E display option in mdb: You can run nm and see whether the variable is 4 or 8 bytes. If it's 8 bytes (64 bit) then you need to use /E otherwise /D.
-bash-3.00$ /usr/ccs/bin/nm /dev/ksyms |grep maxpgio
[23962] | 25553712| 8|OBJT |GLOB |0 |ABS |maxpgio
In the above example the third column tells us that this maxpgio is 8 byte object therefore we need to use /E
[root@db31:/] mdb -k
Loading modules: [ unix krtld genunix specfs dtrace ufs sd pcisch ip sctp usba fcp fctl ssd md fcip cpc random crypto logindmux ptm nfs ]
> maxpgio/E
maxpgio:
maxpgio: 40
> maxpgio/J
maxpgio:
maxpgio: 28

Use the option /J when you want the value to be displayed as hex.

Tuesday, August 08, 2006

Check disk space [41]

Check disk space (requires bssh)

sudo bssh `cat dbs | tr '\n' ','` 'df -h' > logs/disk_report.080806

Sunday, July 23, 2006

Managing Foreground and Background Jobs and Processes [32-40]

Unix system administrators often need to switch and move jobs from foreground to background and vice versa.
[32] To stop (not kill) a currently running job and return to shell, you can use Ctrl-z.
[33] Then to view the stopped jobs during the current session
jobs
[34] To kill a stopped job number 2
kill -9 %2
[35] Check the status of processes in all sessions running by user frankly
ps -u frankly
[36] Kill a process by its process id (822)
kill -9 822
[37] Bring the job that was sent most recently sent to run in background to foreground
fg
[38] Bring the background job with job id 2 to run in the foreground
fg %2
[39] Start running the most recently stopped job in the background
bg
[40] Run a job in the background
Add & to end of the command

Sunday, July 16, 2006

Copy MySQL tables between different hosts [31]

The following command will allow you to copy MySQL tables between different hosts


mysqldump -h ip -uuser -ppass from_db from_table | mysql -uuser -ppass target_db

Monday, June 19, 2006

Run a command on multiple MySQL hosts

cat /lists/dbs | while read i ; do echo $i; /path/to/mysql -h $i -e "SHOW variables like 'old%'"; done


This programming one liner allows you to run a command on multiple MySQL hosts. To use this command, simply create a file dbs with all the MySQL hosts (one per line). The sample command prints the value of whether the database is using old passwords.

Friday, March 10, 2006

IPCS remove semaphores

If you get an error message saying
"HTTPD dead but PID exists", your disk space is either full or all IPCS semaphores have been used up.

ipcs -s | awk ' $3 == "apache" {print $2, $3}' | awk '{ print $1}' | while read i; do ipcrm sem $i; done


Clean up ipcs semaphores

Thursday, March 09, 2006

Remove blank / empty lines PHP [29]

I found this great implementation to remove blank (empty lines) from a string at PHP web site.


function removeEmptyLines($string)
{
return preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $string);
}