Google+ Followers

Monday, 14 April 2014

How to Run Java code in new terminal Through Java Code in Linux

Hi,
     Here I have written the snippet for running the java process in new terminal through java code
just put your java code name and run simply.

import java.io.*;
class CodeRunInTerminal
{
    public static void main(String args[]) throws IOException
    {
        String command= "/usr/bin/xterm -e java codename";//where the java is command and codename is java code which you want to run in new terminal.
        Runtime rt = Runtime.getRuntime();
        Process pr = rt.exec(command);
    }
}

Thanks.

Thursday, 10 April 2014

How to Kill Java Process in Linux Operating System using Java Code

Java Code for killing the Java process in Linux OS.

Hi,
    Here I have written the small snippet for killing the java running  process in linux OS.

public void checkprocess()
{
    String s = null;
    int x=0;
    try
    {
        Process p = Runtime.getRuntime().exec("jps"); //JPS command is used for showing all the java running process with ID.
        BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
        BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
        while ((s = stdInput.readLine()) != null)
        {
            String[] tokens = s.split(" ");
            if(tokens.length!=2)
            {
                throw new IllegalArgumentException();
            }
            String commandid = tokens[0];
            String prcess = tokens[1];
            System.out.println("Processes  Name is : "+prcesss);
            if(prcs.equals("Process Name which you want to kill"))
            {
                Process p1 = Runtime.getRuntime().exec("kill "+commandid+"");
                x++;
            }
            if(x>1)
            {
                System.out.println("Processes  Name is : "+prcess);
                System.out.println("Processes  ID is : "+commandid);
                System.exit(0);
            }
        }
    }
    catch (IOException e)
    {
    System.out.println("exception : "+e);
    }
}

Friday, 7 March 2014

How to Execute Query & Stored Procedure in Linux Using Shell Scripting.



How to Execute Query & Stored Procedure in Linux Using Shell Scripting.

You can simply use below mention script for executing the query or procedure.
#!/bin/sh
mysql -u root –ppassword -e 'call test_procedure();' Databasename

Where -p is used password in which you can mention the password of your mysql.
Where -e is used for executing the  query or stored procedure.
Where databasename is used for your mysql database name.

#!/bin/sh
mysql -u root –ppassword -e ‘select * from tbl_test;’ Databasename

 This single line can be used for  executing stored procedure as well as sql query.

You can save this script into any extension of file but you need to give the permission first
for executing the script file
for example:
#chmod +x filename

Tuesday, 4 March 2014

Limitations of MySQL Database


Limitations of MySQL Database

Many of the Mysql user does not know the limitations of Mysql database. So here I am writing
some of the Mysql limitations are as follows.
In mysql database the maximum size of the table is determined by operating system in which the Mysql is installed. So the maximum size of table is allowed by the operating system.
Below mentioned table showing the file size limit of operating systems :

Operating System
File Size Limit
Windows (FAT32)
4GB
Windows (NTFS)
2TB
MacOS
2TB
Linux
4TB
Solaris 9/10
16TB


Limitations of Joins :

The maximum number of tables that can be referenced in a single join is 61. This also applies to the number of tables that can be referenced in the definition of a view. It can also applies to LEFT and RIGHT OUTER JOINS.

Limitations of the MyISAM storage engine :


Large files up to 63-bit file length are supported. There is a limitation of 264 (1.8 * 1019) rows in a MyISAM table. The maximum number of indexes per MyISAM table is 64. You can also configure the build by invoking configure with the  -with-max-indexes=N option, where N is the maximum number of indexes to permit per MyISAM table. N must be less than or equal to 128.
The maximum number of columns per index is 16. The maximum key length is 1000 bytes. It can be changed by changing the source and recompiling.

Limitations of the InnoDB Storage Engine :


A table cannot contain more than 1000 columns. The internal maximum key length is 3500 bytes, but MySQL itself restricts this to 1024 bytes.
The maximum row length, except for VARCHAR, BLOB and TEXT columns, is slightly less than half of a database page. That is, the maximum row length is about 8000 bytes. LONGBLOB and LONGTEXT columns must be less than 4GB, and the total row length, including also BLOB and TEXT columns, must be less than 4GB.
Although InnoDB supports row sizes larger than 65535 internally, you cannot define a row containing VARCHAR columns with a combined size larger than 65535.
The maximum tablespace size is 4 Mia database pages (64TB). This is also the maximum size for a table.

 Limitations of Partitions :

The limitation of partitions with MySQL is 1024 (internal mail). But one have to increase open_files_limit.

Limitations of MySQL Cluster :

 Max attributes/columns in an index: 32
Max number of attributes (columns and indexes) in a table: 128
Max number of table: 1792 (v5.0).
Max size in bytes of a row is 8052 byte, excluding blobs which are stored separately.
Max number of nodes in a cluster: 63, max. number of data nodes: 48 (in v5.0/5.1)
Max number of nodes in a cluster: 255 in CGE.
Max number of metadata objects: 20320.
Max attribute name length: 31 characters.
Max database + table name length: 122 characters.







Tuesday, 25 February 2014

How to configure the VNC server in Linux and Centos



How to configure the VNC server in Linux and Centos?

We can configure the VNC server and can be automatically started when the system boots or restart.
Before this service we will have to work with some commands and script needs to be done.
Firstly, need to edit the  /etc/sysconfig/vncservers file to include the users in this file you want to run VNC servers . Append a line to that file as follows:

Step 1 :-
 VNCSERVERS="N:user"

Where N is the number of users want to use the VNC server  sessions to run on where the user is the username you want the server to run as. Here below are the example for the same

VNCSERVERS="N:user1 Y:user2"
Example :- VNCSERVERS="1:root 2:root"

Step 2 :-
$ vncpasswd
   Password:
   Verify:
If you want to have the full Linux environment, create  ~username/.vnc/xstartup and include the following lines:
Step 3 :-
#!/bin/bash
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

Lastly, ensure that the resulting file has the execute bit set:
Step 4 :-
# chmod 755 ~username/.vnc/xstartup

In order to start the vncserver service immediately, run the following command:

Step 5 :-
# service vncserver start
In order for the vncserver service to start during the boot sequence, run the following
command:
Step 6 :-
# chkconfig vncserver on
# chkconfig --list vncserver
vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Tuesday, 11 February 2014

Monitoring of Linux Server & Asterisk Server.



MONITORING OF  LINUX SYSTEM

[1] top : top is a command that neatly list all processes with valuable
info sort by CPU and memory usage.
'top' provides lots of information on the processes running, including the
percentage of the cpu and the memory being consumed by that process, who
'owns' the process and it's pid (Process ID), it also shows the output of
'uptime' and a summary of memory usage, similar to 'free'. The output of
'top' is full screen, and refreshes itself frequently (or at user definable
intervals).
#top



[2] To see last shut down time Of RHEL System:

#last -x|grep shutdown | head -1

[3] To see last reboot history of RHEL System.
#last reboot


[4] W command is use to see the Login Linux user time.
It shows the uptime of the linux system
#w
#w root



[5] netstat -tulpn command to display listening sockets/ports
and associated program.
#netstat -tulpn



[6] control the service :
The ntsysv command is a simple interface for configuring
runlevel services which are also configurable through chkconfig
command. It allows to control which services are
started when the system boots up:
#ntsysv


The rcconf command under Debian / Ubuntu Linux allows you to
control which services are started when the system boots up or
reboots.
#rcconf

[7] uname command :
uname -r: Print the kernel release
#uname -r
uname -v: Showing kernel version:
#uname -v
uname -o : print the operating system
#uname -o
uname -a : print all information
#uname -a
[8] To see list of enable port:
#nmap ‘IP address’
[9] who Command to see who is on the system.
#who

[10] df command to view disk usage and we'll be shown disk usage for
all mounted filesystems in 1K blocks.
#df
Check available space on the hard drive in human readable format.
#df –h

[11] du command:
Now that To know how much space has been used on a filesystem
how can you find out where that data is?
To view usage by a directory or file we can use du. Unless we specify
a filename du will act recursively
Check disk usage for a specific folder:
#du -sh
#du file.txt
130 file.txt
In human readable format.
#du h file.txt
1.2M file.txt

[12] free command shows information about the machine's memory.
This includes physical memory (RAM), swap as well as the shared memory
and buffers used by the kernal. All measurements are in Kb.
#free
To see Total RAM with Free avliable.
#free –k
Display shows how much memory is being used in kilobytes,
because we specified the -k option.
#free –m

[13] ps command to see current working process.
#ps

[14] The 'kill' command is complementary to the 'ps' command as it
will allow you to terminate a process revealed with the previous command.
In cases where a process is not responding, you would use the following
syntax to effectively kill it:
‘Kill-9 pid’
where 'pid' is the Process ID (PID) that 'ps' displays for each task.


[15] ls commands:
To see list of all files with hidden files.
#ls -al
To see the largest files on filsystem.
#ls -lS
[16] Finds all files over 20,000KB (roughly 20MB) in size and presents
their names and size in a human readable format:
#find . -size +20000k -exec du -h {} \;

[17] To search the file.
#locate ‘file name ‘

[18] Shutdown the system.
# shutdown r now.
[19] Reboot the system.
#reboot

MONITORING OF ASTERISK SERVER

Start GUI for asterisk:
Run the following command on terminal to the asterisk
server with a console.
# asterisk –r
or
#asterisk -vvvvr
For ubuntu:
#asterisk –vvvvvcc

Note: Asterisk 1.4.0 CLI commands:

[1]:- Core related commands:
core show channels - Display information on channels.


core show channel - Display information on a specific channel.
core show channeltypes - List available channel types.


core show channeltype - Give more details on that channel type.
core show uptime - Show uptime information of asterisk server.



core show license - Show the license(s) for this copy of Asterisk.



core show file formats - Displays file formats.


core show codecs - Displays a list of codecs.


core show codec - Shows a specific codec.
[2]:- PRI command:
pri show spans - Displays PRI Information.
[3]:- restart gracefully - Restart Asterisk gracefully
[4] :- restart now - Restart Asterisk immediately.
[5]:- stop gracefully - Gracefully shut down Asterisk.
[6]:- stop now - Shut down Asterisk immediately.
[7]:- help - Display help list, or specific help on a command.
[8]:- Manager commands:
manager show commands - List manager interface commands.


manager show users - List configured manager users.


manager show user - Display information on a specific manager user.
[9]:- moh reload - Music on Hold.
[10]:- moh show classes - List MOH classes.
[11]: exit - Closes the asterisk CLI console (command-line interface).
[12]: dialplan show - Show dialplan.
[13]: dialplan reload – This command is used when we want to change in
extension.conf so we need to reload extensions.
[14]: manager reload - This command is used when we want to change in
manager.conf so we need to reload.
[15]: sip reload - This command is used when we want to change in sip.conf
so we need to reload.
[16]: dialplan remove extension - Remove a specified extension.

Thanks,