Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Appmonitor CLI client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Appmonitor CLI client
Commits
ba31c8c3
Commit
ba31c8c3
authored
1 month ago
by
Axel Hahn
Browse files
Options
Downloads
Patches
Plain Diff
more colors in output of debug and help
parent
7f40eb7e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/amcli.php
+18
-17
18 additions, 17 deletions
src/amcli.php
with
18 additions
and
17 deletions
src/amcli.php
+
18
−
17
View file @
ba31c8c3
...
...
@@ -10,6 +10,7 @@
* 2025-03-04 v0.1 Initial version
* 2025-03-05 v0.2 slack notification as hash from ini; check params can be an hash value or JSON
* 2025-03-07 v0.3 set argc and argv from $_SERVER; update help output
* 2025-03-09 v0.4 more colors in output of debug and help
* ======================================================================
*/
...
...
@@ -18,7 +19,7 @@ $argc = $_SERVER['argc'];
$argv
=
$_SERVER
[
'argv'
];
$FLAG_DEBUG
=
0
;
$VERSION
=
"0.
3
"
;
$VERSION
=
"0.
4
"
;
// ---MARK---INCLUDE-CHECKS---START---
if
(
!
file_exists
(
__DIR__
.
"/include_checks.php"
))
{
...
...
@@ -77,7 +78,7 @@ function _wd($s): void
{
global
$FLAG_DEBUG
;
if
(
$FLAG_DEBUG
)
{
fwrite
(
STDERR
,
"DEBUG:
$s
\n
"
);
fwrite
(
STDERR
,
"
\e
[90m
DEBUG:
$s
\
e
[0m
\
n
"
);
}
}
...
...
@@ -88,9 +89,9 @@ function _wd($s): void
function
_showHelp
():
void
{
global
$VERSION
;
$_self
=
str_replace
(
'.php'
,
''
,
basename
(
__FILE__
));
$_self
=
str_replace
(
'.php'
,
''
,
basename
(
__FILE__
));
echo
"
IML Appmonitor as CLI client
$VERSION
\e
[1m
IML Appmonitor as CLI client
$VERSION
\e
[0m
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.
...
...
@@ -101,22 +102,22 @@ You need to reference an INI file that contains the metadata and all checks.
Have a look to the online documentation for details.
You find example snippets in the source code of this project in tests/config/.
👤 Author: Axel Hahn
📄 Source: https://git-repo.iml.unibe.ch/iml-open-source/appmonitor-cli-client
📜 License: GNU GPL 3.0
📗 Docs: https://os-docs.iml.unibe.ch/appmonitor-cli-client/
👤 Author: Axel Hahn
📄 Source: https://git-repo.iml.unibe.ch/iml-open-source/appmonitor-cli-client
📜 License: GNU GPL 3.0
📗 Docs: https://os-docs.iml.unibe.ch/appmonitor-cli-client/
(c) 2025 Institute for Medical Education * University of Bern
(c) 2025 Institute for Medical Education * University of Bern
...............................................................................
✨ SYNTAX:
✨
\e
[1m
SYNTAX:
\e
[0m
$_self
[OPTIONS] --ini=<INI-FILE>
🔷 OPTIONS:
🔷
\e
[1m
OPTIONS:
\e
[0m
-h, --help Print this help and exit
-i, --ini Set an INI File to parse
...
...
@@ -126,7 +127,7 @@ You find example snippets in the source code of this project in tests/config/.
-V, --version Show version and exit
👉 EXAMPLES:
👉
\e
[1m
EXAMPLES:
\e
[0m
$_self
-i=my.ini
$_self
--ini=my.ini
...
...
@@ -176,7 +177,7 @@ if (isset($ARGS['-h']) || isset($ARGS['--help'])) {
_wd
(
"Initializing appmonitor class"
);
$oMonitor
=
new
appmonitor
();
$sPreSpace
=
" - "
;
$sPreSpace
=
" - "
;
// show builtin checks
if
(
isset
(
$ARGS
[
'-l'
])
||
isset
(
$ARGS
[
'--list'
]))
{
...
...
@@ -207,11 +208,11 @@ if (!file_exists($inifile)) {
exit
(
4
);
}
try
{
try
{
$aIni
=
parse_ini_file
(
$inifile
,
true
);
}
catch
(
Exception
$e
)
{
echo
"❌ ERROR: INI File '
$inifile
' could not be parsed.
\n
"
;
exit
(
5
);
exit
(
5
);
}
if
(
!
is_array
(
$aIni
))
{
echo
"❌ ERROR: INI File '
$inifile
' could not be parsed as array.
\n
"
;
...
...
@@ -243,9 +244,9 @@ unset($aChecks["notifications"]);
foreach
(
$aChecks
as
$sKey
=>
$aCheck
)
{
$aChecks
[
$sKey
][
'name'
]
=
$aCheck
[
'name'
]
??
$sKey
;
$aArray
=
$aCheck
[
'params'
]
??
[];
$aArray
=
$aCheck
[
'params'
]
??
[];
if
(
$aArray
)
{
if
(
!
is_array
(
$aCheck
[
'params'
])){
if
(
!
is_array
(
$aCheck
[
'params'
]))
{
$aArray
=
json_decode
(
$aCheck
[
'params'
],
1
);
if
(
!
is_array
(
$aArray
))
{
echo
"❌ ERROR: key 'params' for check [
$sKey
] must be valid JSON.
\n
"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment