Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b2f3a2f
update docker init
axelhahn Jul 17, 2024
183720a
set variable types in classes
axelhahn Jul 17, 2024
19514d0
simplerrd: php 8 only: use typed variables
axelhahn Jul 17, 2024
5b3de7e
fix simplerrd changes
axelhahn Jul 17, 2024
5a82b3d
counteritems: php 8 only: use typed variables
axelhahn Jul 17, 2024
8dbc219
notification handler - php 8 only: use typed variables
axelhahn Jul 17, 2024
d460537
fix version in tinyservice
axelhahn Jul 17, 2024
8700f79
tiny-api: php 8 only: use typed variables
axelhahn Jul 18, 2024
1fcbc2a
set version in tinyapi
axelhahn Jul 18, 2024
ec98565
tinyrouter - php 8 only: use typed variables
axelhahn Jul 18, 2024
8618beb
update ahcache (from github.com branch)
axelhahn Jul 18, 2024
aa1fd58
update files in API folder
axelhahn Jul 18, 2024
a11cd30
update api files: description in help
axelhahn Jul 18, 2024
aafa2ae
update cdnorlocal
axelhahn Jul 19, 2024
cfba009
languag class: php 8 only: use typed variables
axelhahn Jul 19, 2024
28457f5
set version in UI class
axelhahn Jul 19, 2024
7fc0fe7
update readme
axelhahn Jul 19, 2024
b071231
fix dpcker error Archives directory /var/cache/apt/archives/partial i…
axelhahn Jul 19, 2024
08e9cb0
docker init script: add shell fixes
axelhahn Jul 19, 2024
d37b2f6
update ahcache class
axelhahn Jul 22, 2024
71aa95a
remove obsolete version number in docker compose file
axelhahn Jul 22, 2024
857fbe5
show info if there is no database container; speedup replacements
axelhahn Jul 22, 2024
863fa85
update docker-init
axelhahn Jul 22, 2024
0385c1b
update docs
axelhahn Jul 22, 2024
170b79f
update appmonitor client main classes
axelhahn Jul 22, 2024
b4a39d5
update docker init
axelhahn Jul 22, 2024
1ce43e6
update local.php in client
axelhahn Jul 22, 2024
07e42a9
update docs
axelhahn Jul 22, 2024
acd1210
update client
axelhahn Jul 22, 2024
df59be3
apacheprocesses: php 8 only: use typed variables
axelhahn Jul 23, 2024
19adefe
php 8: short array syntax
axelhahn Jul 23, 2024
3dc99bd
cert: php 8 only: use typed variables
axelhahn Jul 23, 2024
72c69a6
checks - php 8 only: use typed variables
axelhahn Jul 23, 2024
1e06b1f
update md docs: short array syntax, fix tables, unneeded spaces and e…
axelhahn Jul 23, 2024
e62bad9
update short array syntax
axelhahn Jul 23, 2024
e4b45ce
fix rrd class for initial usage without data
axelhahn Jul 23, 2024
63c8cfb
generate class docs for client and server files
axelhahn Jul 23, 2024
1c8ed78
update quoting + shellcheck fixes
axelhahn Jul 23, 2024
618d228
add check
axelhahn Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
270 changes: 178 additions & 92 deletions docker/init.sh

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docker/templates/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# (2) run "docker-compose up" to startup
#
# ======================================================================
version: '3.9'

networks:
{{APP_NAME}}-network:

Expand Down
8 changes: 7 additions & 1 deletion docker/templates/web-server-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
#
FROM php:{{APP_PHP_VERSION}}-apache

# install packages old
# RUN apt-get update && apt-get install -y {{APP_APT_PACKAGES}}

# install packages
RUN apt-get update && apt-get install -y {{APP_APT_PACKAGES}}
RUN rm -rf /var/lib/apt/lists/*
RUN mkdir -p /var/cache/apt/archives/partial
RUN apt-get update
RUN apt-get install -y {{APP_APT_PACKAGES}}

# enable apache modules
RUN a2enmod {{APP_APACHE_MODULES}}
Expand Down
9 changes: 4 additions & 5 deletions docs/20_💡_How_does_it_work.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[TOC]
# How does it work? #
## How does it work?

The appmonitor is a monitoring tool that consists of 2 parts

- **client** (for each webapplication to check)
- is executed on a incoming http request (there is no agent)
- makes necessary checks for the full functionality of a website
- makes necessary checks for the full functionality of a website
- uses the credentials of the application
- responds information as JSON
- more: [Client](20_Client/10_Introduction.md) , [PHP-Client](30_PHP-client/10_Introduction.md)
Expand All @@ -23,15 +22,15 @@ The health-check is done from the view of the application server.

The client sends back a result in JSON format.

# Clients #
## Clients

For PHP applications a client with pre defined checks is delivered.

For Non-PHP clients you need to write your own checks and create a response in the pre defined syntax.

![Client](images/appmonitor-overview-client.png "Client")

# Server #
## Server

After collecting all results it stores the results. It renders a web gui and sends notifications.

Expand Down
20 changes: 10 additions & 10 deletions docs/40_📦_Server/10_Installation.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Requirements #
## Requirements

- PHP7 or 8 (up to 8.3)
- php-curl

# Installation #
## Installation

## Install the server ##
### Install the server

Below a document root of a website create a directory [webroot]/appmonitor/ (sure it works to install the server into webroot too).

- download zip file from Github: https://github.com/iml-it/appmonitor
- create a subdir "appmonitor" below your webroot
- download zip file from Github: <https://github.com/iml-it/appmonitor>
- create a subdir "appmonitor" below your webroot
- extract all files of the public_html subdir from this archive into [webroot]/appmonitor/
- verify the installation with your browser
<http://localhost/appmonitor/server/>
You will see a welcome message.
- Go to the setup.
- Add the url <http://localhost/appmonitor/client/check-appmonitor-server.php> to integrate a first check.

## Install server with git ##
### Install server with git

To use git you need access to the webserver configuration to be able to define a webroot that must point to the public_html folder.

Expand All @@ -38,7 +38,7 @@ You will see a welcome message. Go to the settings page and add this url:
`http://localhost/client/check-appmonitor-server.php`
This is the self check of the appmonitor server.

## Using a Docker container ##
### Using a Docker container

The repository includes my development environment.

Expand All @@ -60,7 +60,7 @@ cd appmonitor
./docker/init.sh
```

There you have a menu.
There you have a menu.

```txt
>>>>> MENU
Expand Down Expand Up @@ -98,11 +98,11 @@ In the webbrowser open <http://localhost:8001/>. You will see a welcome message.
`http://localhost/client/check-appmonitor-server.php`
This is the self check of the appmonitor server.

## Production use ##
### Production use

If you are happy with the first clicks around then continue the next chaprters.

# Used 3rd party tools #
## Used 3rd party tools

I use several libraries to save time and to use stable components. I just wanna say thank you to all of them.

Expand Down
42 changes: 20 additions & 22 deletions docs/40_📦_Server/20_Configuration.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
## Configuration

# Configuration #

The config is in json syntax. The files are located in
The config is in json syntax. The files are located in
_[webroot-appmonitor]/server/config/appmonitor-server-config.json_

File | Description
--- |---
appmonitor-server-config.json | Custom settings
appmonitor-server-config-defaults.json | DO NOT OVERWRITE - Defaultsetup

On the first start of the web gui the defaults will be used.
On the first start of the web gui the defaults will be used.
By entering a first client appmonitor url the user config will be written.

If you would like to setup it manually without webgui then copy
If you would like to setup it manually without webgui then copy
appmonitor-server-config-defaults.json to appmonitor-server-config.json
(same name - without "-defaults")

Expand Down Expand Up @@ -92,7 +91,7 @@ _urls_ | \{array\} list of urls

The values with arrays are described below.

## api ##
### api

Configure api access.

Expand All @@ -117,32 +116,32 @@ Example:
...
```

## curl ##
### curl

Curl settings.

Here can be the subkeys

- `timeout`: integer value in seconds; default is 15. If you use a service then you can tweak: set servicecache to true and a higher timeout in curl -> timeout

## notifications ##
### notifications

notification targets (optional)

Here can be the subkeys

- `email`: flat list of email addresses that get notifications for *\*all\** added applications. Maybe you want to add devops and sysadmins here.
- `email`: flat list of email addresses that get notifications for \*\*all\*\* added applications. Maybe you want to add devops and sysadmins here.
- `slack`: key-value list with a readable label for the target channel and the Slack webhook url.
- `from`: sender information which user is delivering notifications ... in the subkeys
- `from`: sender information which user is delivering notifications ... in the subkeys
- `email`: email address for notifications (is reply-to address too)
- `slack`: sender name ("Appmonitor" is default)
- `sleeptimes`: flat array of time definitions when no notification will be sent. Each entry is a regex. If any matches the current system time (PHP function date("Y-m-d D H:i") - it returns the date in YYYY-MM-DD, the short weekday plus hour, ":" and minutes: "2018-07-04 Mon 09:23"). Pay attention to the dividers: "-" is used for dates and ":" to divide hour and minute. The example will disable Notifications:
- `/(Sat|Sun)/` --> Saturday and Sunday
- `/[2][1-3]<span class="mark">:</span>/` --> digit 2 + 1..3 before ":" --> daily from 21:00-23:59
- `/[0][0-4]<span class="mark">:</span>/` --> digit 0 + 0..4 before ":" --> daily from 00:00-04:59
- `/[2][1-3]:/` --> digit 2 + 1..3 before ":" --> daily from 21:00-23:59
- `/[0][0-4]:/` --> digit 0 + 0..4 before ":" --> daily from 00:00-04:59
- other examples
- `/2018<span class="mark">-</span>08<span class="mark">-</span>01/` --> disable notification on complete 1st of August 2018 (Swiss holiday)
- `/[0-9]{4}<span class="mark">-</span>12<span class="mark">-</span>/` --> 4 digits is a year then "minus" + month 12 --> disables notification in December of each year
- `/2018-08-01/` --> disable notification on complete 1st of August 2018 (Swiss holiday)
- `/[0-9]{4}-12-/` --> 4 digits is a year then "minus" + month 12 --> disables notification in December of each year

```json
...
Expand All @@ -164,15 +163,14 @@ Here can be the subkeys
...
```

## users ##
### users

The users section defines users and its roles to access the api or web ui.
The subkey is the user id of a user. There are special user ids:

The subkey is the user id of a user. There are 2 special user ids:

* `*` - contains the roles for anonymous access
* `__default_authenticated_user__` - default roles for an by the webserver authenticated user
* `[userid]` - a user id for api or web ui access. Allowed chars are a-z (lowercase) and 0-9.
- `*` - contains the roles for anonymous access
- `__default_authenticated_user__` - default roles for an by the webserver authenticated user
- `[userid]` - a user id for api or web ui access. Allowed chars are a-z (lowercase) and 0-9.

If you create your first user then copy the entries for \* and __default_authenticated_user__ from default config.

Expand All @@ -197,7 +195,7 @@ php -r 'echo password_hash("your-password-here", PASSWORD_BCRYPT);'

BUT: we recommend to use webservers protection with basic authentication for better performance.

All users without password field or *password: false* will match for users with webservers basic authentication.
All users without password field or `password: false` will match for users with webservers basic authentication.

Existing roles:

Expand Down Expand Up @@ -237,6 +235,6 @@ Example:
...
```

## urls ##
### urls

The urls key is a flat list of urls to fetch appmonitor checks.
45 changes: 21 additions & 24 deletions docs/40_📦_Server/30_Notification.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

# Notification #

## Introduction ##
## Introduction

Notifications will be triggered if ...

Expand All @@ -25,7 +22,7 @@ config are global receivers getting the notifications for all applications.
When sending a notification it loops over all known notification plugins
and sends messages with all methods as long a TO item exists.

### Email ##
### Email

* **FROM** address is taken from server config notification -> from -> email
* **TO** is an array of email addresses; they are merged from
Expand All @@ -38,7 +35,7 @@ For more details to the subject and message see the section for message texts be

The email is send as plain text and high priority.

### Slack ###
### Slack

* FROM - not needed
* **TO** is an array with label + url as items; they are merged from
Expand All @@ -50,7 +47,7 @@ The email is send as plain text and high priority.
A slack message ist using "[APPMONITOR]" as sending user without icon.
As message text it takes the same generated text like for the email.

## Message texts ##
## Message texts

The sent messages are language dependent texts and the appmonitor is
shipped with a default. In the language file they are defined in the subkey "notifications".
Expand Down Expand Up @@ -81,30 +78,30 @@ As an example a snippet from server/lang/en-en.json:

These texts can contain placeholders.

| Placeholder | Description |
|--- |--- |
| _\_\_APPID___ | Id of application |
| _\_\_CHANGE___ | One of new\|no change\|change\|deleted (1) |
| _\_\_CURLERROR___ | Error message from curl library if the request failed. |
| _\_\_DELTA-TIME___ | Delta since last state change i.e. NN min (HH h) (2) |
| _\_\_ERROR___ | Error message of a failed response |
| _\_\_HEADER___ | Http response header (maybe for an email message) |
| _\_\_HOST___ | Hostname (from client meta -> host) |
| _\_\_LAST-RESULT___ | Result of last check; see RESULT (2) |
| _\_\_LAST-TIME___ | Time of last check; see TIME (2) |
| _\_\_MONITORURL___ | Url to monitoring page (3) |
| _\_\_RESULT___ | One of OK\|Unknown\|Warning\|Error (1) |
| _\_\_TIME___ | Current time YYYY-MM-DD hh:mm:ss |
| _\_\_URL___ | Url of web application check |
| _\_\_WEBSITE___ | Name of the website/ service (from client meta -> website) |
| Placeholder | Description
|--- |---
| _\_\_APPID___ | Id of application
| _\_\_CHANGE___ | One of new\|no change\|change\|deleted (1)
| _\_\_CURLERROR___ | Error message from curl library if the request failed.
| _\_\_DELTA-TIME___ | Delta since last state change i.e. NN min (HH h) (2)
| _\_\_ERROR___ | Error message of a failed response
| _\_\_HEADER___ | Http response header (maybe for an email message)
| _\_\_HOST___ | Hostname (from client meta -> host)
| _\_\_LAST-RESULT___ | Result of last check; see RESULT (2)
| _\_\_LAST-TIME___ | Time of last check; see TIME (2)
| _\_\_MONITORURL___ | Url to monitoring page (3)
| _\_\_RESULT___ | One of OK\|Unknown\|Warning\|Error (1)
| _\_\_TIME___ | Current time YYYY-MM-DD hh:mm:ss
| _\_\_URL___ | Url of web application check
| _\_\_WEBSITE___ | Name of the website/ service (from client meta -> website)

Remarks:

* (1) this depends on the set appmonitor server language. The values are these of the English version.
* (2) It requires that a saved state with another status for this url. Value is "-" if there is no state change logged yet
* (3) requires a value for "serverurl" in the config

To preview the texts you can
To preview the texts you can

* set "debug" to true in you config
* add role "ui-debug" for your user in ./server/config/appmonitor-server-config.json
Expand Down
8 changes: 5 additions & 3 deletions docs/40_📦_Server/40_Service.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## Introduction

The server instance can be used by just using the web interface. For your first tests you don't need a running service. But it is highly recommended for a production use.

The service that is a permanently running loop that fetches updated information of the outdated client data and sends notification data around the clock (respecting the sleep times).

# Run as systemd service #
## Run as systemd service

This method works on newer Linux OS with systemd, i.e. CentOS 7.

Expand Down Expand Up @@ -34,13 +36,13 @@ Check it with

Then work these commands:

```
```shell
systemctl start appmonitor
systemctl status appmonitor
systemctl stop appmonitor
```

# Manual start #
## Manual start

This method does runs on all OS (MS Windows, Mac, Linux).

Expand Down
Loading