|
1 | | -[![Build Status][0]][1] |
| 1 | +[![Build Status][1]][2] |
2 | 2 |
|
3 | | -randomhost/icinga-notification |
4 | | -============================== |
| 3 | +# randomhost/icinga-notification |
5 | 4 |
|
6 | | -This package provides a set of common notification commands to a accompany the |
7 | | -`randomhost/icinga` package. |
| 5 | +<!-- TOC --> |
| 6 | +* [1. Purpose](#1-purpose) |
| 7 | +* [2. Usage](#2-usage) |
| 8 | + * [2.1. CM.com](#21-cmcom) |
| 9 | + * [2.1.1. Usage Example](#211-usage-example) |
| 10 | + * [2.1.2. Command Line Parameters](#212-command-line-parameters) |
| 11 | +* [3. License](#3-license) |
| 12 | +<!-- TOC --> |
8 | 13 |
|
9 | | -Usage |
10 | | ------ |
| 14 | +## 1. Purpose |
11 | 15 |
|
12 | | -`NotifyMyAndroid` is currently the only available notification plugin but more |
13 | | -will follow in the future. |
| 16 | +This package provides a set of common notification commands to accompany the |
| 17 | +[`randomhost/icinga`][3] package. |
14 | 18 |
|
15 | | -### NotifyMyAndroid |
| 19 | +## 2. Usage |
16 | 20 |
|
17 | | -Sends notifications using [NotifyMyAndroid][2]. |
| 21 | +`CmDotCom` is currently the only available notification plugin. |
18 | 22 |
|
19 | | -#### Usage example |
| 23 | +### 2.1. CM.com |
| 24 | + |
| 25 | +Sends notifications using [CM.com][4]. |
| 26 | + |
| 27 | +#### 2.1.1. Usage Example |
20 | 28 |
|
21 | 29 | ```php |
22 | 30 | <?php |
23 | | -namespace randomhost\Icinga\Notification; |
24 | 31 |
|
25 | | -require_once '/path/to/vendor/autoload.php'; |
| 32 | +use randomhost\Icinga\Notification\CmDotCom\Factory; |
26 | 33 |
|
27 | | -use randomhost\NotifyMyAndroid\Client as NmaClient; |
| 34 | +include $_composer_autoload_path ?? __DIR__.'/../../vendor/autoload.php'; |
28 | 35 |
|
29 | | -$nmaClient = new NmaClient(); |
30 | | - |
31 | | -$notification = new NotifyMyAndroid($nmaClient); |
32 | | -$notification->setOptions( |
33 | | - getopt( |
34 | | - $notification->getShortOptions(), |
35 | | - $notification->getLongOptions() |
| 36 | +$notification = (new Factory())->getNotification(); |
| 37 | +$notification |
| 38 | + ->setOptions( |
| 39 | + getopt( |
| 40 | + $notification->getShortOptions(), |
| 41 | + $notification->getLongOptions() |
| 42 | + ) |
36 | 43 | ) |
37 | | -); |
38 | | -$notification->run(); |
| 44 | + ->run() |
| 45 | +; |
39 | 46 |
|
40 | 47 | echo $notification->getMessage(); |
| 48 | + |
41 | 49 | exit($notification->getCode()); |
42 | 50 | ``` |
43 | 51 |
|
44 | | -This will instantiate the NotifyMyAndroid notification plugin and send a push |
45 | | -notification to the NMA API key provided on the command line. |
| 52 | +This will instantiate the CM.com notification plugin and send a text message to |
| 53 | +the phone number provided on the command line. |
46 | 54 |
|
47 | | -#### Command line parameters |
| 55 | +#### 2.1.2. Command Line Parameters |
48 | 56 |
|
49 | | -| Parameter | Description | |
50 | | -| ------------------- | ----------------------- | |
51 | | -| --type | Notification type | |
52 | | -| --service | Service name | |
53 | | -| --host | Host name | |
54 | | -| --address | Host address | |
55 | | -| --state | Service state | |
56 | | -| --time | Notification time | |
57 | | -| --output | Check plugin output | |
58 | | -| --apikey | NotifyMyAndroid API key | |
| 57 | +| Parameter | Description | |
| 58 | +|-------------|----------------------------------------------------------| |
| 59 | +| `--type` | Notification type | |
| 60 | +| `--service` | Service name | |
| 61 | +| `--host` | Host name | |
| 62 | +| `--address` | Host address | |
| 63 | +| `--state` | Service state | |
| 64 | +| `--time` | Notification time | |
| 65 | +| `--output` | Check plugin output | |
| 66 | +| `--phone` | Phone number in international format (e.g. +12065550199) | |
| 67 | +| `--apikey` | CM.com API key | |
59 | 68 |
|
60 | | -License |
61 | | -------- |
| 69 | +## 3. License |
62 | 70 |
|
63 | 71 | See LICENSE.txt for full license details. |
64 | 72 |
|
65 | 73 |
|
66 | | -[0]: https://travis-ci.org/randomhost/icinga-notification.svg?branch=master |
67 | | -[1]: https://travis-ci.org/randomhost/icinga-notification |
68 | | -[2]: http://notifymyandroid.com |
| 74 | +[1]: https://github.com/randomhost/icinga-notification/actions/workflows/php.yml/badge.svg |
| 75 | +[2]: https://github.com/randomhost/icinga-notification/actions/workflows/php.yml |
| 76 | +[3]: https://github.com/randomhost/icinga-notification |
| 77 | +[4]: https://cm.com |
0 commit comments