Commanding the CLI

Created by kylin.24th, Dec

Agenda

  • Invoking CLI commands
  • Checking WildFly version
  • Checking WildFly operational mode
  • Getting OS version
  • Getting JVM version
  • Checking JVM option
  • Checking JVM memories
  • Checking server status
  • Checking JNDI tree view
  • Invoking server stop|start|reload
  • Invoking server-group stop|start|restart|reload
  • Creating server-group
  • Creating server
  • Managing an application – deploy, undeploy

Invoking CLI commands

            
//
cp -a standalone std-commands

$ ./bin/standalone.sh -Djboss.server.base.dir=std-commands -bmanagement=192.168.1.106

$ ./bin/jboss-cli.sh -c --controller=192.168.1.106 --user=admin --password=password1!

:read-attribute(name=release-codename)

curl --digest --user admin http://192.168.1.106:9990/management/?operation=attribute\&name=release-codename
curl --digest --user admin:password1! http://192.168.1.106:9990/management/?operation=attribute\&name=release-codename
            
        

Checking the WildFly version

            
//
:read-attribute(name=release-version)

curl --digest --user admin http://192.168.1.106:9990/management/?operation=attribute\&name=release-version
curl --digest --user admin:password1! http://192.168.1.106:9990/management/?operation=attribute\&name=release-version
            
        

Checking WildlyFly operational mode

            
//
:read-attribute(name=launch-type)

curl --digest --user admin http://192.168.1.106:9990/management/?operation=attribute\&name=launch-type
curl --digest --user admin:password1! http://192.168.1.106:9990/management/?operation=attribute\&name=launch-type
            
        

Getting OS version

            
//
/core-service=platform-mbean/type=operating-system:read-resource(include-runtime=true,include-defaults=true)

curl --digest --user admin:password1! http://192.168.1.106:9990/management/core-service/platform-mbean/type/operating-system?operation=resource\&include-runtime=true\&include-defaults=true\&json.pretty=true
            
        

Getting JVM version

            
//
/core-service=platform-mbean/type=runtime:read-attribute(name=spec-version)

curl --digest --user admin:password1! http://192.168.1.106:9990/management/core-service/platform-mbean/type/runtime?operation=attribute\&name=spec-version
            
        

Checking JVM options

            
//
/core-service=platform-mbean/type=runtime:read-attribute(name=input-arguments,include-defaults=true)

curl --digest --user admin:password1! http://192.168.1.106:9990/management/core-service/platform-mbean/type/runtime?operation=attribute\&name=input-arguments\&include-defaults=true\&json.pretty=true
            
        

Checking JVM memories

            
//
/core-service=platform-mbean/type=memory:read-attribute(name=non-heap-memory-usage,include-defaults=true)

/core-service=platform-mbean/type=memory-pool/name=PS_Eden_Space:read-resource(include-runtime=true, include-defaults=true)
/core-service=platform-mbean/type=memory-pool/name=PS_Eden_Space:read-attribute(name=usage,include-defaults=true)

/core-service=platform-mbean/type=memory-pool/name=PS_Old_Gen:read-resource(include-runtime=true,include-defaults=true)
/core-service=platform-mbean/type=memory-pool/name=PS_Old_Gen:read-attribute(name=usage,include-defaults=true)

/core-service=platform-mbean/type=memory-pool/name=PS_Survivor_Space:read-resource(include-runtime=true,include-defaults=true)
/core-service=platform-mbean/type=memory-pool/name=PS_Survivor_Space:read-attribute(name=usage,include-defaults=true)

curl --digest --user admin:password1! http://192.168.1.106:9990/management/core-service/platform-mbean/type/memory?operation=attribute\&name=heap-memory-usage

            
        

Checking server status

            
//
:read-attribute(name=server-state)

curl --digest --user admin:password1! http://192.168.1.106:9990/management/?operation=attribute\&name=server-state
            
        

Checking JNDI tree view

            
//
/subsystem=naming:jndi-view

            
        

Invoking server using stop, start, and reload

            
//
:shutdown(restart=false)
:shutdown(restart=true)
:reload()

curl --digest --user admin:password1! http://192.168.1.106:9990/management/ -X POST -H "Content-Type: application/json" -d '{"operation":"reload"}'
            
        

Invoking server-group using stop, start, restart, and reload

            
//
/server-group=main-server-group:stop-servers()
/server-group=main-server-group:start-servers()
/server-group=main-server-group:restart-servers()

curl --digest --user admin:password1! http://192.168.1.106:9990/management/ -X POST -H "Content-Type: application/json" -d '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"server-group" : "next-server-group"}, "profile" : "ha", "socket-binding-group" : "ha-sockets"}]}'
            
        

Creating a server-group

            
//
/server-group=next-server-group:add(profile=ha,socket-binding-group=ha-sockets)

/server-group=next-server-group:remove()

curl --digest --user admin:password1! http://192.168.1.106:9990/management/ -X POST -H "Content-Type: application/json" -d '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"server-group" : "next-server-group"}, "profile" : "ha", "socket-binding-group" : "ha-sockets"}]}'
	    
        

Creating a server

            
//
/host=master/server-config=server-four:add(group=main-server-group, auto-start=true, socket-binding-port-offset=450

curl --digest --user admin:password1! http://192.168.1.106:9990/management/ -X POST -H "Content-Type: application/json" -d '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : [{"host" : "master"},{"server-config" : "server-four"}], "group" : "main-server-group", "auto-start" : "true", "socket-binding-port-offset" : "450"}]}'
            
        

Managing an application – deploy, undeploy

            
//
deploy example.war
deploy example.war --server-groups=main-server-group

undeploy example.war
undeploy example.war --all-relevant-server-groups

deployment-info example.war

curl  --digest --user admin:password1! http://192.168.1.106:9990/management -X POST -H "Content-Type: application/json" -d '{"content":[{"hash": {"BYTES_VALUE" : "eqfGfLVOCv+p1gz5gjDgwX79ERk="}}], "address": [{"deployment":"example.war"}], "server-groups":"main-server-group", "runtime-name":"example.war", "operation":"add", "enabled":"true"}'
curl --digest --user admin:password1! http://192.168.1.106:9990/management/ -X POST -H "Content-Type: application/json" -d '{"address" : [{"deployment":"example.war"}],"operation":"undeploy"}'
            
        

THE END