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
e50b5e39
Commit
e50b5e39
authored
4 weeks ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
0.8: check missing 'function' in check. get php client version
parent
62db739c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/30_Usage.md
+1
-0
1 addition, 0 deletions
docs/30_Usage.md
src/amcli.php
+17
-8
17 additions, 8 deletions
src/amcli.php
with
18 additions
and
8 deletions
docs/30_Usage.md
+
1
−
0
View file @
e50b5e39
...
...
@@ -85,6 +85,7 @@ The binary could stop and exit with non zero exitcode.
| 4 | Given Ini file does not exist
| 5 | Given Ini file cannot be parsed
| 6 | Ini value
`params=`
is no JSON
| 7 | The key 'function' is not set in the given check. It defines the check function to call.
### appmonitor-client class
...
...
This diff is collapsed.
Click to expand it.
src/amcli.php
+
17
−
8
View file @
e50b5e39
...
...
@@ -18,6 +18,8 @@
* 2025-03-09 v0.4 more colors in output of debug and help
* 2025-03-14 v0.5 add build infos
* 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
* ======================================================================
*/
...
...
@@ -26,7 +28,8 @@ $argc = $_SERVER['argc'];
$argv
=
$_SERVER
[
'argv'
];
$FLAG_DEBUG
=
0
;
$VERSION
=
"0.7"
;
$VERSION
=
"0.8"
;
$PHPCLIENTVERSION
=
"not-detected"
;
$AMCLI_BUILD_DATE
=
"never"
;
...
...
@@ -100,18 +103,18 @@ function _wd($s): void
*/
function
_showHelp
():
void
{
global
$VERSION
;
global
$VERSION
,
$PHPCLIENTVERSION
;
$_self
=
str_replace
(
'.php'
,
''
,
basename
(
__FILE__
));
echo
"
_____ _____ __ _____ _ _
| | | | ___ ___ ___| |___ ___|_| |_ ___ ___
|- -| | | | |__ | .'| . | . | | | | . | | | _| . | _|
|_____|_|_|_|_____| |__,| _| _|_|_|_|___|_|_|_|_| |___|_|
|_| |_|
\e
[1mCLI client v
$VERSION
\e
[0m
|_| |_|
\e
[1mCLI client v
$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.
It contains all checks that are available in the PHP appmonitor client
v
$PHPCLIENTVERSION
.
You can use the compiled binary to monitor any non PHP webapp without
implementing the checks for your programming language.
...
...
@@ -201,6 +204,7 @@ _wd("CLI ARGS: " . print_r($ARGS ?? [], 1));
_wd
(
"Initializing appmonitor class"
);
$oMonitor
=
new
appmonitor
();
$PHPCLIENTVERSION
=
$oMonitor
->
getVersion
();
$sPreSpace
=
" - "
;
// show version
...
...
@@ -219,7 +223,7 @@ if (isset($ARGS['-b']) || isset($ARGS['--buildinfos'])) {
echo
"amcli v
$VERSION
("
.
PHP_OS
.
")
\n\n
"
;
echo
"Build date:
$AMCLI_BUILD_DATE
\n
"
;
echo
"
\n
"
;
echo
"Compiled with PHP "
.
PHP_VERSION
.
"
\n
"
;
echo
"Compiled
PHP client v
$PHPCLIENTVERSION
with PHP "
.
PHP_VERSION
.
"
\n
"
;
echo
"Including these modules:
\n
"
;
$sModules
=
" "
;
$i
=
0
;
...
...
@@ -298,6 +302,7 @@ $aIni['notifications']['slack']=_json2array($aIni['notifications']['slack'] ?? n
_set
(
"setHost"
,
$aIni
[
'meta'
][
'host'
]
??
null
);
_set
(
"setWebsite"
,
$aIni
[
'meta'
][
'website'
]
??
null
);
_set
(
"setTtl"
,
$aIni
[
'meta'
][
'ttl'
]
??
null
);
_set
(
"setVersion"
,
"amcli-
$VERSION
-using"
);
foreach
(
$aIni
[
'meta'
][
'tags'
]
??
[]
as
$sValue
)
{
_set
(
"addTag"
,
$sValue
);
...
...
@@ -322,16 +327,20 @@ foreach ($aChecks as $sKey => $aCheck) {
$aParams
=
_json2array
(
$aCheck
[
'params'
]
??
[]);
if
(
!
is_array
(
$aParams
))
{
echo
"❌ ERROR: key 'params' for check [
$sKey
] must be
\n
- a hash or
\n
- valid JSON
\n
- not set
\n
"
;
echo
"Value in
$inifile
:
$aCheck[params]
\n
"
;
echo
"Value in
$inifile
:
$aCheck[params]
??[]
\n
"
;
echo
"Try to use multiple lines 'params[<KEY>]=<VALUE>'.
\n
"
;
exit
(
6
);
}
if
(
!
isset
(
$aCheck
[
'function'
])){
echo
"❌ ERROR: Missing key 'function' in check [
$sKey
].
\n
"
;
exit
(
7
);
}
$aAddCheck
=
[
"name"
=>
$aCheck
[
'name'
]
??
$sKey
,
"description"
=>
$aCheck
[
'description'
]
??
""
,
"check"
=>
[
"function"
=>
$aCheck
[
'function'
],
"function"
=>
$aCheck
[
'function'
]
??
"not set"
,
"params"
=>
$aParams
,
],
];
...
...
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