FormaServe Training

Welcoming the IBM Community

Service Commander on IBM i

5
(1)

In this article I will talk about another great open-source utility for our IBM i.

Firstly, what a great name!

Service commander was developed by Jesse Gorsinski, the business architect of open source on IBM i.

The github repository for Service Commander can be found at https://github.com/ThePrez/ServiceCommander-IBMi

Check-out this repository, not only to see the coding, but additionaly, the documentation is very helpful. 

There is also a quick tutorial, with hands on exercises to help you learn, and get the full benefits from Service Commander.  This can be found at https://github.com/ThePrez/ServiceCommander-IBMi/blob/main/quickstart/HANDS_ON.md

Service Commander is a command line utility, that is run from a SSH shell session, that helps manage services and applications running on IBM i.

It can answer the following questions we may have:

  1. Which TCP/IP port numbers are currently in use (Port is listening)?
  2. Is the MariaDB server running?
  3. Why can’t I connect to the IBM i with SSH?
  4. Can I use port 1234 for my new application?
  5. Is a group of jobs are running?
  6. What is in the log for a job running on a certain port?
  7. Are all my companies applications running ?

Installing Service Commander

Service Commander is installed on your IBM i by using yum.  From a shell session run the command listed below.

Bash

yum install service-commander
Bash

As with other open-source packages, you can install Service Commander using Open Source Package Management from ACS.  Here you can see I have the Service Commander package installed at version 1.1.

Configuration

Service commander can be used straight out of the box, but there is the ability to configure it to your own requirements.

It has already been configured for common system services, like the IBM i host services and the HTTP administration interfaces.

If I wanted to check the default Apache group, I would run the command

Bash

sc check group:apache
Bash

Every defined apache instance will then be reported on. 

This can be seen in the figure below.

Wow, forgot I had an old version of Zend Server still configured (can be seen on the last line!)

For example, we have a few node applications that we need to be up and running at all times.

We could create a service commander group that will check on the status of these applications.

Format of Yaml Files

Service Commander uses YAML files for its configuration. 

For those who have never come across these files, they are just normal text files, that use keywords for definitions, often used for configuration/settings.

If we look at the configuration for the SSH server we can see

Check out the GitHub repo for full details of all the keywords available in these configuration files.

These configuration files can either reside in a system directory of;

Bash

/QOpenSys/etc/sc/services
Bash

Please note that to place definitions in the above directory, you will need *ALLOBJ authority.

Or a user directory of;

Bash

your_home_directory/.sc/services
Bash

To set up your own definitions run the scinit command.

Configure a New SC Definition

To configure one of our applications here, to use Service Commander, we need to run the scinit command, with the name of the program used to run our application and the start-up script.

Bash
scinit node ./bin/www
Bash

In this example, node is used to start the node.js program www in the /bin directory.

Then we need to answer the questions that Service Commander needs to manage our application.

Once we have answered all the questions, Service Commander will write a YAML file to my home directory and it will know all about our application.

To start this application, just run the following command

Bash

sc start weather
Bash

our weather app is now running, so we had better check it!

Yes, all looking good.

If I need to check the console log of this application, we can use Service Commander to achieve this.

Run the command

Bash

sc loginfo weather
Bash

as can be seen in the figure below, it instructs us to run the tail command, which in turn shows the console log for this application.

While we are monitoring this application, we can see basic performance details here too.

Bash
sc perfinfo weather
Bash

To follow on, use sc stop weather to end this application.

Top-Tip

Do you have the excellent man utility on your box, if not, why not!  Grab it from ACS Open-Source Package Management.

See my previous PowerWire article Where’s that manual gone?  for more details about man.

Using man, we can see the manual for Service Commander.

Bash

man sc
Bash

Open Ports

In my opinion, one of the most useful commands in this package is the scopenports utility.  It reports, in a three column table, which ports are currently in use on your server. 

All very useful in deciding which port to use in a new application or to check if your application is running on the desired port.

The scopenports command can be seen below.

This utility can also be run to only show which ports were opened by your user profile.  Just add the –mine argument to the utility.

Bash
scopenports –mine
Bash

That certainly cut the list down!

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *