Programing, Shell scripting, Windows, Linux. I'm using this as a repository for all those niggling little tasks that get done just often enough to be annoying, but maybe not often enough to commit to memory, and other things I feel like writing about.
Friday, June 24, 2011
Delay for a few seconds in a Batch file
choice /T 10 /D Y /N
Replace 10 with the number of seconds to replace. This will return an error code of 1 (1st choice on the list) so just be aware that errorcode=1 is success for this.
Zabbix monitoring MySQL on a windows Server
Then add the following lines to your agentd configuration file:
UserParameter=mysql.queries[*],mysql -u root -ptest -N -e "show global status like 'Com_$1'" -s | cut -f2Replace test with the root@localhost password for your MySQL box. Once you have done this you can use the Template_App_MySQL to monitor all of those UserParameters. I ended up making a clone of that template so that I could change the service from "mysql" to "mysqld.exe" in order to monitor it.
UserParameter=mysql.ping,mysqladmin -uroot -ptest ping | grep alive | wc -l | cut -d" " -f 7
UserParameter=mysql.uptime,mysqladmin -uroot -ptest status | cut -d: -f2 | cut -d " " -f2
UserParameter=mysql.threads,mysqladmin -uroot -ptest status | cut -d: -f3 | cut -d " " -f2
UserParameter=mysql.questions,mysqladmin -uroot -ptest status | cut -d: -f4 | cut -d " " -f2
UserParameter=mysql.slowqueries,mysqladmin -uroot -ptest status | cut -d: -f5 | cut -d " " -f2
UserParameter=mysql.qps,mysqladmin -uroot -ptest status | cut -d: -f9 | cut -d " " -f2
UserParameter=mysql.version,mysql -V
Tuesday, September 23, 2008
Mounting Shares with Spaces
//ip.of.server/Home\040Folders/ejh /home/ejh/Documents cifs username=ejh,password=*****,uid=500,gid=500 0 0
Monday, September 22, 2008
Removing SVN folders from a directory
rm -rf `find . -type d -name .svn`
Incorrect DNS Settings Reappearing
After many frustrating hours I decided to check DHCP, and sure enough, DHCP had the old and new leases both with the same host name and was reporting them both to Active Direcotry.
Solution: Simply remove the old lease from DHCP, I'm sure eventualy it would have expired and fixed itself as well.
Monday, March 3, 2008
Hiding SVN Directories using .htaccess
RewriteEngine onThis same format could be used to hide any directory on a web server.
RewriteRule \.svn/ - [F]
Thursday, February 21, 2008
Finding Disk space Hogs
du -k -s * |sort -nthis will list the directories and files in the current directory in asc order so that the last one you see is the largest. Using this it is easy to move down the directory tree and quickly identify the offending files.
Using date in file name (and compressing files)
Yea this is stupid an easy, and also very annoying if you forget how!
backup=`date +%Y%m%d`That backs up all the current .sql files in a directory into a file with todays date as the name
tar czvf SQL-$backup.tar.gz *.sql
Deleting Files over Certain Age
The command to delete files over a certain age is deceptivly easy in linux.
find * -mtime +5 -exec rm {} \;That finds all files over 5 minutes old in the current directory. This is quite usefull in a backup script run from cron.
Tuesday, February 5, 2008
VMWare Server (Guests very slow)
If you are having trouble with guest machines being slow it could be because they don't have any shared memory setup. Make sure you have /dev/shm setup with tmpfs and at least half your physical memory mounted. Then add tmpDirectory="/dev/shm" to your /etc/vmware/config file and restart vmware. (Full directions at above link).