Skip to content

Commit

Permalink
Merge pull request #97 from iml-it/add-wordpress
Browse files Browse the repository at this point in the history
Add wordpress
  • Loading branch information
axelhahn authored Jul 31, 2024
2 parents 3d766c0 + 7f02891 commit 1e600ba
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 18 deletions.
4 changes: 3 additions & 1 deletion docs/60_📃_PHP-client/50_Groups_of_checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ This is work in progress.

In the folder plugins/apps are the files that contain grouped checks for a few applications.

In a check script instead of writing single checks unclude the bundle:
In a check script instead of writing single checks include the bundle:

```php
// set variable sApproot
$sApproot = $_SERVER['DOCUMENT_ROOT'];
// include default checks for an application
@require 'plugins/apps/[name-of-app].php';
```
86 changes: 86 additions & 0 deletions docs/60_📃_PHP-client/60_Plugins/10_Apps/Wordpress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
## Wordpress

### Minimal variant

The following steps describe a first (and most simple) approach for a Wordpress monitoring with IML appmonitor.

If you have installed ...

* Wordpress directly into `[webroot]`
* the appmonitor client in `[webroot]/appmonitor/`.

Create a file `[webroot]/appmonitor/minimal.php` with this content:

```php
<?php
$sApproot = $_SERVER['DOCUMENT_ROOT'];
@require 'plugins/apps/wordpress.php';
```

If wordpress was installed in a subdirectory you need to set its path, eg.

```php
$sApproot = $_SERVER['DOCUMENT_ROOT'].'/wordpress';
```

Then request this file, eg. <https://example.com/appmonitor/minimal.php>. You should get a JSON response.

If so then add this url in Appmonitor server. Done.

!!! "Note"
This is the most simple variant and just a quick winner.
You cannot customize the builtin checks or other metadata.

### Customize checks

This is the preferred variant. You can...

* set metadata:
* name of the instance (website)
* customize the ttl
* set an app specific contact that will be informed on errors
* add additional checks

Approach:

* initialize the appmonitor class
* set wanted metadata
* include the app plugin for wordpress
* add your own checks
* send the response

Create a file `[webroot]/appmonitor/check-wordpress.php` with this content:

```php
<?php

// ----------------------------------------------------------------------
// initialize
require_once('classes/appmonitor-client.class.php');
$oMonitor = new appmonitor();

// ----------------------------------------------------------------------
// set metadata
// $oMonitor->setWebsite('My wordpress Blog');
// $oMonitor->setTTL(300);
// $oMonitor->addTag('production');

// ----------------------------------------------------------------------
// include the app plugin for wordpress
$sApproot = $_SERVER['DOCUMENT_ROOT'];
@require 'plugins/apps/wordpress.php';

// ----------------------------------------------------------------------
// add your custom checks
// $oMonitor->addCheck(...)

// ----------------------------------------------------------------------
// send the response

$oMonitor->setResult();
$oMonitor->render();

// ----------------------------------------------------------------------
```

Check it with <https://example.com/appmonitor/check-wordpress.php>.
13 changes: 8 additions & 5 deletions docs/60_📃_PHP-client/60_Plugins/10_Apps/_index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Plugins/apps folder #
<html>
<div class="hero">
<h2>Plugins/apps/ folder</h2>
In the folder plugins/apps are the files that contain grouped checks for a few applications.
</div>
</html>

In the folder plugins/apps are the files that contain grouped checks for a few applications.

Remark:
### Remark

This is work in progress. Currently a few groups for products are in the repository

https://github.com/iml-it/appmonitor-clients
<https://github.com/iml-it/appmonitor-clients>
9 changes: 6 additions & 3 deletions docs/60_📃_PHP-client/60_Plugins/20_Checks/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Plugins/checks folder #

In the folder plugins/checks/ are the files that contain the logic of a single check.
<html>
<div class="hero">
<h2>Plugins/checks/ folder</h2>
In the folder plugins/checks/ are the files that contain the logic of a single check.
</div>
</html>

## Included checks ##

Expand Down
25 changes: 16 additions & 9 deletions public_html/client/index.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,33 @@
*
*/

// ----------------------------------------------------------------------
// initialize
require_once('classes/appmonitor-client.class.php');
$oMonitor = new appmonitor();

// set a name with application name and environment or hostname
$oMonitor->setWebsite('[My CMS on host XY]');

// how often the server should ask for updates
$oMonitor->setTTL(300);
// ----------------------------------------------------------------------
// set metadata
// $oMonitor->setWebsite('My wordpress Blog');
// $oMonitor->setTTL(300);
// $oMonitor->addTag('cms');
// $oMonitor->addTag('production');

// a general include ... the idea is to a file with the same actions on all
// installations and hosts that can be deployed by a software delivery service
// (Puppet, Ansible, ...)
@include 'general_include.php';

// add any tag to add it in the filter list in the server web gui
// $oMonitor->addTag('cms');
// $oMonitor->addTag('production');

// ----------------------------------------------------------------------
// include the app plugin

// set variable sApproot
// $sApproot = $_SERVER['DOCUMENT_ROOT'];

// include default checks for an application
// @require 'plugins/apps/[name-of-app].php';

// ----------------------------------------------------------------------
// add a few custom checks
// $oMonitor->addCheck(...)
$oMonitor->addCheck(
Expand All @@ -48,8 +52,11 @@
);

// ----------------------------------------------------------------------
// send the response

$oMonitor->setResult();
$oMonitor->render();

// ----------------------------------------------------------------------

// ----------------------------------------------------------------------

0 comments on commit 1e600ba

Please sign in to comment.