diff --git a/docs/30_Usage.md b/docs/30_Usage.md index 9fa5cfdfc9e2acf89a3534f68503f73ad2e55be6..8b4a142d050c4f72df5d5473d0f5c9bdea867521 100644 --- a/docs/30_Usage.md +++ b/docs/30_Usage.md @@ -1,7 +1,7 @@ ## Show help ```text -./src/amcli -h +./amcli -h IML Appmonitor as CLI client 0.2 This client performs appmonitor checks and puts the results as JSON to stdout. diff --git a/docs/40_Embed.md b/docs/40_Embed.md new file mode 100644 index 0000000000000000000000000000000000000000..669ee6eae0a1fac0181032b9d662d4853ecc0b94 --- /dev/null +++ b/docs/40_Embed.md @@ -0,0 +1,32 @@ +## Introduction + +To embed the cli tool into your web application you need to + +* perform the execution of the binary with referencing the ini `<PATH>amcli --ini=<INI-FILE>` +* catch exitcode and output of STDOUT +* check returncode: + * if it is `0` then the excution was successful - we have a result. You can send the JSON after setting the content type as http response header + * if it is `> 0` the response is no JSON syntax. You should send the output that the error is seen in the appm nitor server. + +## PHP + +This code snippet is for demonstration purposes only. A PHP web app should use the PHP client - see <https://os-docs.iml.unibe.ch/appmonitor/PHP_client/index.html> + +```php +<?php + +$AMCLI=__DIR__.'/../built_packages/amcli'; +$INI=__DIR__.'/../src/simple.ini'; + +$sCommand="$AMCLI --ini='$INI'"; +$aOut=[]; + +exec($sCommand, $aOut, $iRc); + +if($iRc==0){ + header('Content-type: application/json'); +}else{ + echo "Error: occured...\n"; +} +echo implode("\n", $aOut); +``` diff --git a/docs/40_Build.md b/docs/50_Build.md similarity index 93% rename from docs/40_Build.md rename to docs/50_Build.md index e137f50b43e4f590afe8e08b0da3c8a126e3794a..e6813f191205ea19b3c6ab88f84c93d24205d00f 100644 --- a/docs/40_Build.md +++ b/docs/50_Build.md @@ -1,11 +1,11 @@ ## Requirements -To update and test the command line tool you need +To update and test the command line tool you need * git * a local PHP8 cli. -## Prepare environemnt +## Prepare environment ### Get sources @@ -22,6 +22,8 @@ You get this initial structure: ```txt . ├── build.php +├── examples + └── embed_example.php ├── inc_functions.php ├── inc_vars.php ├── installer.php