Prerequisites
- Download and install the Site24x7 Linux server monitoring agent in the server where the WordPress application is running.
- The plugin requires 'Curl' tool to fetch the statistics. Please ensure this tool is installed before using the plugin.
- Download and install the Site24x7 Linux server monitoring agent in the server where the WordPress application is running.
- The Site24x7 plugin integration uses the http://yourwebsite.com/wp-json/wp/v2/plugins WordPress API endpoint to fetch the WordPress plugins' status. If the user disabled the WordPress API, enable it for the aforementioned endpoint.
Plugin installation:
- Create a directory with the name "wordpress", under the Site24x7 Linux Agent's plugin directory - /opt/site24x7/monagent/plugins/
- Download the file ""wordpress.sh" from our GitHub repository and place it under the "wordpress" directory
- Commands to perform the above step:
cd /opt/site24x7/monagent/plugins/
mkdir wordpress
cd wordpress
wget https://raw.githubusercontent.com/site24x7/plugins/master/wordpress/wordpress.sh
Configure Apache to support statistics
- Edit your httpd.conf file so that it enables sending statistics. As mentioned at https://httpd.apache.org/docs/2.4/mod/mod_status.html#machinereadable
- Sample code for stats setup in the file "/usr/local/apache/conf/httpd.conf":
SetHandler server-statusOrder deny,allowDeny from allAllow from 127.0.0.1 ::1< /Location>
- Restart apache server and check wether the configured URL is receiving apache statistics by opening it in a browser
WordPress plugin configuration
- Now change the following values in the plugin file (copied to agent plugin's directory earlier):
"APACHE_STATS" to "ENABLED" ("DISABLED" by default)
- Enter your stats URL as specified while configuring Apache for statistics to the variable "APACHE_STATUS_URL". The final stats URL should contain "?auto" in the end as this is required to fetch the statistics from our agent
Sample value - APACHE_STATUS_URL="http://localhost:80/server-status?auto"
Monitor additional metrics
- To monitor additional metrics, edit the "wordpress.sh" file and add the new metrics that need monitoring
- Increment the plugin version value in the file "wordpress.sh" to view the newly added metrics ( For e.g., change the default plugin version from PLUGIN_VERSION = "1" to "PLUGIN_VERSION = "2")
- Create a folder named wordpress_plugin_performance.
- Download the wordpress_plugin_performance.py and the wordpress_plugin_performance.cfg files from our GitHub repository and place them in the wordpress_plugin_performance folder.
wget https://raw.githubusercontent.com/site24x7/plugins/master/wordpress_plugin_performance/wordpress_plugin_performance.pywget https://raw.githubusercontent.com/site24x7/plugins/master/wordpress_plugin_performance/wordpress_plugin_performance.cfg
- To check if the plugin is working, execute the command below with appropriate arguments and check for a valid JSON output with applicable metrics and their corresponding values.
python3 wordpress_plugin_performance.py --url="http://<Domain or Website>/wp-json/wp/v2/plugins" --username="<Wordpress UserName>" --app_password="<Application Password>"
- Add the applicable configurations in the wordpress_plugin_performance.cfg file:
[Wordpress Plugin Process]url = "http://<Domain or Website>/wp-json/wp/v2/plugins"username = "<Wordpress UserName>"app_password = "<Application Password>"
The http://yourwebsite.com/wp-json/wp/v2/plugins is the REST API endpoint for fetching the status of the WordPress plugins. Provide the equivalent endpoint with http or https://localhost or domain name/wp-json/wp/v2/plugins. Provide an equivalent URL used for your Wordpress setup.
In the above, ensure that the WordPress username is the administrator or a user with access to the REST API. Enter the application password generated in your WordPress site at Admin login > Users > All Users > Application Passwords. Do not enter the password of the user.
Generating an application passwordIf the user doesn't have an application password, follow the below steps to generate an application password:- Open your WordPress site and log in to the wp-admin page.
- Go to Users > All Users and click the username that you want to generate the application password for.
Note: Before generating the password, ensure that the user is an administrator or a user with access to the REST API.
- Scroll down to the bottom and find the option to generate application passwords. In the appropriate fields, provide the application name and click Generate Password.
- After generating the application password, add the applicable configurations in the wordpress_plugin_performance.cfg file.
- Move the wordpress_plugin_performance folder to the Site24x7 Linux server monitoring plugin directory: /opt/site24x7/monagent/plugins/
- Log in to Site24x7.
- Navigate to Plugins and click the required monitor.
Related Articles
- Redis Monitoring
- PostGres Monitoring
- Nagios Integration
- 100+ Integrations
- Create custom plugins: Linux and Windows