Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Admin Automation with wlshell

A CHANGE FROM TRADITIONAL SCRIPTING LANGUAGES

Wlshell is a tool designed specifically for WebLogic administrators. It combines the flexibility of a scripting language with the full control provided by the JMX interface. It is, therefore, a natural environment for the systems administrator. The units of work of the JMX specification - the Management Beans, or MBeans - are presented in wlshell in the familiar form of the file system and they look like files organized into directories and drive units. This user-friendly environment makes it easy to write scripts to automate daily administrative WebLogic tasks.

Administrative Tasks
Since the beginning of computing, automation has been one of the driving forces of innovation. A couple of examples are the adding machine developed by Blaise Pascal and the punch-card tabulator for the U.S. Census built by Herman Hollerith.

Today, and in a more modest scenario, BEA WebLogic administrators have to face repetitive tasks similar to those just described in the sense that they are candidates for automation. These administrative tasks can be classified in two categories: configuration and monitoring.

A typical configuration task is the deployment of a new application on production servers. In order to deploy the application, it might be necessary to create, configure, and target services this application could rely on, like JDBC connection pools, data sources, JMS messaging servers, and JMS message queues, to name some resources. If the production system contains several WebLogic servers and domains, then the process could be repeated several times, maybe with some differences in parameters like server name and address. Automating this task will produce clear benefits over performing the same task manually using the administration console: the WebLogic administrator will be more productive by doing more in less time, and the possibility of making configuration mistakes will be minimized. In some organizations there are specific and strict regulations about how to roll out applications. In these cases, to automate is more than a nice-to-have practice, it is enforced by law. This is, for example, the case of some companies in the financial and pharmaceutical sectors. In these cases, every application deployment must be performed through an automated process that's documented, repeatable, and auditable.

Another task frequently performed daily by an administrator is supervising the status of servers and services. An administrator might be interested in monitoring the servers in a domain to see if they are active and to check the utilization level. In the case of services, some interesting metrics are the current database connections and the status of the JMS servers.

Administration Using Scripts
Traditionally, scripting languages are the tool of choice to automate administrative tasks, like the UNIX shell. Some of the more radical system administrators say "real administrators don't click." This is a strong statement but it might be telling us that graphical-based tools have some limitations when it comes to task automation. Graphical tools might also lack the level of granularity a professional administrator demands for advanced custom control.

The JMX specification (Java Management eXtensions), on the other hand, provides the right level of detail and control over the systems, but it provides a programmatic interface, a Java API. Experience also tells us "real administrators don't compile code," paraphrasing the previous statement. In reality this means that the power and level of detail of JMX is not directly available to administrators, who aren't necessarily developers. The programming interface lacks the flexibility, dynamism, and conciseness of an interpreted environment like that provided by scripting languages. Is there any way to reconcile both terms? Yes, there are several alternatives. In the remainder of the article, I'll analyze one of them, wlshell, and I'll look at some examples of how to automate some typical administrative tasks.

Creating Services
In the first example I'll create, configure, and start three WebLogic servers. I'll also create three JMS messaging servers, with three message queues each, and deploy the JMS servers on the WebLogic servers.

The first three lines of Listing 1 define the variables that allow the shortening of commands in the rest of the script. The first for loop creates three WebLogic servers, using a combination of the name and the index to produce servers with the names "s1", "s2" and "s3". The listen port is also configured based on the index variable, creating the integer values "7101", "7201", and "7301". wlshell supports two syntaxes for variables, $var and ${var}. The first one is more succinct and is good for interactive typing. The second notation should be used to clearly mark the end of the variable name and avoid any possible mistakes. The last line in the loop starts the server, which assumes the Node Manager is already up and running.

The next loop creates three JMS servers and three message queues for each JMS server using a nested for loop. The "addTarget" MBean operation is used at the end of the loop to target the server to the corresponding WebLogic server.

Finally, the configuration is explicitly persisted on the config.xml file, the default configuration repository. This script can be saved on a file to be executed later in batch mode with wlshell with the "read" command or as a start parameter with the "-f" flag, as shown here.

wlsh -f listing1.wlsh

read listing1.wlsh

Every BEA WebLogic administrator will probably understand immediately the benefits of using a script like this, especially compared to making configuration changes manually with the Web-based console or writing a Java program that uses JMX. The script presented above is relatively easy to read and understand at a first glance, prevents unintended errors, and saves time that can be used to work on more creative tasks.

Offline Configuration
Another new feature of wlshell version 2 is its ability to configure a WebLogic domain when the administration server is not running. This new characteristic creates new and exciting possibilities. We can now configure a domain in offline mode, very much like in the online case, just by using the "connect" command with the name of the "config.xml" file. In this case, the protocol for the connection has the keyword "file" to indicate that it is an offline type connection. We also need to check that the server is not running, so there is only one process making changes to the file.

In offline mode configuration, wlshell reads the config.xml file and presents a directory and file structure very similar to the online mode. All the commands available in the online connection are also available offline, so it is possible to navigate, create, set up, and remove servers, services, and applications. Listing 2 is an example of server configuration to increase the output information displayed on the console.

Once the config.xml file is modified, the administration server can be started with the new configuration. Changes made through wlshell on the config.xml are consistent with the document structure; therefore, the file is always valid. Offline mode is also useful for prepackaging a domain configuration without an administration server, and then distributing the configured package to another environment (testing, production, etc.).

Security Configuration
An important part of systems administration is security, specifically the management of users and groups. BEA WebLogic Security is completely managed through JMX MBeans, and as a result, totally available through wlshell, where administrators can write security management scripts. Within the default settings, the security MBeans are registered under the "Security" domain, without specifying any particular type. wlshell is capable of handling these MBeans with no type and gathers them under a directory named "typeless". Figure 1 shows the wlshell Explorer displaying the Security MBeans. It displays the attributes and operations of the "myrealmDefaultAuthenticator" Security MBean on the right pane. The authenticator MBean is responsible for user authentication and provides operations to manage users and groups. Using these methods, administrators can write scripts to create users in batch mode, assign users to groups, and change the user password. The following code snippet shows how to use the "createUser"operation to create a new user.

 

Security:
cd /typeless/myrealmDefaultAuthenticator
invoke createUser pgomez password "WebLogic Account for Paco Gomez"

Monitoring
WebLogic Runtime MBeans provide a detailed view of the different subsystems of the application server. wlshell makes them easier to access. The "get -r <interval> attribute(s)" command iteratively displays the value of one or more MBean attributes. Sometimes it could be necessary to display information based on the value of a particular MBean attribute or a particular condition. In those cases it might be necessary to write a small script to customize the output. Listing 3 illustrates this point. The script is flexible enough to print the state of the servers configured in the domain without knowing in advance the name or number of them.

The script generates the following output for a particular domain configuration:

Mon Nov 10 21:59:47 GMT-06:00 2003
s1 7101 RUNNING 5899744
s2 7201 not running n/a
s3 7301 RUNNING 5682584

Summary
Some automation examples have been presented in this article. They illustrate how to write wlshell scripts to automate administrative tasks for configuration and monitoring. This approach provides clear advantages over other methods, improving productivity and legibility, and reducing the chances of committing configuration mistakes. You can find more administrative scripts at the wlshell home page.

References

  • wlshell home page: www.wlshell.com
  • wlshell scripts catalog: www.wlshell.com/scripts
  • Scripting advocacy: http://home.pacbell.net/ouster/scripting.html
  • More Stories By Paco Gomez

    Paco Gómez is Principal Systems Architect at BEA Systems. He designs and develops proof-of-concept architectures for BEA customers and prospects. He is co-writer of the first published book about WebLogic and author of wlshell.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    @ThingsExpo Stories
    SYS-CON Events announced today that N3N will exhibit at SYS-CON's @ThingsExpo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. N3N’s solutions increase the effectiveness of operations and control centers, increase the value of IoT investments, and facilitate real-time operational decision making. N3N enables operations teams with a four dimensional digital “big board” that consolidates real-time live video feeds alongside IoT sensor data a...
    In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). According to the survey, a quarter of the respondents have already deployed Docker containers and nearly as many (23 percent) are employing the AWS Lambda serverless computing framework. It’s clear: serverless is here to stay. The adoption does come with some needed changes, within both application development and operations. Tha...
    SYS-CON Events announced today that Avere Systems, a leading provider of enterprise storage for the hybrid cloud, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere delivers a more modern architectural approach to storage that doesn't require the overprovisioning of storage capacity to achieve performance, overspending on expensive storage media for inactive data or the overbui...
    With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
    SYS-CON Events announced today that mruby Forum will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. mruby is the lightweight implementation of the Ruby language. We introduce mruby and the mruby IoT framework that enhances development productivity. For more information, visit http://forum.mruby.org/.
    Digital transformation is changing the face of business. The IDC predicts that enterprises will commit to a massive new scale of digital transformation, to stake out leadership positions in the "digital transformation economy." Accordingly, attendees at the upcoming Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA, Oct 31-Nov 2, will find fresh new content in a new track called Enterprise Cloud & Digital Transformation.
    Amazon is pursuing new markets and disrupting industries at an incredible pace. Almost every industry seems to be in its crosshairs. Companies and industries that once thought they were safe are now worried about being “Amazoned.”. The new watch word should be “Be afraid. Be very afraid.” In his session 21st Cloud Expo, Chris Kocher, a co-founder of Grey Heron, will address questions such as: What new areas is Amazon disrupting? How are they doing this? Where are they likely to go? What are th...
    Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, will discuss how given the magnitude of today's applicati...
    SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp emp...
    Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
    SYS-CON Events announced today that SkyScale will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. SkyScale is a world-class provider of cloud-based, ultra-fast multi-GPU hardware platforms for lease to customers desiring the fastest performance available as a service anywhere in the world. SkyScale builds, configures, and manages dedicated systems strategically located in maximum-security...
    Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant th...
    SYS-CON Events announced today that Avere Systems, a leading provider of hybrid cloud enablement solutions, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere Systems was created by file systems experts determined to reinvent storage by changing the way enterprises thought about and bought storage resources. With decades of experience behind the company’s founders, Avere got its ...
    SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. ANSeeN are the measurement electronics maker for X-ray and Gamma-ray and Neutron measurement equipment such as spectrometers, pulse shape analyzer, and CdTe-FPD. For more information, visit http://anseen.com/.
    High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, will discuss how by using...
    In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
    SYS-CON Events announced today that Yuasa System will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Yuasa System is introducing a multi-purpose endurance testing system for flexible displays, OLED devices, flexible substrates, flat cables, and films in smartphones, wearables, automobiles, and healthcare.
    SYS-CON Events announced today that CAST Software will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CAST was founded more than 25 years ago to make the invisible visible. Built around the idea that even the best analytics on the market still leave blind spots for technical teams looking to deliver better software and prevent outages, CAST provides the software intelligence that matter ...
    SYS-CON Events announced today that Daiya Industry will exhibit at the Japanese Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ruby Development Inc. builds new services in short period of time and provides a continuous support of those services based on Ruby on Rails. For more information, please visit https://github.com/RubyDevInc.
    As businesses evolve, they need technology that is simple to help them succeed today and flexible enough to help them build for tomorrow. Chrome is fit for the workplace of the future — providing a secure, consistent user experience across a range of devices that can be used anywhere. In her session at 21st Cloud Expo, Vidya Nagarajan, a Senior Product Manager at Google, will take a look at various options as to how ChromeOS can be leveraged to interact with people on the devices, and formats th...