diff --git a/TODO.md b/TODO.md index eaa02fb1be5d4be51e968be0a1e60969dc7266bc..4937271852e7d869faad2b9aa548a92439b03f55 100644 --- a/TODO.md +++ b/TODO.md @@ -3,35 +3,45 @@ was ich so sehe ... ✅ Slack-Notifikation: statt Parsing-mechanismus eines Strings --> JSON in der INI schreiben + ✅ `--ini=<FILE>` bei relativem Pfad ist relativ zum Binary --> nicht ins eigene Verzeichnis wechseln + ⬜ Dokumentation + ⬜ Code aufräumen ## Tests schreiben ✅ Test auf gesetzte Metadaten + ⬜ für alle Checks einen Test schreiben ⬜ ApacheProcesses - ✅ Cert - ✅ Diskfree + ✅ Cert --> Hostname bei Wildcard-Zertifikat wird nicht erkannt + ✅ Diskfree --> preg_replace hat den Integer Wert noch geholt ✅ Exec - ⬜ File --> "exists": false meldet bei Test einer nicht existierenden Datei fälschlicherweise einen Fehler + ✅ File --> "exists": false meldet bei Test einer nicht existierenden Datei fälschlicherweise einen Fehler ✅ Hello ✅ HttpContent ✅ Loadmeter - ⬜ MysqlConnect - ⬜ PdoConnect + ✅ MysqlConnect -> mysqli->real_connect() Fatal error: Uncaught mysqli_sql_exception: No such file or directory + ✅ PdoConnect ⬜ Phpmodules ⬜ Ping ⬜ PortTcp ⬜ Simple ⬜ SqliteConnect +⬜ parent Option testen + +⬜ group testen + ## Done ✅ PHP compiliert zum Binary + ✅ Binary startet in einem fremden Verzichnis + ✅ Binary startet auf einen Nicht-PHP-System --- diff --git a/inc_vars.php b/inc_vars.php index 2fdeb032d7b50e92d2ec1c75ffee45a893fc4494..498f5b2a8244706a7fe83d7da10657e67e5022b7 100644 --- a/inc_vars.php +++ b/inc_vars.php @@ -1,7 +1,9 @@ <?php $php_version="8.3"; -$php_libs="zlib"; + +// extensions - see https://static-php.dev/en/guide/extensions.html +$php_libs="mysqli,openssl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,zlib"; $myos=strtolower(PHP_OS); $myarchitecture="x86_64"; diff --git a/tests/00_start.php b/tests/00_start.php index bb0df25c5755da3d25aa2cff3a3baf9bd207f541..416a2bd09791082c813d053dfac7b04d89d2da49 100755 --- a/tests/00_start.php +++ b/tests/00_start.php @@ -5,6 +5,9 @@ require_once __DIR__.'/../inc_functions.php'; require_once __DIR__.'/../inc_vars.php'; $AMCLI??=__DIR__.'/../src/amcli.php'; +$AMCLI=__DIR__.'/../built_packages/amcli'; + +_chdir(__DIR__); echo "\n\nSTART TESTS\n\n"; foreach(glob("*.php") as $sFile){ diff --git a/tests/110_set_metadata.php b/tests/100_set_metadata.php similarity index 100% rename from tests/110_set_metadata.php rename to tests/100_set_metadata.php diff --git a/tests/200_mysqlconnect.php b/tests/200_mysqlconnect.php new file mode 100644 index 0000000000000000000000000000000000000000..1fe4dc9ddb809ea33cad958232a30a76de99aab1 --- /dev/null +++ b/tests/200_mysqlconnect.php @@ -0,0 +1,7 @@ +#!/usr/bin/env php +<?php + +echo " +WHAT: Run check mysqlconnect +"; +_exec("$AMCLI --ini='".__DIR__."/configs/mysqlconnect.ini'"); diff --git a/tests/200_pdoconnect.php b/tests/200_pdoconnect.php new file mode 100644 index 0000000000000000000000000000000000000000..30e4bcd2f09b83088bda72241bc1f38dc2ef8478 --- /dev/null +++ b/tests/200_pdoconnect.php @@ -0,0 +1,7 @@ +#!/usr/bin/env php +<?php + +echo " +WHAT: Run check pdoconnect +"; +_exec("$AMCLI --ini='".__DIR__."/configs/pdoconnect.ini'"); diff --git a/tests/configs/mysqlconnect.ini b/tests/configs/mysqlconnect.ini new file mode 100644 index 0000000000000000000000000000000000000000..c2cab2dd951631413ce664dab501c5787da8334b --- /dev/null +++ b/tests/configs/mysqlconnect.ini @@ -0,0 +1,26 @@ +; ======================================================================= +; +; APPMONITOR CLI CLIENT +; +; for the checks see its parameters +; <https://os-docs.iml.unibe.ch/appmonitor/PHP_client/Plugins/Checks/index.html> +; +; ======================================================================= + + +; ----------------------------------------------------------------------- +; CHECKS +; ----------------------------------------------------------------------- + +["Mysqlconnect"] +description="Test Mysql database connection" +function="Mysqlconnect" +params='{ + "server": "127.0.0.1", + "user": "root", + "password": "12345678", + "db": "ahcrawler", + "port": "13306" +}' + +; ----------------------------------------------------------------------- diff --git a/tests/configs/pdoconnect.ini b/tests/configs/pdoconnect.ini new file mode 100644 index 0000000000000000000000000000000000000000..b97be289c3b1b2aafb1285dcf58b571cb379b111 --- /dev/null +++ b/tests/configs/pdoconnect.ini @@ -0,0 +1,24 @@ +; ======================================================================= +; +; APPMONITOR CLI CLIENT +; +; for the checks see its parameters +; <https://os-docs.iml.unibe.ch/appmonitor/PHP_client/Plugins/Checks/index.html> +; +; ======================================================================= + + +; ----------------------------------------------------------------------- +; CHECKS +; ----------------------------------------------------------------------- + +["PDO connect mysql"] +description="PDO - Test Mysql database connection" +function="Pdoconnect" +params='{ + "connect": "mysql:host=127.0.0.1;port=13306;dbname=ahcrawler;", + "user": "root", + "password": "12345678" +}' + +; -----------------------------------------------------------------------