IBM Performance Management

Configuring the Python agent

You must configure the Monitoring Agent for Python so that the agent can collect data from the Python application that is being monitored.

Before you begin

Ensure that the Apache HTTPD server is started before you configure the agent.

Open the Apache HTTPD server httpd.conf configuration files and ensure that mod_status is loaded.

Make sure the command apachectl status works properly in the monitored Apache server with no code changes to the httpd.conf configuration file. If it doesn't work fine you might not be able to see some metrics in the dashboards, for example, Busy worker and Idle worker.
Note: You must have Lynx installed for the command apachectl status work properly. For more information about enabling the command, see apachectl - Apache HTTP Server Control Interface.
If this is not the first time you configure the agent instance, follow the steps:
  1. Stop the agent instance.
  2. Follow one of the procedures to configure the agent instance:
  3. Make sure that the new middleware is deployed to the Django setting folder. To do that, make sure the kpg_numeric_string.py file in the Django setting folder is updated.
  4. Restart the Apache server.

About this task

To avoid permission issues when you configure the agent, be sure to use the same root user or non-root user ID that was used for installing the agent. If you installed your agent as a selected user and want to configure the agent as a different user, see Configuring agents as a non-root user. If you installed and configured your agent as a selected user and want to start the agent as a different user, see Starting agents as a non-root user.

The Python agent is a multiple instance agent; you must create the first instance and start the agent manually. The Managed System Name includes the instance name that you specify, for example, instance_name:host_name:pc, where pc is your two character product code. The Managed System Name is limited to 32 characters. The instance name that you specify is limited to 28 characters, minus the length of your host name. For example, if you specify Python2 as your instance name, your managed system name is Python2:hostname:PG.
Important: If you specify a long instance name, the Managed System name is truncated and the agent code does not display correctly.

Procedure

What to do next

After you start the agent instance, an injection script to customize your monitoring middleware is generated and provided in a temporary directory.

The injection shell script runs automatically after the agent starts. If you want to make sure that this step was correctly executed, you can make sure that the following files exist:
  • install_dir/tmp/kpg/inject_numeric_string.sh
  • Django_setting_folder/kpg_numeric_string.py
Important: The suffix numeric string identifies a Django application. If you have multiple injection scripts that were generated in that temp folder, you see the same number of kpg_numeric_string.py files.
Generally, an injection script does the following jobs:
  • Backs up the original WSGI setting file for each Django application.
  • Copies the customized WSGI setting file to override the original file
  • Moves the customized middleware to the Django application folder.
  • Enables module status for Apache server.
The injection script also generates the uninstallation scripts to help you uninstall the middleware from each Django application.
Note: Multiple injection scripts might include the enablement of the Apache status module, however, when executing the scripts the module is only added once.
For your reference, you can use the following stop and restart commands for the Apache server:
  • Stop: apache_bin_directory/httpd -k graceful-stop
  • Restart: apache_bin_directory/httpd -k graceful