Table of Contents
- ๐ฆ Class \appmonitorserver_api
- ๐ถ Properties
-
๐ท Methods
- ๐น public __construct()
- ๐น public actionAddUrl()
- ๐น public actionDeleteUrl()
- ๐น public addUrl()
- ๐น public apiGetFilteredApp()
- ๐น public apiGetHeatlth()
- ๐น public apiGetTags()
- ๐น public getAlreadyAuthenticatedUser()
- ๐น public getApiConfig()
- ๐น public getApiUsers()
- ๐น public getAppIds()
- ๐น public getConfigVars()
- ๐น public getMonitoringData()
- ๐น public getResultValue()
- ๐น public getRoles()
- ๐น public getUser()
- ๐น public getUserid()
- ๐น public getUsername()
- ๐น public hasRole()
- ๐น public loadClientData()
- ๐น public loadConfig()
- ๐น public removeUrl()
- ๐น public saveConfig()
- ๐น public saveUrls()
- ๐น public send()
- ๐น public setDemoMode()
- ๐น public setLogging()
- ๐น public setUser()
๐ฆ Class \appmonitorserver_api
/**
* ____________________________________________________________________________
*
* _____ _____ __ _____ _ _
* | | | | ___ ___ ___| |___ ___|_| |_ ___ ___
* |- -| | | | |__ | .'| . | . | | | | . | | | _| . | _|
* |_____|_|_|_|_____| |__,| _| _|_|_|_|___|_|_|_|_| |___|_|
* |_| |_|
*
* ___ ___ ___ _ _ ___ ___
* |_ -| -_| _| | | -_| _|
* |___|___|_| \_/|___|_|
*
* ____________________________________________________________________________
*
* APPMONITOR SERVER<br>
* <br>
* THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE <br>
* LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR <br>
* OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, <br>
* EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED <br>
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE <br>
* ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. <br>
* SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY <br>
* SERVICING, REPAIR OR CORRECTION.<br>
* <br>
* --------------------------------------------------------------------------------<br>
* @version v0.137
* @author Axel Hahn
* @link https://github.com/iml-it/appmonitor
* @license GPL
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL 3.0
* @package IML-Appmonitor
* --------------------------------------------------------------------------------<br>
* 2024-07-17 0.137 axel.hahn@unibe.ch php 8 only: use typed variables
* 2024-11-14 0.141 axel.hahn@unibe.ch API access with basic auth and hmac hash key
*/
๐ถ Properties
๐ธ public $oNotification
notificationhandler object to send email/ slack messages it is initialized in method loadConfig()
@var notificationhandler object
type: notificationhandler
default value:
๐ท Methods
๐น public __construct()
constructor
Return: ``
Parameters: 0
๐น public actionAddUrl()
Setup action: add a new url and save the config
Return: bool
Parameters: 2
Parameter | Type | Description |
---|---|---|
<required> string $sUrl | string |
url to add |
<optional> bool $bMakeCheck = true | bool |
Flag: check a valid url and response is JSON |
๐น public actionDeleteUrl()
Setup action: Delete an url to fetch and trigger to save the new config file
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> string $sUrl | string |
url to delete in the config |
๐น public addUrl()
Add appmonitor url to current object
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> $sUrl | url * |
url to add |
๐น public apiGetFilteredApp()
Get an array of all applications that match a filter
Return: array
Parameters: 2
Parameter | Type | Description |
---|---|---|
<optional> array $aFilter = [] | array |
filter definitions using AND condition over all filters appid - string of appid tags - array of tags that must match (AND condition) website - substring of website |
<optional> string $outmode = โallโ | string |
kind of result data; one of appid |
๐น public apiGetHeatlth()
Generate JSON to show a health status
Return: array
Parameters: 0
๐น public apiGetTags()
Get a flat array with all application ids and website + url as subkeys
Return: array
Parameters: 0
๐น public getAlreadyAuthenticatedUser()
Return a detected user from $_SERVER env
Return: string
Parameters: 0
๐น public getApiConfig()
Get the โapiโ section from configuration
Return: array
Parameters: 0
๐น public getApiUsers()
Get an array with users in the config to apply it on tinyapi init Syntax: username and keys โpasswordโ and/ or โsecretโ Array ( [] => Array ( [password] => )
[api] => Array
(
[password] => $2y$10$5E4ZWyul.VdZjpP1.Ff6Le0z0kxu3ix7jnbYhv0Zg5vhvhjdJTOm6
)
[api-test] => Array
(
[password] =>
[secret] => tryme
)
[superuser] => Array
(
[password] =>
)
)
Return: array
Parameters: 0
๐น public getAppIds()
Get a flat array with all application ids and website + url as subkeys
Return: array
Parameters: 0
๐น public getConfigVars()
Get a hash with all configuration items
Return: array
Parameters: 0
๐น public getMonitoringData()
Get all client data and final result as array
Return: array
Parameters: 1
Parameter | Type | Description |
---|---|---|
<optional> string $sHost = โโ | string |
filter by given hostname |
๐น public getResultValue()
Get a readable result by given integer; i.e. 0=OK, 1=unknown, โฆ
Return: string
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> int $i | int |
๐น public getRoles()
Get roles of a user. If the user itself has no roles but was authenticated by the webserver then it gets default roles from user โdefault_authenticated_userโ
Return: array|bool
Parameters: 0
๐น public getUser()
Get meta fields for current or given user
Return: array|bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<optional> string $sUsername = โโ | string |
optional: override current user id |
๐น public getUserid()
Get current username that was detected or set
Return: string
Parameters: 0
๐น public getUsername()
Get current username that was detected or set
Return: string
Parameters: 0
๐น public hasRole()
Return if a user has a given role
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> string $sRequiredRole | string |
name of the role to verify |
๐น public loadClientData()
load monitoring data โฆ if not done yet; used in gui and api
Return: bool
Parameters: 0
๐น public loadConfig()
(re) load config and get all urls to fetch (and all other config items) This method
- fills $this->_aCfg
- newly initializes $this->oNotification
Return: void
Parameters: 0
๐น public removeUrl()
remove appmonitor url from current object
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> string $sUrl | string |
url to remove |
๐น public saveConfig()
Save the current or new config data as file.
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<optional> array $aNewCfg = [] | array |
๐น public saveUrls()
Save the current or new config data as file.
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<optional> array $aNewCfg = [] | array |
๐น public send()
Write a message to STDOUT (if actiated or logging is on)
Return: bool
Parameters: 2
Parameter | Type | Description |
---|---|---|
<required> string $sMessage | string |
message text |
<optional> $bShow = false | flag * |
flag to write to stdout (overrides set show log value) |
๐น public setDemoMode()
switch demo mode on and off TODO: check how switch demo mode and handle parameters
Return: bool *
Parameters: 1
Parameter | Type | Description |
---|---|---|
<optional> $bBool = true | * |
๐น public setLogging()
Set flag for logging to standard output
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> bool $bShow | bool |
new logging flag |
๐น public setUser()
Set a username to work with
Return: bool
Parameters: 1
Parameter | Type | Description |
---|---|---|
<required> string $sNewUser | string |
username; it should be a user in config users key (or you loose all access) |
Generated with Axels PHP class doc parser.