jps and jstat for tomcat on jdk-1.6.0_24
Fri, 03/25/2011 - 16:53 — sandipRecently upgrading to java version "1.6.0_24", jps and jstat seemed to be broken to get monitoring information from running tomcat process.
By default java.io.tmpdir is /tmp, however tomcat usually uses it's own temp directory. That is where jps/jstat looks for hsperfdata_* dirs. If java.io.tmpdir is not set, it would look in /tmp. If jps can't find the hsperfdata directory, it won't report anything.
jps/jstat however allows to specify java.io.tmpdir in case you're using a JVM that places those directories in a different location.
So to get it to work:
$JAVA_HOME/bin/jps -J-Djava.io.tmpdir=/path/to/to mcat/temp -l
$JAVA_HOME/bin/jstat -J-Djava.io.tmpdir=/path/to/to mcat/temp -gc $PID
- sandip's blog
- Login or register to post comments
- Read more
Django HTTPS Redirects
Fri, 03/25/2011 - 15:04 — sandipThis works for both HTTP and HTTPS where any front end web server such as nginx which handles the actual request sets a header when request comes via HTTPS. In Apache configuration you then use mod_setenvif to set the HTTPS variable, which Django then picks up to use for redirection.
With front end nginx server which handles SSL, set header "X-Forwarded-Proto=https" via:
proxy_set_header X-Forwarded-Proto https;
On Apache, add directive:
SetEnvIf X-Forwarded-Proto https HTTPS=1
The HTTPS variable is picked up as being special by mod_wsgi and it will fix the wsgi.url_scheme in WSGI environment which Django then uses for redirection.
This way you don't need to customize Django stack.
- sandip's blog
- Login or register to post comments
- Read more
Check number of file descriptors opened by process
Fri, 03/25/2011 - 11:51 — sandipTo check on the file descriptors opened by process:
lsof -p {PID} | awk '$4 ~ /^[0-9]/ {print $4}' | wc -l
alternately:
ls -1 /proc/{PID}/fd | wc -l
To check all file descriptors opened by a user:
lsof -u {user} | awk '$4 ~ /^[0-9]/ {print $4}' | wc -l
By default the hard and soft limits for a single process are set to 1024 on linux systems. To check on the limits:
ulimit -Hn
ulimit -Sn
To increase edit the "/etc/security/limits.conf" file for corresponding user:
{user} soft nofile 4096
{user} hard nofile 4096
To check if the new limits has been applied type `ulimit -n` after you get a new shell.
Logfile '/var/log/kav/5.5/kav4mailservers/avstats.log' does not exist
Mon, 03/21/2011 - 14:05 — sandipTo resolve kluser cron error on missing log file:
Logfile '/var/log/kav/5.5/kav4mai lservers/avstats.log' does not exist
Modify kluser cron as below via `crontab -e -u kluser` appending "/bin/touch /var/log/kav/5.5/kav4mailserve
/bin/touch /var/log/kav/5.5/kav4mailserve rs/avstats.log; /opt/kav/5.5/kav4mailservers/b in/parse_avstat.pl -d -sd=/opt/kav/5.5/kav4mailserve rs/proc_avstat /var/log/kav/5.5/kav4mailserve rs/avstats.log
- sandip's blog
- Login or register to post comments
- Read more
Plesk and SPF records
Fri, 03/18/2011 - 10:56 — sandipThe Plesk DNS zone template for TXT record does not include the servers hostname by default. If the host IP is different from the domains being hosted, may want to update the default template as below:
<domain>. TXT v=spf1 +a +mx a:host.domain.tld -all
- sandip's blog
- Login or register to post comments
- Read more
Backup and restore lvm data with dd
Sun, 03/13/2011 - 01:18 — sandipRecently I've had to backup/restore data from a failing drive with LVM over Raid.
Luckily I had access to the backup of the current metadata configuration located in "/etc/lvm/backup/".
Below is what the volumegroup looked like:
vg0 {
&nbs p; id = "xvni1W-24Xu-dVoR-PlXh-gQ vQ-62fL-QX64O3"
&nbs p; seqno = 9
&nbs p; status = ["RESIZEABLE", "READ", "WRITE"]
&nbs p; flags = []
&nbs p; extent_size = 65536 & nbsp; & nbsp; # 32 Megabytes
&nbs p; max_lv = 0
&nbs p; max_pv = 0
&nbs p; physical_volumes {
&nbs p; &nbs p; &nbs p; pv0 {
&nbs p; &nbs p; &nbs p; &nbs p; id = "9gbyhX-Owvj-u4Q4-wR1E-IE f2-gyUA-CJBCJK"
&nbs p; &nbs p; &nbs p; &nbs p; device = "/dev/md3" &nbs p; # Hint only
&nbs p; &nbs p; &nbs p; &nbs p; status = ["ALLOCATABLE"]
&nbs p; &nbs p; &nbs p; &nbs p; flags = []
&nbs p; &nbs p; &nbs p; &nbs p; dev_size = 1928892288 # 919.768 Gigabytes
&nbs p; &nbs p; &nbs p; &nbs p; pe_start = 384
&nbs p; &nbs p; &nbs p; &nbs p; pe_count = 29432 & nbsp; # 919.75 Gigabytes
&nbs p; &nbs p; &nbs p; }
&nbs p; }
&nbs p; logical_volumes {
&nbs p; &nbs p; &nbs p; lv0_sites {
&nbs p; &nbs p; &nbs p; &nbs p; id = "Sg1fYr-NTzr-8AA2-v29K-tc z5-rUMj-uRoXY1"
&nbs p; &nbs p; &nbs p; &nbs p; status = ["READ", "WRITE", "VISIBLE"]
&nbs p; &nbs p; &nbs p; &nbs p; flags = []
&nbs p; &nbs p; &nbs p; &nbs p; segment_count = 1
&nbs p; &nbs p; &nbs p; &nbs p; segment1 {
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; start_extent = 0
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; extent_count = 1280 # 40 Gigabytes
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; type = "striped"
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; stripe_count = 1   ; # linear
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; stripes = [
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; "pv0", 0
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; ]
&nbs p; &nbs p; &nbs p; &nbs p; }
&nbs p; &nbs p; &nbs p; }
&nbs p; &nbs p; &nbs p; lv0_m {
&nbs p; &nbs p; &nbs p; &nbs p; id = "scNeN4-4bmg-Y6kq-zKuO-n8 B8-s8mw-FTUYqk"
&nbs p; &nbs p; &nbs p; &nbs p; status = ["READ", "WRITE", "VISIBLE"]
&nbs p; &nbs p; &nbs p; &nbs p; flags = []
&nbs p; &nbs p; &nbs p; &nbs p; segment_count = 1
&nbs p; &nbs p; &nbs p; &nbs p; segment1 {
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; start_extent = 0
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; extent_count = 12800 # 400 Gigabytes
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; type = "striped"
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; stripe_count = 1   ; # linear
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; stripes = [
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; "pv0", 1280
&nbs p; &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; ]
&nbs p; &nbs p; &nbs p; &nbs p; }
&nbs p; &nbs p; &nbs p; }
&nbs p; }
}
Now to extract data with dd, use the below formula (this will only work for linear stripe):
skip=$[extent_size*stripes+pe_ start] count=$[extent_size*(extent_co unt-1)]
So to get the lv0_m data off of the volume:
dd if=/dev/sdb4 of=/opt/bak/lv0_m.iso bs=512 skip=$[65536*1280+384] count=$[65536*(12800-1)] conv=sync,noerror
Once the iso is created, it can then be loop mounted via:
mount -o loop -t ext3 /opt/bak/lv0_m.iso /mnt/lv0_m
You should then be able to see all the files in the mount point which can then be used for data restoration.
Tracking slow running mysql queries
Fri, 03/04/2011 - 18:13 — sandipFirst enable logging of slow running queries in "mysqld" section of "my.cnf".
[mysqld]
log_slow_queries=/var/log/my sqld.slow.log
long_query_time=2
Once queries get logged, you can get the top 10 queries sorted by number of occurrences in the log via:
mysqldumpslow -s c -t 10 /var/log/mysqld.slow.log
- sandip's blog
- Login or register to post comments
- Read more
Dry run update with svn and cvs
Fri, 03/04/2011 - 17:04 — sandipTo test what files would get changed or conflict when running an update:
With svn:
svn merge --dry-run -r BASE:HEAD .
With cvs:
cvs -nq update -d
- sandip's blog
- Login or register to post comments
- Read more
Remote backups with tar over ssh
Mon, 02/28/2011 - 15:26 — sandipBelow is example of backing up users' home directory to remote host piped via ssh:
tar -cvzf - -C /home {username} | ssh {remotehost} 'cat >/path/to/bak/{username}.tg z'
- sandip's blog
- Login or register to post comments
- Read more
check webpage load time via wget
Tue, 02/22/2011 - 17:19 — sandipHere is a simple one liner to check on download time of a webpage:
(time wget -p --no-cache --delete-after www.linuxweblog.com -q ) 2>&1 | awk '/real/ {print $2}'
- sandip's blog
- Login or register to post comments
- Read more