Archive for May, 2009

How to build and deploy JRDS

May 25th, 2009 9 comments

At my work, we currently use nagios and cacti for monitoring, the “standard” tools. However, why it’s difficult to replace nagios – for many reasons (it use standard flat configuration flies) – I’m looking for a way to replace Cacti. Indeed, it’s written in pure PHP, there is almost no CLI. So, when I add a new host, I need to use my browser, and my mouse, and I don’t like that. By chance, a friend of mine wrote his own tool, called JRDS, in pure Java. I’m actually in test phase, however, here are some pros:

  • It’s Java, no need for php, whatever.
  • JRDS use rrd4j, RRDTool Java implementation
  • Use flat files for configuration, so it’s very easy to manage

However, one of its wort cons i s the lack of documentation! So here some notes to build JRDS :

  1. Fetch and extract JRDS sources from the subversion repository
  2. Fetch and extract RRD4j sources from the subversion repository (note: a account seem to be required)
  3. Build RRD4j
    • # cd rrd4j/rrd4j
    • # ant
    • # cp rrd4j-<version>.jar $JRDS_HOME/trunk/lib
  4. Build JRDS
    • If you don’t have it, download ivy and copy its jar in ~/.ant/lib directory
    • # cd $JRDS_HOME/trunk
    • # ant resolve
    • Extrat c.tld from lib/standard.jar and copy the file in the lib/ directory ( # unzip lib/standard.jar META-INF/c.tld ; mv META-INF/c.tld lib/ ; rmdir META-INF
    • # cp
    • Edit, don’t forget to set jai.home at the end of file
    • # ant war
  5. Before deploy jrds.war, you need to create a properties file, and some directories. See the inital setup chapter of JRDS Userguide.
  6. Note: to deploy JRDS on Glassfish, the only way I found to create the property is to defined in the JVM options. I also have sometimes a deadlock, if that appears, you need to kill the Glassfish process and restart it.



<?xml version="1.0" encoding="UTF-8"?>
<host name="">
        <snmp community="secret" version="2"/>
        <probe type="TcpSnmp" />
        <probe type="IpSnmp" />
        <probe type="UdpSnmp" />
        <probe type="IcmpSnmp" />
        <probe type="MemLinux" />
        <probe type="CpuRawTimeLinux" />
        <probe type="UcdRawSystemCounter" />
        <probe type="PartitionSpace">
                <arg type="String" value="/" />
        <probe type="IfSnmp">
               <arg type="String" value="eth0" />
        <probe type="CpuLoadFloat" />
        <probe type="TcpStat" />

Categories: Java, Sysadmin Tags:

Create a JDBC Connection Pool using JMX/AMX

May 22nd, 2009 No comments

In my previous post, I demonstrate how to set a property for each http-service in a glassfish domain using groovy and jmx. Here the code to create a new JDBC Connection Pool, still using groovy and JMX/AMX APIs.

import as JmxFactory
import as JmxUrl
//def uri = 'service:jmx:rmi:///jndi/rmi://portal3:46302/jmxrmi'
def uri = 'service:jmx:rmi:///jndi/rmi://localhost:8686/jmxrmi'
def login = 'admin'
def password = 'adminadmin'
def jmxurl = new JmxUrl(uri)
def attributes = new Hashtable()
def buffer = [ login, password ]
attributes.put("jmx.remote.credentials", (String[]) buffer)
def server = JmxFactory.connect(jmxurl, attributes).mBeanServerConnection
def createJDBCConnectionPool = { name ->
    def objectname = new ObjectName("amx:j2eeType=X-DomainConfig,name=na")
    def options = new ArrayList()
    def properties = [
    options.add(properties as Map)
                options as Object[],
                ["java.lang.String","java.lang.String","java.util.Map"] as String[] )
    /* To add other properties, we need to invoke setProperty to new object */
    objectname = new ObjectName("amx:j2eeType=X-JDBCConnectionPoolConfig,name=" + name)
    server.invoke(objectname, "setPropertyValue", [ "user", "xwiki"] as Object[], [ "java.lang.String", "java.lang.String"] as String[])
    server.invoke(objectname, "setPropertyValue", [ "password", "xwiki"] as Object[], [ "java.lang.String", "java.lang.String"] as String[])
    server.invoke(objectname, "setPropertyValue", [ "databaseName", "xwiki"] as Object[], [ "java.lang.String", "java.lang.String"] as String[])
    server.invoke(objectname, "setPropertyValue", [ "serverName", "localhost"] as Object[], [ "java.lang.String", "java.lang.String"] as String[])
    server.invoke(objectname, "setPropertyValue", [ "port", "3306"] as Object[], [ "java.lang.String", "java.lang.String"] as String[])
    server.invoke(objectname, "setPropertyValue", [ "networkProtocol", "tcp"] as Object[], [ "java.lang.String", "java.lang.String"] as String[])

As you probably noticed, I can’t create properties directly using the invokation of createJDBCConnectionPool. Indeed, we can specifly only few properties (take a look at the complete list). However, once the object is created, we can use the setPropertValue to create any properties we want.

Categories: Java, Sysadmin Tags: ,

Soirée CloudCamp à Paris le 11 Juin

May 19th, 2009 2 comments

Comme tout le monde, vous entendez parler du cloud computing, mais vous ne savez pas forcément ce qui se cache derrière ce terme ? Vous connaissez déjà, mais vous voulez en savoir plus ? Bref, dans tous les cas, si ce sujet vous intéresse, je vous invite à participer à la soirée organiser par cloudcamp. Cette soirée aura lieu le 11 Juin, à partir de 18h30. Pour ma part, je dois y intervenir pour parler de la sécurité.

Je me permet de rappeler, pour mes fidèles lecteurs, que Solaris/OpenSolaris est très proche du concept de cloud computing notamment grâce aux containers (zones + resource shapping), et OpenStorage.

Categories: Security, Sysadmin Tags:

Configure glassfish via JMX and Groovy

May 19th, 2009 1 comment

At my new work, we have a lot of glassfish in production. For some of them, we even have almost 10 instances per DAS (Domain Admin Server). As a (good) system administrator, I’m a lazy man. After having to installed and created a glassfish with 10 instances, I was really tired to click, click, and click again through the web interface. Yes I know, it’s possible to edit the files directly, but I think it’s not very convenient. First, it’s easy to make mistakes, it’s not atomic, and finally you need to restart/reload the instance.

So, I was wondering if it’s possible to proceed some configuration using JMX/AMX (AppServer Management Extensions). I start to browse MBeans using JConsole, and check that’s really possible to modify the configuration, and the answer is yes. Ok, my first try is a simple one, I just want enable access.log, meaning set accessLoggingEnabled property to true for each http-service. Since I’m not really good to write Java, I wrote a groovy script. Here it comes :

import as JmxFactory
import as JmxUrl
def uri = 'service:jmx:rmi:///jndi/rmi://localhost:8686/jmxrmi'
def login = 'admin'
def password = 'adminadmin'
def jmxurl = new JmxUrl(uri)
def attributes = new Hashtable()
def buffer = [ login, password ]
attributes.put("jmx.remote.credentials", (String[]) buffer)
def server = JmxFactory.connect(jmxurl, attributes).MBeanServerConnection
def enableAccessLog = { serviceUri ->
    properties = [ "accessLoggingEnabled", "true" ]
    def signature = [ "java.lang.String", "java.lang.String"]
    server.invoke(serviceUri, "setPropertyValue", properties as Object[], signature as String[] );
def checkAccessLog = { serviceUri ->
    def properties = [ "accessLoggingEnabled" ]
    def answer = server.invoke(serviceUri, "getPropertyValue", properties as Object[], "java.lang.String");
    println "Access log for: " + serviceUri + " enabled: " + answer
def query = new ObjectName("amx:*,j2eeType=X-HTTPServiceConfig")
server.queryNames(query, null).each { service ->

That’s magic… Sure I’ll post some others script to manage more complex configuration, like create a connection pool, etc.

Categories: Java, Sysadmin Tags: , ,

Petit amusement du lundi

May 18th, 2009 8 comments

Vu sur un blog sur lequel je suis tombé par hasard :

ZFS ? Un outil de masturbation intellectuelle. Je préfère encore le btrfs des linux.

Enfin, il vaut mieux en rire qu’en pleurer, ah ces linuxiens ! Et dire que j’étais comme ça il y a une certaine (mais lointaine) époque.

Categories: Social Tags:

Utiliser une datasource pour XWiki

May 11th, 2009 No comments

Actuellement, la configuration de la base de données utilisée par XWiki est directement effectuée au travers du fichier hibernate.cfg.xml du répertoire WEB-INF de l’application. Néanmoins, comme ce week end je voulais tester un peu de monitoring au niveau du serveur d’application, je me suis penché sur la question de comment utiliser un pool de connexion JDBC définit au niveau du serveur d’application en lieu et place de celui créer directement par hibernate.

Dans glassfish :

  • Dans l’onglet Resources, Connections Pools créer une nouvelle ressource du type javax.sql.ConnectionPoolDataSource en sélectionnant le driver approprié
  • De la même manière, créer une JDBC Resources, par exemple jdbc/xwiki
  • Puis finalement dans le fichier hibernate.cfg.xml, utiliser la configuration suivante
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="connection.datasource">jdbc/xwiki</property>
    <mapping resource="xwiki.hbm.xml"/>
    <mapping resource="feeds.hbm.xml"/>

Categories: Java Tags: ,

Présentation OpenSolaris à Parinux le 12 Mai

May 5th, 2009 1 comment

Pour les personnes qui ne connaissent pas du tout, et qui sont intéressés, je donnerais une présentation sur OpenSolaris pour Parinux ce Mardi 12 à 19h30.

Étant donné que cette manifestation s’adresse plutôt à des utilisateurs finaux (plutôt qu’à des administrateurs systèmes), la présentation se contentera de présenter rapidement la distribution OpenSolaris ainsi que ses fonctionnalités phares. Et pour les développeurs PHP qui sont dans le coin ce jour là, je vous invite fortement à venir assister à la présentation, une surprise vous attend !

Categories: OpenSolaris, Social Tags:

IAM track at LSM

May 4th, 2009 No comments

As a member of the LSM staff, I organize a track about IAM. The schedule is almost closed, including:

  • Pat Patterson, from OpenSSO, the famous Access Manager (SSO) of Identity Federation tool from Sun (english)
  • Ludovic Poitou, from OpenDS, the future Sun’s Directory Server (english or french)
  • Clément Oudot, from LemonLDAP::NG, an opensource Web SSO (english or french
  • Tomas Gustavsson, from EJBCA, the most famous opensource PKI product (english)
  • Jonathan Clarke, from LSC, a tool to synchronize directory from JDBC or LDAP (english or french)
  • Myself, introducing about IAM, especially the provisionning (french)

This day is planned for July, the 10th, at Nantes. Check LSM website to register in a near future (registration are not opened yet). For OpenDS, LemonLDAP::NG and LSC talks, the language will be choosen according the audience.

Categories: IAM, PKI, Social, SSO, Sysadmin Tags: