Archive January 2014

disk analyzer : how to ignore mounts

under ubuntu the default disk analyser (baobab) don’t offer ignore directories option.
In the case of we would like analyse the root folder / and ignore mounts in /media for example the easy way is to :
– create new temporary folder,
– mount the root filesystem on it,
– analyse the temporary folder
– unmount and delete it

So, first proceed like following

> sudo mkdir tmpAnalysis
> sudo mount /dev/sda1 tmpAnalysis
> baobab tmpAnalysis

Analysis is ready to explore.
Then

> sudo umount tmpAnalysis
> sudo rm -rf tmpAnalysis

list html page elements not having id

Icefaces ajax render performances issues could be sequence of dom elements without id. The present post helps to list all elements not having id to be fixed.

Open your page in your browser.
In developer console create following function

function chkid(ch){
  if(ch.id==""){
    console.log(ch.tagName+' : '+ch.id + ' childof ==> ' + ch.up().id)
  }
  ch.childElements().each(
    function(fils){
      chkid(fils)
    }
  );
}

then call chkid with any dom element. To get all, call chkid with body element

$$('body')[0].childElements().each(function(ch){chkid(ch)});

Nota : Here we use prototypejs framework

ajax displaying jboss server state

We aim to have web page which displays continually three jboss7 servers states.
For this we need the shell script (status.sh) to be found here.

environment requirement

    servers in same machine :

  • apache server
  • three jboss7 servers: jboss1, jboss2, jboss3

get result of status.sh in our php file

Following php code displays one jboss server state

echo exec('/path/to/script/status.sh /path/to/jboss/home')

For our example we need three php files containing the previous one line php code corresponding to each one of the three jboss server : state-jboss1.php, state-jboss2.php, and state-jboss3.php

ajax state display

We need here the load() method of jquery javascript framework.

  
$('#jboss').load('state-jboss.php');

continuous update of servers state

We’ll resort to javascript timer

setInterval(function(){$('#jboss').load('state-jboss.php')},3000);

deloyment

    root folder :

  • create folder jboss-state in apache server root www
    files :

  • www/jboss-state/status.sh
  • www/jboss-state/index.html
  • www/jboss-state/state-jboss1.php
  • www/jboss-state/state-jboss2.php
  • www/jboss-state/state-jboss3.php

full code

status.sh (myArtifactName string in code must be replaced by the right artifact name)

#!/bin/bash

res=$($1/bin/jboss-cli.sh --commands="connect,read-attribute server-state" 2>&1)

if [[ $res != 'running' ]]
then
        echo "STOPPED ($res)"
else
        artifactDeployed=$($1/bin/jboss-cli.sh --commands="connect,deploy -l" | grep myArtifactName | grep OK  2>&1)
        if [[ X$artifactDeployed == 'X' ]]
        then
                echo "STARTING ($res / $artifactDeployed)"
        else
                echo "RUNNING ($res / $artifactDeployed)"
        fi
fi

state-jboss1.php


state-jboss2.php


state-jboss3.php


index.html


  
    Jboss1 state : 
Jboss2 state :
Jboss3 state :
setInterval(function(){$('#jboss1').load('state-jboss1.php')},3000); setInterval(function(){$('#jboss2').load('state-jboss2.php')},3000); setInterval(function(){$('#jboss3').load('state-jboss3.php')},3000);

get jboss7 server state with shell script

Shell script (status.sh) bellow returns three jboss server state :

  • STOPPED : jboss is stopped (script could not connect with jboss-cli)
  • STARTING : jboss is starting (its state is running but project is not deployed)
  • RUNNING : jboss is ready (its state is running and project is deployed successfully)

Use :


> ./status.sh /path/to/jbossHome

This script may be improved …
Also you need to replace in code myArtifactName fake value by your right value

#!/bin/bash

res=$($1/bin/jboss-cli.sh --commands="connect,read-attribute server-state" 2>&1)

if [[ $res != 'running' ]]
then
        echo "STOPPED ($res)"
else
        artifactDeployed=$($1/bin/jboss-cli.sh --commands="connect,deploy -l" | grep myArtifactName | grep OK  2>&1)
        if [[ X$artifactDeployed == 'X' ]]
        then
                echo "STARTING ($res / $artifactDeployed)"
        else
                echo "RUNNING ($res / $artifactDeployed)"
        fi
fi

hbm2java with ant step by step

– workspace structure:
    + hbm/
        + build.xml
        + hibernate.cfg.xml
        + reveng.xml
        + lib/

– build.xml




 
<!--  -->
 
 
 
 
 
 
 
 
 
 
 <!--  -->
 
 
 
 
 

 
 
 






 
  
 

 
 



– hibernate.cfg.xml




  
        true
        oracle.jdbc.driver.OracleDriver
        jdbc:oracle:thin:@127.0.0.1:1522:WITRDB
        witr
        witr
        org.hibernate.dialect.Oracle10gDialect
        false
 

– reveng.xml






        
                
                
                
                
                
                
                
        

        
        
        
        ...etc


then type

> cd hbm
> ant

your hibernate beans are ready in hbm/generated directory