Skip to content

Commit 1a3c81d

Browse files
committed
release 1.0.0
1 parent 3b2f377 commit 1a3c81d

7 files changed

+120
-19
lines changed

README.md

+59
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,65 @@ Check mServer availbility
1818
}
1919
```
2020

21+
Example of unsuccessfull test
22+
23+
```
24+
"/usr/bin/php" "/home/vitex/Projects/Spoje/pohoda-client-checker/src/pohoda-checker.php"
25+
01/02/2025 10:43:18 ⚙ ❲mPohoda Check⦒mServer\Client❳ mPohoda Check EaseCore 1.45.0 (PHP 8.3.6) mServer http://[email protected]:10010 PHPmServer vdev-main
26+
{
27+
"message": "Failed to connect to 10.11.25.23 port 10010 after 133252 ms: Couldn't connect to server",
28+
"diag": {
29+
"url": "http:\/\/10.11.25.23:10010\/status",
30+
"content_type": null,
31+
"http_code": 0,
32+
"header_size": 0,
33+
"request_size": 0,
34+
"filetime": -1,
35+
"ssl_verify_result": 0,
36+
"redirect_count": 0,
37+
"total_time": 133.252747,
38+
"namelookup_time": 3.9e-5,
39+
"connect_time": 0,
40+
"pretransfer_time": 0,
41+
"size_upload": 0,
42+
"size_download": 0,
43+
"speed_download": 0,
44+
"speed_upload": 0,
45+
"download_content_length": -1,
46+
"upload_content_length": -1,
47+
"starttransfer_time": 0,
48+
"redirect_time": 0,
49+
"redirect_url": "",
50+
"primary_ip": "",
51+
"certinfo": [],
52+
"primary_port": 0,
53+
"local_ip": "",
54+
"local_port": 0,
55+
"http_version": 0,
56+
"protocol": 0,
57+
"ssl_verifyresult": 0,
58+
"scheme": "",
59+
"appconnect_time_us": 0,
60+
"connect_time_us": 0,
61+
"namelookup_time_us": 39,
62+
"pretransfer_time_us": 0,
63+
"redirect_time_us": 0,
64+
"starttransfer_time_us": 0,
65+
"total_time_us": 133252747,
66+
"effective_method": "POST",
67+
"capath": "\/etc\/ssl\/certs",
68+
"cainfo": "\/etc\/ssl\/certs\/ca-certificates.crt",
69+
"when": "0.12675300 1735814732"
70+
},
71+
"status": false
72+
}01/02/2025 10:45:32 🌼 ❲mPohoda Check⦒mServer\Client❳ Saving result to php://stdout
73+
Done.
74+
01/02/2025 10:45:32 💀 ❲mPohoda Check⦒mServer\Client❳ 0: Curl Error (HTTP 0): Failed to connect to 10.11.25.23 port 10010 after 133252 ms: Couldn't connect to server
75+
01/02/2025 10:45:32 💀 ❲mPohoda Check⦒mServer\Client❳ Connection problem
76+
01/02/2025 10:45:32 💀 ❲mPohoda Check⦒mServer\Client❳ No XML response
77+
78+
```
79+
2180
![Connection Problem](connection-problem.png?raw=true)
2281

2382
```json

debian/changelog

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
pohoda-client-checker (0.2.0) UNRELEASED; urgency=medium
1+
pohoda-client-checker (1.0.0) UNRELEASED; urgency=medium
22

33
* pohoda-transaction-report added
4+
* improved error report
45

5-
-- vitex <[email protected]> Fri, 25 Oct 2024 18:20:19 +0200
6+
-- vitex <[email protected]> Thu, 02 Jan 2025 11:54:41 +0100
67

78
pohoda-client-checker (0.1.0) unstable; urgency=low
89

multiflexi/pohoda_checker.multiflexi.app.json

+12
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@
4444
"description": "write log messages using",
4545
"defval": "console|syslog",
4646
"required": false
47+
},
48+
"APP_DEBUG": {
49+
"type": "checkbox",
50+
"description": "Show debug messages",
51+
"defval": "False",
52+
"required": true
53+
},
54+
"ZABBIX_KEY": {
55+
"type": "string",
56+
"description": "Default name for Zabbix Item key name",
57+
"defval": "mServer-attainability-{POHODA_ICO}",
58+
"required": false
4759
}
4860
},
4961
"multiflexi": "1.7.3"

multiflexi/pohoda_transaction_report.multiflexi.app.json

+12
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@
6262
"description": "write log messages using",
6363
"defval": "console|syslog",
6464
"required": false
65+
},
66+
"APP_DEBUG": {
67+
"type": "checkbox",
68+
"description": "Show debug messages",
69+
"defval": "False",
70+
"required": true
71+
},
72+
"ZABBIX_KEY": {
73+
"type": "string",
74+
"description": "Default name for Zabbix Item key name",
75+
"defval": "pohoda-transaction-report-{POHODA_ICO}",
76+
"required": false
6577
}
6678
},
6779
"multiflexi": "1.7.3"

src/Pohoda/BankProbe.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ public function getColumnsFromPohoda($columns = ['id'], $conditions = []): array
175175
}
176176
}
177177

178-
return (array)$data;
178+
return (array) $data;
179179
}
180180
}
181-

src/pohoda-checker.php

+27-9
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,37 @@
1313
* file that was distributed with this source code.
1414
*/
1515

16+
use Ease\Shared;
17+
use mServer\Client;
18+
use mServer\HttpException;
19+
20+
/**
21+
* This file is part of the PohodaClientChecker package.
22+
*
23+
* https://github.com/Spoje-NET/pohoda-client-checker
24+
*
25+
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
26+
*
27+
* For the full copyright and license information, please view the LICENSE
28+
* file that was distributed with this source code.
29+
*/
30+
1631
require_once '../vendor/autoload.php';
1732

1833
\define('APP_NAME', 'mPohoda Check');
1934
$exitCode = 0;
35+
$result = [];
2036
$options = getopt('o::e::', ['output::', 'environment::']);
21-
\Ease\Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD', 'POHODA_ICO'], \array_key_exists('environment', $options) ? $options['environment'] : '../.env');
22-
$destination = \array_key_exists('output', $options) ? $options['output'] : \Ease\Shared::cfg('RESULT_FILE', 'php://stdout');
37+
Shared::init(['POHODA_URL', 'POHODA_USERNAME', 'POHODA_PASSWORD', 'POHODA_ICO'], \array_key_exists('environment', $options) ? $options['environment'] : '../.env');
38+
$destination = \array_key_exists('output', $options) ? $options['output'] : Shared::cfg('RESULT_FILE', 'php://stdout');
2339

24-
if (\Ease\Shared::cfg('EASE_LOGGER', false) === false) {
40+
if (Shared::cfg('EASE_LOGGER', false) === false) {
2541
\define('EASE_LOGGER', 'console');
2642
}
2743

28-
$client = new \mServer\Client();
44+
$client = new Client();
2945

30-
if (strtolower(\Ease\Shared::cfg('APP_DEBUG', 'false')) === 'true') {
46+
if (strtolower(Shared::cfg('APP_DEBUG', 'false')) === 'true') {
3147
$client->logBanner();
3248
}
3349

@@ -36,12 +52,14 @@
3652

3753
if ($result['status'] === false) {
3854
$client->addStatusMessage(_('Connection').' problem', 'error');
39-
$exitCode = 503;
55+
$exitCode = $client->lastResponseCode ? $client->lastResponseCode : 503 ;
4056
}
41-
} catch (\mServer\HttpException $ex) {
57+
} catch (HttpException $ex) {
4258
$client->addStatusMessage($ex->getCode().': '.$ex->getMessage(), 'error');
43-
$payments['message'] = $ex->getCode().': '.$ex->getMessage();
59+
$result['message'] = $ex->getCode().': '.$ex->getMessage();
60+
$result['diag'] = $client->curlInfo;
4461
$result['status'] = false;
62+
$exitCode = $client->lastResponseCode;
4563
}
4664

4765
$client->addStatusMessage(_('Connection').' '.($result['status'] ? 'OK' : 'problem'), $result['status'] ? 'success' : 'error');
@@ -72,7 +90,7 @@
7290
}
7391
}
7492

75-
$written = file_put_contents($destination, json_encode($result, \Ease\Shared::cfg('DEBUG') ? \JSON_PRETTY_PRINT : 0));
93+
$written = file_put_contents($destination, json_encode($result, Shared::cfg('APP_DEBUG') ? \JSON_PRETTY_PRINT : 0));
7694
$client->addStatusMessage(sprintf(_('Saving result to %s'), $destination), $written ? 'success' : 'error');
7795

7896
exit($exitCode ?: ($written ? 0 : 1));

src/pohoda-transaction-report.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
$banker->setScope(\Ease\Shared::cfg('REPORT_SCOPE', false) ? \Ease\Shared::cfg('REPORT_SCOPE', 'yesterday') : 'this_year');
3838

39-
$payments = [
39+
$result = [
4040
'source' => \Ease\Logger\Message::getCallerName($banker),
4141
'account' => $banker->accuntNumber(),
4242
'status' => $banker->lastResponseMessage,
@@ -64,7 +64,7 @@
6464
}
6565
} catch (\mServer\HttpException $ex) {
6666
$banker->addStatusMessage($ex->getCode().': '.$ex->getMessage(), 'error');
67-
$payments['message'] = $ex->getCode().': '.$ex->getMessage();
67+
$result['message'] = $ex->getCode().': '.$ex->getMessage();
6868
}
6969

7070
if ($transactionList) {
@@ -79,9 +79,9 @@
7979
$amount = (float) $transaction['bankSummary']['homeCurrency']['priceNone'];
8080
}
8181

82-
$payments[$direction ? 'in' : 'out'][$id] = $amount;
83-
$payments[$direction ? 'in_sum_total' : 'out_sum_total'] += $amount;
84-
++$payments[$direction ? 'in_total' : 'out_total'];
82+
$result[$direction ? 'in' : 'out'][$id] = $amount;
83+
$result[$direction ? 'in_sum_total' : 'out_sum_total'] += $amount;
84+
++$result[$direction ? 'in_total' : 'out_total'];
8585
}
8686
} elseif (\array_key_exists('account', $transaction)) {
8787
if ($banker->bankIDS === $transaction['account']['ids']) {
@@ -91,7 +91,7 @@
9191
}
9292
}
9393

94-
$written = file_put_contents($destination, json_encode($payments, \Ease\Shared::cfg('DEBUG') ? \JSON_PRETTY_PRINT : 0));
94+
$written = file_put_contents($destination, json_encode($result, \Ease\Shared::cfg('DEBUG') ? \JSON_PRETTY_PRINT : 0));
9595
$banker->addStatusMessage(sprintf(_('Saving result to %s'), $destination), $written ? 'success' : 'error');
9696

9797
exit($exitCode ?: ($written ? 0 : 1));

0 commit comments

Comments
 (0)