LinuxHelps.com

A blog for Linux Lovers.

Posted by sibu on March 13, 2015

GC overhead limit exceeded ….!!!

java.lang.OutOfMemoryError: GC overhead limit exceeded

All Java applications include a built-in Garbage Collection (GC). In many other programming languages, the developers need to manually allocate and free memory regions so that the freed memory can be reused. Java applications on the other hand only need to allocate memory. Whenever a particular space in memory is no longer used a separate process called Garbage Collection clears the memory for you.

The “java.lang.OutOfMemoryError: GC overhead limit exceeded” error means that GC has been trying to free the memory but is pretty much unable to get any job done. By default it happens when the JVM is spending more than 98% of the total time in GC. In addition, after GC less than 2% of the heap is recovered.

So – the “java.lang.OutOfMemoryError: GC overhead limit exceeded” error will be displayed when your application has exhausted pretty much all the available memory and GC has repeatedly failed to clean it.
Cause of java.lang.OutOfMemoryError

When failing with the “java.lang.OutOfMemoryError: GC overhead limit exceeded” error, the JVM is signalling that your application is spending too much time in garbage collection with little to show for it. By default the JVM is configured to throw this error if you are spending more than 98% of the total time in GC and after the GC less than 2% of the heap is recovered.

What would happen if this GC overhead limit was not present?  Note that the “GC overhead limit exceeded” error is thrown only when 2% of the memory was freed after several GC cycles.

This means that the little amount GC was able to clean will be quickly filled again thus forcing GC to restart the cleaning process again.This forms a vicious cycle where the CPU is 100% busy with GC and no actual work can be done. End users of the application are facing extreme slowdowns – operations which used to be completed in milliseconds are now likely to take minutes to finish.

Posted by sibu on October 7, 2014

How to check Windows Uptime

Go to command Prompt ( start –> Run –> cmd)
Execute:          net stats srv | find “Statistics”

Posted by sibu on October 1, 2014

Analyzing proftpd xferlog

The xferlog file contains logging information from the FTP server daemon, This file usually is found in /var/log but can be located anywhere by using a proftpd configuration directive.

The three characters following the file name represent the transfer-type (ascii or binary), any special actions (usually _ meaning none) and the direction (outgoing, incoming or deleted).

  1. ascii format:
    • a _ i (uploaded)
    • a _ o (downloaded)
    • a _ d (deleted)
  2. binary format:
    • b _ i (uploaded)
    • b _ o (downloaded)
    • b _ d (deleted)

    The last character in each row shows the completion status of the transfer. This should be “c” for complete and “i” for incomplete transfer.

Commands to extract the list of file got deleted

$ grep "_ d" /path/to/xferlog

Return all incomplete transfers:

$ egrep "i$" /path/to/xferlog

current-time : server Time

transfer-time : is the total time in seconds for the transfer.

remote-host : is the remote host name.

file-size : is the size of the transferred file in bytes.

filename : is the name of the transferred file. If the filename contains any spaces or control characters, each such character is replaced by an underscore (’_') character.

transfer-type : is a single character indicating the type of transfer.
a : for an ascii transfer,
b : for a binary

transferspecial-action-flag : is one or more single

character flags indicating any special action taken. Can be one or more of:

C :file was compressed
U :
file was uncompressed
T :
file was tar’ed
_ : no action was taken

direction : is the direction of the transfer. Can be one of:
o : outgoing
i : incoming
d : deleted

access-mode : is the method by which the user is logged in. Can be one of:
a :(anonymous) is for an anonymous guest user.
r : (real) is for a local authenticated user.

username : is the local username, or if guest, theID string given.

service-name : s the name of the service being invoked, usually FTP.

authentication-method :is the method of authentication used. Can be one of:
0 :none
1 :RFC931 Authentication

authenticated-user-id : is the user id returned by the authentication method. A * is used if an authenticated user id is not available.

completion-status :is a single character indicating the status of the transfer. Can be one of:

c : complete transfer
i : incomplete transfer

Posted by sibu on October 1, 2014

Diff between .java vs .class

.java file is Java source code, in a plain text that programmers edit.

java compiler converts your java code into byte-code (.class)

Example: javac filename.java

a new file filename.class is created by the Java compiler. This is a file containing Java bytecode, which is essentially a file that the Java interpreter can read. That’s what makes Java multi-platform. You can transport this .class file from Windows to Linux and run:

java filename

you will be getting the same result.

Posted by sibu on August 28, 2014

Disable TRACE and TRACK Methods in Apache

For security purposes you might want to disable Trace and Track methods on  Apache Web Server.

Add the following to httpd.conf file:

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

-OR-

With newer versions of Apache 1.3.34 or later or 2.0.55 or later, you can just add the following line

TraceEnable off

Posted by sibu on August 28, 2014

Values in the “TOP command.

PID — Process Id
The task’s unique process ID, which periodically wraps, though
never restarting at zero.

PPID — Parent Process Pid
The process ID of a task’s parent.

RUSER — Real User Name
The real user name of the task’s owner.

UID — User Id
The effective user ID of the task’s owner.

USER — User Name
The effective user name of the task’s owner.

GROUP — Group Name
The effective group name of the task’s owner.

TTY — Controlling Tty
The name of the controlling terminal. This is usually the
device (serial port, pty, etc.) from which the process was
started, and which it uses for input or output. However, a
task need not be associated with a terminal, in which case
you’ll see ‘?’ displayed.

PR — Priority
The priority of the task.

NI — Nice value
The nice value of the task. A negative nice value means higher
priority, whereas a positive nice value means lower priority.
Zero in this field simply means priority will not be adjusted
in determining a task’s dispatchability.

P
— Last used CPU (SMP)
A number representing the last used processor. In a true SMP
environment this will likely change frequently since the kernel
intentionally uses weak affinity. Also, the very act of
running top may break this weak affinity and cause more
processes to change CPUs more often (because of the extra
demand for cpu time).

%CPU — CPU usage
The task’s share of the elapsed CPU time since the last screen
update, expressed as a percentage of total CPU time. In a true
SMP environment, if ‘Irix mode’ is Off, top will operate in
‘Solaris mode’ where a task’s cpu usage will be divided by the
total number of CPUs. You toggle ‘Irix/Solaris’ modes with the
‘I’ interactive command.

TIME — CPU Time
Total CPU time the task has used since it started. When
‘Cumulative mode’ is On, each process is listed with the cpu
time that it and its dead children has used. You toggle
‘Cumulative mode’ with ‘S’, which is a command-line option and
an interactive command. See the ‘S’ interactive command for
additional information regarding this mode.

TIME+ — CPU Time, hundredths
The same as ‘TIME’, but reflecting more granularity through
hundredths of a second.

%MEM — Memory usage (RES)
A task’s currently used share of available physical memory.

VIRT — Virtual Image (kb)
The total amount of virtual memory used by the task. It
includes all code, data and shared libraries plus pages that
have been swapped out and pages that have been mapped but not
used.

SWAP — Swapped size (kb)
Memory that is not resident but is present in a task. This is
memory that has been swapped out but could include additional
non-resident memory. This column is calculated by subtracting
physical memory from virtual memory.

RES
— Resident size (kb)
The non-swapped physical memory a task has used.

CODE — Code size (kb)
The amount of virtual memory devoted to executable code, also
known as the ‘text resident set’ size or TRS.

DATA — Data+Stack size (kb)
The amount of virtual memory devoted to other than executable
code, also known as the ‘data resident set’ size or DRS.

SHR — Shared Mem size (kb)
The amount of shared memory used by a task. It simply reflects
memory that could be potentially shared with other processes.

nFLT — Page Fault count
The number of major page faults that have occurred for a task.
A page fault occurs when a process attempts to read from or
write to a virtual page that is not currently present in its
address space. A major page fault is when backing storage
access (such as a disk) is involved in making that page
available.

nDRT — Dirty Pages count
The number of pages that have been modified since they were
last written to disk. Dirty pages must be written to disk
before the corresponding physical memory location can be used
for some other virtual page.

S — Process Status
The status of the task which can be one of:
‘D’ = uninterruptible sleep
‘R’ = running
‘S’ = sleeping
‘T’ = traced or stopped
‘Z’ = zombie

Posted by sibu on February 8, 2012

Verify the Certificates using openssl command

If you need to check the information within a Certificate, CSR or Private Key you can use following cmmans

  • Check a Certificate Signing Request (CSR)

openssl req -text -noout -verify -in CSR.csr

  • Check a private key

openssl rsa -in privateKey.key -check

  • Check a certificate

openssl x509 -in certificate.crt -text -noout

  • Check a PKCS#12 file (.pfx or .p12)

openssl pkcs12 -info -in keyStore.p12

Debugging Using OpenSSL

If you are receiving an error that the private doesn’t match the certificate or that a certificate that you installed to a site is not trusted, try one of these commands..

  • Check an MD5 hash of the public key to ensure that it matches with what is in a CSR or private key

openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in privateKey.key | openssl md5
openssl req -noout -modulus -in CSR.csr | openssl md5

  • All the certificates (including Intermediates) should be displayed

openssl s_client -connect www.paypal.com:443

Posted by sibu on February 6, 2012

How To Determine If The Solaris Kernel Is 32- Or 64-bit

OS details:

root@ server:/root$ uname -a

SunOS server 5.10 Generic_137111-02 sun4v sparc SUNW,T5140

isainfo command will give you whether the solaris kernel is 32 bit or 64 bit

$ isainfo -b

64

$

The -b option prints the number of bits in the address space of the native instruction set. In this case, 64 bits.

$ isainfo -kv

64-bit sparcv9 kernel modules

$

The -k option prints the name of the instruction set used by the operating system kernel components, i.e. sparcv9; -v provides more detailed information, i.e. 64-bit sparcv9

Posted by sibu on December 28, 2011

SED and AWK command

sed (stream editor)

Sed is a non-interactive editor. Instead of altering a file by moving the cursor on the screen, you use a script of editing instructions to sed, plus the name of the file to edit. You can also describe sed as a filter.
Let’s have a look at some examples:
$sed ’s/to_be_replaced/replaced/g’ /tmp/dummy

Sed replaces the string ‘to_be_replaced’ with the string ‘replaced’ and reads from the /tmp/dummy file. The result will be sent to stdout (normally the console) but you can also add ‘> capture’ to the end of the line above so that sed sends the output to the file ‘capture’.
$sed 12, 18d /tmp/dummy

Sed shows all lines except lines 12 to 18. The original file is not altered by this command.

awk (manipulation of datafiles, text retrieval and processing)

Many implementations of the AWK programming language exist. AWK scans for a pattern, and for every matching pattern a action will be performed.

I’ve created a dummy file containing the following lines:
“test123
test
tteesstt”

$awk ‘/test/ {print}’ /tmp/dummy

test123
test

The pattern AWK looks for is ‘test’ and the action it performs when it found a line in the file /tmp/dummy with the string ‘test’ is ‘print’.
$awk ‘/test/ {i=i+1} END {print i}’ /tmp/dummy

Another example

-bash-3.00# ls -al |grep boot
-rw——- 1 root root 170 Aug 7 17:14 boot.log
-rw——- 1 root root 0 May 9 2010 boot.log.1
-rw——- 1 root root 0 May 2 2010 boot.log.2

-bash-3.00# ls -al |grep boot |awk ‘{print $9 }’
boot.log
boot.log.1
boot.log.2
-bash-3.00#

Posted by sibu on April 16, 2011

How to delete all comments in the wordpress

To Delete All Comments Awaiting Moderation in WordPress:

(Make sure that you have tacken a db backup)

From phpmyadmin  select your WordPress database, click the sql tab, and enter the following query:

SELECT *FROM wp_comments WHERE comment_approved ="0"

That will select all the un-moderated comments. Then enter this query:

delete from wp_comments WHERE comment_approved ="0"

Run a check and repair on the WordPress database afterwards to be sure everything is working fine.