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
d82d6c89
Commit
d82d6c89
authored
2 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update first simple example
parent
60ab4324
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/amcli.php
+107
-5
107 additions, 5 deletions
src/amcli.php
src/simple.ini
+5
-0
5 additions, 0 deletions
src/simple.ini
with
112 additions
and
5 deletions
src/amcli.php
+
107
−
5
View file @
d82d6c89
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
<?php
<?php
chdir
(
__DIR__
);
chdir
(
__DIR__
);
$FLAG_DEBUG
=
0
;
$VERSION
=
"0.0.1"
;
// ---MARK---INCLUDE-CHECKS---START---
// ---MARK---INCLUDE-CHECKS---START---
if
(
!
file_exists
(
"include_checks.php"
)){
if
(
!
file_exists
(
"include_checks.php"
)){
...
@@ -19,11 +20,112 @@ if(!include "include_checks.php"){
...
@@ -19,11 +20,112 @@ if(!include "include_checks.php"){
// ---MARK---INCLUDE-CHECKS---END
// ---MARK---INCLUDE-CHECKS---END
if
(
$argc
>
1
)
// --------------------------------------------------------------------
parse_str
(
implode
(
'&'
,
array_slice
(
$argv
,
1
)),
$_GET
);
//
// FUNCTIONS
//
// --------------------------------------------------------------------
function
_wd
(
$s
):
void
{
global
$FLAG_DEBUG
;
if
(
$FLAG_DEBUG
){
// echo "DEBUG: $s\n";
fwrite
(
STDERR
,
"DEBUG:
$s
\n
"
);
}
}
function
_showHelp
():
void
{
global
$VERSION
;
$_self
=
basename
(
__FILE__
);
echo
"IML Appmonitor as CLI client
$VERSION
This client performs appmonitor checks and puts the results as JSON to stdout.
You can use the compiled binary on non PHP systems.
(c) 2025 Institute for Medical education * University of Bern
!!! This tool is in alpha stadium !!!
SYNTAX:
$_self
[OPTIONS]
OPTIONS:
-v, --verbose Verbose output
-h, --help Print this help
-i, --ini INI File
"
;
}
// --------------------------------------------------------------------
//
// MAIN
//
// --------------------------------------------------------------------
// put params to $ARGS
if
(
$argc
>
1
){
parse_str
(
implode
(
'&'
,
array_slice
(
$argv
,
1
)),
$ARGS
);
}
// check params
if
(
isset
(
$ARGS
[
'-v'
])
||
isset
(
$ARGS
[
'--verbose'
]))
{
$FLAG_DEBUG
=
1
;
}
_wd
(
"CLI ARGS: "
.
print_r
(
$ARGS
,
1
));
if
(
isset
(
$ARGS
[
'-h'
])
||
isset
(
$ARGS
[
'--help'
]))
{
_wd
(
"Showing help"
);
_showHelp
();
exit
(
0
);
}
$inifile
=
$ARGS
[
"--ini"
]
??
(
$ARGS
[
"-i"
]
??
"simple.ini"
);
_wd
(
"Using ini file '
$inifile
'."
);
if
(
!
file_exists
(
$inifile
)){
echo
"ERROR: INI File '
$inifile
' does not exist.
\n
"
;
exit
(
1
);
}
$aIni
=
parse_ini_file
(
$inifile
);
if
(
!
is_array
(
$aIni
)){
echo
"ERROR: INI File '
$inifile
' could not be parsed.
\n
"
;
exit
(
1
);
}
_wd
(
"Parsed INI data: "
.
print_r
(
$aIni
,
1
));
// ----------------------------------------------------------------------
_wd
(
"Initializing appmonitor class"
);
$oMonitor
=
new
appmonitor
();
$oMonitor
->
addEmail
(
'sysadmin@example.com'
);
$oMonitor
->
addSlackWebhook
(
"mywebhook"
,
"https://hooks.slack.com/services/(...)"
);
$oMonitor
->
addCheck
(
[
"name"
=>
"hello plugin"
,
"description"
=>
"Test a plugin ... plugins/checks/hello.php"
,
"check"
=>
[
"function"
=>
"Hello"
,
"params"
=>
[
"message"
=>
"Here I am"
,
],
],
]
);
// ----------------------------------------------------------------------
// send the response
echo
"PARAMS: "
;
_wd
(
"Setting result"
)
;
print_r
(
$_GET
);
$oMonitor
->
setResult
(
);
_wd
(
"Send response"
);
$oMonitor
->
render
();
This diff is collapsed.
Click to expand it.
src/simple.ini
0 → 100644
+
5
−
0
View file @
d82d6c89
[meta]
host
=
"www.example.com"
website
=
"Company website"
ttl
=
300
tags
[]
="monitoring"
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