feature: Add osTicket Alert Transport (#4791)

This commit is contained in:
Søren Rosiak
2016-10-20 21:31:30 +03:00
committed by Neil Lathwood
parent c3140218b3
commit 23da8be9c3
4 changed files with 92 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ Table of Content:
- [PlaySMS](#transports-playsms)
- [VictorOps](#transports-victorops)
- [Canopsis](#transports-canopsis)
- [osTicket](#transports-osticket)
- [Entities](#entities)
- [Devices](#entity-devices)
- [BGP Peers](#entity-bgppeers)
@@ -521,6 +522,23 @@ For more information about canopsis and its events, take a look here :
http://www.canopsis.org/
http://www.canopsis.org/wp-content/themes/canopsis/doc/sakura/user-guide/event-spec.html
## <a name="transports-osticket">osTicket</a>
[Using a proxy?](../Support/Configuration.md#proxy-support)
osTicket, open source ticket system. LibreNMS can send alerts to osTicket API which are then converted to osTicket tickets. To configure the transport, go to:
Global Settings -> Alerting Settings -> osTicket Transport.
This can also be done manually in config.php :
~~
```php
$config['alert']['transports']['osticket']['url'] = 'http://osticket.example.com/api/http.php/tickets.json';
$config['alert']['transports']['osticket']['token'] = '123456789';
```
~~
# <a name="entities">Entities
Entities as described earlier are based on the table and column names within the database, if you are unsure of what the entity is you want then have a browse around inside MySQL using `show tables` and `desc <tablename>`.

View File

@@ -953,6 +953,38 @@ echo '
<input id="canopsis_vhost" class="form-control" type="text" name="global-config-input" value="'.$canopsis_vhost['config_value'].'" data-config_id="'.$canopsis_vhost['config_id'].'">
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
</div>
</div>';
$osticket_url = get_config_by_name('alert.transports.osticket.url');
$osticket_token = get_config_by_name('alert.transports.osticket.token');
echo '
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#osticket_transport_expand"><i class="fa fa-caret-down"></i> osTicket transport</a> <button name="test-alert" id="test-alert" type="button" data-transport="osticket" class="btn btn-primary btn-xs pull-right">Test transport</button>
</h4>
</div>
<div id="osticket_transport_expand" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group has-feedback">
<label for="osticket_url" class="col-sm-4 control-label">osTicket API URL</label>
<div class="col-sm-4">
<input id="osticket_url" class="form-control" type="text" name="global-config-input" value="'.$osticket_url['config_value'].'" data-config_id="'.$osticket_url['config_id'].'">
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>
<div class="form-group has-feedback">
<label for="osticket_token" class="col-sm-4 control-label">osTicket API Token</label>
<div class="col-sm-4">
<input id="osticket_token" class="form-control" type="text" name="global-config-input" value="'.$osticket_token['config_value'].'" data-config_id="'.$osticket_token['config_id'].'">
<span class="form-control-feedback">
<i class="fa" aria-hidden="true"></i>
</span>
</div>
</div>

View File

@@ -0,0 +1,40 @@
/*
* LibreNMS
*
* Copyright (c) 2016 Søren Friis Rosiak <sorenrosiak@gmail.com>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
$url = $opts['url'];
$token = $opts['token'];
$protocol = array(
'name' => 'LibreNMS',
'email' => $_SERVER['SERVER_NAME'],
'subject' => ($obj['name'] ? $obj['name'] . ' on ' . $obj['hostname'] : $obj['title']) ,
'message' => strip_tags($obj['msg']) ,
'ip' => $_SERVER['REMOTE_ADDR'],
'attachments' => array() ,
);
$curl = curl_init();
set_curl_proxy($curl);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-type' => 'application/json',
'Expect:',
'X-API-Key: ' . $token
));
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($protocol));
$ret = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($code != 201) {
var_dump("osTicket returned Error, retry later");
return false;
}
return true;

2
sql-schema/147.sql Normal file
View File

@@ -0,0 +1,2 @@
INSERT INTO config VALUES ('','alert.transports.osticket.url','','','osTicket API URL','alerting',0, 'transports', 0, 0, 0);
INSERT INTO config VALUES ('','alert.transports.osticket.token','','','osTicket API Token','alerting',0, 'transports', 0, 0, 0);