initial commit
This commit is contained in:
3
dev/itop/itop-integrations/Dockerfile
Executable file
3
dev/itop/itop-integrations/Dockerfile
Executable file
@@ -0,0 +1,3 @@
|
||||
FROM ubuntu
|
||||
RUN apt update && apt upgrade -y
|
||||
RUN apt install wget -y
|
||||
2
dev/itop/itop-integrations/add-person.sh
Executable file
2
dev/itop/itop-integrations/add-person.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
php webservices/import.php --auth_user=login --auth_pwd=password --csvfile="location.csv"
|
||||
--charset="UTF-8" --no_localize=1 --class="Location" --reconcialiationkeys="name,org_id->name"
|
||||
135
dev/itop/itop-integrations/apifunction.php
Executable file
135
dev/itop/itop-integrations/apifunction.php
Executable file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
class itopApi {
|
||||
|
||||
|
||||
|
||||
// Define API details
|
||||
|
||||
public function __construct() {
|
||||
|
||||
$this->itopApi = array(
|
||||
|
||||
"url" => "http://itop.alldcs.nl",
|
||||
|
||||
"user" => "allard",
|
||||
|
||||
"pass" => "Itop01@"
|
||||
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Get details function
|
||||
|
||||
|
||||
public function get($class,$key) {
|
||||
|
||||
|
||||
$params['operation'] = 'core/get';
|
||||
|
||||
$params['class'] = $class;
|
||||
|
||||
$params['key'] = $key;
|
||||
|
||||
|
||||
$execute = $this->execute($params);
|
||||
|
||||
RETURN $execute;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Apply stimulus to an object
|
||||
|
||||
|
||||
|
||||
public function stimulus($param,$fields) {
|
||||
|
||||
|
||||
$params['operation'] = 'core/apply_stimulus';
|
||||
|
||||
$params['comment'] = $param['comment'];
|
||||
|
||||
$params['stimulus'] = $param['stimulus'];
|
||||
|
||||
$params['class'] = $param['class'];
|
||||
|
||||
$params['key'] = $param['key'];
|
||||
|
||||
$params['fields'] = $fields;
|
||||
|
||||
|
||||
$execute = $this->execute($params);
|
||||
|
||||
|
||||
RETURN $execute;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Hit data to itop server
|
||||
|
||||
private function execute($params) {
|
||||
|
||||
|
||||
$param['auth_user'] = $this->itopApi['user'];
|
||||
|
||||
$param['auth_pwd'] = $this->itopApi['pass'];
|
||||
|
||||
$param['json_data'] = json_encode($params);
|
||||
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $this->itopApi['url']);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, count($param));
|
||||
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param));
|
||||
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$result = json_decode(curl_exec($ch),true);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
RETURN $result; // Returning data on array format
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Testing purpose function
|
||||
|
||||
|
||||
public function test() {
|
||||
|
||||
|
||||
|
||||
echo $this->itopApi['url'];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
12
dev/itop/itop-integrations/change.json
Executable file
12
dev/itop/itop-integrations/change.json
Executable file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"operation":"core/create",
|
||||
"comment":"Synchronization from blah...",
|
||||
"class":"RoutineChange",
|
||||
"fields":
|
||||
{
|
||||
"org_id":"SELECT Organization WHERE name = 'ALLDCS'",
|
||||
"caller_id":{"name":"Krings","first_name":"Allard"},
|
||||
"title":"container",
|
||||
"description":"container gebouwd"
|
||||
}
|
||||
}
|
||||
28
dev/itop/itop-integrations/create-change.sh
Executable file
28
dev/itop/itop-integrations/create-change.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
##################################################################################
|
||||
# #
|
||||
# Example script for creating a UserRequest ticket via the REST/JSON webservices #
|
||||
# #
|
||||
##################################################################################
|
||||
|
||||
# iTop location and credentials, change them to suit your iTop installation
|
||||
ITOP_URL="https://itop.alldcs.nl"
|
||||
ITOP_USER="tekton"
|
||||
ITOP_PWD="Itop01@@@"
|
||||
ORGANIZATION="0002"
|
||||
TITLE="Change registration"
|
||||
DESCRIPTION="Container created"
|
||||
CALLER="0001"
|
||||
COMMENT="commentaar"
|
||||
CHANGE="RoutineChange"
|
||||
# Let's create the ticket via the REST/JSON API
|
||||
JSON_DATA='{"operation":"core/create", "class":"'"${CHANGE}"'", "fields": {"org_id":"'"${ORGANIZATION}"'", "title":"'"$TITLE"'", "description":"'"$DESCRIPTION"'"}, "caller": "'"$CALLER"'", "comment": "'"$COMMENT"'"}'
|
||||
RESULT=`wget -q --post-data='auth_user='"${ITOP_USER}"'&auth_pwd='"${ITOP_PWD}"'&json_data='"${JSON_DATA}" --no-check-certificate -O - "${ITOP_URL}/webservices/rest.php?version=1.0"`
|
||||
PATTERN='"key":"([0-9])+"'
|
||||
if [[ $RESULT =~ $PATTERN ]]; then
|
||||
echo "Change created successfully"
|
||||
else
|
||||
echo "ERROR: failed to create change"
|
||||
echo $RESULT
|
||||
exit 1
|
||||
fi
|
||||
1
dev/itop/itop-integrations/curl.sh
Executable file
1
dev/itop/itop-integrations/curl.sh
Executable file
@@ -0,0 +1 @@
|
||||
curl -X POST -F 'version=1.3' -F 'auth_user=allard' -F 'auth_pwd=Itop01@@@' http://itop.alldcs.nl/webservices/rest.php -F 'json_data=@./change.json'
|
||||
3
dev/itop/itop-integrations/itop-integrations/Dockerfile
Executable file
3
dev/itop/itop-integrations/itop-integrations/Dockerfile
Executable file
@@ -0,0 +1,3 @@
|
||||
FROM ubuntu
|
||||
RUN apt update && apt upgrade -y
|
||||
RUN apt install wget -y
|
||||
2
dev/itop/itop-integrations/itop-integrations/add-person.sh
Executable file
2
dev/itop/itop-integrations/itop-integrations/add-person.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
php webservices/import.php --auth_user=login --auth_pwd=password --csvfile="location.csv"
|
||||
--charset="UTF-8" --no_localize=1 --class="Location" --reconcialiationkeys="name,org_id->name"
|
||||
135
dev/itop/itop-integrations/itop-integrations/apifunction.php
Executable file
135
dev/itop/itop-integrations/itop-integrations/apifunction.php
Executable file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
class itopApi {
|
||||
|
||||
|
||||
|
||||
// Define API details
|
||||
|
||||
public function __construct() {
|
||||
|
||||
$this->itopApi = array(
|
||||
|
||||
"url" => "http://itop.alldcs.nl",
|
||||
|
||||
"user" => "allard",
|
||||
|
||||
"pass" => "Itop01@"
|
||||
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Get details function
|
||||
|
||||
|
||||
public function get($class,$key) {
|
||||
|
||||
|
||||
$params['operation'] = 'core/get';
|
||||
|
||||
$params['class'] = $class;
|
||||
|
||||
$params['key'] = $key;
|
||||
|
||||
|
||||
$execute = $this->execute($params);
|
||||
|
||||
RETURN $execute;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Apply stimulus to an object
|
||||
|
||||
|
||||
|
||||
public function stimulus($param,$fields) {
|
||||
|
||||
|
||||
$params['operation'] = 'core/apply_stimulus';
|
||||
|
||||
$params['comment'] = $param['comment'];
|
||||
|
||||
$params['stimulus'] = $param['stimulus'];
|
||||
|
||||
$params['class'] = $param['class'];
|
||||
|
||||
$params['key'] = $param['key'];
|
||||
|
||||
$params['fields'] = $fields;
|
||||
|
||||
|
||||
$execute = $this->execute($params);
|
||||
|
||||
|
||||
RETURN $execute;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Hit data to itop server
|
||||
|
||||
private function execute($params) {
|
||||
|
||||
|
||||
$param['auth_user'] = $this->itopApi['user'];
|
||||
|
||||
$param['auth_pwd'] = $this->itopApi['pass'];
|
||||
|
||||
$param['json_data'] = json_encode($params);
|
||||
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $this->itopApi['url']);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, count($param));
|
||||
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param));
|
||||
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$result = json_decode(curl_exec($ch),true);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
RETURN $result; // Returning data on array format
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Testing purpose function
|
||||
|
||||
|
||||
public function test() {
|
||||
|
||||
|
||||
|
||||
echo $this->itopApi['url'];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
12
dev/itop/itop-integrations/itop-integrations/change.json
Executable file
12
dev/itop/itop-integrations/itop-integrations/change.json
Executable file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"operation":"core/create",
|
||||
"comment":"Synchronization from blah...",
|
||||
"class":"RoutineChange",
|
||||
"fields":
|
||||
{
|
||||
"org_id":"SELECT Organization WHERE name = 'ALLDCS'",
|
||||
"caller_id":{"name":"Krings","first_name":"Allard"},
|
||||
"title":"container",
|
||||
"description":"container gebouwd"
|
||||
}
|
||||
}
|
||||
27
dev/itop/itop-integrations/itop-integrations/create-change.sh
Executable file
27
dev/itop/itop-integrations/itop-integrations/create-change.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
##################################################################################
|
||||
# #
|
||||
# Example script for creating a UserRequest ticket via the REST/JSON webservices #
|
||||
# #
|
||||
##################################################################################
|
||||
|
||||
# iTop location and credentials, change them to suit your iTop installation
|
||||
ITOP_URL="https://itop.alldcs.nl"
|
||||
ITOP_USER="allard"
|
||||
ITOP_PWD="Itop01@@@"
|
||||
ORGANIZATION="0001"
|
||||
TITLE="UserRequest"
|
||||
DESCRIPTION="Container created"
|
||||
CALLER="0001"
|
||||
COMMENT="commentaar"
|
||||
CHANGE="RoutineChange"
|
||||
# Let's create the ticket via the REST/JSON API
|
||||
JSON_DATA='{"operation":"core/create", "class":"'"${CHANGE}"'", "fields": {"org_id":"'"${ORGANIZATION}"'", "title":"'"$TITLE"'", "description":"'"$DESCRIPTION"'"}, "caller": "'"$CALLER"'", "comment": "'"$COMMENT"'"}'
|
||||
RESULT=`wget -q --post-data='auth_user='"${ITOP_USER}"'&auth_pwd='"${ITOP_PWD}"'&json_data='"${JSON_DATA}" --no-check-certificate -O - "${ITOP_URL}/webservices/rest.php?version=1.0"`
|
||||
#PATTERN='"key":"([0-9])+"'
|
||||
#if [[ $RESULT =~ $PATTERN ]]; then
|
||||
# echo "Change created successfully"
|
||||
# else
|
||||
# echo "ERROR: failed to create change"
|
||||
# echo $RESULT
|
||||
#fi
|
||||
1
dev/itop/itop-integrations/itop-integrations/curl.sh
Executable file
1
dev/itop/itop-integrations/itop-integrations/curl.sh
Executable file
@@ -0,0 +1 @@
|
||||
curl -X POST -F 'version=1.3' -F 'auth_user=allard' -F 'auth_pwd=Itop01@@@' http://itop.alldcs.nl/webservices/rest.php -F 'json_data=@./change.json'
|
||||
13
dev/itop/itop-integrations/itop-integrations/my-json-operation.json
Executable file
13
dev/itop/itop-integrations/itop-integrations/my-json-operation.json
Executable file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"operation":"core/create",
|
||||
"comment":"Synchronization from blah...",
|
||||
"class":"UserRequest",
|
||||
"output_fields":"id, friendlyname",
|
||||
"fields":
|
||||
{
|
||||
"org_id":"SELECT Organization WHERE name = 'ALLDCS'",
|
||||
"caller_id":{"name":"Krings","first_name":"Allard"},
|
||||
"title":"issue blah",
|
||||
"description":"something happened"
|
||||
}
|
||||
}
|
||||
3
dev/itop/itop-integrations/itop-integrations/person.csv
Executable file
3
dev/itop/itop-integrations/itop-integrations/person.csv
Executable file
@@ -0,0 +1,3 @@
|
||||
Last Name,Status,Organization->Name,Email,Phone,Notification,Function,First Name
|
||||
"Monet","Active","Demo","monet@demo.com","","yes","","Claude"
|
||||
"Flaubert","Active","IT Department","flaubert@it.com","","yes","","Gustave"
|
||||
|
65
dev/itop/itop-integrations/itop-integrations/test-json.sh
Executable file
65
dev/itop/itop-integrations/itop-integrations/test-json.sh
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
##################################################################################
|
||||
# #
|
||||
# Example script for creating a UserRequest ticket via the REST/JSON webservices #
|
||||
# #
|
||||
##################################################################################
|
||||
|
||||
# iTop location and credentials, change them to suit your iTop installation
|
||||
ITOP_URL="https://itop.alldcs.nl"
|
||||
ITOP_USER="allard"
|
||||
ITOP_PWD="Itop01@@@"
|
||||
|
||||
|
||||
# Parameters checking, see below for default values
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Missing parameter 1: host"
|
||||
exit -1
|
||||
else
|
||||
HOST="$1"
|
||||
fi
|
||||
|
||||
if [ "$2" == "" ]; then
|
||||
echo "Missing parameter 2: Service"
|
||||
exit -1
|
||||
else
|
||||
SERVICE="$2"
|
||||
fi
|
||||
|
||||
if [ "$3" == "" ]; then
|
||||
echo "Missing parameter 3: Service Status"
|
||||
exit -1
|
||||
else
|
||||
SERVICE_STATUS="$3"
|
||||
fi
|
||||
|
||||
if [ "$4" == "" ]; then
|
||||
echo "Missing parameter 4: Service State Type"
|
||||
exit -1
|
||||
else
|
||||
SERVICE_STATUS_TYPE="$4"
|
||||
fi
|
||||
|
||||
# Default values, adapt them to your configuration
|
||||
TICKET_CLASS="UserRequest"
|
||||
ORGANIZATION="SELECT Organization JOIN FunctionalCI AS CI ON CI.org_id=Organization.id WHERE CI.name='"${HOST}"'"
|
||||
TITLE="Service Down on $1"
|
||||
DESCRIPTION="The service $SERVICE is in state $SERVICE_STATUS on $HOST"
|
||||
|
||||
# Let's create the ticket via the REST/JSON API
|
||||
if [[ ( "$SERVICE_STATUS" != "OK" ) && ( "$SERVICE_STATUS" != "UP" ) && ( "$SERVICE_STATUS_TYPE" == "HARD" ) ]]; then
|
||||
CIS_LIST='[{"functionalci_id":"SELECT FunctionalCI WHERE name=\"'"$1"'\"", "impact_code": "manual"}]'
|
||||
JSON_DATA='{"operation":"core/create", "class":"'"${TICKET_CLASS}"'", "fields": {"functionalcis_list":'"${CIS_LIST}"', "org_id":"'"${ORGANIZATION}"'", "title":"'"$TITLE"'", "description":"'"$DESCRIPTION"'"}, "comment": "Created by the Monitoring", "output_fields": "id"}'
|
||||
|
||||
RESULT=`wget -q --post-data='auth_user='"${ITOP_USER}"'&auth_pwd='"${ITOP_PWD}"'&json_data='"${JSON_DATA}" --no-check-certificate -O - "${ITOP_URL}/webservices/rest.php?version=1.0"`
|
||||
|
||||
PATTERN='"key":"([0-9])+"'
|
||||
if [[ $RESULT =~ $PATTERN ]]; then
|
||||
echo "Ticket created successfully"
|
||||
else
|
||||
echo "ERROR: failed to create ticket"
|
||||
echo $RESULT
|
||||
fi
|
||||
else
|
||||
echo "Service State Type != HARD, doing nothing"
|
||||
fi
|
||||
8
dev/itop/itop-integrations/itop-integrations/test.sh
Executable file
8
dev/itop/itop-integrations/itop-integrations/test.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
HTTP POST itop.alldcs.nl/webservices/rest.php?version=1.3
|
||||
auth_user=Itop_admin
|
||||
auth_pwd=Itop01@
|
||||
json_data=
|
||||
{
|
||||
"operation": "list_operations"
|
||||
}
|
||||
73
dev/itop/itop-integrations/itop-integrations/tester.php
Executable file
73
dev/itop/itop-integrations/itop-integrations/tester.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
include('apifunction.php');
|
||||
|
||||
$itopApi = new itopApi;
|
||||
|
||||
/** GET Function Test **/
|
||||
|
||||
/**
|
||||
|
||||
$api = $itopApi->get("Incident","1620");
|
||||
|
||||
echo "<pre>";
|
||||
|
||||
print_r($api);
|
||||
|
||||
echo "</pre>";
|
||||
|
||||
**/
|
||||
|
||||
|
||||
/** ASSIGN (Stimulus) Function Test **/
|
||||
|
||||
/* $param['comment'] = "Assigned from API";
|
||||
|
||||
$param['stimulus'] = "ev_assign";
|
||||
|
||||
$param['class'] = "Incident";
|
||||
|
||||
$param['key'] = "1620";
|
||||
|
||||
$fields['team_id'] = "39";
|
||||
|
||||
$fields['agent_id'] = "3";
|
||||
|
||||
$api = $itopApi->stimulus($param,$fields);
|
||||
|
||||
echo "<pre>";
|
||||
|
||||
print_r($api);
|
||||
|
||||
echo "</pre>"; */
|
||||
|
||||
|
||||
/** RESOLVE (Stimulus) Function Test **/
|
||||
|
||||
|
||||
|
||||
/* $param['comment'] = "Resolved from API";
|
||||
|
||||
$param['stimulus'] = "ev_resolve";
|
||||
|
||||
$param['class'] = "Incident";
|
||||
|
||||
$param['key'] = "1653";
|
||||
|
||||
$fields['solution'] = "PC Sudah terinstall iReap";
|
||||
|
||||
|
||||
$api = $itopApi->stimulus($param,$fields);
|
||||
|
||||
|
||||
echo "<pre>";
|
||||
|
||||
print_r($api);
|
||||
|
||||
echo "</pre>"; */
|
||||
|
||||
|
||||
|
||||
?>
|
||||
13
dev/itop/itop-integrations/my-json-operation.json
Executable file
13
dev/itop/itop-integrations/my-json-operation.json
Executable file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"operation":"core/create",
|
||||
"comment":"Synchronization from blah...",
|
||||
"class":"UserRequest",
|
||||
"output_fields":"id, friendlyname",
|
||||
"fields":
|
||||
{
|
||||
"org_id":"SELECT Organization WHERE name = 'ALLDCS'",
|
||||
"caller_id":{"name":"Krings","first_name":"Allard"},
|
||||
"title":"issue blah",
|
||||
"description":"something happened"
|
||||
}
|
||||
}
|
||||
3
dev/itop/itop-integrations/person.csv
Executable file
3
dev/itop/itop-integrations/person.csv
Executable file
@@ -0,0 +1,3 @@
|
||||
Last Name,Status,Organization->Name,Email,Phone,Notification,Function,First Name
|
||||
"Monet","Active","Demo","monet@demo.com","","yes","","Claude"
|
||||
"Flaubert","Active","IT Department","flaubert@it.com","","yes","","Gustave"
|
||||
|
65
dev/itop/itop-integrations/test-json.sh
Executable file
65
dev/itop/itop-integrations/test-json.sh
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
##################################################################################
|
||||
# #
|
||||
# Example script for creating a UserRequest ticket via the REST/JSON webservices #
|
||||
# #
|
||||
##################################################################################
|
||||
|
||||
# iTop location and credentials, change them to suit your iTop installation
|
||||
ITOP_URL="https://itop.alldcs.nl"
|
||||
ITOP_USER="allard"
|
||||
ITOP_PWD="Itop01@@@"
|
||||
|
||||
|
||||
# Parameters checking, see below for default values
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Missing parameter 1: host"
|
||||
exit -1
|
||||
else
|
||||
HOST="$1"
|
||||
fi
|
||||
|
||||
if [ "$2" == "" ]; then
|
||||
echo "Missing parameter 2: Service"
|
||||
exit -1
|
||||
else
|
||||
SERVICE="$2"
|
||||
fi
|
||||
|
||||
if [ "$3" == "" ]; then
|
||||
echo "Missing parameter 3: Service Status"
|
||||
exit -1
|
||||
else
|
||||
SERVICE_STATUS="$3"
|
||||
fi
|
||||
|
||||
if [ "$4" == "" ]; then
|
||||
echo "Missing parameter 4: Service State Type"
|
||||
exit -1
|
||||
else
|
||||
SERVICE_STATUS_TYPE="$4"
|
||||
fi
|
||||
|
||||
# Default values, adapt them to your configuration
|
||||
TICKET_CLASS="UserRequest"
|
||||
ORGANIZATION="SELECT Organization JOIN FunctionalCI AS CI ON CI.org_id=Organization.id WHERE CI.name='"${HOST}"'"
|
||||
TITLE="Service Down on $1"
|
||||
DESCRIPTION="The service $SERVICE is in state $SERVICE_STATUS on $HOST"
|
||||
|
||||
# Let's create the ticket via the REST/JSON API
|
||||
if [[ ( "$SERVICE_STATUS" != "OK" ) && ( "$SERVICE_STATUS" != "UP" ) && ( "$SERVICE_STATUS_TYPE" == "HARD" ) ]]; then
|
||||
CIS_LIST='[{"functionalci_id":"SELECT FunctionalCI WHERE name=\"'"$1"'\"", "impact_code": "manual"}]'
|
||||
JSON_DATA='{"operation":"core/create", "class":"'"${TICKET_CLASS}"'", "fields": {"functionalcis_list":'"${CIS_LIST}"', "org_id":"'"${ORGANIZATION}"'", "title":"'"$TITLE"'", "description":"'"$DESCRIPTION"'"}, "comment": "Created by the Monitoring", "output_fields": "id"}'
|
||||
|
||||
RESULT=`wget -q --post-data='auth_user='"${ITOP_USER}"'&auth_pwd='"${ITOP_PWD}"'&json_data='"${JSON_DATA}" --no-check-certificate -O - "${ITOP_URL}/webservices/rest.php?version=1.0"`
|
||||
|
||||
PATTERN='"key":"([0-9])+"'
|
||||
if [[ $RESULT =~ $PATTERN ]]; then
|
||||
echo "Ticket created successfully"
|
||||
else
|
||||
echo "ERROR: failed to create ticket"
|
||||
echo $RESULT
|
||||
fi
|
||||
else
|
||||
echo "Service State Type != HARD, doing nothing"
|
||||
fi
|
||||
8
dev/itop/itop-integrations/test.sh
Executable file
8
dev/itop/itop-integrations/test.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
HTTP POST itop.alldcs.nl/webservices/rest.php?version=1.3
|
||||
auth_user=Itop_admin
|
||||
auth_pwd=Itop01@
|
||||
json_data=
|
||||
{
|
||||
"operation": "list_operations"
|
||||
}
|
||||
73
dev/itop/itop-integrations/tester.php
Executable file
73
dev/itop/itop-integrations/tester.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
include('apifunction.php');
|
||||
|
||||
$itopApi = new itopApi;
|
||||
|
||||
/** GET Function Test **/
|
||||
|
||||
/**
|
||||
|
||||
$api = $itopApi->get("Incident","1620");
|
||||
|
||||
echo "<pre>";
|
||||
|
||||
print_r($api);
|
||||
|
||||
echo "</pre>";
|
||||
|
||||
**/
|
||||
|
||||
|
||||
/** ASSIGN (Stimulus) Function Test **/
|
||||
|
||||
/* $param['comment'] = "Assigned from API";
|
||||
|
||||
$param['stimulus'] = "ev_assign";
|
||||
|
||||
$param['class'] = "Incident";
|
||||
|
||||
$param['key'] = "1620";
|
||||
|
||||
$fields['team_id'] = "39";
|
||||
|
||||
$fields['agent_id'] = "3";
|
||||
|
||||
$api = $itopApi->stimulus($param,$fields);
|
||||
|
||||
echo "<pre>";
|
||||
|
||||
print_r($api);
|
||||
|
||||
echo "</pre>"; */
|
||||
|
||||
|
||||
/** RESOLVE (Stimulus) Function Test **/
|
||||
|
||||
|
||||
|
||||
/* $param['comment'] = "Resolved from API";
|
||||
|
||||
$param['stimulus'] = "ev_resolve";
|
||||
|
||||
$param['class'] = "Incident";
|
||||
|
||||
$param['key'] = "1653";
|
||||
|
||||
$fields['solution'] = "PC Sudah terinstall iReap";
|
||||
|
||||
|
||||
$api = $itopApi->stimulus($param,$fields);
|
||||
|
||||
|
||||
echo "<pre>";
|
||||
|
||||
print_r($api);
|
||||
|
||||
echo "</pre>"; */
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user