Friday, 29 December 2017

IBM UrbanCode Deploy - Commanding the Line

As ever, a Work-in-Progress, as I seek to understand the What, the Why and the How of IBM UrbanCode Deploy (UCD).

This time, it's getting to grips with the command-line, which leverages the out-of-the-box UCD REST interface.

This is the source from which I am working; -



and here I'm creating a new Version ( to be used by a Component Process ) : -

/opt/ibm/UCD/agent/opt/udclient/udclient -username admin -password passw0rd -weburl https://ucd.uk.ibm.com:8443 createVersion -component WebSphereLibertyProfile -name 1.0

and then uploading a file to that newly created version: -

/opt/ibm/UCD/agent/opt/udclient/udclient -username admin -password passw0rd -weburl https://ucd.uk.ibm.com:8443 addVersionFiles -component WebSphereLibertyProfile -version 1.0 -base /wlpsource/5/

The latter command looks within the directory /wlpsource/5 and uploads EVERYTHING it finds, in this instance a single JAR file: -

wlp-nd-all-17.0.0.4.jar

I'm now tinkering with using the same REST API to actually invoke an Application Process, using this JSON: -

~/runProcess.json

{
  "application": "Install WLP",
  "description": "Requesting deployment",
  "applicationProcess": "Install WLP",
  "environment": "Development",
  "onlyChanged": "false"
  },
  "versions": [
    {
      "version": "1.0",
      "component": "WebSphereLibertyProfile"
    }
  ]
}


and this command: -

/opt/ibm/UCD/agent/opt/udclient/udclient -username admin -password passw0rd -weburl https://ucd.uk.ibm.com:8443 requestApplicationProcess ~/runProcess.json

It's not working thus far …. even though it returns a JSON response e.g. 

{"requestId": "160a34da-b3e6-fd1d-de6e-1069f89f0461"}

etc.

the GUI reports "No Version Selected" : -


but that's tomorrow's problem :-)

IBM UrbanCode Deploy - Syntax FTW

As per previous posts, I'm tinkering with IBM UrbanCode Deploy : -



This time around, I'm using UCD to install WebSphere Liberty Profile (WLP), using the appropriately named WebSphere Liberty Plugin: -

IBM WebSphere Liberty

One of the steps provided by this Plugin is Install Server Archive which expands a JAR or ZIP file containing the WLP codebase.

This step takes a few mandatory ( indicated below with a red asterisk ) including Source File: -


I specify the Source File property at the Application level: -


but saw this: -

  license=true
  source=wlp-webProfile7-17.0.0.3.zip

… 
  wlpHome=/opt/ibm/WebSphere/Liberty/
  wlpUserDir=

Unzipping server archive in : /opt/ibm/WebSphere/Liberty
Caught: : src '/opt/ibm/UCD/agent/var/work/WLP/wlp-webProfile7-17.0.0.3.zip
' doesn't exist.
: src '/opt/ibm/UCD/agent/var/work/WLP/wlp-webProfile7-17.0.0.3.zip
' doesn't exist.
at org.apache.tools.ant.taskdefs.Expand.execute(Expand.java:128)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at com.urbancode.air.plugin.websphereliberty.WebSphereLibertyHelper.installServerArchive(WebSphereLibertyHelper.groovy:194)
at com.urbancode.air.plugin.websphereliberty.WebSphereLibertyHelper$installServerArchive.call(Unknown Source)
at installServerArchive.run(installServerArchive.groovy:25)

 
when I executed the Component Process.

One of my colleagues immediately spotted the flaw: -

Caught: : src '/opt/ibm/UCD/agent/var/work/WLP/wlp-webProfile7-17.0.0.3.zip
' doesn't exist.


The clue is that there's a space between .zip and the trailing apostrophe.

As he rightly suggested, I'd inserted a Carriage Return / Line Feed ( CR/LF ) in the Application Property.

Once I edited this from: -


to: -


all was well: -


Wednesday, 27 December 2017

IBM Installation Manager - Uninstalling EVERYTHING

***CAUTION - THIS IS DESTRUCTIVE***

On the rare occasion that one needs to uninstall a whole bunch o' products installed by IBM Installation Manager (IIM) *AND* IIM itself, here's what one needs: -

/opt/ibm/InstallationManager/eclipse/tools/imcl uninstallAll

/opt/ibm/InstallationManager/eclipse/tools/imcl uninstall `/opt/ibm/InstallationManager/eclipse/tools/imcl listInstalledPackages`


***CAUTION - THIS IS DESTRUCTIVE***

It may also be necessary to clean up what IIM etc. leaves behind e.g.

rm -Rf /opt/ibm/WebSphere/
rm -Rf /opt/ibm/WebSphereProfiles

etc.

IBM UrbanCode Deploy - Error Creating New Version: The provided base is not a directory

I saw this today, whilst creating some new Application Components, needed to install IBM Installation Manager and IBM BPM: -

Error Creating New Version: The provided base is not a directory: /source
java.io.IOException: The provided base is not a directory: /source
at com.urbancode.air.plugin.command.ImportVersion.execute(ImportVersion.java:119)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at com.urbancode.air.plugin.Main.execute(Main.java:113)
at com.urbancode.air.plugin.Main.main(Main.java:47)

It took me a while before I smacked myself on the forehead ….

Yes, you've guessed it, I'd created the /source directory on …. the box upon which the Agent is installed rather than the box upon which the Server is running.

Obviously this is a mistake - the Agent "phones home" to the Server to get its configuration etc. including required versioned files such as response files etc.

Can you say "Doh" ? I bet you can ….

IBM UrbanCode Deploy - Upgrading - Don't forget the database

So I'm upgrading my UCD installation, from 6.2.6.1.940532 to 6.2.7.0.951830, using the provided script install-server.sh as per this: -

….
     [echo] Installing IBM UrbanCode Deploy version 6.2.7.0.951830
     [echo] A previous version (6.2.6.1.940532) exists in the specified directory. Do you want to upgrade the currently installed version? Y,n [Default Y]
y
     [echo] 
     [echo] Installing IBM UrbanCode Deploy to: /opt/ibm/UCD/server
     [echo] JVM Version detected: 1.8.0
     [echo] JAVA_HOME: /opt/ibm/Java/jre
     [echo] NOTICE: Upgrading the server while there are processes currently running is not supported. Before proceeding with an upgrade, verify that there are no running processes on the Current Activity page.
     [echo] 
     [echo] Server upgrades cannot be rolled back. Please ensure that you have backed up the server's database and filesystem before proceeding. (press enter to continue)

   [delete] Deleting directory /opt/ibm/UCD/server/opt/tomcat/webapps/ROOT/static
     [copy] Copying 2 files to /mnt/ibm-ucd-install/bin/server
     [copy] Copying 168 files to /mnt/ibm-ucd-install/.tmp-old-lib
  [upgrade] Adding upgrade file for processing: /mnt/ibm-ucd-install/database/deploy/always/all/always_sql.xml
java.lang.Exception: Error trying to cancel currently running processes
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:88)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
Caused by: : : com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2043][11550][3.72.30] Exception java.net.ConnectException: Error opening socket to server ucd.uk.ibm.com/127.0.0.1 on port 60,006 with message: Connection refused. ERRORCODE=-4499, SQLSTATE=08001
Caused by: : com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2043][11550][3.72.30] Exception java.net.ConnectException: Error opening socket to server ucd.uk.ibm.com/127.0.0.1 on port 60,006 with message: Connection refused. ERRORCODE=-4499, SQLSTATE=08001

Guess what I forgot to do ?

Yep, having rebooted this VM, I forgot to start DB2: -

su - db2inst1
db2start

Having done that, quelle surprise, the upgrade just worked …

...
[propertyfile] Updating property file: /opt/ibm/UCD/server/conf/installed.version
     [echo] After starting the server, you may access the web UI by pointing your web-browser at
     [echo] https://ucd.uk.ibm.com:8443 
     [echo] Installer Complete. (press return to exit installer)

   [delete] Deleting directory /tmp/install-6103865522074515176.tmp
     [copy] Copying 1 file to /opt/ibm/UCD/server/var/install-log

BUILD SUCCESSFUL
Total time: 3 minutes 1 second




Saturday, 23 December 2017

Windows, and missing my rm -rf

Whilst I know that things like PowerShell gives me Unix-like capabilities on Windows, I was looking for a Q&D solution.

All I wanted to do was to remove an entire directory structure.

Back in the day, we had deltree but that appears to have gone in later versions of Windows.

However, we do have rmdir which does the job, as per this example: -

rmdir C:\IBM /S/Q

whereas my muscle memory would be do use this: -

rm -Rf /IBM

In the words of the prophet, good luck with that.

IBM HTTP Server on Windows - 32-bit or 64-bit ?

Following a previous post: -


I'm continuing to tinker with IBM HTTP Server (IHS) 9.0 on Windows.

Most of my work involves Unix ( Linux, AIX, macOS ), so Windows is relatively new to me, leastways in the context of IBM middleware etc.

So, given that I'm running a 64-bit version of Windows: -


I assumed that I could use the 64-bit version of the WebSphere Plugin: -

LoadModule was_ap24_module "c:\IBM\WebSphere\Plugins\bin\64bits\mod_was_ap24_http.dll"

Alas, no, not possible :-(

I see this when I start IHS: -

httpd.exe: Syntax error on line 806 of C:/IBM/HTTPServer/WAS/conf/httpd.conf: Cannot load c:\\IBM\\WebSphere\\Plugins\\bin\\64bits\\mod_was_ap24_http.dll into server: %1 is not a valid Win32 application.

I checked the underlying Apache binaries: -

c:\IBM\HTTPServer\bin\apache.exe -v

Server version: IBM_HTTP_Server/9.0.0.6 (Win32)
Server built:   Oct 10 2017 20:22:21


c:\IBM\HTTPServer\bin\apache.exe -V

Server version: IBM_HTTP_Server/9.0.0.6 (Win32)
Apache version: 2.4.12 (with additional fixes)
Server built:   Oct 10 2017 20:22:21
Build level:    RIHSX.IHS/webIHS1741.01
Server's Module Magic Number: 20120211:57
Server loaded:  APR 1.5.1, APR-UTIL 1.5.2
Compiled using: APR 1.5.1, APR-UTIL 1.5.2
Architecture:   32-bit
Operating System: Windows
Server MPM:     WinNT
  threaded:     yes (fixed thread count)
    forked:     no
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses disabled)
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/apache"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error.log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
Apache vulnerability fixes included:
  CVE-2009-1191  CVE-2009-1890  CVE-2009-3094  CVE-2009-3095
  CVE-2010-0434  CVE-2010-0425  CVE-2010-0408  CVE-2009-3555
  CVE-2010-1452  CVE-2010-1623  CVE-2011-3368  CVE-2011-3607
  CVE-2011-3192  CVE-2011-3348  CVE-2011-4317  CVE-2012-0021
  CVE-2012-0031  CVE-2012-0053  CVE-2012-0883  CVE-2012-2687
  CVE-2012-3502  CVE-2012-4558  CVE-2012-3499  CVE-2013-2249
  CVE-2013-1896  CVE-2013-4352  CVE-2013-6438  CVE-2014-0098
  CVE-2014-0963  CVE-2014-0231  CVE-2014-0118  CVE-2014-0226
  CVE-2014-3523  CVE-2014-0117  CVE-2013-5704  CVE-2014-8109
  CVE-2014-3581  CVE-2014-3583  CVE-2015-0253  CVE-2015-3185
  CVE-2015-3183  CVE-2015-1829  CVE-2014-8730  CVE-2015-0228
  CVE-2015-4947  CVE-2015-1283  CVE-2015-7420  CVE-2016-0201
  CVE-2016-0718  CVE-2016-5387  CVE-2012-0876  CVE-2016-4472
  CVE-2016-8743  CVE-2017-3169  CVE-2017-3167  CVE-2017-7668
  CVE-2017-7679  CVE-2017-12618  CVE-2017-9798

even though I chose to install the 64-bit version of IHS itself: -

  <profile id='IBM HTTP Server V9.0' installLocation='c:\IBM\HTTPServer'>
    <data key='cic.selector.arch' value='x86_64'/>
    <data key='user.ihs.http.server.service.name.key' value='IBMHTTPServerV9.0'/>
    <data key='user.ihs.http.server.service.name' value='IBM HTTP Server V9.0'/>
    <data key='user.ihs.win.serverServiceStartType' value='auto'/>
    <data key='user.ihs.win.serverServicePassword' value='XjTveChg5ba6olBVMK/Reg=='/>
    <data key='user.ihs.allowNonRootSilentInstall' value='true'/>
    <data key='user.ihs.win.serverServiceLogOnAsLocalSystem' value='true'/>
    <data key='user.ihs.installHttpService' value='false'/>
    <data key='user.ihs.win.serverServiceUser' value='Administrator'/>
    <data key='user.ihs.httpPort' value='8080'/>
  </profile>


which explains everything.

Once I changed IHS, from: -

LoadModule was_ap24_module "c:\IBM\WebSphere\Plugins\bin\64bits\mod_was_ap24_http.dll"

to: -

LoadModule was_ap24_module "c:\IBM\WebSphere\Plugins\bin\32bits\mod_was_ap24_http.dll"

everything was fine.

It's also worth noting that, given that I'm running Apache 2.4 under the covers, the syntax in the httpd.conf is to use was_ap24_module rather than was_ap22_module.

I'm not sure I've paid much attention to 2.2 vs 2.4 in the past, but it's more important with v9.0, as per this: -

Migrating to IBM HTTP Server 9.0

Migrate an IBM® HTTP Server, Version 7 or 8 server, to IBM HTTP Server 9.0. Because IHS 9.0 is based on Apache 2.4, you must modify your existing configuration.


This document describes changes in Apache HTTP Server 2.4 that might require you to change your configuration or how you use the server in order to use IHS 9.0 (Based on Apache 2.4) as you are currently using IHS 7.0 or 8.x (based on Apache 2.2) . For step by step instructions on migrating a configuration file, see the "Migrating a configuration" section below.

IBM HTTP Server on Windows - New(ish) to me

This briefly caught me out.

Having install IBM HTTP Server 9.0.0.6 on a 64-bit Windows Server 2012 environment, I was trying, and failing, to start an instance: -

c:\IBM\HTTPServer\bin\apache.exe -k start -f c:\IBM\HTTPServer\WAS\conf\httpd.conf

[Sat Dec 23 09:08:44.988185 2017] [mpm_winnt:error] [pid 6328:tid 280] (OS 2)The system cannot find the file specified.  : AH00436: No installed service named "IBM HTTP Server V9.0".
[Sat Dec 23 09:08:44.988185 2017] [mpm_winnt:error] [pid 6328:tid 280] (OS 2)The system cannot find the file specified.  : If IBM HTTP Server was installed more than once, or installed with other than the default offering name, the service name must be passed to httpd.exe -k start via the -n <servicename>  parameter.


When I installed IHS, using a response file, I'd specifically chosen NOT to install IHS as a service: -

  <profile id='IBM HTTP Server V9.0' installLocation='c:\IBM\HTTPServer'>
    <data key='cic.selector.arch' value='x86_64'/>
    <data key='user.ihs.http.server.service.name.key' value='IBMHTTPServerV9.0'/>
    <data key='user.ihs.http.server.service.name' value='IBM HTTP Server V9.0'/>
    <data key='user.ihs.win.serverServiceStartType' value='auto'/>
    <data key='user.ihs.win.serverServicePassword' value='XjTveChg5ba6olBVMK/Reg=='/>
    <data key='user.ihs.allowNonRootSilentInstall' value='true'/>
    <data key='user.ihs.win.serverServiceLogOnAsLocalSystem' value='true'/>
    <data key='user.ihs.installHttpService' value='false'/>
    <data key='user.ihs.win.serverServiceUser' value='Administrator'/>
    <data key='user.ihs.httpPort' value='8080'/>
  </profile>


This, it transpires, was an error on my part :-)

The solution ?

Install IHS as a Windows service: -

c:\IBM\HTTPServer\bin\apache.exe -k install

Installing the IBM HTTP Server V9.0 service
The IBM HTTP Server V9.0 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.

c:\IBM\HTTPServer\bin\apache.exe -k start -f c:\IBM\HTTPServer\WAS\conf\httpd.conf

No errors this time around :-)


Happy days, more to learn :-)

Friday, 22 December 2017

IBM Cloud Private - 2.1.0.1 now available

From this: -

IBM Cloud Private version 2.1.0.1 is now available for download

Announcing the arrival of IBM Cloud Private version 2.1.0.1!

I know you didn't think that we were going to let the year end without another delivery from the IBM Cloud Private team. So here you go, to round out 2017 we got another one.........introducing IBM Cloud Private 2.1.0.1.

IBM Cloud Private Version 2.1.0.1 iterates on our 2.1.0 edition, with console enhancements, new capabilities, and a Kubernetes version update. We do highly recommend this upgrade, as alongside these new features, we took the time to also improve on some features and fix some of those pesky bugs.

We do hope you enjoy!

What's new in version 2.1.0.1

Here is a snapshot of what to expect with the release of version 2.1.0.1. You can also find more details on our Bluemix blog, or by reviewing our What's new page in the IBM Knowledge Center.

Kubernetes upgraded to 1.8.3

IBM Cloud Private version 2.1.0.1 is now upgraded to use Kubernetes version 1.8.3. For more information about the features that are introduced in Kubernetes 1.8.3, see https://github.com/kubernetes/features/blob/master/release-1.8/release-notes-draft.md.

Redesigned navigation menu

The navigation menu is now redesigned for better alignment of functions, this should improve ease of use of the IBM Cloud Private management console.

New networking capability

You can now integrate VMware NSX-T 2.0 with IBM Cloud Private.

Technology Previews

Try out one of our beta features and let us know what you think

• Cluster federation - In multiple cluster environments, you can use a federation to deploy and manage common services across multiple Kubernetes clusters.
• Vulnerability advisor - Use the advisor to get vulnerability reports for containers and images in your IBM® Cloud Private private registry. Note: The Vulnerability advisor is not available with IBM Cloud Private Community Edition.

WebSphere Liberty Profile - 17.0.0.4

I missed this announcement t'other day, although I did see this: -


WebSphere Liberty 17.0.0.4 update will be available shortly. It includes many new enhancements. During the Liberty vPOT, you'll have a chance to get your hands on a download containing the Liberty driver and a set of labs to help get started quickly. The webcast will also include the latest updates on licensing and product support. During the Q&A and labs session, developers from the WebSphere team will be on-hand to answer any questions about Liberty or help get you unstuck with any of the Liberty labs, which you can do on your machine.

Anyway, here's WLP ….


Abstract

IBM WebSphere Application Server Liberty Fix Pack 17.0.0.4 for all platforms.

Download Description

Notice: Please read the important information included in this document in the Known side effects section. 
WebSphere Application Server Liberty 17.0.0.4 content is provided as below:

• Archives packages
• Liberty installation archives with all features
• Convenience ZIP files with Java™ EE 7 or OSGi applications
• Edition-specific archives
• License upgrade archives
• Directory-based repository for working offline
• Cloud packages
• Liberty Buildpack
• IBM Installation Manager packages
• Local repository files for IM install
• Java SDK packages
• IBM Java SDKs for WebSphere Liberty
• IBM WebSphere Java SDKs for WebSphere Application Server V8.5

Thursday, 14 December 2017

WebSphere Liberty Profile - Customising the Logging

On my current engagement, we had a requirement to trim out ( temporarily ) some information log messages which were "spamming" the console.log of a WebSphere Liberty Profile (WLP) environment.

Firstly, here's some context about WLP logging: -

There are three primary log files for a server:

• console.log - containing the redirected standard output and standard error from the JVM process. This console output is intended for direct human consumption. The console output contains major events and errors if you use the default consoleLogLevel configuration. The console output also contains any messages that are written to the System.out and System.err streams if you use the default copySystemStreams configuration. The console output always contains messages that are written directly by the JVM process, such as -verbose:gc output. This file is created only if the server start command is used, and its location can be altered only by using the LOG_DIR environment variable. For more information, see Administering Liberty from the command line.

• messages.log - containing all messages except trace messages that are written or captured by the logging component. All messages that are written to this file contain additional information such as the message time stamp and the ID of the thread that wrote the message. This file does not contain messages that are written directly by the JVM process.

• trace.log - containing all messages that are written or captured by the product. This file is created only if you enable additional trace. This file does not contain messages that are written directly by the JVM process.

and: -

The console.log file does not have the same level of management as other log files. The only property that you can change is consoleLogLevel.

and: -

consoleLogLevel

This filter controls the granularity of messages that go to the console.log file. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. By default, the level is AUDIT.
...


As an example, from my own VM ( and this is a TERRIBLE example ), let's say I wanted to suppress this message: -

[AUDIT   ] CWWKS1100A: Authentication did not succeed for user ID appcenteradmin. An invalid user ID or password was specified.

In a default, vanilla, installation of WLP, the default for consoleLogLevel is AUDIT.

If I wanted to turn off ALL logging, I could change that to OFF, but that'd be a daft idea.

Therefore, there's this: -

...
After version 8.5.5.4+ Liberty Profile; added new attribute "hideMessage" to logging element.

You can configure logging element on server.xml file;

<logging hideMessage="WELD-000900" />

The "WELD-000900" messages will redirect to trace.log file.

If you want to add multiple message, you can seperate it with a comma.

<logging hideMessage="WELD-000900, CWWKE0001I" />


so I validated this, by changing server.xml : -

vi /opt/ibm/WebSphere/Liberty/usr/servers/defaultServer/server.xml

and adding: -

        <logging consoleLogLevel="AUDIT"/>
        <logging hideMessage="CWWKS1100A"/>

before the closing </server> directive.

Now I can try/fail to login as many times as I like, and console.log will tell me nothing: -

tail -f /opt/ibm/WebSphere/Liberty/usr/servers/defaultServer/logs/console.log

[AUDIT   ] CWWKS1100A: Authentication did not succeed for user ID adsda. An invalid user ID or password was specified.
[AUDIT   ] CWWKG0016I: Starting server configuration update.
[AUDIT   ] CWWKG0017I: The server configuration was successfully updated in 0.050 seconds.


Note the CWWKG0016I and CWWKG0017I messages; they tell me that the server automatically updated its configuration once I saved the changes to server.xml.

And, of course, I'm going to change it back: -

vi /opt/ibm/WebSphere/Liberty/usr/servers/defaultServer/server.xml

        <logging consoleLogLevel="AUDIT"/>

and now I see all of the bad login messages: -

tail -f /opt/ibm/WebSphere/Liberty/usr/servers/defaultServer/logs/console.log

[AUDIT   ] CWWKS1100A: Authentication did not succeed for user ID adsdas. An invalid user ID or password was specified.
[AUDIT   ] CWWKS1100A: Authentication did not succeed for user ID asdads. An invalid user ID or password was specified.
a[AUDIT   ] CWWKS1100A: Authentication did not succeed for user ID asda. An invalid user ID or password was specified.

IBM MobileFirst 8 - Commanding the CLI

As with many of my projects, this is another one in the category of "Tinkering".

In order to better support my current client, I needed a quick-start into the world of IBM MobileFirst Platform (MFP).

I've blogged about MFP before, but mainly in the context of building out a runtime on the WebSphere Liberty Platform: -


but now I wanted to go a little bit further.

I started here: -


and quickly ended up here: -


and: -


Having downloaded and installed the MobileFirst Developer Kit for macOS, as per this: -


I was able to start up the native MobileFirst Server: -

cd /Users/davidhay/MobileFirst-8.0.0.0
./run.sh

….
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
objc[10046]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java (0x100da94c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x100e674e0). One of the two will be used. Which one is undefined.
Listening for transport dt_socket at address: 10777
Launching mfp (WebSphere Application Server 8.5.5.8/wlp-1.0.11.cl50820151201-1942) on Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_151-b12 (en_GB)
[AUDIT   ] CWWKE0001I: The server mfp has been launched.
[AUDIT   ] CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/8.5.5.8/lafiles/en.html
[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications. 

[AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.153.1:9080/doc/
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.153.1:9080/mfp-dev-artifacts/
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.153.1:9080/IBMJMXConnectorREST/

[AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.153.1:9080/mfpconsole/
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.153.1:9080/mfpadminconfig/

[AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.153.1:9080/analytics/
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.153.1:9080/imfpush/
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://192.168.153.1:9080/mfpadmin/


I then hit the MFP Console: -


and navigated to the Get CLI link: -



At this point, I hit a blocker.

When I tried to use the local version ( having downloaded it from here http://192.168.153.1:9080/mfp-dev-artifacts/mfpdev-cli.tgz ) : -

sudo npm install -g ~/Downloads/mfpdev-cli.tgz 

I saw this: -

npm WARN deprecated minimatch@3.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated express@2.5.11: express 2.x series is deprecated
npm WARN deprecated connect@1.9.2: connect 1.x series is deprecated
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated node-uuid@1.4.7: Use uuid module instead
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm ERR! code E404
npm ERR! 404 Not Found: ibm-strings@0.1.4

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/davidhay/.npm/_logs/2017-12-14T15_19_12_355Z-debug.log


When I tried the version from the net: -

sudo npm install -g mfpdev-cli

I saw this: -

npm WARN deprecated minimatch@3.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated express@2.5.11: express 2.x series is deprecated
npm WARN deprecated connect@1.9.2: connect 1.x series is deprecated
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated node-uuid@1.4.7: Use uuid module instead
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/mfpdev-cli/node_modules/fsevents):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/fsevents-4718b8bb/node_modules/tar' -> '/usr/local/lib/node_modules/.staging/tar-0c43e4b7'

npm ERR! path /Users/mdo-windows-support/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno -2
npm ERR! syscall open
npm ERR! package.json ENOENT: no such file or directory, open '/Users/mdo-windows-support/package.json'
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/davidhay/.npm/_logs/2017-12-14T15_19_51_237Z-debug.log

Interestingly, this page: -

doesn't specify dependencies, in terms of NodeJS and NPM.

However, this: -


does say: -

IBM MobileFirst CLI is not supported in the npm version whatever you are trying with.

Try installing the same with npm version 3.10.10 and this should resolve the issue which you are facing.

I checked my versions: -

npm -v

5.5.1

node -v

v8.9.3

Ah, ha :-)

This table: -


helped me find the Node <-> NPM relationship: -

so I went here: -


Having downloaded and installed, I re-checked my versions: -

npm -v

3.10.10

node -v

v7.3.0

Whilst I still struggled with the local version: -

sudo npm install -g ~/Downloads/mfpdev-cli.tgz

npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-adapter-actions
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-android-support
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-app-config
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-app-preview
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-app-pull
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-app-push
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-app-register
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-app-webencrypt
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-app-webupdate
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-cmd-adapter
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-cmd-app
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-cmd-config
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-cmd-info
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-cmd-server
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-cordova-support
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-errors
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-exec
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-ios-support
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-mbs
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-server-support
npm ERR! addLocal Could not install /usr/local/lib/node_modules/mdo-windows-support
npm ERR! addLocal Could not install /usr/local/lib/node_modules/platform-manager
npm ERR! fetch failed https://registry.npmjs.org/mfp-config-xml/-/mfp-config-xml-0.0.3.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404
npm ERR! fetch failed https://registry.npmjs.org/pluggington/-/pluggington-0.3.3.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404
npm ERR! fetch failed https://registry.npmjs.org/ibm-strings/-/ibm-strings-0.1.4.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404
npm ERR! fetch failed https://registry.npmjs.org/mfp-config-xml/-/mfp-config-xml-0.0.3.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404
npm ERR! fetch failed https://registry.npmjs.org/pluggington/-/pluggington-0.3.3.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404
npm ERR! fetch failed https://registry.npmjs.org/ibm-strings/-/ibm-strings-0.1.4.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404
npm ERR! fetch failed https://registry.npmjs.org/mfp-config-xml/-/mfp-config-xml-0.0.3.tgz
npm ERR! fetch failed https://registry.npmjs.org/pluggington/-/pluggington-0.3.3.tgz
npm ERR! fetch failed https://registry.npmjs.org/ibm-strings/-/ibm-strings-0.1.4.tgz
npm ERR! Darwin 17.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "/Users/davidhay/Downloads/mfpdev-cli.tgz"
npm ERR! node v7.3.0
npm ERR! npm  v3.10.10
npm ERR! path /usr/local/lib/node_modules/mdo-adapter-actions
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/usr/local/lib/node_modules/mdo-adapter-actions'
npm ERR! enoent ENOENT: no such file or directory, open '/usr/local/lib/node_modules/mdo-adapter-actions'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/local/bin/npm-debug.log

I was able to install / use the online version: -

sudo npm install -g mfpdev-cli

which mfpdev

/usr/local/bin/mfpdev

mfpdev -v

8.0.0-2017102406

Now to learn what to do with it ...

Tuesday, 12 December 2017

Oracle Database 11gR2 - Get the dependencies right ...

Having just installed Oracle 11.2 ( 11gR2 ) onto a Red Hat Enterprise Linux 7.4 VM, I was kinda getting fed up with the sqlplus command not working …..

sqlplus 

sqlplus: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory

ls -al `locate libclntsh.so`

-rwxrwx---. 1 oracle oracle 48797739 Dec 12 08:49 /home/oracle/app/oracle/product/11.2.0/dbhome_1/inventory/backup/2017-12-12_08-48-58AM/Scripts/ext/lib/libclntsh.so.11.1
-rwxrwx---. 1 oracle oracle 48797739 Dec 12 08:49 /home/oracle/app/oracle/product/11.2.0/dbhome_1/inventory/Scripts/ext/lib/libclntsh.so.11.1
-rwxr-xr-x. 1 oracle oracle        0 Dec 12 08:50 /home/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so


echo $LD_LIBRARY_PATH

/home/oracle/app/oracle/product/11.2.0/dbhome_1/lib:

ls -al /home/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so*

-rwxr-xr-x. 1 oracle oracle 0 Dec 12 08:50 /home/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so

and yet ….

As is ever the case, Google came to my rescue; more importantly, Cody Burleson: -


which told me about the relink command: -

~/app/oracle/product/11.2.0/dbhome_1/bin/relink

The log for this: -

/home/oracle/app/oracle/product/11.2.0/dbhome_1/install/relink.log

showed me the error of my ways: -

INFO: gcc -o tnslsnr -m64
INFO: /bin/sh: gcc: command not found

INFO: make: *** [tnslsnr] Error 127


Ah, dependency time :-)

So I installed gcc using Yum, and reinstalled Oracle: -

rm -Rf /home/oracle/app/
/mnt/database/runInstaller -silent -responseFile ~/db_install.rsp 

and now it works: -

sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Tue Dec 12 09:46:19 2017

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: 

Next time (!), check the dependencies, doofus !

Thursday, 7 December 2017

DB2 on Windows - where does the db2nodes.cfg file live ?

I was briefly tinkering with the need to update the db2nodes.cfg file to help DB2 Express 11.1 cope with the hostname change of a Windows Server 2012 R2 boxen.

I'd created a new VM, via OpenStack, using a snapshot from an existing VM - which I'd NOT yet deleted.

Therefore, OpenStack, being the nice IaaS solution that it is, kindly helped me out by creating the new instance with a new hostname.

This borked DB2, as you'd expect ….

I've seen similar issues with DB2 on Linux: -

SQL10003C There are not enough system resources to process the request. The request cannot be processed.
and it's typically just a case of updating the db2nodes.cfg file, which lives under the DB2 instance's home directory: -

/home/db2inst1/sqllib/db2nodes.cfg

On Windows …. yeah, good luck with that.

Of course, I found it ….

It's HERE

C:\ProgramData\IBM\DB2\DB2COPY1\BPMINST\db2nodes.cfg

Easy when you know how.

For the record, DB2 was installed, via IBM Installation Manager, as part of an IBM BPM 8.6 installation.

But that's not important right now ….

For more info about changing DB2 hostnames ( ideally you don't want to do this but … ), please go here: -


which says, in part: -

Locate db2nodes.cfg in one of the following directories:
• UNIX/Linux:
<db2 instance home directory>/sqllib/db2nodes.cfg

• All Windows flavors running DB2 v8 and v9.1: 
Program Files\IBM\SQLLIB\DB2\db2nodes.cfg 

• Windows XP and 2003 running DB2 v9.5: 
Documents and Settings\All Users\Application Data\IBM\DB2\<DB2COPY>\DB2\db2nodes.cfg

NOTE: Application Data is a hidden folder

• Windows Vista and later operating systems: ProgramData\IBM\DB2\<DB2COPY>\DB2\db2nodes.cfg

Ah, Windows Vista, how quaint !

Windows Server 2012 - Ooops, I locked my account

One of my colleagues had a bad day with a shared Windows Server 2012 R2 environment, in that he locked out the main account that we use to access the box, via Remote Desktop Protocol (RDP).

This is NOT an Active Directory environment, so there's no domain controller in the mix; these are merely local accounts.

Thankfully, I had another account that WASN'T locked out, so I RDP'd into the box using that account and used the Advanced User Accounts Control Panel ( aka netplwiz ), which did the trick: -


and: -


The "Account is locked out" checkbox WAS checked, it's checked no longer :-)

Thanks to the internet for the assist: -



Wednesday, 6 December 2017

Nagios and NRPE - There's more ...

Following on from my earlier post: -


things are starting to become more clear.

As far as I can establish, on the NRPE client/agent side, we have several components at work here.

So we have the NRPE agent itself, as started using xinetd : -

/etc/xinetd.d/nrpe
 
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
        flags           = REUSE
        socket_type     = stream    
port = 5666    
        wait            = no
        user            = nagios
group = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
# only_from       = 192.168.153.130
}


and then we have the command(s) that we want to invoke from the Nagios server itself: -

ls -1 /usr/local/nagios/libexec

check_disk
check_load
check_nrpe
check_procs
check_swap
check_users
diskfree.py
hello.pl


and then we have the configuration file that acts as the lookup/aliasing agent: -

cat /usr/local/nagios/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -r -w .15,.10,.05 -c .30,.25,.20
command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[sayHello]=/usr/local/nagios/libexec/hello.pl
command[diskFree]=/usr/local/nagios/libexec/diskfree.py


This means that, from the Nagios server, I can invoke any of the above commands: -

/usr/local/nagios/libexec/check_nrpe -H mfp.uk.ibm.com -c check_users

USERS OK - 2 users currently logged in |users=2;5;10;0

/usr/local/nagios/libexec/check_nrpe -H mfp.uk.ibm.com -c check_load

CRITICAL - load average: 0.39, 0.24, 0.17|load1=0.390;0.150;0.300;0; load5=0.240;0.100;0.250;0; load15=0.170;0.050;0.200;0; 

/usr/local/nagios/libexec/check_nrpe -H mfp.uk.ibm.com -c check_sda1

DISK OK - free space: /boot 274 MB (55.29% inode=100%);| /boot=222MB;396;446;0;496

/usr/local/nagios/libexec/check_nrpe -H mfp.uk.ibm.com -c check_zombie_procs

PROCS OK: 0 processes with STATE = Z | procs=0;5;10;0;

/usr/local/nagios/libexec/check_nrpe -H mfp.uk.ibm.com -c check_total_procs

PROCS WARNING: 185 processes | procs=185;150;200;0;

/usr/local/nagios/libexec/check_nrpe -H mfp.uk.ibm.com -c sayHello

Hello, World!

/usr/local/nagios/libexec/check_nrpe -H mfp.uk.ibm.com -c diskFree

FREE SPACE OK: '/' is 26.00% full

From a Nagios console perspective, I can define all/any of these

sudo vi /usr/local/nagios/etc/servers/mfp.cfg 

define command {
        command_name                    check_nrpe_with_args
        command_line                    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

define service {
        use                             generic-service
        host_name                       mfp.uk.ibm.com
        service_description             Check_Load
        check_command                   check_nrpe_with_args!check_load
        notifications_enabled           1
}
define service {
        use                             generic-service
        host_name                       mfp.uk.ibm.com
        service_description             Hello_World
        check_command                   check_nrpe!sayHello
        notifications_enabled           0
}
define service {
        use                             generic-service
        host_name                       mfp.uk.ibm.com
        service_description             Disk_Free
        check_command                   check_nrpe!diskFree
        notifications_enabled           0
}


sudo systemctl restart nagios.service

and then check the Nagios dashboard: -



Finally, purely for the record, whilst the shipped plugins are mainly C/C++ binaries e.g.

file /usr/lib64/nagios/plugins/check_disk 

/usr/lib64/nagios/plugins/check_disk: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0f75d7633e74455320d40f0b75071f8eabe148de, stripped

but I also have a Perl script: -

file hello.pl 

hello.pl: Perl script, ASCII text executable

and a Python script: -

file diskfree.py 

diskfree.py: Python script, ASCII text executable

( kudos to Linux Magazine for this latter script )

Nagios Remote Plugin Executor (NRPE) and xinetd on Red Hat Enterprise Linux

As per a few previous posts, I'm tinkering ( there's that word again, I must think of another simile ) with Nagios.

This time I'm looking to have my Nagios monitoring server ( which runs on Ubuntu ) execute an agent on a remote boxen running Red Hat Enterprise Linux (RHEL).

Having installed the pre-requisites ( and I do need to document those steps more clearly ), I setup a NRPE script to be started using xinetd ( A Powerful Replacement For Inetd )

cat /etc/xinetd.d/nrpe 

# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
        flags           = REUSE
        socket_type     = stream    
port = 5666    
        wait            = no
        user            = nagios
group = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
# only_from       = 192.168.153.130
}


Having started the service: -

systemctl restart xinetd.service

I was expecting to see NRPE listening on port 5666: -

netstat -aon | grep LISTEN | grep 5666

but saw nothing alas.

I checked the logs: -

tail -f /var/log/messages

Dec  6 14:00:01 mfp systemd: Starting Session 222 of user root.
Dec  6 14:00:14 mfp xinetd[5771]: unexpected signal: 18 (Continued) in signal pipe
Dec  6 14:00:14 mfp systemd: Stopping Xinetd A Powerful Replacement For Inetd...
Dec  6 14:00:14 mfp xinetd[5771]: Exiting...
Dec  6 14:00:14 mfp systemd: Starting Xinetd A Powerful Replacement For Inetd...
Dec  6 14:00:14 mfp systemd: PID file /var/run/xinetd.pid not readable (yet?) after start.
Dec  6 14:00:14 mfp xinetd[6205]: service/protocol combination not in /etc/services: nrpe/tcp
Dec  6 14:00:14 mfp xinetd[6205]: xinetd Version 2.3.15 started with libwrap loadavg labeled-networking options compiled in.
Dec  6 14:00:14 mfp xinetd[6205]: Started working: 0 available services
Dec  6 14:00:14 mfp systemd: Started Xinetd A Powerful Replacement For Inetd.

which makes sense.

Following this: -


I updated the services table: -

vi /etc/services

and changed it from: -

...
cfengine        5308/tcp                        # CFengine
cfengine        5308/udp                        # CFengine
cvsup           5999/tcp        CVSup           # CVSup file transfer/John Polstra/FreeBSD
cvsup           5999/udp        CVSup           # CVSup file transfer/John Polstra/FreeBSD

...

to: -

...
cfengine        5308/tcp                        # CFengine
cfengine        5308/udp                        # CFengine

nrpe            5666/tcp                        # NRPE

cvsup           5999/tcp        CVSup           # CVSup file transfer/John Polstra/FreeBSD
cvsup           5999/udp        CVSup           # CVSup file transfer/John Polstra/FreeBSD

...

Once I again restarted xinetd : -

systemctl restart xinetd.service

the nrpe service started listening on port 5666: -

netstat -aon | grep LISTEN | grep 5666

tcp6       0      0 :::5666                 :::*                    LISTEN      off (0.00/0/0)

with no issues in the logs: -

tail -f /var/log/messages

Dec  6 14:09:54 mfp systemd: Starting Xinetd A Powerful Replacement For Inetd...
Dec  6 14:09:54 mfp systemd: PID file /var/run/xinetd.pid not readable (yet?) after start.
Dec  6 14:09:54 mfp xinetd[6803]: xinetd Version 2.3.15 started with libwrap loadavg labeled-networking options compiled in.
Dec  6 14:09:54 mfp xinetd[6803]: Started working: 1 available service
Dec  6 14:09:54 mfp systemd: Started Xinetd A Powerful Replacement For Inetd.


Thanks, Google, you again served me well ...

WebSphere Liberty Profile - Monitoring via JMX over REST using Jython

For this, I'm using two excellent IBM developerWorks articles as inspiration: -



Without reposting the entire pair of articles ( which would be a daft idea ), here's a short-cut of what I ended up doing.

For the record, I am using Liberty 17.0.0.3: -

/opt/ibm/WebSphere/Liberty/bin/server version

WebSphere Application Server 17.0.0.3 (1.0.18.cl170320170927-1854) on IBM J9 VM, version pxa6480sr3fp12-20160919_01 (SR3 FP12) (en_GB)

Java 8: -

java -fullversion

java full version JRE 1.8.0 IBM Linux build pxa6480sr3fp12-20160919_01(SR3 FP12)

and Jython 2.7.0: -


So I started by setting up the Jython runtime environment ( this is on the same Red Hat Enterprise Linux box that's hosting Liberty etc. ): -

Create the directory structure

mkdir /opt/ibm/WebSphere/Liberty/jython
cd /opt/ibm/WebSphere/Liberty/jython

Pull Jython 2.7.0

wget http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar
mv remotecontent\?filepath\=org%2Fpython%2Fjython-standalone%2F2.7.0%2Fjython-standalone-2.7.0.jar jython-standalone-2.7.0.jar

Copy the requisite REST Connector classes - both Jython and Java

cp /opt/ibm/WebSphere/Liberty/clients/jython/restConnector.py .
cp /opt/ibm/WebSphere/Liberty/clients/restConnector.jar .

and then started the Jython environment: -

java -cp jython-standalone-2.7.0.jar:restConnector.jar org.python.util.jython

From there, I established connectivity to my Liberty runtime: -

from restConnector import JMXRESTConnector
JMXRESTConnector.trustStore = '/opt/ibm/WebSphere/Liberty/usr/servers/defaultServer/resources/security/key.jks'
JMXRESTConnector.trustStorePassword = 'passw0rd'
connector = JMXRESTConnector()
connection = connector.connect( 'mfp.uk.ibm.com', 9443, 'appcenteradmin', 'admin')
mconnection=connector.getMBeanServerConnection()


Note that, contrary to the article, this code did not work: -

mconnection = connection.getMBeanServerConnection()

It instead returned: -

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'getMBeanServerConnection'


However, this code DID work: -

mconnection=connector.getMBeanServerConnection()

and I was able to validate connectivity etc. : -

mconnection

com.ibm.ws.jmx.connector.client.rest.internal.RESTMBeanServerConnection@fcbd91c2

dir(mconnection)

['MBeanCount', 'PollingMode', 'ServerPollingThread', '__class__', '__copy__', '__deepcopy__', '__delattr__', '__doc__', '__ensure_finalizer__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__subclasshook__', '__unicode__', 'addNotificationListener', 'class', 'createMBean', 'defaultDomain', 'domains', 'equals', 'getAttribute', 'getAttributes', 'getClass', 'getDefaultDomain', 'getDomains', 'getMBeanCount', 'getMBeanInfo', 'getObjectInstance', 'hashCode', 'invoke', 'isInstanceOf', 'isRegistered', 'notify', 'notifyAll', 'queryMBeans', 'queryNames', 'removeNotificationListener', 'setAttribute', 'setAttributes', 'toString', 'unregisterMBean', 'wait']

mconnection.getClass()

<type 'com.ibm.ws.jmx.connector.client.rest.internal.RESTMBeanServerConnection'>

The article then takes one through creating a pair of Python scripts: -

wlp_collect_conf.py
wlp_collect.py

to create an importable library of functions, including: -

connection = connect()

9443
/opt/ibm/WebSphere/Liberty/usr/servers/defaultServer/resources/security/key.jks
Connecting to the server...
Successfully connected to the server "mfp.uk.ibm.com:9443"

and: -

collect( connection, True,  "WebSphere:type=JvmStats,*")

 MBean details for WebSphere:type=JvmStats

   7 attributes
      UsedMemory [long] = 83109880
      FreeMemory [long] = 41080840
      Heap [long] = 124321792
      UpTime [long] = 22864299
      ProcessCPU [double] = 2.04226135228
      GcCount [long] = 1187
      GcTime [long] = 2457

   0 operations
array(java.lang.Object, [WebSphere:type=JvmStats])

So, in principle, I could use these via Nagios ……

That's the next step ….