Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
  • v0.1
2 results

Target

Select target project
No results found
Select Git revision
  • main
  • v0.1
2 results
Show changes

Commits on Source 4

9 files
+ 77
12
Compare changes
  • Side-by-side
  • Inline

Files

Original line number Diff line number Diff line
@@ -7,11 +7,11 @@
  |     |     |  |      ___ ___ ___|     |___ ___|_| |_ ___ ___ 
  |-   -| | | |  |__   | .'| . | . | | | | . |   | |  _| . |  _|
  |_____|_|_|_|_____|  |__,|  _|  _|_|_|_|___|_|_|_|_| |___|_|  
                           |_| |_|                              
                                               CLI client v0.7
                           |_| |_|             CLI client v0.8


This client performs appmonitor checks and puts the results as JSON to stdout.
It contains all checks that are available in the PHP appmonitor client.
It contains all checks that are available in the PHP appmonitor client v0.155.
You can use the compiled binary to monitor any non PHP webapp without 
implementing the checks for your programming language.

Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ On my test system I've installed with Chocolatey:
* PHP 8.4.4
* Wget

During install the spc build process failed while compiling `libiconv`.
🤕 During install the spc build process failed while compiling `libiconv`.
I will continue if I found a solution or it.

## Prepare environment
+3 −1
Original line number Diff line number Diff line
<html>
<div class="hero">
    <h2>Appmonitor CLI</h2>
    Cli client of IML appmonitor for non PHP web projects
    Compiled cli client of IML appmonitor for non PHP web projects
</div>
</html>

It is a sister project for <https://github.com/iml-it/appmonitor>.

👤 Author: Axel Hahn; Institute for Medical Education; University of Bern \
📄 Source: <https://git-repo.iml.unibe.ch/iml-open-source/appmonitor-cli-client> \
📜 License: GNU GPL 3.0 \
+7 −0
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ $aFiles2Merge=array_merge(
    [
        "$dirExternal/appmonitor/public_html/client/classes/appmonitor-checks.class.php",
        "$dirExternal/appmonitor/public_html/client/classes/appmonitor-client.class.php",
        "$dirExternal/appmonitor/public_html/client/classes/validateparam.class.php",
        // "$dirExternal/appmonitor/public_html/client/classes/validateparam.settings.php",
    ],
    glob("$dirExternal/appmonitor/public_html/client/plugins/checks/*php")
);
@@ -128,14 +130,19 @@ $out="<?php
*/
";

$sValidationRules=file_get_contents("$dirExternal/appmonitor/public_html/client/classes/validateparam.settings.php");
// echo "$sValidationRules"; die();

foreach($aFiles2Merge as $sMyFile){
    $sSource=file_get_contents($sMyFile);
    $sSource=preg_replace(
        [
            "/include 'validateparam.settings.php';/",
            "/(require[\ \_].*;)/",
            "/(\<\?php)/"
        ], 
        [
            $sValidationRules,
            "// REMOVED-BY-MERGER: $1",
            "",
        ], 
+3 −1
Original line number Diff line number Diff line
# POC Appmonitor client cli
# Appmonitor client as cli binary

💡 **Idea**: For non PHP systems we prepare a compiled binary containing all written PHP checks. Then those non PHP systems do not need to implement the checks again.

It is a sister project for <https://github.com/iml-it/appmonitor>.

👤 Author: Axel Hahn; Institute for Medical Education; University of Bern \
📄 Source: <https://git-repo.iml.unibe.ch/iml-open-source/appmonitor-cli-client> \
📜 License: GNU GPL 3.0 \
+56 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
 * 2025-03-14  v0.6    add meta tags, check count+visual; add _json2array()
 * 2025-03-17  v0.7    update help
 * 2025-03-17  v0.8    check missing 'function' in check. get php client version
 * 2025-03-20  v0.9    add --explain; hardening using more intensive validation
 * ======================================================================
 */

@@ -28,7 +29,7 @@ $argc = $_SERVER['argc'];
$argv = $_SERVER['argv'];

$FLAG_DEBUG = 0;
$VERSION = "0.8";
$VERSION = "0.9";
$PHPCLIENTVERSION = "not-detected";

$AMCLI_BUILD_DATE = "never";
@@ -145,6 +146,8 @@ You find example snippets in the source code of this project in tests/config/.
    -v, --verbose     Enable verbose output (written to STDERR)

    -b, --buildinfos  show build information and exit
    -e, --explain <CHECK>
                      Explain a check and exit
    -l, --list        list available checks and exit
    -m, --modules     list available Php modules in this binary and exit
    -V, --version     Show version and exit
@@ -248,6 +251,49 @@ if (isset($ARGS['-h']) || isset($ARGS['--help'])) {

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

// explain
if (isset($ARGS['-e']) || isset($ARGS['--explain'])) {
    $sCheckname=$inifile = $ARGS["--explain"] ?? ($ARGS["-e"] ?? "");
    _wd("Explain check '$sCheckname'");
    $sCheckClass = "check$sCheckname";
    if (!class_exists($sCheckClass)) {
        echo "❌ ERROR: Check '$sCheckname' does not exist. Use -l to list existing checks.\n";
        exit(8);
    }
    $oPlugin = new $sCheckClass;
    if (!method_exists($oPlugin,"explain")){
        echo "❌ ERROR: Check '$sCheckname' has no method explain (yet).\n";
        exit(9);
    }
    $a=$oPlugin->explain();
    // print_r($a);
    echo "\e[90m
; -----------------------------------------------------------------------------
;
; $a[name]
; $a[description]
;\e[0m
\e[34m[<Your check name>]\e[0m
description=\"A short description what will be tested\"
function=\"$sCheckname\"

";
    foreach($a['parameters'] as $sKey => $aInfos){
        echo "\n";
        echo "\e[90m; key '$sKey' "
            .($aInfos['type']??false ? "{" .$aInfos['type'] ."}" : ' (type not provided)')
            ." "
            .($aInfos['required']??false ? '🔸(required)' : '🔹(optional)')
            . "\n";
        echo "; $aInfos[description]\n";
        echo "; example: ".($aInfos['example']??false ? $aInfos['example'] : '(not provided)') . "\n";
        echo "; default: ".($aInfos['default']??false ? $aInfos['default'] : '(not provided)') . "\e[0m\n";
        echo "params[$sKey]=<Your value here>\n";
    }
    echo "\n\n";
    exit(0);
}


// show builtin checks
if (isset($ARGS['-l']) || isset($ARGS['--list'])) {
@@ -280,6 +326,15 @@ if (!file_exists($inifile)) {

try {
    $aIni = parse_ini_file($inifile, true);
    array_walk_recursive($aIni, function(&$value, $key)
    {
        if(is_numeric($value))
        {
            $value = (string)((int)$value)===$value
                ?(int)$value
                :(double)$value;
        }
    });
} catch (Exception $e) {
    echo "❌ ERROR: INI File '$inifile' could not be parsed.\n";
    exit(5);
Original line number Diff line number Diff line
@@ -2,6 +2,6 @@
<?php

echo "
WHAT: Run check sqlite connect
WHAT: Run check apache processes
";
_exec("$AMCLI --ini='".__DIR__."/configs/apacheprocesses.ini'");
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ function="File"
params='{
    "filename": "/tmp",
    "exists": true,
    "flag": "dir",
    "dir": true,
    "readable": true,
    "writable": true
}'
@@ -28,8 +28,7 @@ description="Check non existing maintenance flag file"
function="File"
params='{
    "filename": "/some/where/maintenance.txt",
    "exists": false,
    "flag": "file"
    "exists": false
}'

; -----------------------------------------------------------------------
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ params='{
    "user": "root",
    "password": "12345678",
    "db": "ahcrawler",
    "port": "13306"
    "port": 13306
}'

; -----------------------------------------------------------------------