1.0 Summary
We have built a plugin for a health check.Customer can configure the monitor plugin from plugins.
Plugin name : Health Check
Whenever an incident is tracked on the particular server (which may affect the working condition
of particular number), SI will update the same using client payload.
Payload format:
Below API formats are supported
1. GET
2. POST
3. Post with RAW JSON
With the help of the payload, incident will be pushed to client.
2.0 Design Considerations
2.1 DB Design
Tables :
infi_voice_monitor: Table contains server and status details.
COLUMN | DATA TYPE | DESCRIPTION |
id | int(11) | unique identification number |
server_id | smallint(5) | Server id |
name | varchar(100) | Server name |
server_tag | varchar(30) | Component id |
channel_id | int(10) | Channel id |
capacity
| int(10) | Channel capacity |
used | int(10) | Channel used value |
primary_server | varchar(100)
| Primary server |
region | varchar(100) | Region |
region_code | varchar(100) | Region code |
incident_status | varchar(50) | Status from the incident api |
final_status | varchar(50) | Wrapping status |
status_report | tinyint(4) | Flag to send callback |
meta | text | Text field (optional) |
created | int(11) | Created date |
modified | int(11) | Modified date |
2.2 Application Design
Component : com_monitor
3.0 Database
infi_voice_monitor
3.1 Migration
3.2 Archival Policy
4.0 Cron Jobs
4.1 Callback cron
php -f /var/www/html/voice/cron/runHelper?helper=Callback&component=monitor
4.2 Incident cron
php -f /var/www/html/voice/cron/runHelper?helper=Incident&component=monitor
5.0 Reports
6.0 API
Incident API :
API - voice.kaleyra.com/v1/?api_key=yourapikeyhere&method=monitor&format=xml
Fields :
api_key → unique api key.
method → function name.
format → response format (xml/json).
Responses :
<api>
<status>200</status>
<message>OK</message>
<data>
<incidents>
<monitor>
<region>karnataka</region>
<region_code>DL-IN</region_code>
<type>operational</type>
<service>all</service>
<numbers>
<monitor>+0809900112234</monitor>
</numbers>
</monitor>
<monitor>
<region>karnataka</region>
<region_code>KA-IN</region_code>
<type>operational</type>
<service>all</service>
<numbers>
<monitor>+878788197367616</monitor>
</numbers>
</monitor>
</incidents>
</data>
</api>
Field | Description | Example |
status | API Status | 200 |
message | Api response message | OK |
data | Data array contain all the incidents | Data array |
incidents | Region wise incidents listing | Incidents array |
region | Server region | karnataka |
region-code | Region codes | KA-IN |
type | Server status | Operational / warning / critical |
service | It can be incoming / outgoing or all | Currently we wrapped ‘all’ for all the results. |
numbers | All the numbers subscribed for the user. | 9988xxxxxx |
Response Codes :
Response codes | Description | Example Message |
E542 | Plugin not subscribed for user | User Plugin not found or inactive |
E701 | If Incidents not present | No incidents found |
OK | For valid response with data | Message : OK |
These payloads will be only triggered when the status particular number is changed.
Api is available in the monitor plugin configuration page.
7.0 Callback :
7.1 configure callback url
Fields :
Status : Active / Inactive
Title : Title for the callback
Name : Name of the callback
Callback URL : callback api
Payload : payload for POST request
Headers : headers if any
Checkbox : For raw http post request
Methods:
GET :
For the GET request,
Example:
Callback URL : https://webhook.site/6746153d-cd3f-46db-803f-de5ed1dfdc0b?data={response}
Payload : empty
Headers : if present
POST:
For POST request,
Example:
Callback URL : https://webhook.site/6746153d-cd3f-46db-803f-de5ed1dfdc0b
Payload : data={response}
Headers : if present
For JSON request,
Callback URL : https://webhook.site/6746153d-cd3f-46db-803f-de5ed1dfdc0b
Payload : data={response}
Headers: if present
Checkbox : need to check this option for raw json response.