Thursday, July 30, 2020

Viewing HTTP server information using SQL

view data about apache http server on ibm i

I want to give credit to IBM's Db2 for i team for continually adding SQL views, table functions, etc. to information that was not easy to get using APIs or other tools. Another example of their excellent work, introduced with the latest Technology Refreshes, is the view HTTP_SERVER_INFO. Previously this information was only available using the Web Administration for i GUI.

This view, which is located in the library QSYS2, displays information about the Apache server in the HTTP server for IBM i, and will only display data about the enabled and active functions.

As usual with my examples of Db2 for i views and table functions I am not going to list all of the available columns, just the ones I found interesting:

  1. SERVER_NAME:  Name of the HTTP server instance
  2. JOB_NAMEIBM i job name for the server
  3. HTTP_FUNCTION:  HTTP server function. Data for the function is returned only if it is active
  4. SERVER_RESTART_TIME:  Time the server was restarted. According to the documentation if the server had never been restarted then the result is null. In my experience I have found this value is the same as the one found in the column SERVER_START_TIME
  5. REQUESTS:  Number of requests received
  6. RESPONSES:  Number of responses sent
  7. ERROR_RESPONSES:  Number of error responses

For a list and description of all the columns in this view you can use the link to IBM's documentation at the bottom of this post.

Let me see what Apache servers are active on the partition I am using:

01  SELECT SERVER_NAME,
02         JOB_NAME,
03         HTTP_FUNCTION,
04         SERVER_RESTART_TIME,
05         REQUESTS,RESPONSES,
06         ERROR_RESPONSES
07    FROM QSYS2.HTTP_SERVER_INFO

Four rows were returned in the results:

SERVER_NAME  JOB_NAME               HTTP_FUNCTION
-----------  ---------------------  --------------
ADMIN        266174/QTMHHTTP/ADMIN  WEBSPHERE
ADMIN        266175/QTMHHTTP/ADMIN  SERVER HANDLED
ADMIN        266175/QTMHHTTP/ADMIN  CGI
ADMIN        266175/QTMHHTTP/ADMIN  SSL


SERVER_RESTART_TIME  REQUESTS  RESPONSES  ERROR_RESPONSES
-------------------  --------  ---------  ---------------
2020-08-02 09:22:37         1          1                0
2020-08-02 09:22:30       757        757              373
2020-08-02 09:22:30       106        106                0
2020-08-02 09:22:30       863        863              373

I am not sure how I would use this view, except for checking if a server was active.

01  SELECT SERVER_NAME,
02         HTTP_FUNCTION
03    FROM QSYS2.HTTP_SERVER_INFO
04   WHERE SERVER_NAME = 'ADMIN'

 

You can learn more about the HTTP_SERVER_INFO SQL View from the IBM website here.

 

This article was written for IBM i 7.4 TR2 and 7.3 TR8.

1 comment:

  1. I thought this was my answer to determine if my http server is running but, it turns out that entries only appear in this table if the server has received at least one request.

    ReplyDelete

To prevent "comment spam" all comments are moderated.
Learn about this website's comments policy here.

Some people have reported that they cannot post a comment using certain computers and browsers. If this is you feel free to use the Contact Form to send me the comment and I will post it for you, please include the title of the post so I know which one to post the comment to.