-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from iml-it/visual-options
Visual options v0.145 * add config entry to show tags in app details * add config entry to show/ hide validation warnings * update format of notification email * update docs
- Loading branch information
Showing
53 changed files
with
209 additions
and
62 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
docs/40_📦_Server/30_Notification.md → docs/40_Server/30_Notification.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/bash | ||
# ====================================================================== | ||
# | ||
# pmu - process memory usage | ||
# | ||
# ---------------------------------------------------------------------- | ||
# 2013-07-31 v1.0 Axel Hahn | ||
# 2023-01-10 v1.1 Axel Hahn shell fixes; add total status | ||
# 2023-12-22 v1.2 Axel Hahn speedup factor 5..10 | ||
# ====================================================================== | ||
|
||
typeset -i lines=0 | ||
_version=1.2 | ||
|
||
# ---------------------------------------------------------------------- | ||
# MAIN | ||
# ---------------------------------------------------------------------- | ||
|
||
echo "_______________________________________________________________________________ | ||
>>>> Memory usage by each process in MB v$_version | ||
" | ||
|
||
# ----- show help | ||
if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then | ||
self=$( basename $0 ) | ||
cat <<EOF | ||
HELP | ||
$self groups all processes and shows their memory usage in MB. | ||
The output is ordered by largest consumers. | ||
Coloumns: | ||
process process name | ||
total MB aggregated memory by all processes | ||
count count of processes | ||
average MB average memory usage (total divided by count) | ||
You can limit the output by intger parameter for count of lines to show. | ||
SYNTAX: | ||
$self shows all processes | ||
$self [integer] limit output to top n consumers | ||
$self [-? -h --help] show this help | ||
EXAMPLE: | ||
$self 10 shows top 10 consumers | ||
EOF | ||
exit 0 | ||
fi | ||
|
||
|
||
# ----- output of total status | ||
top -n 1 -E M -b | head | grep -E "^(Tasks|MiB Mem|MiB Spch)" | ||
echo "_______________________________________________________________________________ | ||
" | ||
|
||
# ----- aggregate data | ||
|
||
pslist=$( ps -yle ) | ||
pslist2=$( | ||
for processname in $( echo "$pslist" | awk {'print $13'} | sort -u | grep -Fv "/") | ||
do | ||
grep " ${processname}$" <<< "$pslist"| awk ' | ||
{x += $8;y += 1; process=$13} | ||
END {printf "%-15s %10.0f %5s %10.3f\n", process, x/1024, y, x/(y*1024)}' 2>/dev/null | ||
done | sort -k 2 -n -r | ||
) | ||
|
||
# ----- output for processes | ||
lines=$1 | ||
echo "process total MB count average MB" | ||
echo "--------------- ---------- ----- ----------" | ||
|
||
if [ $lines -gt 0 ]; then | ||
echo "$pslist2" | head -$lines | ||
else | ||
echo "$pslist2" | ||
fi | ||
echo | ||
|
||
exit | ||
|
||
# ---------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
* SERVICING, REPAIR OR CORRECTION.<br> | ||
* <br> | ||
* --------------------------------------------------------------------------------<br> | ||
* @version 0.143 | ||
* @version 0.145 | ||
* @author Axel Hahn | ||
* @link https://github.com/iml-it/appmonitor | ||
* @license GPL | ||
|
@@ -44,14 +44,15 @@ | |
* 2024-11-26 0.142 [email protected] handle invalid response data | ||
* 2024-11-29 0.143 [email protected] filter by multiple tags | ||
* 2024-12-06 0.144 [email protected] prevent multiple values of same tag (see functions.js) | ||
* 2024-12-09 0.145 [email protected] shwo tags in appdetails; config flag: show validation warnings | ||
*/ | ||
class appmonitorserver_gui extends appmonitorserver | ||
{ | ||
/** | ||
* Version | ||
* @var string | ||
*/ | ||
protected string $_sVersion = "0.144"; | ||
protected string $_sVersion = "0.145"; | ||
|
||
/** | ||
* Title/ project name | ||
|
@@ -419,6 +420,7 @@ protected function _generateWebappTiles(string $sAppId): string | |
} | ||
|
||
foreach ($this->_aCfg['view']['appdetails'] as $key => $bVisibility) { | ||
if(!$bVisibility) continue; | ||
switch ($key) { | ||
case 'appstatus': | ||
$aLast = $this->oNotification->getAppLastResult(); | ||
|
@@ -437,27 +439,23 @@ protected function _generateWebappTiles(string $sAppId): string | |
); | ||
break; | ||
case 'httpcode': | ||
$sReturn .= $bVisibility | ||
? $this->_getTile([ | ||
$sReturn .= $this->_getTile([ | ||
'result' => ((int) $aHostdata['httpstatus'] == 0 || $aHostdata['httpstatus'] >= 400) | ||
? RESULT_ERROR | ||
: false, | ||
'label' => $this->_tr('Http-status'), | ||
'count' => $aHostdata['httpstatus'] ? $aHostdata['httpstatus'] : '??', | ||
]) | ||
: ''; | ||
]); | ||
break; | ||
case 'age': | ||
$bOutdated = isset($aHostdata["outdated"]) && $aHostdata["outdated"]; | ||
$sReturn .= $bVisibility | ||
? $this->_getTile([ | ||
$sReturn .= $this->_getTile([ | ||
'result' => $bOutdated ? RESULT_ERROR : RESULT_OK, | ||
'icon' => $this->_aIco['age'], | ||
'label' => $this->_tr('age-of-result'), | ||
'count' => '<span class="timer-age-in-sec">' . (time() - $aHostdata['ts']) . '</span>s', | ||
'more' => $this->_tr('TTL') . '=' . $aHostdata['ttl'] . 's', | ||
]) | ||
: ''; | ||
]); | ||
break; | ||
case 'checks': | ||
$sReturn .= $bVisibility && isset($aHostdata['summary']['total']) | ||
|
@@ -488,26 +486,34 @@ protected function _generateWebappTiles(string $sAppId): string | |
// .'<pre>'.print_r($this->oNotification->getAppNotificationdata(), 1).'</pre>' | ||
. (count($aSlackChannels) ? '<span title="' . implode("\n", array_keys($aSlackChannels)) . '">' . count($aSlackChannels) . ' x ' . $this->_aIco['notify-slack'] . '</span> ' : ''); | ||
$iNotifyTargets = count($aEmailNotifiers) + count($aSlackChannels); | ||
$sReturn .= $bVisibility | ||
? $this->_getTile([ | ||
$sReturn .= $this->_getTile([ | ||
'result' => $iNotifyTargets ? false : RESULT_WARNING, | ||
'icon' => $this->_aIco['notifications'], | ||
'label' => $this->_tr('Notify-address'), | ||
'count' => $iNotifyTargets, | ||
'more' => $sMoreNotify | ||
]) | ||
: ''; | ||
]); | ||
break; | ||
case 'notification': | ||
$sSleeping = $this->oNotification->isSleeptime(); | ||
$sReturn .= $bVisibility | ||
? $this->_getTile([ | ||
$sReturn .= $this->_getTile([ | ||
'result' => ($sSleeping ? RESULT_WARNING : false), | ||
'icon' => ($sSleeping ? $this->_aIco['sleepmode-on'] : $this->_aIco['sleepmode-off']), | ||
'label' => ($sSleeping ? $this->_tr('Sleepmode-on') : $this->_tr('Sleepmode-off')), | ||
'more' => $sSleeping, | ||
]) | ||
: ''; | ||
]); | ||
break; | ||
case 'tags': | ||
$aTags = $this->_data[$sAppId]['meta']['tags'] ?? []; | ||
|
||
$sTaglist = implode(', ', $aTags); | ||
$sReturn .= $this->_getTile([ | ||
'result' => $sTaglist ? RESULT_OK : RESULT_WARNING, | ||
'icon' => $this->_aIco['tag'], | ||
'count' => count($aTags), | ||
'label' => $this->_tr('Tags'), | ||
'more' => $sTaglist ?: $this->_tr('Tags-none'), | ||
]); | ||
break; | ||
|
||
default: | ||
|
@@ -666,7 +672,8 @@ protected function _checkClientResponse(string $sAppId): bool|array | |
$aErrors[] = $this->_tr('msgErr-missing-key-meta-' . $sMetakey); | ||
} | ||
} | ||
foreach (['ttl', 'time', 'notifications'] as $sMetakey) { | ||
unset($aData['meta']['tags']); | ||
foreach (['ttl', 'time', 'notifications', 'tags'] as $sMetakey) { | ||
if (!isset($aData['meta'][$sMetakey])) { | ||
$aWarnings[] = $this->_tr('msgWarn-missing-key-meta-' . $sMetakey); | ||
} | ||
|
@@ -1375,7 +1382,7 @@ public function generateViewApp(string $sAppId): string | |
(isset($aEntries["result"]) && isset($aEntries["result"]["result"]) && isset($aEntries["result"]["website"]) && isset($aEntries["result"]["host"])) | ||
) { | ||
|
||
// --- | ||
// --- top breadcrumb | ||
$sTopHeadline = $oA->getSectionHead( | ||
'' | ||
. '<a href="#divwebs"' | ||
|
@@ -1404,9 +1411,12 @@ public function generateViewApp(string $sAppId): string | |
]); | ||
} | ||
|
||
if (!$sValidationContent && $aValidatorResult) { | ||
$bShowWarnings=!!$this->_aCfg['view']['validationwarnings'] ?? true; | ||
if (!$sValidationContent && $aValidatorResult ) { | ||
foreach ($aValidatorResult as $sSection => $aMessageItems) { | ||
if (count($aMessageItems)) { | ||
if (count($aMessageItems) | ||
&& ( $sSection == 'error' || $sSection == 'warning' && $bShowWarnings ) | ||
) { | ||
$sDivContent = ''; | ||
foreach ($aMessageItems as $sSingleMessage) { | ||
$sDivContent .= '- ' . $sSingleMessage . '<br>'; | ||
|
@@ -2018,11 +2028,14 @@ function _generateWeblist(bool $bSkipOk = false, array $aOptions = []): array | |
: $this->_getIconClass($this->_aIco['host']); | ||
$sAppLabel = str_replace('.', '.­', $this->_getAppLabel($sAppId)); | ||
|
||
$bShowWarnings=!!$this->_aCfg['view']['validationwarnings'] ?? true; | ||
$aValidaion = $this->_checkClientResponse($sAppId); | ||
$sValidatorinfo = ''; | ||
if ($aValidaion) { | ||
foreach ($aValidaion as $sSection => $aMessages) { | ||
if (count($aValidaion[$sSection])) { | ||
if (count($aValidaion[$sSection]) | ||
&& ( $sSection == 'error' || ($sSection == 'warning' && $bShowWarnings) ) | ||
) { | ||
$sValidatorinfo .= '<span class="ico' . $sSection . '" title="' . sprintf($this->_tr('Validator-' . $sSection . '-title'), count($aMessages)) . '">' . $this->_aIco[$sSection] . '</span> ' . count($aMessages); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
$sTO="[email protected]"; | ||
$sSUBJECT="AppMonitor - ".date("Y-m-d H:i:s"); | ||
$sBody=" | ||
Hallihallo | ||
Hier ist meine Test-Nachricht. | ||
Viele Grusse | ||
Axel | ||
"; | ||
|
||
echo "$sTO - $sSUBJECT<br>"; | ||
echo "$sBody<br>"; | ||
|
||
$ret = mail($sTO, $sSUBJECT, $sBody); | ||
var_dump($ret); // (bool)true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.