lundi 24 septembre 2018

JMX Tutorial

Hello Everyone,

In this tutorial, I'm going to show you guys how to create JMX services for your java application.
JMX allows to manage and monitor software applications and also hardware (like printers) through objects called Managed Beans (MBeans for short).
JMX defines a three levels architecture as shown in this diagram :





Probe level defines the MBeans that are going to represent our manageable resources where we implement various services to instrument the target object
for our example, we are going call our Mbean, FirstMbean. FirstMbean is an interface that defines the services that are going to be exposed through the JMX protocol.


public interface FirstMBean {

    //Person's name
    public String getPersonName();



    //Person's age
    public int getPersonAge();


    //Person's adress
    public String getPersonAdress();
    public void setPersonAdress(String adress);

}


the implementation of this interface goes like this


public class First implements FirstMBean {

    private Person p;

    public First(){

        p = new Person();

    }  

    @Override
    public String getPersonName() {

        return p.getName();

    }


    @Override
    public int getPersonAge() {

        return p.getAge();

    }

    @Override
    public void setPersonAdress(String adress) {

        p.setAdress(adress);



    }


    @Override
    public String getPersonAdress() {

        return p.getAdress();

    }
}

note that the names of the class and interface are important in the JMX ecosystem. a ManagedBean interface should be named like "randomnameMBean " and the implementation goes like " random name".

here we expose four services three in read-only and one in writing mode. with these services, we can get the name, age, and address of a person, and also we can update the address of that person.



Agent level where the MBeanServer belongs. the MBeanServer act as an interface with the external applications on one side and the MBeans on the other side

we get an instance of the MBeanServer by using the factory ManagementFactory with the method getPlatformMBeanServer().

after that, we register the MBean in the MBeanServer using the method registerMBean of the MBeanServer.


 public static void main(String[] args) {

        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

        First bean = new First();

        try {

            mbs.registerMBean(bean, new ObjectName("com.std.mbean:type=MyMbean"));

        } catch (Exception e) {

           System.out.println("Error while registring MBean (MyTargetClass) in JMX Agent" + e);

        }
     

        // infinit loop to keep the application up and runing

        while (true) {

        }

    }

Remote Management Level contains all external application. that needs the instrumentation of the exposed resources.  for this tutorial, we use  JConsole for monitoring the Java Application.






with JConsole, we can update variables in order to trigger specific action in the instrumented application.


I hope you guys liked this tutorial,
like, comment and share and if you have any questions, any doubt, let me know in the comment section.



lundi 5 août 2013

Bootable linux flash drive


Hello, Everyone :)

In this tutorial post, we are going to show you how to create a bootable Linux flash drive, for your emergency system installations :)

In this tutorial, I have chosen SliTaz which is a light-weight distribution.
it requires approximately 100 MB of hard disk space.

Slitaz is a French standalone distribution built directly from the kernel due to its lightweight and it is not based on other distribution like Redhat, Fedora, Ubuntu, ...

For the sake of this tutorial, I have chosen the Oracle virtual box to do the installation.





I- prepare the flash disk

First things first, prepare the Flash disk.
Let start by creating a folder USB and then create a new primary partition in the flash drive :


root@RH # mkdir usb

root@RH # fdisk /dev/sdd

   n (new)

   p (primary)

   1 (n° of partition)

   1 (starting @)

   12 (ending @)

   w (writing the modifications )


Once done let's format the flash drive with ext3 and then mount the drive in the USB folder :

root@RH # mkfs -t ext3 /dev/sdd1

root@RH # mount /dev/sdd1 usb



II-install the grub

Grub is a piece of program that is called BootLoader. This program allows the user to boot one or multiple operating systems in the hard drive, for our example, Grub is going to allow us to boot the Slitaz distribution from the USB drive.
The master boot record (the MBR for short) located in the first sector of the drive, will call the BootLoader to launch the OS.

To install the Grub it's quite simple, you just need to use the command grub-install and it will do the trick like this :


root@RH # grub-install roor-directory=/root/exo/usb /dev/sdd



III-copy the files from the disk into the flash drive

After the grub installation is done, we proceed to copy the OS files to the USB drive.

root@RH# cp -rf disk/* usb/


Here I made some optional modifications, I moved the kernel file "vmlinuz-2.6.37-slitaz" and some additional modules files with the pattern "rootfs*"  into the parent directory.


root@RH# cd usb/boot/

root@RH# mv rootfs* ../

root@RH# mv vmlinuz-2.6.37-slitaz ../linux





IV-configure the grub.conf file

Now it's time to set the configuration file grub.conf.


root@RH# cd grub

root@RH# cp /boot/grub/grub.conf .

root@RH# ln -s grub.conf menu.lst

root@RH# vi grub.conf



   default=0

   timeout=300

   color blue/black

   title Linux_SliTaz

   root (hd3,0)

   kernel /linux rw root=/dev/null

   initrd /rootfs1.gz

   initrd /rootfs2.gz

   initrd /rootfs3.gz

   initrd /rootfs4.gz



   :wq



V- reboot the VM with the flash drive connected

root@RH# init 6

Before login the grub start and shows us the user interface to choose which system to load.




Once you get to the login prompt , you can use the user root with the password root to login.
And now you can enjoy configuring your brand new system linux system as you pleased :)

I hope this tutorial allowed you guys to create a bootable Linux flash drive with Slitaz.

Thank you for reading! :)

jeudi 6 décembre 2012

Oracle XE On Ubuntu

ORACLE XE 10g for Linux


Hello Everyone :)

In this tutorial, I'm going to show you guys how to install Oracle XE (Express Edition) 10g on a Linux system.

for this tutorial, we will use as a Linux system Ubuntu on it's latest version 12.0. you can guys download it from here.

Oracle Express Edition Database is lightweight Database made for the development environment. Oracle XE is a great tool for developing POC (proof of concept) kind of applications. it comes with some dummy data that can be used by developers and save for them a lot of time setting the Db Environment.

This tutorial will guide you through the installation and the configuration steps so you can have a set and ready to use environment.


I #  INSTALLATION

First, we need to download and install the following packages. 
                                 1 -> oracle-xe-universal_10.2.0.1-1.1_i386.deb  
                                 2 -> oracle-xe-client_10.2.0.1-1.2_i386.deb

use the command dpkg  to install the packages.

                                   dpkg -i "name_of_package" 
                                
once done we are going to install some additional tools
                           
                                    aptitude install libaio1 bc

those dependencies (libaio1, bc) are needed to be installed with Oracle xe10g
and then we install rlwrap tool to make our life easier with sqlplus client

                                    apt-get install rlwrap  //(it will help us with sqlplus )

II # CONFIGURATION

once the installation is done we configure the environment, we will configure some parameters and some Linux system variables


           1) excute this cmd  " /etc/init.d/oracle-xe configure " (as root) and follow the steps that gives you

              2) add the following lignes in a terminal and in your user file profile  " ~/.profile "   (or /etc/profile 
                  for everyone )

                           export ORACLE_SID=XE
                           export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
                           export PATH=$PATH:$ORACLE_HOME/bin
                           export ORACLE_BASE=/usr/lib/oracle/xe

              3) add the following ligne in this file -> "$ORACLE_HOME/sqlplus/admin/glogin.sql" 

                           DEFINE _EDITOR = "/usr/bin/gedit" (or an other text editor that you want ) 

              4)type in a terminal the following alias and  add it  to your list of aliases , here(~/.bashrc)

                           alias sqlplus='rlwrap sqlplus'



III # GET STARTED !

               1) open your browser and type this (http://localhost:8080/apex) 
                         Login : system
                         pass : you already configured it when you did the 1st step in configuration
             
               2) enable the user HR ( in administration  )

               3) to connect from sqlplus run this cmd in the terminal

                        $ sqlplus hr/hr@xe
           
               4) enjoy ! :)


               i hope that tutorial allowed you to install and configure Oracle on your UBUNTU ,


thank you for reading :)

samedi 19 novembre 2011

Flash-Quran (DOWNLOAD)

Download  a Flash Quran application  for windows 


http://dl.dropbox.com/u/69759267/Quran%20Flash.rar

OR

https://docs.google.com/uc?id=0B88xh3EJdkgbeGZoVlNCQ2pSNHlqcXEwUzl4Ti03QQ&export=download