/
sipsecmon_service_restart.php
57 lines (47 loc) · 1.28 KB
/
sipsecmon_service_restart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/*
* sipsecmon service restart
*/
include_once 'setting.inc.php';
require_once PEST_PATH.'pest/PestJSON.php';
$options['server'] = 'http://' . SERVER;
$options['request'] = 'POST';
$base_url = $options['server'] .'/SAFe/sng_rest/api/';
$method_name = 'restart';
$module_name = 'sipsecmon';
$obj_type = 'service';
$obj_name = '';
$request_uri = $method_name .'/'. $module_name .'/'. $obj_type .'/'. $obj_name;
$json_data ='
{
}';
$data = json_decode($json_data);
try {
//API_KEY defined in 'setting.inc.php' send api key in header
//$header_array[]="X-API-KEY:C2FF69E5B86551C8062F9B56E1065370"
//$header_array[]="Content-Type: application/json" auto set by PestJSON
if(defined('API_KEY'))
{
$header_array[] = 'X-API-KEY:'.API_KEY;
}else{
$header_array = null;
}
$pest = new PestJSON($base_url);
$status = $pest->post($request_uri, $data, $header_array);
} catch(Exception $e) {
$status = json_decode($e->getMessage(), true);
}
$rc = $pest->lastStatus();
print('URL : ' . $base_url.$request_uri.PHP_EOL);
print('Output : ' . json_encode($status) .PHP_EOL);
print('Status : ' . $rc.PHP_EOL);
/*
* Output sample
{
"status": true,
"method": "restart",
"module": "sipsecmon",
"type": "service"
}Status: 200
*/
?>