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:
- Which TCP/IP port numbers are currently in use (Port is listening)?
- Is the MariaDB server running?
- Why can’t I connect to the IBM i with SSH?
- Can I use port 1234 for my new applicaion?
- Is a group of jobs are running?
- What is in the log for a job running on a certain port?
- 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.
yum install service-commander
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.
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
sc check group:apache
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;
Please note that to place definitions in the above directory, you will need *ALLOBJ authority.
Or a user directory of;
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.
scinit node ./bin/www
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
sc start weather
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
sc loginfo weather
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.
sc perfinfo weather
To follow on, use sc stop weather to end this application.
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.
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.
That certainly cut the list down!
scopenports is certainly my favourite Service Commander utility by a long way. A much used feature here.
Another great addition to the open source on IBM i catalogue. It’s great to see IBM contributing and giving worth and credibility to Open Source.
All the examples I have written for this article, and previous ones, can be found on my open-source repository on GitHub, which can be found at https://github.com/AndyYouens/f_Learning
If you have any questions, either on this article, or anything else on the IBM i, use the comments below, or send me a message on twitter @AndyYouens
Andy Youens is an IBM i consultant/instructor at Milton Keynes, UK-based FormaServe Systems with over 40 years IBM midrange experience.
IBM Champion 2021
Leave a Reply