Sciencelogic Api 11-2-0
Sciencelogic Api 11-2-0
1
Introduction
Overview
This manual describes the functionality of the ScienceLogic API and is intended for developers who are
responsible for integrating SL1 with external systems. To use this manual, you should have a general
understanding of the HTTP protocol.
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
l Valid SL1 login credentials. The API uses HTTP authentication methods. The credentials you include in the
HTTP request are validated against the user accounts stored in the system.
l A Resource URI. The URI for the resource (entity) you are performing the request on.
l An HTTP Method. Correlates to the action you would like to perform on the resource.
l An Accept Header. Specifies which format should be used for the response. The API supports
application/xml and application/json formats.
l The base URI of the API. The base URI of the API is the full address of the main API index. The base URI
includes information about the appliance you are using to access the API:
o
For Database Servers, Administration Portals, and All-In-One Appliances, the base URI of the API is:
https://<ip-address or hostname of appliance>/api
o
For Integration Servers, the base URI of the API is:
https://<ip-address or hostname of appliance>
NOTE: When you request a resource from the API using a web browser, the API will respond in raw
XML format. Some browsers, including Safari and Internet Explorer, will not display raw XML
correctly. If possible, you should use Mozilla Firefox to perform these steps.
2. Navigate to the base URI of the API for the appliance you are using. The standard authentication window is
displayed.
3. Enter the username and password for a user account in the system. The response for the main resource
index is displayed.
The response contains a list of URIs for the resources that are available through the API:
NOTE: If you are accessing the API through an Administration Portal, Database Server, or All-In-One
Appliance, the "/api" portion of the base URI is included in all resource URIs returned by the API.
<base URI>/organization
The index for the organization resource, which contains descriptions and URIs for every organization in the
system, is returned.
The browser handles the required elements of the request in the following ways:
l The credentials you enter are used to authenticate the request. Most browsers will save these credentials so
you need to enter them only once per session.
l You enter the resource URI (/organization) in the browser address bar.
l By default, the browser performs a GET request.
l The browser supplies a default accept header with the request. The default accept header used by Mozilla
Firefox contains "application/xml", one of the two response formats returned by the API.
Although using a web browser is the easiest way to make simple requests, using a browser provides limited
control and functionality. For example, you cannot explicitly perform PUT, POST of DELETE requests with a
browser. A browser will also handle certain aspects of requests and responses, such as automatically following
redirects, differently than they will be handled by integration code. ScienceLogic recommends you use command
line cURL to test requests.
API Settings
The REST API Settings page System > Settings > API allows you to define global parameters that affect the
behavior of the ScienceLogic API.
NOTE: The REST API Settings page is available only to administrator users.
1. Go to the REST API Settings page System > Settings > API.
2. In the REST API Settings page, edit the values in one or more of the following fields:
l Internal Request Account. Specify the user account that allows appliances to make API requests
without a password. For details on building such an API request, see the Internal API User section.
9 API Settings
l X-EM7-run-as Header Support. Specifies whether administrator users can make API requests using
the permissions of another user without that user's password. Choices are
o
Disabled. Administrator users cannot make API requests using the permissions of another user.
o
Enabled (Admin only). Administrator users can include the X-EM7-run-as Header to make API
requests using the permissions of another user. For details on using this header, see the
Authenticating Requests as Other Users section.
l Logging. Specifies which logs SL1 will write to when tickets are created or updated using the API.
Choices are:
o
Transaction Logging Only (System Logs). If a ticket is created or updated using the API, SL1 will
write an entry to the audit log that indicates that a user performed a write-operation using the
API. However, SL1 will not write to the ticket log for the ticket that was created or updated.
o
Normal (Ticket and System Logs). If a ticket is created or updated using the API, SL1 will write
to the audit log and to the ticket log for the ticket that was created or updated.
l X-EM7-suppress-logging Header Support. If Normal (Ticket and System Logs) is selected in the
Logging field, this field specifies whether an administrator can use the X-EM7-suppress-logging
header can be used when creating or updating a ticket with the API. If the X-EM7-suppress-logging
header is used when creating or updating a ticket, SL1 will not write to the ticket log for that ticket.
o
Disabled. The X-EM7-suppress-logging header cannot be used.
o
Enabled (Admin only). The X-EM7-suppress-logging header can be used to stop SL1 from
writing to the ticket log for the ticket that was created or updated.
l Send Notification. When a ticket is created or updated, SL1 can automatically send notification
Emails to the ticket assignee and ticket watchers. This option specifies the conditions under which SL1
will send notification Emails when tickets are created or updated using the API. Choices are:
o
Only if X-EM7-send-notification:1 is sent. EM7 will send notification Emails for a ticket only
when the X-EM7-send-notification header is set to 1.
o
Sent after every write operation. SL1 will send notification Emails for every API request that
creates or updates a ticket.
API Settings 10
Chapter
2
HTTP Methods, Headers and Response
Formats
Overview
This chapter covers how the API uses elements of the HTTP protocol to handle and respond to requests.
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
HTTP Methods 11
HTTP Status Codes 12
SL1-Specific Headers 13
Response Headers 13
Request Headers 14
Response Formats 14
HTTP Methods
To perform operations on API resources, you can use one of the following four HTTP methods in your requests.
Each resource has a different set of rules that determines which of the four methods can be used to make
requests.
GET
HTTP Methods 11
GET fetches resources. The response to a GET request contains information about the resource you requested.
POST
l To update a resource, use the POST method in a request to a specific instance of a resource. For example,
to update a ticket with ID "1", you would POST JSON or XML data to the following URI:
/ticket/1
If POST is used to update a resource, not all attributes of the resource need to be specified. The API will
update only the attributes specified in the request.
l To create a resource, use the POST method in a request to the index for that resource. For example, to
create a ticket, you would POST JSON or XML data to the following URI:
/ticket
The system creates a unique ID for the new resource. The URI for the new resource is based on the unique
ID for the resource.
PUT
PUT adds or replaces a resource. Unlike POST, PUT will replace an entire resource. PUT requires a specific
resource URI. The result of a PUT request will be consistent if the request is repeated.
DELETE
DELETE removes resources. If a resource allows the DELETE method, a successful DELETE request will remove the
corresponding entry in the ScienceLogic Database.
l 200 OK. Indicates that the request was valid and the transaction executed normally.
l 201 Created. Indicates that a new resource was created. 201 Created is not used when a resource is
updated.
l 202 Accepted. Indicates the request was accepted for processing.
l 204 No Content Returned. Indicates the request was successful but the API returned no content. This
response is typical when a file is uploaded via a PUT request.
l 301 Moved Permanently. Indicates that the request was made on a sub-resource, but the sub-resource ID
used in the request URI does not match a sub-resource associated with the main resource. For example, a
GET request was made for an interface (the sub-resource) for a device (the main resource), but the interface
ID in the URI is associated with a different device than the device ID used in the URI.
SL1-Specific Headers
Response Headers
In addition to HTTP status codes, every response from the API includes headers that provide additional details
about the result of a request:
SL1-Specific Headers 13
l X-EM7-authenticated-user. The URI of the user account that authenticated the request. If the request
included the X-EM7-run-as header, the X-EM7-authenticated-user will return the run-as user.
l X-EM7-status-code. Typically a human-readable version of the HTTP Status Code. For certain errors, X-
EM7-status-code might include additional information about why a request was unsuccessful. For
example, if a response has the HTTP Status code "400 Bad Request", the X-EM7-status-code might be
"FAILED_INPUT_VALIDATION".
l X-EM7-status-message. A human-readable description of the result of a request. The X-EM7-status-
message can contain multiple messages delimited by a newline character (\n). For example, if a response
has the HTTP Status code "302 Found", the X-EM7-status-message might be "ticket index requires a limit",
indicating the request was missing the required limit option.
l X-EM7-Last-updated. This header is returned only when requesting device configuration data from the API.
Returns the date and time that at least one value in the returned data changed.
Request Headers
The following ScienceLogic-specific headers can be used when making an API request:
l X-em7-beautify-response. By default, responses from the API use the minimum required amount of
whitespace. If you are making requests using a tool that does not format the output (such as command line
cURL), specify the X-em7-beautify-response header with a value of "1" to request additional whitespace in
the response to make it easier to read.
CAUTION: Using the X-em7-beautify-response:1 header can greatly increase the amount of time
required to process a request. Do not use this header in integration code.
l X-em7-run-as. The X-em7-run-as header can be used by administrator users to execute a request as a
different user. For information about the X-em7-run-as header, see the section on Authentication and
Access Permissions.
l X-em7-suppress-logging. If the system is configured to write to an entry in the ticket log when a ticket is
modified via the API, the X-em7-suppress-logging header can be used to modify a ticket via the API
without updating the ticket log. If the X-em7-suppress-logging header with a value of "1" is included in an
API request that modifies a ticket and the request is authenticated by an administrator user, the ticket logs
will not be updated based on the result of the request.
l X-em7-send-notification. When a ticket is created or updated, SL1 can automatically send notification
Emails to the ticket assignee and ticket watchers. If the system is not configured to send notification Emails
when tickets are created or updated using the API, the X-em7-send-notification header can be used to
send notification Emails for a specific request. If the X-em7-send-notification header with a value of "1" is
included in an API request that modifies a ticket, notification Emails will be sent based on the result of the
request.
Response Formats
The API can respond in XML and JSON formats. Use one of the following accept headers in your requests:
14 Response Formats
l accept: application/json, */*. The API will respond in JSON format. If the accept header is "*/*", the API
will respond with JSON as the default response format; however, it is recommended that you explicitly
accept "application/json" for clarity.
l accept: application/xml, */*. The API will respond in XML format.
If the accept header for a request does not include application/xml, application/json or */*, the API will
respond with a "406 Method Not Acceptable" status code.
The contents of responses are described in the Resources & URIs section.
Response Formats 15
Chapter
3
Resources & URIs
Overview
This chapter covers the available resources for the ScienceLogic API and information about creating and
updating API resources.
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
Available Resources 17
URI Formatting 18
Resource Index Responses 19
Constructing URIs Using a searchspec 20
Filters 20
Options 21
Sorting 22
Specifying a Query String in the Request Body 22
Required Options for Indexes 23
Resource Responses 23
Creating and Updating Resources 24
Asynchronous Operations 24
Links Between Resources 25
16
Size Limits 25
Available Resources
You can interact with the following entities through the API:
l Accounts
l Account Lockouts
l Alerts
l Appliances
l Assets
l Collector Groups
l CBQoS Objects
l Collection Labels
l Credentials
l Custom Attributes
l Dashboards
l Devices
l Device Categories
l Device Classes
l Device Interfaces
l Device Groups
l Device Relationships
l Device Templates
l Discovery Sessions
l Dynamic Applications
l Events
l Event Categories
l External Contacts
l File Uploads
l Interfaces
l Monitoring Policies
l Organizations
l Performance Data
l PowerPacks
17 Available Resources
l Product SKUs
l Schedules
l System Patches
l System Settings
l Tasks
l System Thresholds
l Themes
l Thresholds
l Tickets
l Ticket Categories
l Ticket Chargeback
l Ticket Logs
l Ticket Notes
l Ticket Queues
l Ticket States
l User Policies
l Vendors
NOTE: Some resources support only view access to the corresponding SL1 entity, while other resources
provide support for create, edit, and/or delete operations. For a full listing of all actions that can be
performed through the API, see the Available Actions section.
URI Formatting
All resources have a URI relative to the base URI for the API:
l For Database Servers, Administration Portals, and All-In-One Appliances, the base URI of the API is:
https://<ip-address or hostname of appliance>/api
For the resource URIs listed in the previous section, the full URI of the index is:
The URIs for specific resources combine the resource index URI and the unique ID of the specific resource. For
example, the URI for the ticket with ticket ID 1 is:
/ticket/1
URI Formatting 18
Some resources include sub-resources. For example, a note is a sub-resource of a ticket. If a resource includes a
sub-resource, each instance of that resource includes an index for the sub-resource. For example, the index of
notes attached to the ticket with ticket ID 1 is:
/ticket/1/note
/ticket/1/note/<note ID>
NOTE: If you are accessing the API through an Administration Portal, Database Server, or All-In-One
Appliance, the "/api" portion of the base URI is included in all resource URIs returned by the API.
{
"searchspec":{
"fields":{
"data":[
"field",
.
.
]
},
"options":{
"option name":{
"type":"...",
"description":"...",
"default":"...",
};
.
.
},
},
"total_matched":"X",
"total_returned":"Y",
"result_set":[
{
}
]
}
The XML response for the same request contains the same attributes in a similar structure.
Any number of options and filters can be added to the URI after the question mark (?), delimited by ampersands
(&).
All resource indexes support an additional option that allows you to specify the sort order. The sort order option
can be included only once in a single request.
Filters
You can filter the results contained in the response using any of the fields contained in the "fields" section of the
searchspec. For basic equality operations, filters have the following syntax:
You can add the following operators before the equals sign (=) to perform different comparisons:
l .min. The specified value is the minimum value for the field. Equivalent to a "greater than or equal to"
operation.
l .max. The specified value is the maximum value for the field. Equivalent to a "less than or equal to"
operation.
l .contains. The field contains the specified value as a sub-string.
l .begins_with. The field begins with the specified value as a sub-string.
l .ends_with. The field ends with the specified value as a sub-string.
l .isnull. The specified value must be 0 or 1. If you specify a value of 0, records that have a non-null value in
the specified field will be returned. If you specify a value of 1, records that have a null (empty) value in the
specified field will be returned.
l .in. The field equates to one of the values given in a list. The value to equate must be in the following list
format:
<value 1>, <value 2>, <value 3>, ...
filter.severity.min=3
The inverse of a filter can be created by adding ".not" to the filter clause. To request the inverse of the previous
example:
filter.severity.not.min=3
NOTE: If you include multiple filters for the same field in a URI, the API will return only results that match all
the filters for that field (i.e. the API will perform an AND operation).
Options
Every resource index has a set of options that can be added to a request URI to limit or change the results
contained in the response. Each entry in the "options" section of the searchspec has the following attributes:
l type. The data type of the option value. The value you pass for this option must be of this data type.
l description. A description of how the option affects the response.
l default. The default value of the option.
l extended_fetch. By default, the result_set will contain only the URI and description for each returned
resource. If extended_fetch is set to 1 in the URI, the response will contain all attributes of all returned
resources.
l hide_filterinfo. If this option is set to 1 in the URI, the response will contain only the result_set.
l limit. The maximum number of resources that should be returned in the response. For example, if you
include "limit=100" in the URI, the first 100 resources are returned in the response.
l offset. After the API has assembled a list of possible resources to include in the response, based on the
specified filters, offset determines which resource will be the first entry in the response list. offset begins at
zero for the first resource, one for the second resource, and so forth. For example, if you include
"limit=5&offset=5" in the /ticket URI, the response contains tickets six through ten from the list of the
possible tickets.
l link_disp_field. If the extended_fetch option is not enabled, you can use the link_disp_field to specify
which field will be used to populate the description for each resource. For example, the default description
of each resource returned by the /account resource index is the username. If you want the description of
each resource returned by the /account resource index to be the primary Email address of each user, set the
link_disp_field option to email.
NOTE: Although the above options are common to most resource indexes, not all resource indexes support
all of these options.
For example, to request 10 tickets with all attributes returned from the ticketing index, use the following URI:
/ticket?limit=10&extended_fetch=1
Sorting
You can sort the order of results in the response by using the order option. This option is available for every
resource index. The syntax of the order option is:
For example, to sort the response for the /account resource by descending username, include the following
option:
order.user=DESC
For example, to sort the response for the /account resource with the user accounts in organization 2 first, then all
other user accounts, you would include the following option:
order.organization=/api/organization/2,*
l Do not include the query string when specifying the URL in the request
l Include the query string in the body of the request, excluding the leading question mark character
l Include the content-type header "content-type:application/x-www-form-urlencoded" in the request
For example, the following cURL request specifies a GET request to the /ticket API that includes options and filters
as part of the URL:
Resource Responses
If you perform a GET request using the URI for a specific resource, the response has the following structure in
JSON format:
{
"field":"value",
.
.
.
"custom_fields":{
},
"sub resource":{
"URI":"...",
"description":"...",
},
.
.
.
}
The XML response for the same request contains the same attributes in a similar structure.
l field:value pairs. In the structure shown above, field is the name of an attribute that is common to every
resource of that type, e.g. "severity" for a ticket resource. value is the value of the attribute for this specific
resource.
l custom_fields. Has the same structure as the "field":"value" pairs, but for custom fields specific to this
resource type in this SL1 systems.
l sub resource links. In the structure shown above, sub resource is name of a sub resource associated with
the resource type, e.g. "notes" for a ticket resource. Each sub resource in the response contains a URI for the
sub-resource index and a description of the sub resource.
The XML or JSON you include in a POST or PUT request must have the same format as an XML or JSON
response from a GET request on the same resource. For example, if you:
1. Perform a GET request on a ticket resource and save the response in a file.
2. In the saved file, modify the value in a single field.
3. POST the XML or JSON back to the same ticket URI.
When using POST to update a resource, the XML or JSON can contain only the fields that need to be updated;
any fields you want to remain the same can be removed from the XML or JSON.
To create a new resource using a POST request, you must use the URI of the resource index. The new resource
will be assigned a unique ID. The API returns the URI for the new resource in the response.
In the XML or JSON structure used in a POST request, the format of the data in each field must be identical to the
format the API uses when responding to GET requests. For example:
NOTE: If you create a new resource using POST, the API ignores any links to sub-resources included in the
XML or JSON structure. The response contains new URIs for sub-resource indexes.
NOTE: For information on the difference between PUT and POST, see the HTTP Methods, Headers and
Response Formats section.
NOTE: If you use GraphQL for a bulk update, GraphQL will make multiple single calls to the REST API
rather than one bulk call, even if SL1 does not use the bulk capability.
Asynchronous Operations
Asynchronous operations, such as starting a discovery session, can be performed using the POST method with
the "application/em7-resource-uri" content type. The "application/em7-resource-uri" content type is proprietary
to the ScienceLogic API.
l Applying a device template. POST a /device_template resource URI to a specific /device or /devcie_
group resource.
l Performing a "Save As" operation on a dashboard. POST a /dashboard resource URI to the /dashboard
resource index. All properties of the dashboard are copied, including those that cannot be modified directly
through API requests.
l Installing a PowerPack. POST a /filestore/powerpack resource URI to the /powerpack resource index.
l Registering a Patch. POST a /filestore/system_patch resource URI to the /system_patch resource index.
l Staging a Patch. POST a /system_patch resource URI to the /system_patch_stage resource index.
l Installing a Patch. POST a /system_patch_stage resource URI to the /system_patch_deploy_active
resource index.
For an example of how this content type is used, see the Example: Using the Discovery Resource section.
"organization":"\/organization\/0",
NOTE: This example shows the response from an Integration Server in JSON format with the forward slash
characters (/) escaped. If you are accessing the API through an Administration Portal, Database
Server, or All-In-One Appliance, the "/api" portion of the base URI is included in all resource URIs
returned by the API.
If you are creating, updating or replacing a resource that includes links to other resources, ensure that you
include the URI for the other resource in the appropriate fields.
Size Limits
The API has the following limits for URI length and POST content:
l The maximum URI length that can be used in an API request is 8199 characters.
l The maximum size of JSON content that can be included in a POST request to the API is 2 GB.
l The maximum size of XML content that can be included in a POST request to the API is 1,000,000
characters.
4
Authentication and Access Permissions
Overview
This chapter describes the authentication and access permissions needed to use the ScienceLogic API.
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
l A user can interact only with entities associated with their organizations. Entities are either explicitly aligned
with organizations, aligned with organizations based on the user that created the entity, or are not aligned
with an organization.
NOTE: The new user interface architecture requires API access for all users; API access is automatically
granted to users. The following API-specific access hooks have been deprecated and removed from
SL1: API: Resource Indexes, API: Server Access, API: Virtual Device.
This chapter describes how the access permissions system applies to the API. For more information on the access
permissions system in SL1, see the Access Permissions manual.
NOTE: User accounts that use a SAML provider for authentication cannot perform API requests unless the
authentication profile for that user also includes an EM7 Internal or AD/LDAP authentication
resource.
Account Lockouts
The account lockout functionality applies to API requests (i.e., if an incorrect password is specified in multiple,
sequential API requests for a valid user account, the user account will be locked out). The following settings in the
Behavior Settings page (System > Settings > Behavior) control account lockouts:
l Account Lockout Attempts. Number of times a user can supply incorrect login information (i.e., the
number of consecutive API requests with an incorrect password before a lockout occurs). Choices are 1 time
through 10 times.
l Account Lockout Type. If a user enters incorrect login information multiple times in a row, that user will be
locked out of the user interface. In this field, you can select how the lockout will be applied. Choices are:
o
Lockout by IP Address. All login attempts from the IP address will be denied.
o
Lockout by Username and IP Address. All login attempts by the username from the IP address will be
denied.
o
Lockout by Username (default). All login attempts by the username will be denied.
o
Disabled. Lockouts are disabled.
l Account Lockout Duration. Specifies how long a user will be locked out of the user interface. Choices are
1 hour through 24 hours, in one-hour increments.
While a user account is locked out, API requests specifying that user will return an HTTP 403 status code with the
following ScienceLogic-specific header values:
27 Account Lockouts
X-EM7-info-message: Authentication temporarily locked due to too many failed
authentication attempts
Account lockouts can be removed via the API using the /access_lock resource. The /access_lock resource
supports the following methods:
/account/_self
This resource returns the equivalent of the standard /account resource for the user that authenticated the request,
even if that user account has not been granted permission to access other /account resources.
Audit Logging
All requests that use a PUT, POST, or DELETE method are included in the audit logs for the user's primary
organization. Organizational audit logs are accessible through the [Logs] tab in the Organizational Summary
page; a log for all organizations is displayed on the Audit Logs page (System > Monitor > Audit Logs). Each log
message generated by an API request includes the following information:
l Supply the URI of the "run-as" user account in the "x-em7-run-as" header. For example, to specify the user
account with ID 2 as the "run-as" user, you would include "x-em7-run-as:/api/account/2" as a header in
your request.
l Authenticate using an administrator account.
NOTE: If SL1 is not running in FIPS-compliant mode, you can create the hash with MD5.
For example, suppose you want to perform an API request from a Data Collector. You would:
1. Go to the Appliance Manager page (System > Settings > Appliances) and note the ID value for the Data
Collector. For this example, suppose the ID is "2".
2. Go to the REST API Settings page (System > Settings > API) and note the API Internal Req Account. For
this example, suppose the user is "em7admin"
1_SILO_API_INTERNAL_2
5. Supply the user ID, appliance ID, and SHA256 hash (or MD5 hash) in a comma-delimited list as the
username for the request. For this example, the username for the request is:
1,2,9ec1df2f13d940c80597b9e5a09bf001
5
Custom Attributes
Overview
This chapter describes how to view, add, and edit custom attributes for API resources.
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
l /asset
l /device
l The /interface sub-resource under /device resources
l For any instance of that resource (e.g., a specific device), you can perform a POST operation specifying a
value for that attribute for that instance.
l If you configure the attribute as a base attribute, the attribute will appear in the list of fields for all instances
of that resource. For example, if you define a custom attribute as a base attribute for the /device resource,
the response to a GET request for any /device/device_id resource includes the custom attribute in the list of
fields.
l If you configure the attribute as an extended attribute, the attribute will appear in the list of fields for
instances of that resource only if a value has been specified for the attribute for that instance. For example,
suppose you define a custom attribute as an extended attribute for the /device resource. The response to a
GET request on the /device resource index with the extended_fetch option enabled will include the custom
attribute only for devices that have a value for that custom attribute.
l GET requests for the resource index can include filter and sort criteria that use that custom attribute.
When you define a value for a custom attribute by performing a POST request to a resource, the value is
available through the API and can be used in dynamic rules for device groups and viewed in the custom table
widget.
l /custom_attribute/asset
l /custom_attribute/device
l /custom_attribute/interface
l /custom_attribute/theme
l /custom_attribute/vendor
l /custom_attribute/_lookup. Allows for searching across all custom attributes for all entity types.
NOTE: The "limit" option is required for all resource indexes for custom attributes.
Each resource custom attribute resource index returns a list of custom attributes including the URI for each custom
attribute. URIs for custom attributes are in the following format:
By default, no custom attributes are defined for any of the resources that support custom attributes.
The body of a POST request to an /custom_attribute/resource resource index must have the following JSON
structure:
{
"name":"attribute name",
"label":"attribute label",
"type":"attribute type",
"index":"attribute index type",
"extended":"attribute extended option"
}
Or the following XML structure:
<custom_attribute>
<name>attribute name</name>
<label>attribute label</label>
<type>attribute type</type>
<index>attribute index type</index>
<extended>attribute extended option</extended>
</custom_attribute>
The body of a POST request to an /custom_attribute/resource/name resource must have the following JSON
structure:
{
"label":"attribute label",
"type":"attribute type",
"index":"attribute index type",
"extended":"attribute extended option"
}
Or the following XML structure:
<custom_attribute>
<label>attribute label</label>
<type>attribute type</type>
<index>attribute index type</index>
<extended>attribute extended option</extended>
</custom_attribute>
NOTE: You can request example JSON or XML content that must be posted to a /custom_
attribute/resource/name resource by performing a GET request to the following URI: /custom_
attribute/resource/_example.
Where attribute name, attribute label, attribute type, attribute index type, and attribute extended option are
properties of the custom attribute you want to add. Attributes have the following properties:
l type. The data type of the custom attribute. You must specify one of the following two values in the type
field:
o
integer. The custom attribute will be used to store signed 64-bit integer values.
o
string. The custom attribute will be used to store string values up to 512 characters in length.
l index. You must specify one of the following three values in the index field:
o
index. When SL1 creates the database table that stores this custom attribute, the column that stores
this value will be set as an index for the table. Setting index values can speed up queries performed
on the database table, but does not affect which filter or search options will be available for this
custom attribute.
o
unique. When SL1 creates the database table that stores this custom attribute, the column that stores
this value will be set as a unique index for the table. The values defined for this custom attribute must
be unique for all resources. For example, if you add a custom attribute called "c-external-id" to the
/custom_attribute/device resource and define the index as unique, the value of "c-external-id" for a
/device/device_id resource cannot be re-used for another /device/device_id resource. Setting index
values can speed up queries performed on the database table, but does not affect which filter or
search options will be available for this custom attribute.
o
none. When SL1 creates the database table that stores this custom attribute, the column that stores
this value will not be set as an index or unique index.
When you add a custom attribute, the default value for all resources where that attribute is now defined is NULL.
To add these custom attributes, you would perform two POST requests with the following JSON structures to the
/custom_attribute/device resource to create the two custom attributes:
{
"name":"external-id",
"label":"ID from external provisioning system",
"type":"integer",
"index":"unique",
"extended":"0"
}
Request 2:
{
"name":"external-name",
"label":"Name from external provisioning system",
"type":"string",
"index":"none",
"extended":"0"
}
Each request specifies a custom attributes:
l external_id. An integer value that will contain the ID value from the external provisioning system. The index
field is set to unique because all ID values from the external provisioning system will be unique.
l external_name. A string value that will contain the name from the external provisioning system.
Request 1:
<custom_attribute>
<name>external-id</name>
<label>ID from external provisioning system</label>
<type>integer</type>
<index>unique</index>
<extended>0</extended>
</custom_attribute>
Request 2:
<custom_attribute>
<name>external-name</name>
<label>Name from external provisioning system</label>
<type>string</type>
<index>none</index>
<extended>0</extended>
</custom_attribute>
{
"label":"attribute label",
"type":"attribute type",
"index":"attribute index type"
}
<custom_attribute>
<label>attribute label</label>
<type>attribute type</type>
<index>attribute index type</index>
</custom_attribute>
NOTE: You cannot update the name or the extended option of a custom attribute.
l If the attribute is a "base" attribute, the attribute is displayed in the list of fields for all instances of the
specified resource regardless of whether a value has been specified for the attribute.
l If the attribute is an "extended" attribute, the attribute is displayed in the list of fields for an instance of the
specified resource only if a value has been specified for the attribute.
NOTE: To view or define custom attributes, you must prefix the attribute key with c-.
For example, if you created the "external_id" and "external_name" attributes described in the Example of How to
Add Custom Attributes section, both of which are base attributes, the response to a GET request for a
/device/device_id resource would look like this:
{
"name":"em7_ap",
"ip":"10.0.9.50",
"snmp_cred_id":"\/credential\/snmp\/1",
"snmp_w_cred_id":null,
"class_type":"\/device_class\/20036",
"organization":"\/organization\/0",
"auto_update":"1",
"event_suppress_mask":"00:10:00",
"auto_clear":"1",
"log_all":"1",
"daily_port_scan":"1",
"critical_ping":"0",
"scan_all_ips":"0",
"preserve_hostname":"1",
To define a value for a custom attribute for a specific instance of a resource, you can include the custom attribute
when performing a POST request to that resource. For example, to define a value for the "external-id" attribute for
the device with ID "3", you would POST to following JSON to the /device/3 resource:
{
"ip":"10.0.9.50",
"c-external-id":"4"
}
When you perform a GET request on a resource index, you can use custom attributes in filter and sort criteria. For
example, if you want to perform a GET request on the /device resource index and want to sort the response by the
external-id field, you would request the following URI:
/device?limit=100&order.c-external-id=ASC
If you want to perform a GET request on the /device resource index and want to filter the response to include only
devices that contain the string "server" in the "external-name" field, you would request the following URI:
/device?limit=100&filter.c-external-name.contains=server
NOTE: If you want to unalign a custom attribute for an interface, you can perform a PUT action and set the
value to null(lowercase without quotes).
6
Generating Events Using the API
Overview
The /alert API resource can be used to generate alerts in SL1 that will appear as log messages in the Device Logs
& Messages page, similar to how SL1 processes inbound syslog and trap messages. You can optionally create
one or more event policies that will trigger when an alert generated through the API meets the criteria specified in
the policy.
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
Generating Alerts 38
Defining API Event Policies 40
Defining API Event Policies in the Classic SL1 User Interface 41
Generating Alerts
To generate an alert, you must perform a POST request to the /alert resource index. The content you POST must
have the following structure:
{
"force_ytype":"0",
"force_yid":"0",
"force_yname":"",
"message":"",
"value":"0",
Generating Alerts 38
"threshold":"0",
"message_time":"0",
"aligned_resource":""
}
Supply the following values in each field:
l force_ytype. Optional. The type of sub-entity on a device that you want to associate the alert with. This field
can be set to the following numeric values that represent sub-entity types:
o
1. CPU
o
2. Disk
o
3. File System
o
4. Memory
o
5. Swap
o
6. Hardware Component
o
7. Interface
o
9. Process
o
10. Port
o
11. Windows Service
o
12. Web Content
o
13. Email Monitor
For example, to associate the alert with a specific interface on a device, supply "7" in this field. If you are
not supplying information about a sub-entity, supply 0 (zero) in this field.
l force_yid. Optional. The ID value of the specific sub-entity on the device that you want to associate the alert
with. For example, if you are associating the alert with the interface with ID 2, supply "2" in this field. If you
are not supplying information about a sub-entity, supply 0 (zero) in this field.
l force_yname. Optional. The name of the specific sub-entity on the device that you want to associate the
alert with. For example, if you are associating the alert with the interface called "eth0", supply "eth0" in this
field. If you are not supplying information about a sub-entity, supply en empty string in this field.
NOTE: If an event policy is configured to clear another event policy, an instance of the event is
cleared only when the clearing event has a matching sub-entity type, sub-entity ID, and sub-
entity name.
l message. Enter message text to associate with the alert. If the alert does not match an event, this text will be
displayed in the Device Logs & Messages page. This text will be used to match against the First Match
String and Second Match String values in event policies. If the alert triggers an event, this text will be
substituted for the %M substitution character in the event message.
l value. Optionally, supply the numeric value that triggered the alert. For example, if an alert indicates that
CPU usage is high, you might pass the current CPU usage in this field. If you are not supplying a specific
value, supply 0 (zero) in this field.
39 Generating Alerts
l threshold. Optionally, supply the numeric threshold that was exceeded for this alert to be generated. This
threshold can be used in an event policy message by using the %T substitution. If you are not supplying a
specific threshold, supply 0 (zero) in this field.
l message_time. The timestamp to associate with the alert in unix time format. The device log message will
be listed at this date and time. Valid values include a timestamp or an empty string, "0" (zero), or "now", the
latter three of which default to the current timestamp.
l When creating a new API alert, the /api/alert endpoint now allows a custom timestamp. Valid values for
message_time include a timestamp or an empty string, 0, or now, the latter three of which default to the
current timestamp.
l aligned_resource. The relative URI of the device with which you want to associate the alert. For example, to
align the alert with device ID 1, supply /device/1.
When you create API event policies, the event messages are generated by inserting messages into the main
database. These messages can be inserted by a snippet automation action, a snippet Dynamic Application, or by
a request to the ScienceLogic API.
l Event Source. Specifies the source for the event. Select API.
5. After selecting and defining your Event Source, enter values in the fields on the right side of the Match
Logic tab:
l Second Match String (Optional). Optionally, a second text string or regular expression to match
against the originating log message field of each alert generated through the API. The event will be
generated if the message matches the Match String and the Second Match String values.
NOTE: The other fields on this page can be used to define specific event behavior or enable advanced event
features. For a description of every option on this page, see the Events manual.
6. Click the [Event Message] tab, then enter the following information:
l Event Message. Define the message that appears in the Event Console page or the Viewing
Events page when this event occurs.
NOTE: For more information about the Event Message field and descriptions of the other fields on this
page that can be used to define the event severity, event masking, and other options, see the Events
manual.
7. Optionally, you can click the [Suppression] tab, where you can define specific devices or device groups for
which the event should not appear.
NOTE: For more information about the [Suppression] tab and the fields that appear on this page, see the
Events manual.
8. After entering information in each tab, click [Save] to save your new event policy.
To create an event policy of type "API" in the classic SL1 user interface:
1. Go to the Event Policy Manager page (Registry > Events > Event Manager).
2. Click the [Create] button. The Event Policy Editor page is displayed.
3. Supply values in the following fields:
NOTE: The Use Modifier checkbox is not applicable to API event policies.
CAUTION: If you do not supply a value in the First Match String field, your event policy will
match all alerts generated through the API.
l Second Match String. Optionally, a second text string or regular expression to match against the
message field of each alert generated through the API. The event will be generated if the message
matches the First Match String and the Second Match String values.
l Match Logic. Specifies whether the First Match String and Second Match String values are
matched as text strings or regular expressions.
NOTE: The other fields on this page can be used to define specific event behavior or enable
advanced event features. For a description of every option on this page, see the Events
manual.
7
Requesting Performance Data in Bulk
Overview
The resources /data_performance, /data_performance_raw, and their sub-resources can be used to request
performance data for multiple devices or interfaces in a single request. This chapter describes how to use these
resources to request performance data.
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
Resource URIs 44
Specifying the Time Range for a Data Request 46
Specifying Data Fields 47
Fields for Dynamic Application Resources 47
Fields for Port Monitor Resources 47
Fields for Web Content Monitor Resources 49
Fields for SOAP/XML Transaction Monitor Resources 51
Fields for Process Monitor Resources 53
Fields for Windows Service Monitor Resources 54
Fields for Email Round-Trip Monitor Resources 55
Fields for DNS Monitor Resources 56
Fields for File System Resources 57
43
Fields for Availability Resources 58
Fields for Interface Resources 59
Fields for CBQoS Resources 70
Requesting Data for Specific Devices or Interfaces 77
Filtering Device Resources 77
Filtering Interface Resources 80
Filtering CBQoS Resources 81
Additional Options 82
Responses from Bulk Performance Data Resources 82
Resource URIs
The following table lists the resource URIs for the resources: /data_performance and /data_performance_raw.
NOTE: For resources that return data, you must specify a timestamp option. If you do not specify a
timespan, the API will return an HTTP 400 (Bad Request) status code.
URI Description
44 Resource URIs
URI Description
Resource URIs 45
URI Description
/data_performance_raw/device/filesystem Returns raw data about file system usage. The data
matches specified parameters.
/data_performance_raw/cbqos Returns raw data for CBQoS metrics. The data matches
specified parameters.
You can use the following options in the resource URI to specify a time range:
l duration. Specifies the duration of the time range in human-readable shorthand format. A valid value for
this option includes an integer and one of the following characters:
o
m. The integer specifies the number of minutes in the time range.
o
h. The integer specifies the number of hours in the time range.
o
d. The integer specifies the number of days in the time range.
l beginstamp. The UNIX timestamp for the start of the time range.
l endstamp. The UNIX timestamp for the end of the time range.
l Specify a beginstamp and endstamp. The time range starts at the time specified in the beginstamp option
and ends at the time specified in the endstamp option.
l Specify a beginstamp and duration. The time range starts at the time specified in the beginstamp option
and covers the amount of time specified in the duration option.
For the sub-resources of /data_performance, you must also specify a value in the rollup_freq option. Valid
values for this option are:
To specify data fields, supply a comma-delimited list of fields in the data_fields option. The available data fields
are different for each resource. The available fields for each resource are listed in the options section of the
searchspec returned by the resource.
Field Description
A presentation object ID. The presentation objects for which data sets will be
Presentation object IDs are different for each SL1 returned.
system and can be looked up using the /dynamic_app
resource and sub-resources.
A presentation object GUID. The presentation objects for which data sets will be
Presentation object GUIDs are the same for all SL1 returned.
system and can be looked up using the /dynamic_app
resource and sub-resources.
avg_d_state The average availability of the port, calculated from the raw data points for the
rollup period. Availability values are either zero (0, unavailable) or one (1,
available); average values will range from zero to one.
max_d_state The value of the single highest availability poll for the port during the rollup period.
Values are either zero (0, unavailable) or one (1, available).
min_d_state The value of the single lowest availability poll for the port during the rollup period.
Values are either zero (0, unavailable) or one (1, available).
sum_d_state The sum of all availability values for the port during the rollup period. Availability
values are either zero (0, unavailable) or one (1, available).
std_d_state The standard deviation of availability values for the port, calculated from the raw
data points for the rollup period.
For the resource /data_performance_raw/device/monitor_port , the data_fields option can include the
following fields :
Field Description
d_state The availability of the port. Availability values are either zero (0, unavailable) or one
(1, available).
Field Description
min_d_conn_time The lowest connection time, in seconds, of all polls during the rollup period.
max_d_conn_time The highest connection time, in seconds, of all polls during the rollup period.
avg_d_conn_time The average connection time, in seconds, calculated from the raw data points for
the rollup period.
sum_d_conn_time The sum of all connection times, in seconds, during the rollup period.
std_d_conn_time The standard deviation of the connection times, calculated from the raw data points
for the rollup period.
min_d_dl_size The lowest download size, in bytes, of all polls during the rollup period.
max_d_dl_size The highest download size, in bytes, of all polls during the rollup period.
avg_d_dl_size The average download size, in bytes, calculated from the raw data points for the
rollup period.
sum_d_dl_size The sum of all download sizes, in bytes, during the rollup period.
std_d_dl_size The standard deviation of the download sizes, calculated from the raw data points
for the rollup period.
min_d_dl_speed The lowest download speed, in bytes/second, of all polls during the rollup period.
max_d_dl_speed The highest download speed, in bytes/second, of all polls during the rollup period.
avg_d_dl_speed The average download speed, in bytes/second, calculated from the raw data points
for the rollup period.
sum_d_dl_speed The sum of all download speeds, in bytes/second, during the rollup period.
std_d_dl_speed The standard deviation of the download speeds, calculated from the raw data
points for the rollup period.
min_d_ns_time The lowest DNS lookup time, in seconds, of all polls during the rollup period.
max_d_ns_time The highest DNS lookup time, in seconds, of all polls during the rollup period.
avg_d_ns_time The average DNS lookup time, in seconds, calculated from the raw data points for
the rollup period.
sum_d_ns_time The sum of all DNS lookup times, in seconds, during the rollup period.
std_d_ns_time The standard deviation of the DNS lookup times, calculated from the raw data
points for the rollup period.
avg_d_state The average availability of the web page, calculated from the raw data points for
the rollup period. Availability values are either zero (0, unavailable) or one (1,
available); average values will range from zero to one.
max_d_state The value of the single highest availability poll for the web page during the rollup
period. Values are either zero (0, unavailable) or one (1, available).
min_d_state The value of the single lowest availability poll for the web page during the rollup
period. Values are either zero (0, unavailable) or one (1, available).
sum_d_state The sum of all availability values for the web page during the rollup period.
Availability values are either zero (0, unavailable) or one (1, available).
std_d_state The standard deviation of availability values for the web page, calculated from the
raw data points for the rollup period.
min_d_trans_time The lowest transaction time, in seconds, of all polls during the rollup period.
max_d_trans_time The highest transaction time, in seconds, of all polls during the rollup period.
avg_d_trans_time The average transaction time, in seconds, calculated from the raw data points for
the rollup period.
sum_d_trans_time The sum of all transaction times, in seconds, during the rollup period.
std_d_trans_time The standard deviation of the transaction times, calculated from the raw data points
for the rollup period.
For the resource /data_performance_raw/device/monitor_cv, the data_fields option can include the
following fields:
Field Description
d_state The availability of the web page. Availability values are either zero (0, unavailable)
or one (1, available).
Field Description
min_d_conn_time The lowest connection time, in seconds, of all polls during the rollup period.
max_d_conn_time The highest connection time, in seconds, of all polls during the rollup period.
avg_d_conn_time The average connection time, in seconds, calculated from the raw data points for
the rollup period.
sum_d_conn_time The sum of all connection times, in seconds, during the rollup period.
std_d_conn_time The standard deviation of the connection times, calculated from the raw data points
for the rollup period.
min_d_dl_size The lowest download size, in bytes, of all polls during the rollup period.
max_d_dl_size The highest download size, in bytes, of all polls during the rollup period.
avg_d_dl_size The average download size, in bytes, calculated from the raw data points for the
rollup period.
sum_d_dl_size The sum of all download sizes, in bytes, during the rollup period.
std_d_dl_size The standard deviation of the download sizes, calculated from the raw data points
for the rollup period.
min_d_dl_speed The lowest download speed, in bytes/second, of all polls during the rollup period.
max_d_dl_speed The highest download speed, in bytes/second, of all polls during the rollup period.
avg_d_dl_speed The average download speed, in bytes/second, calculated from the raw data points
for the rollup period.
sum_d_dl_speed The sum of all download speeds, in bytes/second, during the rollup period.
std_d_dl_speed The standard deviation of the download speeds, calculated from the raw data
points for the rollup period.
min_d_ns_time The lowest DNS lookup time, in seconds, of all polls during the rollup period.
max_d_ns_time The highest DNS lookup time, in seconds, of all polls during the rollup period.
avg_d_ns_time The average DNS lookup time, in seconds, calculated from the raw data points for
the rollup period.
sum_d_ns_time The sum of all DNS lookup times, in seconds, during the rollup period.
std_d_ns_time The standard deviation of the DNS lookup times, calculated from the raw data
points for the rollup period.
avg_d_state The average availability of the web service, calculated from the raw data points for
the rollup period. Availability values are either zero (0, unavailable) or one (1,
available); average values will range from zero to one.
max_d_state The value of the single highest availability poll for the web service during the rollup
period. Values are either zero (0, unavailable) or one (1, available).
min_d_state The value of the single lowest availability poll for the web service during the rollup
period. Values are either zero (0, unavailable) or one (1, available).
sum_d_state The sum of all availability values for the web service during the rollup period.
Availability values are either zero (0, unavailable) or one (1, available).
std_d_state The standard deviation of availability values for the web service, calculated from the
raw data points for the rollup period.
min_d_trans_time The lowest transaction time, in seconds, of all polls during the rollup period.
max_d_trans_time The highest transaction time, in seconds, of all polls during the rollup period.
avg_d_trans_time The average transaction time, in seconds, calculated from the raw data points for
the rollup period.
sum_d_trans_time The sum of all transaction times, in seconds, during the rollup period.
std_d_trans_time The standard deviation of the transaction times, calculated from the raw data points
for the rollup period.
For the resource /data_performance_raw/device/monitor_tv, the data_fields option can include the following
fields:
Field Description
d_state The availability of the web service. Availability values are either zero (0, unavailable)
or one (1, available).
Field Description
min_d_check The average availability of the process, calculated from the raw data points for the
rollup period. Availability values are either zero (0, valid process is not running or
illicit process is running) or one (1, valid process is running or illicit process is not
running); average values will range from zero to one.
max_d_check The value of the single highest availability poll for the process during the rollup
period. Values are either zero (0, valid process is not running or illicit process is
running) or one (1, valid process is running or illicit process is not running).
avg_d_check The value of the single lowest availability poll for the process during the rollup
period. Values are either zero (0, valid process is not running or illicit process is
running) or one (1, valid process is running or illicit process is not running).
sum_d_check The sum of all availability values for the process during the rollup period.
Availability values are either zero (0, valid process is not running or illicit process is
running) or one (1, valid process is running or illicit process is not running).
std_d_check The standard deviation of availability values for the process, calculated from the
raw data points for the rollup period.
min_d_counter The average number of instances of the process, calculated from the raw data
points for the rollup period.
max_d_counter The number of instances of the process at the single poll with the highest value.
avg_d_counter The number of instances of the process at the single poll with the loqest value.
sum_d_counter The sum of the number of instances of the process running at each poll during the
rollup period.
std_d_counter The standard deviation of number of instances of the process running, calculated
from the raw data points for the rollup period.
For the resource /data_performance_raw/device/monitor_process, the data_fields option can include the
following fields:
Field Description
d_check The availability of the process. Availability values are either zero (0, valid process is
not running or illicit process is running) or one (1, valid process is running or illicit
process is not running).
Field Description
avg_d_state The average availability of the service,calculated from the raw data points for the
rollup period. Availability values are either zero (0, valid service is not running or
illicit service is running) or one (1, valid service is running or illicit service is not
running); average values will range from zero to one.
max_d_state The value of the single highest availability poll for the service during the rollup
period. Values are either zero (0, valid service is not running or illicit service is
running) or one (1, valid service is running or illicit process is not running).
min_d_state The value of the single lowest availability poll for the service during the rollup
period. Values are either zero (0, valid service is not running or illicit service is
running) or one (1, valid service is running or illicit service is not running).
sum_d_state The sum of all availability values for the service during the rollup period. Availability
values are either zero (0, valid service is not running or illicit service is running) or
one (1, valid service is running or illicit service is not running).
std_d_state The standard deviation of availability values for the service, calculated from the raw
data points for the rollup period.
For the resource /data_performance_raw/device/monitor_service, the data_fields option can include the
following fields:
Field Description
d_state The availability of the service. Availability values are either zero (0, valid service is
not running or illicit service is running) or one (1, valid service is running or illicit
service is not running).
Field Description
min_d_rt_time The lowest email round-trip time, in seconds, of all polls during the rollup period.
max_d_rt_time The highest email round-trip time, in seconds, of all polls during the rollup period.
avg_d_rt_time The average email round-trip time, in seconds, calculated from the raw data points
for the rollup period.
sum_d_rt_time The sum of all email round-trip times, in seconds, during the rollup period.
std_d_rt_time The standard deviation of the email round-trip times, calculated from the raw data
points for the rollup period.
min_d_state The value of the single lowest availability poll for the mail process during the rollup
period. Values are either zero (0, email response was not received within the
threshold time) or one (1, email response was received within the threshold time).
max_d_state The value of the single highest availability poll for the mail process during the rollup
period. Values are either zero (0, email response was not received within the
threshold time) or one (1, email response was received within the threshold time).
avg_d_state The average availability of the mail process, calculated from the raw data points for
the rollup period. Availability values are either zero (0, email response was not
received within the threshold time) or one (1, email response was received within the
threshold time); average values will range from zero to one.
sum_d_state The sum of all availability values for the mail process during the rollup period.
Availability values are either zero (0, email response was not received within the
threshold time) or one (1, email response was received within the threshold time).
std_d_state The standard deviation of availability values for the mail process, calculated from
the raw data points for the rollup period.
For the resource /data_performance_raw/device/monitor_email, the data_fields option can include the
following fields:
Field Description
d_state The availability of the mail service. Availability values are either zero (0, email
response was not received within the threshold time) or one (1, email response was
received within the threshold time).
Field Description
min_d_ns_time The lowest DNS lookup time, in seconds, of all polls during the rollup period.
max_d_ns_time The highest DNS lookup time, in seconds, of all polls during the rollup period.
avg_d_ns_time The average DNS lookup time, in seconds, calculated from the raw data points for
the rollup period.
sum_d_ns_time The sum of all DNS lookup times, in seconds, during the rollup period.
std_d_ns_time The standard deviation of the DNS lookup times, calculated from the raw data
points for the rollup period.
min_d_state The value of the single lowest availability poll for the DNS record during the rollup
period. Values are either zero (0, no response or DNS record does not match the
policy) or one (1, DNS record matches the policy).
max_d_state The value of the single highest availability poll for the DNS record during the rollup
period. Values are either zero (0, no response or DNS record does not match the
policy) or one (1, DNS record matches the policy).
avg_d_state The average availability of the DNS record, calculated from the raw data points for
the rollup period. Availability values are either zero (0, no response or DNS record
does not match the policy) or one (1, DNS record matches the policy); average
values will range from zero to one.
sum_d_state The sum of all availability values for the DNS record during the rollup period.
Availability values are either zero (0, no response or DNS record does not match the
policy) or one (1, DNS record matches the policy).
std_d_state The standard deviation of availability values for the DNS record, calculated from
the raw data points for the rollup period.
For the resource /data_performance_raw/device/monitor_dns, the data_fields option can include the
following fields:
Field Description
d_state The availability of the DNS record. Availability values are either zero (0, no
response or DNS record does not match the policy) or one (1, DNS record matches
the policy).
Field Description
min_d_used The lowest file system usage, in kilobytes, of all polls during the rollup period.
max_d_used The highest file system usage, in kilobytes, of all polls during the rollup period.
avg_d_used The average file system usage, in kilobytes, calculated from the raw data points for
the rollup period.
sum_d_used The sum of file system usage values, in kilobytes, during the rollup period.
std_d_used The standard deviation of the file system usage values, calculated from the raw data
points for the rollup period.
min_d_used_percent The lowest file system utilization, in percent, of all polls during the rollup period.
max_d_used_percent The highest file system utilization, in percent, of all polls during the rollup period.
avg_d_used_percent The average file system utilization, in percent, calculated from the raw data points
for the rollup period.
sum_d_used_percent The sum of all file system utilization values, in percent, during the rollup period.
sum_d_used_percent The standard deviation of the file system usage values, calculated from the raw data
points for the rollup period.
For the resource /data_performance_raw/device/filesystem, the data_fields option can include the following
fields:
Field Description
Field Description
min_d_check The value of the single lowest availability poll for the device during the rollup
period. Values are either zero (0, unavailable) or one (1, available).
max_d_check The value of the single highest availability poll for the device during the rollup
period. Values are either zero (0, unavailable) or one (1, available).
avg_d_check The average availability of the device, calculated from the raw data points for the
rollup period. Availability values are either zero (0, unavailable) or one (1,
available); average values will range from zero to one.
sum_d_check The sum of all availability values for the device during the rollup period. Availability
values are either zero (0, unavailable) or one (1, available).
std_d_check The standard deviation of availability values for the device, calculated from the raw
data points for the rollup period.
min_d_latency The value of the single lowest latency poll, in milliseconds, for the device during the
rollup period.
max_d_latency The value of the single highest latency poll, in milliseconds, for the device during the
rollup period.
avg_d_latency The average latency of the device, in milliseconds, calculated from the raw data
points for the rollup period.
sum_d_latency The sum of all latency values, in milliseconds, for the device during the rollup
period.
std_d_latency The standard deviation of latency values for the device, calculated from the raw
data points for the rollup period.
For the resource /data_performance_raw/device/avail, the data_fields option can include the following fields:
Field Description
d_check The availability of the device. Availability values are either zero (0, unavailable) or
one (1, available).
NOTE: A single request to /data_performance/interface cannot include data fields from this list and data
fields for packet metrics.
Field Description
min_d_discards_in The lowest number of discarded inbound packets per poll for the interface during
the rollup period.
max_d_discards_in The highest number of discarded inbound packets per poll for the interface during
the rollup period.
avg_d_discards_in The average number of discarded inbound packets per poll for the interface during
the rollup period.
sum_d_discards_in The total number of discarded inbound packets for the interface during the rollup
period.
std_d_discards_in The standard deviation of discarded inbound packets for the interface, calculated
from the raw data points for the rollup period.
min_d_discards_out The lowest number of discarded outbound packets per poll for the interface during
the rollup period.
max_d_discards_out The highest number of discarded outbound packets per poll for the interface during
the rollup period.
avg_d_discards_out The average number of discarded outbound packets per poll for the interface
during the rollup period.
sum_d_discards_out The total number of discarded outbound packets for the interface during the rollup
period.
std_d_discards_out The standard deviation of discarded outbound packets for the interface, calculated
from the raw data points for the rollup period.
min_d_errors_in The lowest number of inbound packet errors per poll for the interface during the
rollup period.
max_d_errors_in The highest number of inbound packet errors per poll for the interface during the
rollup period.
avg_d_errors_in The average number of inbound packet errors per poll for the interface during the
rollup period.
sum_d_errors_in The total number of inbound packet errors for the interface during the rollup period.
std_d_errors_in The standard deviation of inbound packet errors for the interface, calculated from
the raw data points for the rollup period.
min_d_errors_out The lowest number of outbound packet errors per poll for the interface during the
rollup period.
max_d_errors_out The highest number of outbound packet errors per poll for the interface during the
rollup period.
avg_d_errors_out The average number of outbound packet errors per poll for the interface during the
rollup period.
sum_d_errors_out The total number of outbound packet errors for the interface during the rollup
period.
std_d_errors_out The standard deviation of outbound packet errors for the interface, calculated from
the raw data points for the rollup period.
min_d_octets_in The lowest number of inbound octets per poll for the interface during the rollup
period.
max_d_octets_in The highest number of inbound octets per poll for the interface during the rollup
period.
avg_d_octets_in The average number of inbound octets per poll for the interface during the rollup
period.
sum_d_octets_in The total number of inbound octets for the interface during the rollup period.
std_d_octets_in The standard deviation of inbound octets for the interface, calculated from the raw
data points for the rollup period.
min_d_octets_out The lowest number of outbound octets per poll for the interface during the rollup
period.
max_d_octets_out The highest number of outbound octets per poll for the interface during the rollup
period.
avg_d_octets_out The average number of outbound octets per poll for the interface during the rollup
period.
sum_d_octets_out The total number of outbound octets for the interface during the rollup period.
std_d_octets_out The standard deviation of outbound octets for the interface, calculated from the raw
data points for the rollup period.
min_d_perc_discards_in The lowest percentage of discarded inbound packets per poll for the interface
during the rollup period.
max_d_perc_discards_in The highest percentage of discarded inbound packets per poll for the interface
during the rollup period.
avg_d_perc_discards_in The average percentage of discarded inbound packets per poll for the interface
during the rollup period.
sum_d_perc_discards_in The sum of all percentages of discarded inbound packets for the interface during
the rollup period.
std_d_perc_discards_in The standard deviation of discarded inbound packets in percent for the interface,
calculated from the raw data points for the rollup period.
min_d_perc_discards_out The lowest percentage of discarded outbound packets per poll for the interface
during the rollup period.
max_d_perc_discards_out The highest percentage of discarded outbound packets per poll for the interface
during the rollup period.
avg_d_perc_discards_out The average percentage of discarded outbound packets per poll for the interface
during the rollup period.
sum_d_perc_discards_out The sum of all percentages of discarded outbound packets for the interface during
the rollup period.
std_d_perc_discards_out The standard deviation of discarded outbound packets in percent for the interface,
calculated from the raw data points for the rollup period.
min_d_perc_errors_in The lowest percentage of inbound packet errors per poll for the interface during the
rollup period.
max_d_perc_errors_in The highest percentage of inbound packet errors per poll for the interface during
the rollup period.
avg_d_perc_errors_in The average percentage of inbound packet errors per poll for the interface during
the rollup period.
sum_d_perc_errors_in The sum of all percentages of inbound packet errors for the interface during the
rollup period.
std_d_perc_errors_in The standard deviation of inbound packet errors in percent for the interface,
calculated from the raw data points for the rollup period.
min_d_perc_errors_out The lowest percentage of outbound packet errors per poll for the interface during
the rollup period.
max_d_perc_errors_out The highest percentage of outbound packet errors per poll for the interface during
the rollup period.
avg_d_perc_errors_out The average percentage of outbound packet errors per poll for the interface during
the rollup period.
sum_d_perc_errors_out The sum of all percentages of outbound packet errors for the interface during the
rollup period.
std_d_perc_errors_out The standard deviation of outbound packet errors in percent for the interface,
calculated from the raw data points for the rollup period.
min_d_perc_in The lowest inbound utilization, in percent, per poll for the interface during the rollup
period.
max_d_perc_in The highest inbound utilization, in percent, per poll for the interface during the
rollup period.
avg_d_perc_in The average inbound utilization, in percent, for the interface during the rollup
period.
sum_d_perc_in The sum of all percentage values for inbound utilization for the interface during the
rollup period.
std_d_perc_in The standard deviation of inbound utilization values for the interface, calculated
from the raw data points for the rollup period.
min_d_perc_out The lowest outbound utilization, in percent, per poll for the interface during the
rollup period.
max_d_perc_out The highest outbound utilization, in percent, per poll for the interface during the
rollup period.
avg_d_perc_out The average outbound utilization, in percent, for the interface during the rollup
period.
sum_d_perc_out The sum of all percentage values for outbound utilization for the interface during
the rollup period.
std_d_perc_out The standard deviation of outbound utilization values for the interface, calculated
from the raw data points for the rollup period.
For the resource /data_performance/interface, the data_fields option can include the following fields for
packet metrics:
NOTE: A single request to /data_performance_raw/interface cannot include data fields from this list and
data fields for utilization, error, and discard metrics.
Field Description
min_d_ifp_inbound_ The lowest number of inbound unicast packets per poll for the interface during the
unicast_packets rollup period.
max_d_ifp_inbound_ The highest number of inbound unicast packets per poll for the interface during the
unicast_packets rollup period.
avg_d_ifp_inbound_ The average number of inbound unicast packets per poll for the interface during the
unicast_packets rollup period.
sum_d_ifp_inbound_ The total number of inbound unicast packets for the interface during the rollup
unicast_packets period.
std_d_ifp_inbound_ The standard deviation of inbound unicast packets for the interface, calculated from
unicast_packets the raw data points for the rollup period.
min_d_ifp_inbound_ The lowest number of inbound multicast packets per poll for the interface during the
multicast_packets rollup period.
max_d_ifp_inbound_ The highest number of inbound multicast packets per poll for the interface during
multicast_packets the rollup period.
avg_d_ifp_inbound_ The average number of inbound multicast packets per poll for the interface during
multicast_packets the rollup period.
sum_d_ifp_inbound_ The total number of inbound multicast packets for the interface during the rollup
multicast_packets period.
std_d_ifp_inbound_ The standard deviation of inbound multicast packets for the interface, calculated
multicast_packets from the raw data points for the rollup period.
min_d_ifp_inbound_ The lowest number of inbound broadcast packets per poll for the interface during
broadcast_packets the rollup period.
max_d_ifp_inbound_ The highest number of inbound broadcast packets per poll for the interface during
broadcast_packets the rollup period.
avg_d_ifp_inbound_ The average number of inbound broadcast packets per poll for the interface during
broadcast_packets the rollup period.
sum_d_ifp_inbound_ The total number of inbound broadcast packets for the interface during the rollup
broadcast_packets period.
std_d_ifp_inbound_ The standard deviation of inbound broadcast packets for the interface, calculated
broadcast_packets from the raw data points for the rollup period.
min_d_ifp_outbound_ The lowest number of outbound unicast packets per poll for the interface during the
unicast_packets rollup period.
max_d_ifp_outbound_ The highest number of outbound unicast packets per poll for the interface during
unicast_packets the rollup period.
avg_d_ifp_outbound_ The average number of outbound unicast packets per poll for the interface during
unicast_packets the rollup period.
sum_d_ifp_outbound_ The total number of outbound unicast packets for the interface during the rollup
unicast_packets period.
std_d_ifp_outbound_ The standard deviation of outbound unicast packets for the interface, calculated
unicast_packets from the raw data points for the rollup period.
min_d_ifp_outbound_ The lowest number of outbound multicast packets per poll for the interface during
multicast_packets the rollup period.
max_d_ifp_outbound_ The highest number of outbound multicast packets per poll for the interface during
multicast_packets the rollup period.
avg_d_ifp_outbound_ The average number of outbound multicast packets per poll for the interface during
multicast_packets the rollup period.
sum_d_ifp_outbound_ The total number of outbound multicast packets for the interface during the rollup
multicast_packets period.
std_d_ifp_outbound_ The standard deviation of outbound multicast packets for the interface, calculated
multicast_packets from the raw data points for the rollup period.
min_d_ifp_outbound_ The lowest number of outbound broadcast packets per poll for the interface during
broadcast_packets the rollup period.
max_d_ifp_outbound_ The highest number of outbound broadcast packets per poll for the interface during
broadcast_packets the rollup period.
avg_d_ifp_outbound_ The average number of outbound broadcast packets per poll for the interface
broadcast_packets during the rollup period.
sum_d_ifp_outbound_ The total number of outbound broadcast packets for the interface during the rollup
broadcast_packets period.
std_d_ifp_outbound_ The standard deviation of outbound broadcast packets for the interface, calculated
broadcast_packets from the raw data points for the rollup period.
min_d_ifp_unicast_perc_ The lowest percentage of inbound unicast packets per poll for the interface during
in the rollup period.
max_d_ifp_unicast_perc_ The highest percentage of inbound unicast packets per poll for the interface during
in the rollup period.
avg_d_ifp_unicast_perc_ The average percentage of inbound unicast packets per poll for the interface during
in the rollup period.
sum_d_ifp_unicast_perc_ The sum of all percentages of inbound unicast packets for the interface during the
in rollup period.
std_d_ifp_unicast_perc_in The standard deviation of inbound unicast packets in percent for the interface,
calculated from the raw data points for the rollup period.
min_d_ifp_multicast_ The lowest percentage of inbound multicast packets per poll for the interface during
perc_in the rollup period.
max_d_ifp_multicast_ The highest percentage of inbound multicast packets per poll for the interface
perc_in during the rollup period.
avg_d_ifp_multicast_ The average percentage of inbound multicast packets per poll for the interface
perc_in during the rollup period.
sum_d_ifp_multicast_ The sum of all percentages of inbound multicast packets for the interface during the
perc_in rollup period.
std_d_ifp_multicast_perc_ The standard deviation of inbound multicast packets in percent for the interface,
in calculated from the raw data points for the rollup period.
min_d_ifp_broadcast_ The lowest percentage of inbound broadcast packets per poll for the interface
perc_in during the rollup period.
max_d_ifp_broadcast_ The highest percentage of inbound broadcast packets per poll for the interface
perc_in during the rollup period.
avg_d_ifp_broadcast_ The average percentage of inbound broadcast packets per poll for the interface
perc_in during the rollup period.
sum_d_ifp_broadcast_ The sum of all percentages of inbound broadcast packets for the interface during
perc_in the rollup period.
std_d_ifp_broadcast_ The standard deviation of inbound broadcast packets in percent for the interface,
perc_in calculated from the raw data points for the rollup period.
min_d_ifp_unicast_perc_ The lowest percentage of outbound unicast packets per poll for the interface during
out the rollup period.
max_d_ifp_unicast_perc_ The highest percentage of outbound unicast packets per poll for the interface
out during the rollup period.
avg_d_ifp_unicast_perc_ The average percentage of outbound unicast packets per poll for the interface
out during the rollup period.
sum_d_ifp_unicast_perc_ The sum of all percentages of outbound unicast packets for the interface during the
out rollup period.
std_d_ifp_unicast_perc_ The standard deviation of outbound unicast packets in percent for the interface,
out calculated from the raw data points for the rollup period.
min_d_ifp_multicast_ The lowest percentage of outbound multicast packets per poll for the interface
perc_out during the rollup period.
max_d_ifp_multicast_ The highest percentage of outbound multicast packets per poll for the interface
perc_out during the rollup period.
avg_d_ifp_multicast_ The average percentage of outbound multicast packets per poll for the interface
perc_out during the rollup period.
sum_d_ifp_multicast_ The sum of all percentages of outbound multicast packets for the interface during
perc_out the rollup period.
std_d_ifp_multicast_perc_ The standard deviation of outbound multicast packets in percent for the interface,
out calculated from the raw data points for the rollup period.
min_d_ifp_broadcast_ The lowest percentage of outbound broadcast packets per poll for the interface
perc_out during the rollup period.
max_d_ifp_broadcast_ The highest percentage of outbound broadcast packets per poll for the interface
perc_out during the rollup period.
avg_d_ifp_broadcast_ The average percentage of outbound broadcast packets per poll for the interface
perc_out during the rollup period.
sum_d_ifp_broadcast_ The sum of all percentages of outbound broadcast packets for the interface during
perc_out the rollup period.
std_d_ifp_broadcast_ The standard deviation of outbound broadcast packets in percent for the interface,
perc_out calculated from the raw data points for the rollup period.
min_d_ifp_inbound_total_ The lowest number of inbound packets per poll for the interface during the rollup
packets period.
max_d_ifp_inbound_ The highest number of inbound packets per poll for the interface during the rollup
total_packets period.
avg_d_ifp_inbound_total_ The average number of inbound packets per poll for the interface during the rollup
packets period.
sum_d_ifp_inbound_ The total number of inbound packets for the interface during the rollup period.
total_packets
std_d_ifp_inbound_total_ The standard deviation of inbound packets for the interface, calculated from the
packets raw data points for the rollup period.
min_d_ifp_outbound_ The lowest number of outbound packets per poll for the interface during the rollup
total_packets period.
max_d_ifp_outbound_ The highest number of outbound packets per poll for the interface during the rollup
total_packets period.
avg_d_ifp_outbound_ The average number of outbound packets per poll for the interface during the rollup
total_packets period.
sum_d_ifp_outbound_ The total number of outbound packets for the interface during the rollup period.
total_packets
std_d_ifp_outbound_ The standard deviation of outbound packets for the interface, calculated from the
total_packets raw data points for the rollup period.
min_d_ifp_unicast_in The lowest inbound unicast packet rate (packets/second) per poll for the interface
during the rollup period.
max_d_ifp_unicast_in The highest inbound unicast packet rate (packets/second) per poll for the interface
during the rollup period.
avg_d_ifp_unicast_in The average inbound unicast packet rate (packets/second) per poll for the interface
during the rollup period.
sum_d_ifp_unicast_in The total of all inbound unicast packet rates (packets/second) for the interface
during the rollup period.
std_d_ifp_unicast_in The standard deviation of inbound unicast packet rates (packets/second) for the
interface, calculated from the raw data points for the rollup period.
min_d_ifp_multicast_in The lowest inbound multicast packet rate (packets/second) per poll for the interface
during the rollup period.
max_d_ifp_multicast_in The highest inbound multicast packet rate (packets/second) per poll for the
interface during the rollup period.
avg_d_ifp_multicast_in The average inbound multicast packet rate (packets/second) per poll for the
interface during the rollup period.
sum_d_ifp_multicast_in The total all inbound multicast packet rates (packets/second) for the interface
during the rollup period.
std_d_ifp_multicast_in The standard deviation of inbound multicast packet rates (packets/second) for the
interface, calculated from the raw data points for the rollup period.
min_d_ifp_broadcast_in The lowest inbound broadcast packet rate (packets/second) per poll for the
interface during the rollup period.
max_d_ifp_broadcast_in The highest inbound broadcast packet rate (packets/second) per poll for the
interface during the rollup period.
avg_d_ifp_broadcast_in The average inbound broadcast packet rate (packets/second) per poll for the
interface during the rollup period.
sum_d_ifp_broadcast_in The total of all inbound broadcast rates (packets/second) for the interface during
the rollup period.
std_d_ifp_broadcast_in The standard deviation of inbound broadcast packet rates (packets/second) for the
interface, calculated from the raw data points for the rollup period.
min_d_ifp_unicast_out The lowest outbound unicast packet rate (packets/second) per poll for the interface
during the rollup period.
max_d_ifp_unicast_out The highest outbound unicast packet rate (packets/second) per poll for the interface
during the rollup period.
avg_d_ifp_unicast_out The average outbound unicast packet rate (packets/second) per poll for the
interface during the rollup period.
sum_d_ifp_unicast_out The total of all outbound unicast packet rates (packets/second) for the interface
during the rollup period.
std_d_ifp_unicast_out The standard deviation of outbound unicast packet rates (packets/second) for the
interface, calculated from the raw data points for the rollup period.
min_d_ifp_multicast_out The lowest outbound multicast packet rate (packets/second) per poll for the
interface during the rollup period.
max_d_ifp_multicast_out The highest outbound multicast packet rate (packets/second) per poll for the
interface during the rollup period.
avg_d_ifp_multicast_out The average outbound multicast packet rate (packets/second) per poll for the
interface during the rollup period.
sum_d_ifp_multicast_out The total all outbound multicast packet rates (packets/second) for the interface
during the rollup period.
std_d_ifp_multicast_out The standard deviation of outbound multicast packet rates (packets/second) for the
interface, calculated from the raw data points for the rollup period.
min_d_ifp_broadcast_out The lowest outbound broadcast packet rate (packets/second) per poll for the
interface during the rollup period.
max_d_ifp_broadcast_out The highest outbound broadcast packet rate (packets/second) per poll for the
interface during the rollup period.
avg_d_ifp_broadcast_out The average outbound broadcast packet rate (packets/second) per poll for the
interface during the rollup period.
sum_d_ifp_broadcast_out The total of all outbound broadcast rates (packets/second) for the interface during
the rollup period.
std_d_ifp_broadcast_out The standard deviation of outbound broadcast packet rates (packets/second) for
the interface, calculated from the raw data points for the rollup period.
For the resource /data_performance_raw/interface, the data_fields option can include the following fields for
utilization, error, and discard metrics:
NOTE: A single request to /data_performance_raw/interface cannot include data fields from this list and
data fields for packet metrics.
d_perc_discards_in The percentage of inbound packets that were discarded for an interface.
d_perc_discards_out The percentage of outbound packets that were discarded for an interface.
d_perc_errors_in The percentage of inbound packets that caused errors for an interface.
d_perc_errors_out The percentage of outbound packets that caused errors for an interface.
For the resource /data_performance_raw/interface, the data_fields option can include the following fields for
packet metrics:
NOTE: A single request to /data_performance_raw/interface cannot include data fields from this list and
data fields for utilization, error, and discard metrics.
Field Description
d_ifp_unicast_perc_in The percentage of inbound packets that were unicast for an interface.
d_ifp_multicast_perc_in The percentage of inbound packets that were multicast for an interface.
d_ifp_broadcast_perc_in The percentage of inbound packets that were broadcast for an interface.
d_ifp_unicast_perc_out The percentage of outbound packets that were unicast for an interface.
d_ifp_multicast_perc_out The percentage of outbound packets that were multicast for an interface.
d_ifp_broadcast_perc_out The percentage of outbound packets that were broadcast for an interface.
d_ifp_unicast_in The number of inbound unicast packets per second for an interface.
d_ifp_multicast_in The number of inbound multicast packets per second for an interface.
d_ifp_broadcast_in The number of inbound broadcast packets per second for an interface.
d_ifp_unicast_out The number of outbound unicast packets per second for an interface.
d_ifp_multicast_out The number of outbound multicast packets per second for an interface.
d_ifp_broadcast_out The number of outbound broadcast packets per second for an interface.
Field Description
min_classmap_pre_ The lowest interface utilization, in bps, before applying the CBQoS policy during the
policy_rate_bits_per_ rollup period.
second
max_classmap_pre_ The highest interface utilization, in bps, before applying the CBQoS policy during
policy_rate_bits_per_ the rollup period.
second
avg_classmap_pre_ The average interface utilization, in bps, before applying the CBQoS policy during
policy_rate_bits_per_ the rollup period.
second
sum_classmap_pre_ The total interface utilization, in bps, before applying the CBQoS policy during the
policy_rate_bits_per_ rollup period.
second
std_classmap_pre_policy_ The standard deviation of the interface utilization values (calculated from the raw
rate_bits_per_second data points for the rollup period), before applying the CBQoS policy .
min_classmap_post_ The lowest interface utilization, in bps, after applying the CBQoS policy during the
policy_rate_bits_per_ rollup period.
second
max_classmap_post_ The highest interface utilization, in bps, after applying the CBQoS policy during the
policy_rate_bits_per_ rollup period.
second
avg_classmap_post_ The average interface utilization, in bps, after applying the CBQoS policy during the
policy_rate_bits_per_ rollup period.
second
sum_classmap_post_ The total interface utilization, in bps, after applying the CBQoS policy during the
policy_rate_bits_per_ rollup period.
second
std_classmap_post_ The standard deviation of the interface utilization, in bps (calculated from the raw
policy_rate_bits_per_ data points for the rollup period), after applying the CBQoS policy.
second
min_classmap_drop_ The lowest drop rate, in bps, for the class map during the rollup period.
rate_bits_per_second
max_classmap_drop_ The highest drop rate, in bps, for the class map during the rollup period.
rate_bits_per_second
avg_classmap_drop_ The average drop rate, in bps, for the class map during the rollup period.
rate_bits_per_second
sum_classmap_drop_ The total drop rate, in bps, for the class map during the rollup period.
rate_bits_per_second
std_classmap_drop_rate_ The standard deviation of drop rate values (calculated from the raw data points for
bits_per_second the rollup period), in bps, for the class map.
min_classmap_pre_ The lowest inbound interface utilization, in bytes, before applying the CBQoS policy
policy_inbound_bytes during the rollup period.
max_classmap_pre_ The highest inbound interface utilization, in bytes, before applying the CBQoS
policy_inbound_bytes policy during the rollup period.
avg_classmap_pre_ The average inbound interface utilization, in bytes, before applying the CBQoS
policy_inbound_bytes policy during the rollup period.
sum_classmap_pre_ The total inbound interface utilization, in bytes, before applying the CBQoS policy
policy_inbound_bytes during the rollup period.
std_classmap_pre_policy_ The standard deviation of inbound interface utilization values (calculated from the
inbound_bytes raw data points for the rollup period), before applying the CBQoS policy.
min_classmap_post_ The lowest outbound interface utilization, in bytes, after applying the CBQoS policy
policy_outbound_bytes during the rollup period.
max_classmap_post_ The highest outbound interface utilization, in bytes, after applying the CBQoS policy
policy_outbound_bytes during the rollup period.
avg_classmap_post_ The average outbound interface utilization, in bytes, after applying the CBQoS
policy_outbound_bytes policy during the rollup period.
sum_classmap_post_ The total outbound interface utilization, in bytes, after applying the CBQoS policy
policy_outbound_bytes during the rollup period.
std_classmap_post_ The standard deviation of outbound interface utilization values (calculated from the
policy_outbound_bytes raw data points for the rollup period), after applying the CBQoS policy.
min_policing_ The lowest collected traffic value, in bps, that conformed to the policing policy
conforming_rate_bits_ during the rollup period.
per_second
max_policing_ The highest collected traffic value, in bps, that conformed to the policing policy
conforming_rate_bits_ during the rollup period.
per_second
avg_policing_ The average collected traffic value, in bps, that conformed to the policing policy
conforming_rate_bits_ during the rollup period.
per_second
sum_policing_ The total collected traffic value, in bps, that conformed to the policing policy during
conforming_rate_bits_ the rollup period.
per_second
std_policing_conforming_ The standard deviation of the collected traffic values (calculated from the raw data
rate_bits_per_second points for the rollup period) that conformed to the policing policy.
min_classmap_drops_ The lowest drop rate, in bytes, for the class map during the rollup period.
bytes
max_classmap_drops_ The highest drop rate, in bytes, for the class map during the rollup period.
bytes
avg_classmap_drops_ The average drop rate, in bytes, for the class map during the rollup period.
bytes
sum_classmap_drops_ The total drop rate, in bytes, for the class map during the rollup period.
bytes
std_classmap_drops_ The standard deviation (calculated from the raw data points for the rollup period) of
bytes collected drop rate values.
min_policing_non_ The lowest collected traffic value, in bps, that did not conform to the policing policy
conforming_rate_bits_ during the rollup period.
per_second
max_policing_non_ The highest collected traffic value, in bps, that did not conform to the policing policy
conforming_rate_bits_ during the rollup period.
per_second
avg_policing_non_ The average collected traffic value, in bps, that did not conform to the policing
conforming_rate_bits_ policy during the rollup period.
per_second
sum_policing_non_ The total collected traffic value, in bps, that did not conform to the policing policy
conforming_rate_bits_ during the rollup period.
per_second
std_policing_non_ The standard deviation of the collected traffic values (calculated from the raw data
conforming_rate_bits_ points for the rollup period) that did not conform to the policing policy.
per_second
min_policing_violation_ The lowest collected traffic value, in bps, that violated the policing policy during the
rate_bits_per_second rollup period.
max_policing_violation_ The highest collected traffic value, in bps, that violated the policing policy during
rate_bits_per_second the rollup period.
avg_policing_violation_ The average collected traffic value, in bps, that violated the policing policy during
rate_bits_per_second the rollup period.
sum_policing_violation_ The total collected traffic value, in bps, that violated the policing policy during the
rate_bits_per_second rollup period.
std_policing_violation_ The standard deviation of the collected traffic values (calculated from the raw data
rate_bits_per_second points for the rollup period) that violated the policing policy.
min_policing_ The lowest collected traffic value, in bytes, that conformed to the policing policy
conforming_bytes during the rollup period.
max_policing_ The highest collected traffic value, in bytes, that conformed to the policing policy
conforming_bytes during the rollup period.
avg_policing_ The average collected traffic value, in bytes, that conformed to the policing policy
conforming_bytes during the rollup period.
sum_policing_ The total collected traffic value, in bytes, that conformed to the policing policy
conforming_bytes during the rollup period.
std_policing_conforming_ The standard deviation of the collected traffic values (calculated from the raw data
bytes points for the rollup period) that conformed to the policing policy.
min_policing_non_ The lowest collected traffic value, in bytes, that did not conform to the policing
conforming_bytes policy during the rollup period.
max_policing_non_ The highest collected traffic value, in bytes, that did not conform to the policing
conforming_bytes policy during the rollup period.
avg_policing_non_ The average collected traffic value, in bytes, that did not conform to the policing
conforming_bytes policy during the rollup period.
sum_policing_non_ The total collected traffic value, in bytes, that did not conform to the policing policy
conforming_bytes during the rollup period.
std_policing_non_ The standard deviation of the collected traffic values (calculated from the raw data
conforming_bytes points for the rollup period) that did not conform to the policing policy.
min_policing_violations_ The lowest collected traffic value, in bytes, that violated the policing policy during
bytes the rollup period.
max_policing_violations_ The highest collected traffic value, in bytes, that violated the policing policy during
bytes the rollup period.
avg_policing_violations_ The average collected traffic value, in bytes, that violated the policing policy during
bytes the rollup period.
sum_policing_violations_ The total collected traffic value, in bytes, that violated the policing policy during the
bytes rollup period.
std_policing_violations_ The standard deviation of the collected traffic values (calculated from the raw data
bytes points for the rollup period) that violated the policing policy.
min_queueing_discards_ The lowest discarded traffic, in bytes, for the queueing policy during the rollup
bytes period.
max_queueing_discards_ The highest discarded traffic, in bytes, for the queueing policy during the rollup
bytes period.
avg_queueing_discards_ The average discarded traffic, in bytes, for the queueing policy during the rollup
bytes period.
sum_queueing_discards_ The total discarded traffic, in bytes, for the queueing policy during the rollup period.
bytes
std_queueing_discards_ The standard deviation of collected discarded traffic values (calculated from the raw
bytes data points for the rollup period) for the queueing policy.
min_queueing_current_ The lowest queue depth, in bytes, for the queueing policy during the rollup period.
queue_depth_bytes
max_queueing_current_ The highest queue depth, in bytes, for the queueing policy during the rollup period.
queue_depth_bytes
avg_queueing_current_ The average queue depth, in bytes, for the queueing policy during the rollup period.
queue_depth_bytes
sum_queueing_current_ The total queue depth, in bytes, for the queueing policy during the rollup period.
queue_depth_bytes
std_queueing_current_ The standard deviation of collected queue depth values (calculated from the raw
queue_depth_bytes data points for the rollup period) for the queueing policy.
min_classmap_pre_ The lowest inbound interface utilization, in percent, before applying the CBQoS
policy_inbound_ policy during the rollup period.
utilization_percent
max_classmap_pre_ The highest inbound interface utilization, in percent, before applying the CBQoS
policy_inbound_ policy during the rollup period.
utilization_percent
avg_classmap_pre_ The average inbound interface utilization, in percent, before applying the CBQoS
policy_inbound_ policy during the rollup period.
utilization_percent
sum_classmap_pre_ The total inbound interface utilization, in percent, before applying the CBQoS
policy_inbound_ policy during the rollup period.
utilization_percent
std_classmap_pre_policy_ The standard deviation of the percent inbound interface utilization values
inbound_utilization_ (calculated from the raw data points for the rollup period), before applying the
percent CBQoS policy.
min_classmap_post_ The lowest outbound interface utilization, in percent, after applying the CBQoS
policy_outbound_ policy during the rollup period.
utilization_percent
max_classmap_post_ The highest outbound interface utilization, in percent, after applying the CBQoS
policy_outbound_ policy during the rollup period.
utilization_percent
avg_classmap_post_ The average outbound interface utilization, in percent, after applying the CBQoS
policy_outbound_ policy during the rollup period.
utilization_percent
sum_classmap_post_ The total outbound interface utilization, in percent, after applying the CBQoS policy
policy_outbound_ during the rollup period.
utilization_percent
std_classmap_post_ The standard deviation of the percent outbound interface utilization values
policy_outbound_ (calculated from the raw data points for the rollup period, after applying the CBQoS
utilization_percent policy.
min_queueing_discard_ The lowest discard rate, in bps, for the queueing policy during the rollup period.
rate_bytes_per_second
max_queueing_discard_ The highest discard rate, in bps, for the queueing policy during the rollup period.
rate_bytes_per_second
avg_queueing_discard_ The average discard rate, in bps, for the queueing policy during the rollup period.
rate_bytes_per_second
sum_queueing_discard_ The total discard rate, in bps, for the queueing policy during the rollup period.
rate_bytes_per_second
std_queueing_discard_ The standard deviation of collected discard rate values (calculated from the raw
rate_bytes_per_second data points for the rollup period) for the queueing policy.
For the resource /data_performance_raw/cbqos, the data_fields option can include the following fields:
Field Description
classmap_pre_policy_ The total interface utilization, in bps, before applying the CBQoS policy.
rate_bits_per_second
classmap_post_policy_ The total interface utilization, in bps, after applying the CBQoS policy.
rate_bits_per_second
classmap_pre_policy_ The inbound interface utilization, in bps, before applying the CBQoS policy.
inbound_bytes
classmap_post_policy_ The outbound interface utilization, in bps, after applying the CBQoS policy.
outbound_bytes
classmap_pre_policy_ The inbound interface utilization, in percent, before applying the CBQoS policy.
inbound_utilization_
percent
classmap_post_policy_ The outbound interface utilization, in percent, after applying the CBQoS policy.
outbound_utilization_
percent
policing_conforming_ The total traffic, in bps, that conformed to the policing policy.
rate_bits_per_second
policing_non_ The total traffic, in bps, that did not conform to the policing policy.
conforming_rate_bits_
per_second
policing_violation_rate_ The total traffic, in bps, that violated the policing policy.
bits_per_second
policing_conforming_ The total traffic, in bytes, that conformed to the policing policy.
bytes
policing_non_ The total traffic, in bytes, that did not conform to the policing policy.
conforming_bytes
policing_violations_bytes The total traffic, in bytes, that violated the policing policy.
The default response from the sub-resources of /data_performance and /data_performance_raw include a
searchspec section. The fields section of the searchspec includes a list of attribute values for devices or interfaces.
The attribute values can be used to filter the result. See the chapter on Resources and URIs for information on
how to use these fields to filter results.
Field Description
device Supply numeric values to match against device IDs. The response will include
devices with matching IDs.
device/class_type/class Supply string values to match against Device Class (typically vendors or
manufacturers, e.g. "Cisco Systems"). The response will include devices with a
matching device class.
device/class_type/description Supply string values to match against Device Class descriptions (typically
device models, e.g. "Catalyst 3750"). The response will include devices with a
matching device class.
device/class_type/device_ Supply string values to match against device category GUIDs. The response
category/guid will include devices with a matching device category.
device/class_type/guid Supply string values to match against device class GUIDs. The response will
include devices with a matching device class.
device/merged_class_ Supply one or more Device Classes (typically vendors or manufacturers, e.g.
type/class "Cisco Systems") to filter on. The response will include physical devices that are
merged with a component device and that component device has matching
device class.
device/merged_class_ Supply string values to match against Device Class descriptions (typically
type/description device models, e.g. "Catalyst 3750"). The response will include physical
devices that are merged with a component device and that component device
has matching device class.
device/merged_class_ Supply string values to match against device category GUIDs. The response
type/device_category/guid will include physical devices that are merged with a component device and
that component device has matching device category.
device/merged_class_type/guid Supply string values to match against device class GUIDs. The response will
include physical devices that are merged with a component device and that
component device has matching device class.
device/name Supply string values to match against device names. The response will include
devices with matching names.
device/organization Supply URIs to match against organizations. The response will include devices
in the matching organizations.
device/organization/company Supply string values to match against organization names. The response will
include devices in the matching organizations.
series. The response will include time series with matching indexes.
l For monitoring policies, the policy IDs. The response will include
monitoring policies with matching IDs.
l For file systems, the file system IDs. The response will include file
systems with matching IDs.
Field Description
device Supply numeric values to match against device IDs. The response will include
interfaces associated with devices with matching IDs.
device/class_type/class Supply string values to match against Device Classes (typically vendors or
manufacturers, e.g. "Cisco Systems"). The response will include interfaces
associated with devices with a matching device class.
device/class_type/description Supply string values to match against Device Class descriptions (typically
device models, e.g. "Catalyst 3750"). The response will include interfaces
associated with devices with a matching device class.
device/class_type/device_ Supply string values to match against device category GUIDs. The response
category/guid will include interfaces associated with devices with a matching device
category.
device/class_type/guid Supply string values to match against device class GUIDs. The response will
include interfaces associated with devices with a matching device class.
device/merged_class_ Supply one or more Device Classes (typically vendors or manufacturers, e.g.
type/class "Cisco Systems") to filter on. The response will include interfaces associated
with physical devices that are merged with a component device and that
component device has matching device class.
device/merged_class_ Supply string values to match against Device Class descriptions (typically
type/description device models, e.g. "Catalyst 3750"). The response will include interfaces
associated with physical devices that are merged with a component device
and that component device has matching device class.
device/merged_class_ Supply string values to match against device category GUIDs. The response
type/device_category/guid will include interfaces associated with physical devices that are merged with a
component device and that component device has matching device category.
device/merged_class_type/guid Supply string values to match against device class GUIDs. The response will
include interfaces associated with physical devices that are merged with a
component device and that component device has matching device class.
device/name Supply string values to match against device names. The response will include
interfaces associated with devices with matching names.
device/organization Supply URIs to match against organizations. The response will include
interfaces associated with devices in the matching organizations.
device/organization/company Supply string values to match against organization names. The response will
include interfaces associated with devices in the matching organizations.
interface Supply numeric values to match against interface IDs. The response will
include interfaces with matching IDs.
interface/alias Supply string values to match against interface aliases. The response will
include interfaces with matching aliases.
interface/ifDescr Supply string values to match against interface descriptions. The response will
include interfaces with matching descriptions.
interface/name Supply string values to match against interface names. The response will
include interfaces with matching names.
interface/organization Supply string values to match against organization names. The response will
include interfaces in the matching organizations.
interface/tag Supply string values to match against interface tags. The response will include
interfaces with matching tags.
Field Description
cbqos_object Supply numeric values to match against CBQoS object IDs. The response will
include CBQoS metrics associated with objects with matching IDs. CBQoS objects
can be searched and filtered using the /api/cbqos_object resource index.
cbqos_object/name Supply string values to match against CBQoS object names. The response will
include CBQoS metrics associated with objects with matching names.
cbqos_object/type Supply numeric values to match against CBQoS object types. The response will
include CBQoS metrics associated with objects that have a matching type. CBQoS
object types can be searched and filtered using the /api/cbqos_type resource index.
l hide_filterinfo. If this option is set to 1 in the URI, the response will contain only the result_set; the response
will not include the searchpec section.
l An HTTP 400 response code and a human-readable message indicating required options were not
included.
l An HTTP 500 response code and a human-readable message indicating that the appliance servicing the
request does not have sufficient memory to generate the requested data set. If you receive this response, you
must split your request in to multiple smaller requests.
l Zero or more data sets that match the options specified in the request. A data set is represented as a JSON
array or an XML structure bounded by <dataset> tags. Each data set represents:
o
For interface data, the data from a single interface.
o
For CBQoS data, the data from a single interface for a single CBQoS object.
o
For Dynamic Application data, the data for a single index (time series) for a device.
o
For all other device data, the data from a single device.
l The URI of the device, interface (where applicable), and CBQoS metric (where applicable) the data set is
associated with.
l If applicable, the index and index label for the data series.
l The list of field names included for each data point in the data set. This list of fields will include the time
stamp field and the data fields specified in the request options.
l A list of data points. Each data point is a list that includes an entry for each field (time stamp and data fields).
To improve performance, the field names are not included with each data point. The field order for each
data point matches the list of field names that appears at the beginning of each data set.
82 Additional Options
Example
1
Using the Ticket Resource
Overview
In SL1, a ticket is a request for work. This request can be in response to a problem that needs to be fixed, for
routine maintenance, or for any type of work required by your enterprise. A ticket can be assigned to a specific
user, to inform and remind that user of requests for work.
This chapter describes how to use the API to perform some basic tasks for managing tickets.
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
Requirements 84
Getting Started 84
Connecting to the API 85
Viewing a List of Tickets 90
Viewing a List of Tickets and Ticket Details 94
Filtering a List of Tickets 96
Retrieving Information about a Specific Ticket 97
Updating a Ticket 99
Capture Ticket Information in a File 99
Edit the Captured File 100
Use HTTP POST to Update the Ticket with the Edited File 101
83
Sending Only Changes in the ticket99.json File 103
Creating a New Ticket 103
Capturing an Existing Ticket and Storing the Information in a File 103
Determining the URI for a User Account 104
Editing the Captured File 107
Using the Edited File to Create a New Ticket 109
Viewing Notes for a Ticket 110
Adding a Note to a Ticket 114
Capturing an Existing Note and Storing the Information in a File 114
Editing the Captured File 114
Creating a New Note Using the Edited File 115
Viewing the Attachments for a Ticket 116
Adding an Attachment to a Ticket Note 119
Requirements
l This chapter assumes that you have a working version of cURL installed and can run cURL from a command
prompt. For information on cURL, see http://curl.haxx.se/.
l To connect to the API, you must use HTTPS. If you have not installed or configured a security certificate or if
your appliance uses a self-signed certificate, you must use include the "-k" option each time you execute
cURL. The "-k" option tells cURL to perform the HTTPS connection without checking the security certificate.
l Through the API, you can perform only actions for which you have permission in SL1. To perform the tasks in
this chapter, you must connect to the API using an account (username and password), that account must
have Access Keys that grant the following:
o
View tickets and ticket details
o
View Ticket Queues
o
Edit a ticket
o
Create a ticket
o
Assign a ticket to a user
o
Add a new note to a ticket
Getting Started
l In the examples in this chapter, we will connect to the example Administration Portal with the IP address of
192.168.10.205. To run these examples on your system, you should replace this IP address with the base
URI of the API on the appliance you are using.
84 Requirements
l In the examples in this chapter, we will connect to the API using the default account "em7admin", with the
default password "em7admin". To run these examples on your system, you should replace this username
and password with a valid username and password for your system.
l In the examples in this chapter, we will execute each HTTP request at a shell prompt or command prompt.
However, you can include these requests in a script or program.
CAUTION: The examples in this chapter use the custom-header option "X-em7-beautify-response:1".This
header tells the API to include white-space in a response, to make it easier to read. However, this
header can greatly increase the amount of time required to process a request. ScienceLogic
recommends you use this header only when testing requests. ScienceLogic strongly
discourages you from using this header in integration code.
l curl -v. Executes the cURL request. The -v option tells cURL to use verbose mode (displays all header
information and all status and error messages). In the response, lines that start with ">" include header data
returned by cURL. Lines that start with "<" include header data received by cURL.
l -H 'X-em7-beautify-response:1'. The -H option tells cURL to include an additional header in the request.
In this case, we're including a ScienceLogic custom header that tells the API to include white-space in the
response.
l -u 'em7admin:em7admin'. The -u option tells cURL to authenticate as a specified user. In our example, we
authenticated as the user "em7admin" with the password "em7admin".
l "https://192.168.10.205/api". Connect to the specified URL. In our example, we connected to the API at
192.168.10.205.
The response will look like this (however, we've added line numbers for reference):
o
accept: */*. Specifies that we will use the default accept header. The accept header tells the API how
to format the response. The API can respond in XML or JSON. Because we didn't specify an accept
header, the API will use the default format, which is JSON. If you want to view the response in XML,
you can include the header option "
-H 'Accept:application/xml" in the cURL command.
o
X-em7-beautify-response:1. Tells the API to include white-space in the response, for easier
reading.
l Line 12 shows the HTTP version and the HTTP status code for the response.
l Lines 12-19 show the header information for the response.
l Lines 20-81 display the response to the HTTP GET request on the root directory of the API.
The response for the HTTP GET request displays a list of resources. A resource is a functional area in SL1 that you
can access through the API.
You can interact with the following entities through the API:
l Accounts
l Account Lockouts
l Alerts
l Appliances
l Assets
l Collector Groups
l CBQoS Objects
l Collection Labels
l Credentials
l Custom Attributes
l Dashboards
l Devices
l Device Categories
l Device Classes
l Device Interfaces
l Device Groups
l Device Relationships
l Device Templates
l Discovery Sessions
l Dynamic Applications
For each resource, the response displays the associated URI for accessing the resource and a description that lists
the actions you can perform on the resource.
For our example, we'll be looking at the ticket resource. The ticket resource uses the following URI and includes
the following description:
69) {
70) "URI":"\/ticket?limit=100",
71) "description":"Get\/Update\/Add\/Delete Tickets"
72) }
To access a resource, like ticket, we can append its URI to the URI of the root directory. So to access the resource
ticket, we could enter the following at the command line.
The response does not contain the results we wanted, that is, information about the tickets in SL1. Instead, the
response contains:
l HTTP/1.1 302 Found. This status code indicates that ticket resources were found, but our request was
missing required filtering and options.
l Location: /ticket?limit=100. This is a redirect header. Most browsers would automatically redirect our
request to this URI. However, cURL requires an additional option to use redirects.
l "X-EM7-status-message: ticket index requires a limit" and "X-EM7-status-code: FOUND". Human-
readable status messages provided by the API. These messages indicate that our API does include ticket
resources and that our HTTP request was missing the "limit" option.
l "searchspec". The response includes a list of searchspec options. These options allow us to filter the items
(in this case, tickets) that are included in a response.
l "total_matched":"102", "total_returned":"0, "result_set":[]. This line indicates that the request could have
returned 102 tickets, but that our request returned zero tickets.
Let's run the command again with the correct URI that contains the required option. To do this, enter the following
at the command line:
l HTTP/1.1 200 OK. Status code that indicates that our HTTP request was successful.
l An entry for each of the first 100 tickets found. The response includes basic information about the first
100 tickets found (as specified in the "limit" option). For each found ticket, The response includes:
o
URI of the ticket, which includes the ticket ID.
NOTE: Our response is in JSON format. Notice that the URI for the ticket includes escaped
forward slash characters ("\/").
o
Description text from the ticket.
o
To retrieve all information about a ticket, you can use the extended_fetch option. This is described
in the following section.
{
"class":"1",
"severity":"2",
"status":"0",
"source":"43",
"date_create":"2010-01-18 20:12:06",
"date_update":"2010-01-18 20:12:06",
"assigned_to":"\/api\/account\/0",
"resolution":"0",
"cause":"0",
"escalation":"0",
"chargeback":"0",
"date_close":"0000-00-00 00:00:00",
"auto_close":"0",
"custom_fields":{
},
"organization":"\/api\/organization\/0",
"description":"Rollback Configuration On Device CustB_2821-1.cisco.com",
"opened_by":"\/api\/account\/1",
"updated_by":"\/api\/account\/1",
"closed_by":"\/api\/account\/1",
"ticket_queue":"\/api\/ticket_queue\/8",
"parent_ticket":"\/api\/ticket\/0",
"aligned_resource":null,
"notes":{
"URI":"\/api\/ticket\/99\/note\/?hide_filterinfo=1&limit=1000",
"description":"Notes"
}
}
Notice that the response now includes information about all the ticketing fields.
Also notice that some fields, like organization, include URIs. The URI is a link to a different resource (for example,
an organization resource).
NOTE: Our response is in JSON format. Notice that these URIs include escaped forward slash characters
("\/").
l class
l severity
l status
l source
l date_create
l date_update
l assigned_to
l resolution
l cause
l escalation
l chargeback
l date_close
l auto_close
l organization
l description
l opened_by
l updated_by
l closed_by
l ticket_queue
l parent_ticket
l If we wanted to request only tickets with a severity of "major", we would append "&filter.severity=3" to the
URI for our request. To view tickets of a specific severity, use the format:
o
"&filter.severity=number_of_severity"
l If we wanted to view all tickets with a severity of major or higher, we would append "&filter.severity.min=3"
to the URI for our request. You can use the following operators in a filter clause:
o
.not (not equal to)
o
.min (greater than or equal to)
o
.max (less than or equal to)
To request all tickets with a severity of "major", enter the following at the command line:
The response contains all ticket information for all tickets with a severity of "major".
To request all tickets with a severity equal to or greater than major (major and critical), enter the following at the
command line:
The response contains all ticket information for all tickets with a severity of "major" or "critical".
NOTE: When you include the URI for a specific ticket, the results automatically include all the information
for the ticket. If you include the URI for a specific ticket, you do not need to include "&extended_
fetch=1"
For example, if we wanted to request information about ticket 99, we could enter the following at the command
prompt:
l Notice the HTTP status message and the ScienceLogic status messages.
l The response includes all the details about the specified ticket.
Updating a Ticket
The easiest way to update a ticket is to:
1. Use an HTTP GET request to capture the ticket's current values and store them in a file.
2. Edit that captured file.
3. Use an HTTP POST method to update the ticket with the contents of the edited file.
We have now captured the information from ticket 99 and stored it in the file ticket99.json. The file looks like
this:
{
"class":"1",
"severity":"2",
"status":"0",
"source":"43",
"date_create":"1263845526",
"date_update":"1263845526",
"assigned_to":"\/api\/account\/0",
"resolution":"0",
"cause":"0",
"escalation":"0",
"chargeback":"0",
"date_close":"0",
"auto_close":"0",
"organization":"\/api\/organization\/0",
Updating a Ticket 99
"description":"Rollback Configuration On Device CustB_2821-1.cisco.com",
"opened_by":"\/api\/account\/1",
"updated_by":"\/api\/account\/1",
"closed_by":"\/api\/account\/1",
"ticket_queue":"\/api\/ticket_queue\/8",
"parent_ticket":"\/api\/ticket\/0",
"aligned_resource":null,
"custom_fields":{
},
"notes":{
"URI":"\/api\/ticket\/99\/note\/?hide_filterinfo=1&limit=1000",
"description":"Notes"
}
}
NOTE: Do not make changes to the value for notes. This is a sub-resource, which are explained later in this
example.
{
"class":"1",
"severity":"4",
"status":"1",
"source":"43",
"date_create":"1263845526",
"date_update":"1263845526",
"assigned_to":"\/api\/account\/0",
"resolution":"0",
"cause":"0",
"escalation":"0",
"chargeback":"0",
"date_close":"0",
"auto_close":"0",
"organization":"\/api\/organization\/0",
"description":"Rollback Configuration On Device CustB_2821-1.cisco.com",
Use HTTP POST to Update the Ticket with the Edited File
We'll now use an HTTP POST method to update the ticket with the contents of the file ticket99.json. To do this,
enter the following at the command line:
In addition to the optional "beautify response" header and the URI for the ticket, you must specify:
l 'content-type:application/json'. So the API knows that the incoming data is in JSON format.
l --data-binary @file_name.json. Specifies that HTTP POST should transmit the data exactly as is, with no
extra processing. The @ symbol tells cURL that the data is stored in a file.
{
"severity":"4",
"status":"1"
}
We could have sent this shortened file with an HTTP POST method and had the same result.
1. Capture an existing ticket and store the information in a file. We will use this file as our template for creating
a new ticket.
2. Determine the URI for a user account. This is the user that will appear in the opened_by, assigned_to, and
updated_by fields.
3. Edit the captured file to create the new ticket.
4. Perform an HTTP POST method to create a new ticket from the edited file.
First, let's request the index for the account resource. To do this, enter the following at the command line:
l The account URI requires the limit option (like the previous example for the ticket resource).
l We can filter accounts by user-name.
We can now try to find the URI for our current user ID, em7admin. To do this, enter the following at the command
prompt:
l We now know that the URI for the user "em7admin" is "/api/account/1".
NOTE: Our response is in JSON format. Notice that the URI for the account includes escaped forward slash
characters ("\/").
{
"class":"1",
"severity":"3",
"status":"1",
"source":"43",
"assigned_to":"\/api\/account\/1",
"resolution":"0",
l We changed the assigned_to, opened_by, and updated_by field to the URI for the user "em7admin".
Because the file is in JSON format, we must escape the forward slash characters (/). Notice that we did so
when specifying the account URI.
l We removed the entire line that contains "date_create". The API will automatically insert the current date
and time in the new ticket.
l We removed the entire line that contains "date_update". The API will automatically insert the current date
and time in the new ticket.
l We set the organization field to reference the System organization (URI is "/api/organization/0").
l We accepted the previous ticket's values for all other fields. However, you can edit these fields as you want.
To determine a URI value for a field, do an HTTP GET request for the referenced resource (account,
organization, ticket, ticket_queue).
l We left the entries for "notes" and "logs" sub-resources. The API ignores these fields and replaces them with
empty fields that reference the new ticket's URI.
l Notice that unlike when we updated the ticket, in this example we POST to the URI for the general index for
the ticket resource instead of POSTing to a URI for a ticket ID. This is because we do not yet have a ticket
ID.
l Like when we updated a ticket, we include the following in the POST:
o
'content-type:application/json'. So the API knows that the incoming data is in JSON format.
o
--data-binary @file_name.json. Specifies that HTTP POST should transmit the data exactly as is,
with no extra processing. The @ symbol tells cURL that the data is stored in a file.
l Notice that the status codes and status messages specify that the ticket was created successfully and also
specify the ticket ID.
l If our file new_ticket.json had included bad syntax, we would get:
HTTP/1.1 400 Bad Request
< X-EM7-status-message: Unable to decode JSON string.
< X-EM7-status-code: BAD_REQ
...
l Notice that the API automatically inserted the current time (in UNIX timestamp format) for the "date_created"
and "date_updated" fields.
l Notice that the API automatically inserted an appropriate URI for the "notes" sub-resource.
We could look at the response from the ticket we just created (ticket 279). In the response, the reference to the
notes a sub-resource looks like this:
"notes":{
"URI":"\/ticket\/note\/?hide_filterinfo=1&limit=1000",
To view all the notes for the ticket we just created (ticket 279), enter the following at the command prompt:
Because we have not yet added a note to this ticket, the response looks like this:
In the response:
l We see that there are two notes in ticket 97: note 96 and note 270.
l We can view the text included in each note.
Now let's request a specific note. Using ticket 97 and our results above, we can request information about note
96 in ticket 97. To do this, enter the following at the command line:
l HTTP code 200 OK. The API was able to successfully find note 96 within ticket 97. If note 96 did not exist,
we would see the following:
We can use the HTTP POST method to add a note to an existing ticket. We will add a note to the ticket we created
earlier, ticket 279. To add a note to a ticket, we must perform the following steps:
1. Request an existing note and store the information in a file. We will use this file as our template for creating
a new note.
2. Edit the captured file.
3. Execute an HTTP POST method to create a new note from the edited file.
The information from the note will be stored in the file new_ note.json. We will use this file as our template.
{
"hidden":"0",
"note_text":"This is a test note from the API",
"mime_type":"text\/html",
"edited_by":"\/api\/account\/1"
}
l We removed the lines that contain "date_edit" and "ip". The API will automatically insert the current date
and time and the source IP of the request in the new note.
o
When "hidden" is set to "0" (zero), the note is not cloaked.
o
When "hidden" is set to "1" (one), the note is cloaked.
l We changed the value of the note_text field to "This is a test note from the API".
l We changed the edited_by field to the URI for the user "em7admin" (/api/account/1). Because the file is in
JSON format, we must escape the forward slash characters (/). Notice that we did so when specifying the
account URI.
l Notice that we POST to the URI for the index for the note sub-resource for this ticket, instead of to a specific
note ID. This is because we do not yet have a note ID.
l We include the following in the POST:
o
'content-type:application/json'. So the API knows that the incoming data is in JSON format.
o
--data-binary @file_name.json. Specifies that HTTP POST should transmit the data exactly as is,
with no extra processing. The @ symbol tells cURL that the data is stored in a file.
[.... REMOVED CONNECTION INFORMATION and SOME HEADER INFORMATION FROM RESPONSE,
FOR BREVITY]
< HTTP/1.1 201 Created
< Date: Wed, 25 Aug 2010 16:01:49 GMT
< Server: Apache
< X-Implemented-methods: GET,PUT,POST
< X-Powered-By: ScienceLogic,LLC - EM7 API/Integration Server
< Location: /api/ticket/279/note/273
< X-EM7-status-message: Note /ticket/279/note/273 added.
< X-EM7-status-code: CREATED
< Content-Length: 142
< Content-Type: application/json
<
{
"date_edit":"1264525835",
l Notice that the status codes and status messages specify that the note was created successfully and also
specify the note ID (note 273).
l If our file new_ticket.json had included bad syntax, we would get:
For example, to view the attachments for ticket 2058, at note 11, we could enter the following at the command
prompt:
[.... REMOVED CONNECTION INFORMATION AND SOME HEADER INFORMATION FROM RESPONSE,
FOR BREVITY]
< HTTP/1.1 200 OK
< Date: Wed, 25 Aug 2010 16:03:11 GMT
< Server: Apache
< X-Implemented-methods: GET
< X-Powered-By: ScienceLogic,LLC - EM7 API/Integration Server
< X-EM7-status-message: Fileindex found with 1 resources.
< X-EM7-status-code: OK
< Content-Disposition: inline; filename="test_attachment.rtf"
< Content-Length: 357
< Content-Type: application/rtf
<
{
l The status codes and messages specify that one attachment was found.
l If no attachments were found, the response would include:
Now let's request a specific attachment. Using ticket 2058, note 11 and our results above, we can request
information about the "Penguins.jpg" attachment. To do this, enter the following at the command line:
l HTTP code 200 OK. The API was able to successfully find the Penguins.jpg attachment.
l The URI field in the data section specifies the download link for the file.
NOTE: For FIPS-compliant systems, the response will include a SHA hash, not an MD5 hash.
The API will not allow you to add an attachment with an HTTP POST method. If you try, the response will look like
this:
[.... REMOVED CONNECTION INFORMATION AND SOME HEADER INFORMATION FROM RESPONSE,
FOR BREVITY]
< HTTP/1.1 405 Method Not Allowed
< Date: Wed, 25 Aug 2010 16:04:25 GMT
< Server: Apache
< X-Implemented-methods: GET,PUT,DELETE
< X-Powered-By: ScienceLogic,LLC - EM7 API/Integration Server
< X-EM7-status-message: POST not allowed for note media. PUT an explicitly named new
attachment or image
< X-EM7-status-code: BAD_METHOD
< Content-Length: 214
< Content-Type: application/json
<
{
"errors":[
{
"errorcode":"BAD_METHOD",
"message":"POST not allowed for ticket attachments. PUT an explicitly named new
attachment or image"
}
To use HTTP PUT, we must include the "-T" option with the cURL command.
Suppose we want to add the image file "spidey.png" to ticket 97, note 96. We could enter the following at the
command prompt:
l attachment/spidey.png. Tells the API the filename to use when saving the attachment in the system.
l -H "content-type:image/png". Tells the API that the attachment will be an image file of type PNG.
l -T. Tells cURL to perform an HTTP PUT.
l ./spidey.png. Full pathname of the file to attach. "./" means "current directory".
l Notice that unlike HTTP POST, the HTTP PUT method does not require the "--data-binary option" or the "@"
characters before the filename.
NOTE: If an attachment has been prohibited in the Ticket Attachment Blacklist page (Registry . Ticketing
> Attachment Blacklist), the API will not attach the file to the ticket note. The API will not allow you to
attach files with a file extension that matches a blacklist entry.
2
Using the Discovery Resource
Overview
Discovery is the process by which SL1 retrieves data from the devices in a network and then adds and configures
those devices. SL1 runs discovery to perform the initial discovery of your network and then nightly to collect and
update information about your network. You can also manually initiate discovery, for a single device or for a
range of devices, at any time.
To start discovery, you must provide the discovery tool with one or more IP addresses and other information
about how you want SL1 to perform the discovery. You save the list of IP addresses and other information about
how you want SL1 to perform the discovery in a discovery session. When you execute the discovery session, SL1
then finds all the devices and components in the range. For each discovered device or component, SL1 gathers
detailed data. This data is used throughout SL1.
This chapter will show you how to use the API to perform some basic tasks for managing discovery sessions.
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
Requirements 122
Getting Started 122
Connecting to the API 123
Viewing a List of Discovery Sessions 127
Viewing Details about All Discovery Sessions 132
Filtering the List of Discovery Sessions 133
121
Retrieving Information about a Specific Discovery Session 135
Starting a Discovery Session 136
Viewing a List of All Active Discovery Sessions 138
Retrieving Information about a Specific Active Discovery-Session 140
Viewing Logs for a Discovery Session 140
Stopping a Currently Running Discovery-Session 142
Deleting a Discovery Session 144
Requirements
l This chapter assumes that you have a working version of cURL installed and can run cURL from a command
prompt. For information on cURL, see http://curl.haxx.se/.
l To connect to the API, you must use HTTPS. If you have not installed or configured a security certificate or if
your appliance uses a self-signed certificate, you must use include the "-k" option each time your execute
cURL. The "-k" option tells cURL to perform the HTTPS connection without checking the security certificate.
l Through the API, you can perform only actions for which you have permission in the system. To perform the
tasks in this chapter, you must connect to the API using an account (username and password). The account
must have Access Keys that grant the following:
o
Access the Discovery page
o
Schedule or execute a discovery session
Getting Started
l In the examples in this chapter, we will connect to the example Administration Portal with the IP address of
192.168.10.205. To run these examples on your system, you should replace this IP address with the base
URI of the API on the appliance you are using.
l In the examples in this chapter, we will connect using the default account "em7admin", with the default
password "em7admin". To run these examples on your system, you should replace this username and
password with a valid username and password for your system.
l In the examples in this chapter, we will execute each request at a shell prompt or command prompt.
However, you can include these requests in a script or program.
CAUTION: The examples in this chapter use the custom-header option "X-em7-beautify-response:1".This
header tells the API to include white-space in a response, to make it easier to read. However, this
header can greatly increase the amount of time required to process a request. ScienceLogic
recommends you use this header only when testing requests. ScienceLogic strongly
discourages you from using this header in integration code.
122 Requirements
Connecting to the API
To connect to the API and view the root directory (with an HTTP GET request), enter the following at the command
prompt:
l curl -v. Executes the cURL request. The -v option tells cURL to use verbose mode (displays all header
information and all status and error messages). In the response, lines that start with ">" include header data
returned by cURL. Lines that start with "<" include header data received by cURL.
l -H 'X-em7-beautify-response:1'. The -H option tells cURL to include an additional header in the request.
In this case, we're including a ScienceLogic custom header that tells the API to include white-space in the
response.
l -u 'em7admin:em7admin'. The -u option tells cURL to authenticate as a specified user. In our example, we
authenticated as the user "em7admin" with the password "em7admin".
l "https://192.168.10.205/api". Connect to the specified URL. In our example, we connected to the API at
192.168.10.205.
The response will look like this (however, we've added line numbers for reference):
l Lines 1-4 show cURL trying to connect to and authenticate with the API.
l Lines 5-11 show the HTTP GET request we sent. The initial request performs a GET on the root directory of
the API.
l Line 12 shows the HTTP version and the HTTP status code for the response.
l Lines 12-18 show the header information for the response.
l Lines 19-52 display the response to the HTTP GET request on the root directory of the API.
The response for the HTTP GET request displays a list of resources. A resource is a functional area in SL1 that you
can access through the API.
You can interact with the following entities through the API:
l Accounts
l Account Lockouts
l Alerts
l Appliances
l Assets
l Collector Groups
l CBQoS Objects
l Collection Labels
l Credentials
l Custom Attributes
l Dashboards
l Devices
l Device Categories
l Device Classes
l Device Interfaces
l Device Groups
l Device Relationships
l Device Templates
l Discovery Sessions
l Dynamic Applications
l Events
l Event Categories
For each resource, the response displays the associated URI for accessing the resource and a description that lists
the actions you can perform on the resource.
For our example, we'll be looking at the discovery_session resource. The entry for the discovery_session
resource includes the URI of the discovery_session resource and includes the following description:
29) "discovery_session":{
30) "URI":"\/discovery_session\/",
31) "description":"Get\/Update\/Add\/Delete Device Discovery Sessions"
32) },
To access a resource, like discovery_session, we can use an HTTP GET and append a discovery session's URI to
the URI of the root directory. To access the resource discovery_session, we could enter the following at the
command line.
...[REMOVED CONNECTION INFORMATION AND SOME HEADER INFORMATION FROM RESPONSE, FOR
BREVITY]
< HTTP/1.1 302 Found
< Date: Wed, 27 Jan 2010 16:32:05 GMT
< Server: Apache
< X-Powered-By: ScienceLogic,LLC - EM7 API/Integration Server
< Location: /discovery_session?limit=100
< X-EM7-status-message: discovery_session index requires a limit
< X-EM7-status-code: FOUND
< Content-Length: 977
< Content-Type: application/json
<
{
"searchspec":{
"fields":{
"data":[
"dgid",
"date_edit",
"date_run",
"scan_ports",
"organization",
"collector_id",
"edited_by",
"discover_non_snmp"
]
},
"options":{
l HTTP/1.1 302 Found. This status code indicates that discovery_session resources were found, but our
request was missing required filtering and options.
l Location: /discovery_session?limit=100. This is a redirect header. Most browsers would automatically
redirect our request to this URI. However, cURL requires an additional option to use redirects.
l "X-EM7-status-message: discovery_session index requires a limit" and "X-EM7-status-code:
FOUND". Human-readable status messages provided by the API. These messages indicate that our API
does include discovery_session resources and that our HTTP request was missing the "limit" option.
l "searchspec". The response include a list of searchspec options. These options allow use to filter content
contained in the response.
l "total_matched":"14", "total_returned":"0, "result_set":[]. This line indicates that the default "limit" option
would have returned 14 discovery sessions, but that our request returned zero discovery sessions.
Let's run the command again with the correct URI that contains the required option. To do this, enter the following
at the command line:
...[REMOVED CONNECTION INFORMATION AND SOME HEADER INFORMATION FROM RESPONSE, FOR
BREVITY]
< HTTP/1.1 200 OK
< Date: Wed, 27 Jan 2010 16:36:20 GMT
< Server: Apache
< X-Powered-By: ScienceLogic,LLC - EM7 API/Integration Server
< Content-Length: 2530
< Content-Type: application/json
<
{
"searchspec":{
"fields":{
"data":[
"dgid",
"date_edit",
"date_run",
"scan_ports",
"organization",
"collector_id",
"edited_by",
"discover_non_snmp"
]
l HTTP/1.1 200 OK. Status code that indicates that our HTTP request was successful.
l An entry for all of the discovery sessions found. The response includes basic information about 14
discovery sessions, because only 14 sessions exist on our example system. Because we set the limit option to
"100", the response could contain information about the first 100 discovery sessions. For each found
discovery session, the response includes:
o
URI of the discovery session.
NOTE: Our response is in JSON format. Notice that the URI for the discovery session includes
escaped forward slash characters ("\/").
o
Description of the discovery method. A list of values that were selected in the Detection Method &
Port field (in the System > Manage > Classic Discovery page). The possible values are described in
the following section, in the description of the scan_ports field.
o
To request all information about all discovery sessions, you can use the extended_fetch option. This
is described in the following section.
l Discovery Session ID. The unique numeric identifier, assigned to this session by SL1.
NOTE: The Discovery Session ID and the numbered list in the Session Register pane in the System >
Manage > Classic Discovery page may not match. The Session Register pane in the System
> Manage > Classic Discovery page is sorted by date and changes when a discovery session
is edited.
l dgid. ID of the Device Group associated with this discovery session. If no device group is associated with
this discovery session, this field will contain the value "NULL".
l date_edit. Date and time the discovery session was last edited.
l date_run. Date and time the discovery session was last executed.
l scan_ports. A list of values that were selected in the Detection Method & Port field (in the System >
Manage > Classic Discovery page).
o
If in the Detection Method & Port field, a user selected the "Default" method, this list includes the
default TCP ports that are used during discovery (21, 22, 23, 25, and 80).
o
If in the Detection Method & Port field, a user selected one or more TCP ports, the list includes
those ports.
o
If in the Detection Method & Port field, a user selected "UDP 161", the list includes the string
"SNMP".
l ip_list. The start IP and end IP for each IP range included in the discovery session.
l credentials. One or more credentials selected for this discovery session.
l organization. Link to the organization resource associated with the discovery session.
l collector_id. The appliance ID of the Data Collector associated with the discovery session.
l edited_by. Link to the account resource for the user who last edited this discovery session.
l discover_non_snmp. Specifies whether this session will discover devices that don't support SNMP. These
devices are called "pingables" in SL1. "0" (zero) means do not include pingables; "1" (one) means include
pingables.
l logs. Link to the logs sub-resource for this discovery session.
If we wanted to view details about only discovery sessions that do not include pingables, we could enter the
following at the command line:
The response would display full details about the first 100 discovery sessions that do not discover pingables.
For example, if we wanted to view full details about the first 100 discovery sessions that are not associated with
the Data Collector with the ID of 3, we could enter the following at the command line:
NOTE: When you include the URI for a specific discovery session, the response automatically includes all
the information for the session. If you include the URI for a specific discovery session, you do not
need to include "extended_fetch=1"
For example, if we wanted to request information about discovery session ID "1", we could enter the following at
the command prompt:
...[REMOVED CONNECTION INFORMATION AND SOME HEADER INFORMATION FROM RESPONSE, FOR
BREVITY]
< HTTP/1.1 200 OK
< Date: Wed, 27 Jan 2010 19:16:49 GMT
< Server: Apache
< X-Powered-By: ScienceLogic,LLC - EM7 API/Integration Server
< X-EM7-status-message: discovery_session seq:1 loaded successfully
< X-EM7-status-code: OK
< Content-Length: 625
< Content-Type: application/json
<
{
"dgid":null,
"date_edit":"1264540686",
"date_run":"1264544101",
"scan_ports":[
"SNMP",
"1",
"2"
],
"ip_lists":[
{
"start_ip":"192.168.9.1",
l Notice the HTTP status message and the ScienceLogic status messages.
l The response includes all the details about the specified discovery session
l If the discovery session did not exist (for example, if we supplied an incorrect ID), the response would
include:
The discovery_session_active resource allows you to execute a discovery session, view a list of currently active
discovery sessions, and stop a currently active discovery session.
In our example, we'll POST the URI for a discovery session to the discovery_session_active resource. We'll use
discovery session ID 1 as the discovery session.
[...REMOVED CONNECTION INFORMATION AND SOME HEADER INFORMATION FROM RESPONSE, FOR
BREVITY]
< HTTP/1.1 202 Accepted
< Date: Wed, 27 Jan 2010 19:36:44 GMT
< Server: Apache
< X-Powered-By: ScienceLogic,LLC - EM7 API/Integration Server
< X-EM7-status-message: Discovery session queued for discovery
< X-EM7-status-code: ACCEPTED
< Content-Length: 1
< Content-Type: application/json
<
* Connection #0 to host 192.168.10.205 left intact
* Closing connection #0
l The HTTP status code is 202, because the action did not complete within the HTTP response time. This is
because the discovery session is still running when the API generates the response.
l Notice the ScienceLogic status messages, which specify that the session has been queued for execution.
l If the discovery session is already running or is already queued, the response includes:
To view a list of all currently active discovery sessions, enter the cURL command from the previous section, to start
a discovery session:
NOTE: Our response is in JSON format. Notice that the URI for the discovery session includes escaped
forward slash characters ("\/").
First, start a discovery session. Enter the following at the command prompt:
Before the discovery session completes, enter the following at the command prompt:
l The response will be the same as if you requested all the details about the discovery session.
l If the specified discovery_session is not active, the response will include the following:
and will also include a redirect to the discovery_session resource for the discovery session.
If we look at the response from an HTTP GET of discovery session 1, the logs sub-resource looks like this:
"logs":{
"URI":"\/api\/discovery_session\/1\/log",
"description":"Discovery Session Logs"
To view the log for a discovery session, enter the following HTTP GET command at the command prompt:
[...REMOVED CONNECTION INFORMATION AND SOME HEADER INFORMATION FROM RESPONSE, FOR
BREVITY]
< HTTP/1.1 200 OK
< Date: Wed, 27 Jan 2010 20:07:34 GMT
< Server: Apache
< X-Powered-By: ScienceLogic,LLC - EM7 API/Integration Server
< Transfer-Encoding: chunked
< Content-Type: application/json
<
[.... REMOVED SEARCHSPEC INFORMATION FROM response, FOR BREVITY]
"total_matched":null,
"total_returned":71,
"result_set":[
{
"log_tstamp":"1264621963",
"msg_id":"124",
"msg_txt":"Beginning auto-discovery session"
},
{
"did":"\/device\/113",
"ip":"192.168.9.71",
"log_tstamp":"1264621979",
"msg_id":"500",
"msg_txt":"Discovered and modeled existing device"
},
{
"did":"\/device\/114",
"ip":"192.168.9.70",
"log_tstamp":"1264621979",
"msg_id":"500",
Let's first start discovery session 1 again. To do this, enter the following at the command prompt:
Before the discovery session completes, enter the following at the command prompt to stop the discovery session:
l Notice that the ScienceLogic status message indicates that the discovery session will be stopped.
l If the discovery session was not currently running, the response would include the following:
To delete a discovery session from SL1, enter the following at the command line:
3
Searching Component Trees
Overview
The /device resource can be filtered using the following fields, which can be used to search a component tree:
l component_ancestor_device
l component_parent_device
l component_root_device
l component_unique_id
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
For example, suppose that you want to get a list of all component devices associated with a NetApp Cluster.
Suppose that the NetApp Cluster has a device ID of 1656. To get the list of component devices, you can perform
a GET request using the following URL:
<result_set elemtype="list">
<link URI="/api/device/1673" description="KNT_NetApp_83_C2-01:/vol/vol0"
elemtype="href"/>
<link URI="/api/device/1697" description="/vol/vserver1_iscsi_vol2/vserver1_mixed_
vol1_lun01" elemtype="href"/>
<link URI="/api/device/1680" description="vserver1:/vol/vserver1_mix_vol1"
elemtype="href"/>
<link URI="/api/device/1671" description="data_aggr1" elemtype="href"/>
<link URI="/api/device/1679" description="vserver1:/vol/vserver1_iscsi_vol2"
elemtype="href"/>
<link URI="/api/device/1675" description="aggr0_KNT_NetApp_83_C2_02_0"
elemtype="href"/>
<link URI="/api/device/1687" description="vserver2:/vol/vs2_sm_dest_1"
elemtype="href"/>
<link URI="/api/device/1678" description="KNT_NetApp_83_C2-02:/vol/vol0"
elemtype="href"/>
<link URI="/api/device/1660" description="KNT_NetApp_83_C2-01" elemtype="href"/>
<link URI="/api/device/1682" description="vserver1:/vol/vs1_sm_dest_1"
elemtype="href"/>
<link URI="/api/device/1663" description="vserver1" elemtype="href"/>
<link URI="/api/device/1681" description="vserver1:/vol/root" elemtype="href"/>
<link URI="/api/device/1672" description="aggr0" elemtype="href"/>
<link URI="/api/device/1670" description="data_aggr2" elemtype="href"/>
<link URI="/api/device/1662" description="KNT_NetApp_83_C2-02" elemtype="href"/>
<link URI="/api/device/1677" description="data_aggr4" elemtype="href"/>
<link URI="/api/device/1665" description="vserver2" elemtype="href"/>
<link URI="/api/device/1688" description="vserver2:/vol/root" elemtype="href"/>
<link URI="/api/device/1676" description="data_aggr3" elemtype="href"/>
<link URI="/api/device/1664" description="vserver3" elemtype="href"/>
<link URI="/api/device/1686" description="vserver3:/vol/root" elemtype="href"/>
<link URI="/api/device/1661" description="vserver4" elemtype="href"/>
<link URI="/api/device/1674" description="vserver4:/vol/root" elemtype="href"/>
</result_set>
The default response includes the relative API URI and name of each component device. You can add additional
options to adjust the response, e.g., the extended_fetch option can be used to return all attributes of the
component devices in the response.
For example, suppose that you want to get a list of all component devices that are directly associated with an ACI
Pod, which includes APIC, Leaf, and Spine devices. Suppose that the ACI Pod has a device ID of 3. To get the list
of component devices, you can perform a GET request using the following URL:
<result_set elemtype="list">
<link URI="/api/device/4" description="Leaf1" elemtype="href"/>
<link URI="/api/device/5" description="Leaf2" elemtype="href"/>
<link URI="/api/device/6" description="apic2" elemtype="href"/>
<link URI="/api/device/7" description="apic3" elemtype="href"/>
<link URI="/api/device/8" description="apic1" elemtype="href"/>
<link URI="/api/device/9" description="Spine2" elemtype="href"/>
<link URI="/api/device/10" description="Spine1" elemtype="href"/>
</result_set>
The default response includes the relative API URI and name of each component device. You can add additional
options to adjust the response, e.g., the extended_fetch option can be used to return all attributes of the
component devices in the response.
For example, suppose that you want to get a list of all component devices under the US East region component
device in an Azure component tree. Suppose that the US East component device has a device ID of 682. To get
the list of component devices, you can perform a GET request using the following URL:
<result_set elemtype="list">
<link URI="/api/device/693" description="Data & Storage" elemtype="href"/>
<link URI="/api/device/694" description="Compute" elemtype="href"/>
<link URI="/api/device/695" description="Networking" elemtype="href"/>
<link URI="/api/device/724" description="Storage" elemtype="href"/>
<link URI="/api/device/725" description="Cloud Services" elemtype="href"/>
<link URI="/api/device/726" description="Virtual Machines" elemtype="href"/>
<link URI="/api/device/727" description="Virtual Networks" elemtype="href"/>
<link URI="/api/device/786" description="portalvhdsr5fxx3bdbnld5"
elemtype="href"/>
<link URI="/api/device/787" description="temp01tdj" elemtype="href"/>
<link URI="/api/device/788" description="ywtmpstrgacct" elemtype="href"/>
<link URI="/api/device/789" description="wintempeu01" elemtype="href"/>
For example, suppose that you want to get all the attributes of an AWS EC2 instance discovered in SL1. Suppose
that the EC2 instance has an instance ID, which is used by SL1 as the unique identifier, of i-c5cf573a. To get all
the attributes of the device, you can perform a GET request using the following URL:
<result_set elemtype="list">
<device key="/api/device/74">
<name>us-east-1a student34: c3.large: i-c5cf573a</name>
<ip/>
<hostname elemtype="null"/>
<snmp_cred_id>/api/credential/snmp/0</snmp_cred_id>
<snmp_w_cred_id elemtype="null"/>
<class_type>/api/device_class/451</class_type>
<collector_group>/api/collector_group/1</collector_group>
<active>
<user-disabled>0</user-disabled>
<unavailable>1</unavailable>
<maintenance>0</maintenance>
<system-disabled>0</system-disabled>
<user-initiated-maintenance>0</user-initiated-maintenance>
</active>
<organization>/api/organization/0</organization>
<auto_update>1</auto_update>
<event_suppress_mask>00:00:00</event_suppress_mask>
<auto_clear>1</auto_clear>
<log_all>1</log_all>
<daily_port_scan>1</daily_port_scan>
<critical_ping>0</critical_ping>
<scan_all_ips>0</scan_all_ips>
<preserve_hostname>1</preserve_hostname>
<disable_asset_update>0</disable_asset_update>
<date_added>1433793323</date_added>
<alert_avail_and_latency_fail>0</alert_avail_and_latency_fail>
<l3_topo elemtype="null"/>
4
Simple Provisioning System
Overview
This chapter describes a simple provisioning system written in PHP. The provisioning system is designed to be
used by a managed service provider that uses SL1 to provide monitoring services to its customers.
Using customer information supplied through a simple user interface, the example code makes requests to the
API to:
Use the following menu options to navigate the SL1 user interface:
l To view a page containing all the menu options, click the Advanced menu icon ( ).
151
Performing Requests 156
Requesting a List of Entities 160
Organization Lookup 162
Creating Entities 163
Deleting Entities 164
Configuring SNMP Credentials 165
Requesting Discovery Session Logs 169
Requesting an Available Data Collection Unit 173
Requesting a List of Referenced Entities 175
User Interface 177
header.php 177
index.php 178
devices.php 179
remove.php 182
provisioning.css 183
Provisioning a Customer (provision_customer.php) 183
Retrieving and Configuring Devices (configure_devices.php) 189
Removing a Customer (delete_customer.php) 197
System Design
The example provisioning system comprises the following front-end files that display the user interface:
l index.php. Provides a user interface for provisioning a new customer and discovering additional devices for
an existing customer.
l devices.php. Provides a user interface for configuring customer devices that have been discovered in SL1.
l remove.php. Provides a user interface for removing a customer from SL1.
l provision_customer.php. Processes the input values from index.php and performs the following
provisioning tasks:
o
If an organization record does not currently exist for the customer, creates an organization record for
the customer.
o
Configures SNMP credentials for each supplied SNMP community string.
o
Creates a discovery session for the customer using the configured SNMP credentials and the supplied
list of IP addresses.
o
Runs the discovery session.
l configure_devices.php. The configure_devices.php script returns a list of devices and associated device
classes for a specified customer. The list of devices can be all devices associated with the customer's
organization record, all devices from the last discovery session for that customer, or new devices from the
last discovery session for that customer. Additionally, if a user selects the [Configure Devices] button in the
devices.php page, the configure_devices.php script applies the device templates selected by the user to the
specified devices.
l delete_customer.php. Takes a customer name as input; deletes all devices, credentials, and discovery
sessions associated with that customer's organization record; and then deletes the organization record for
that customer.
The following diagram shows the control flow between the files when all procedures are successful:
When a back-end procedure is unsuccessful, an error message is returned to the appropriate front-end page.
The six main PHP files use the following additional files:
l header.php. Includes the common elements used by all three user interface pages.
l provisioning.css. Includes style information for the user interface pages. In this example, minimal style is
applied to the user interface pages. You can customize the user interface pages by adding style information
to this file.
l utils.php. Includes a set of PHP functions that are used by the three back-end files.
l Upgrade your system to version 7.5.5 or later. Some API requests used in the provisioning code are not
compatible with older versions of SL1.
l Manually create a device template in your instance of SL1 that will be applied to all devices discovered
using the provisioning system.
l Edit utils.php to include:
o
The IP address of an Administration Portal, Database Server, or All-In-One Appliance in your system.
o
An administrator username and password.
o
The URI of the device template that will be applied to all devices discovered using the provisioning
system.
See the System-Specific Functions section for a description of the required changes to utils.php.
l Copy the example files to a web server. All the example files must be in the same directory on the web
server. The web server must:
o
Be able to make HTTP requests to your Administration Portal, Database Server, or All-In-One
Appliance.
o
Use a PHP processor module that includes cURL support. The code in this example uses cURL to
communicate with an Administration Portal, Database Server, or All-In-One Appliance. For more
information about cURL support in PHP, see http://www.php.net/manual/en/book.curl.php.
o
Use PHP version 5.2.0 or later. The code in this example uses JSON format for all requests and uses
the json_encode and json_decode functions. For more information about JSON support in PHP, see
http://php.net/manual/en/book.json.php.
l Manually add a custom attribute to the /device resource. The example code uses this custom attribute to
track the last device template that was applied to each device. To add the custom attribute, "c-last_dev_tpl",
POST the following JSON content to the /custom_attribute/device resource index:
{
"name":"last_dev_tpl",
"label":"last_dev_tpl",
"type":"string",
"index":"none",
"extended":"0"
}
For more information about custom attributes, see the Custom Attributes section.
154 Prerequisites
System-Specific Functions
This example includes two functions in utils.php that return information about the instance of SL1 with which the
provisioning code interacts:
l get_admin_uri. Returns the URL of an Administration Portal, Database Server, or All-In-One Appliance with
the username and password of an administrator user embedded in the URL. This value is a required
parameter for most functions in utils.php.
l get_base_template. Returns the relative URI of a device template. This device template specifies the basic
monitoring parameters for customer devices and is applied to every device discovered using the
provisioning system.
To use the example code with your instance of SL1, you must edit the get_admin_uri function to include the
IP address of your Administration Portal, Database Server, or All-In-One Appliance, the username for an
administrator user, and the password for that administrator user:
function get_admin_uri() {
$is_ip = "10.100.100.15";
$is_user = "em7admin";
$is_pass = "em7admin";
return $base_uri;
}
To use the example code with your instance of SL1, you must edit the get_base_template function to include the
relative URI of a device template in your system:
function get_base_template() {
return "/api/device_template/3";
}
In addition, utils.php includes two functions that return information about the instance of SL1 with which the
provisioning code interacts. For this example, the information returned by these system-specific functions is
hard-coded.
Performing Requests
To perform a request to the ScienceLogic API in PHP, you must:
The perform_request function is designed to perform these steps and return the response in a PHP array that has
the following structure:
(
['http_code'] => HTTP status code in the response
['headers'] => Array of headers that were included in the response. Each key in
this array is the name of the header, which points to the value for that header.
['content'] => Array that contains the decoded JSON body of the response.
['error'] => If the HTTP code in the response is not healthy (i.e. not 200, 201,
or 202), a human-readable error message that includes all error information that
was included in the response.
)
l $content. For $type values that require a POST operation ("POST" or "APPLY"), the content to POST must
be passed in this parameter. For a $type value of "POST", $content must be an array, which will be
encoded in JSON format. For a $type value of "APPLY", $content must be the relative URI to POST.
The perform_request function uses the $base and $resource values to construct the full URI of the resource,
then creates a cURL session:
For every request, the following cURL options are configured in the cURL session:
l CURLOPT_RETURNTRANSFER. Set to TRUE. By default, the PHP function that executes a request outputs
the response to standard out. By specifying this option, the function will return the response as a string.
l CURLOPT_HEADER. Set to TRUE. By specifying this option, the response headers will be included in the
output.
l CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST. Set to FALSE. To enable the use of the
example code in a test environment, the verification of the SSL certificate on the API appliance is disabled.
If the $type parameter is set to "POST" and content is supplied, the following additional cURL options are set to
perform a create/update POST request:
If the $type parameter is set to "APPLY" and content is supplied, the following additional cURL options are set to
perform POST request that applies a resource URI:
If the $type parameter is set to "DELETE", the CURLOPT_CUSTOMREQUEST option is set to perform an HTTP
DELETE in the cURL session:
if($type == "DELETE") {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
}
If the $type parameter is set to "POST" or "APPLY" and the $content parameter is not supplied, the perform_
request function returns FALSE without performing a request:
The perform_request function executes the cURL request and stores the HTTP status code from the response in
the output array ($response):
$output = curl_exec($ch);
$response['http_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
The response from the API includes the following information that must be included in the output of the function:
To parse this information, an array called $output_array is created with each line of the response as an array
element. Because the HTTP status code has already been stored, the first line of the response, which contains the
HTTP version and status code, is removed from the array:
foreach($output_array as $line) {
if(strpos($line, "{") < 2 AND strpos($line, "{") !== FALSE) {
$response['content'] = json_decode($line, TRUE);
}
If a line is not content and includes a colon, it is assumed to be a header and is added to the output array
($response):
To allow other functions to assume that the "content" key always exists in the output array, the "content" key in the
output array ($response) is initialized as an empty array if it is not already initialized:
if(!array_key_exists('content', $response)) {
$response['content'] = array();
}
In addition to HTTP status codes, every response from the API includes headers that provide additional details
about the result of a request:
If the HTTP status code from the response is not 200, 201, or 202 (i.e. 301 or above), the "error" key in the output
array ($response) is set to an appropriate message, which includes the values from the X-EM7-status-message
and X-EM7-info-message headers:
Finally, the cURL session is closed and the output array ($response) is returned:
curl_close($ch);
return $response;
}
The get_all function is designed to return a list of all available entities for a given resource index URI. The get_all
function includes a do-while loop that handles cases where multiple requests are required. For example, if the
URI is "/device", the get_all function returns a list of all devices in the system.
l On success, an array of entities. The structure of the array of entities is identical to the structure returned in
the result_set section of the response from the specific resource URI. The array of entities can be empty if
the request to the resource URI was successful, but no results were returned.
l On failure, an error message.
Any function that calls the get_all function can check success/failure by determining if the returned value is an
array or a string.
Before executing the do-while loop in which requests to the resource URI are performed, the array of entities is
initialized, initial offset value is set to 0, and the limit and offset values are added to the URI:
$offset = 0;
$request_uri = $uri . "&limit=100&offset=";
$entities = array();
The the $request_uri variable does not include a value for the offset option. For each iteration of the do-while
loop, the current offset is appended to the end of $request_uri.
The do-while loop performs a GET request for the URI with the current offset. If the request was successful (the
HTTP status code is 200), the result_set from the request is added to the list of entities:
do {
$response = perform_request($base_uri, $request_uri . $offset, "GET");
If the request is unsuccessful, the $message variable is initialized with an error message:
elseif($response['http_code'] != 200) {
$message = "An error occured while requesting entities. ";
if(array_key_exists("error", $response)) {
$message .= $response['error'];
}
}
If an error message was generated by any request performed by the get_all function, the returned value is the
error message generated by the failed request. If no error messages were generated, the array of entities is
returned:
if(isset($message)) {
return $message;
}
else {
return $entities;
}
}
Organization Lookup
The input forms used in this example include a field for customer name. The lookup_organization function is
designed to return the URI for a customer's organization record using the name of a customer.
l On success, the URI of the organization record for the specified customer.
l On failure, boolean FALSE.
The lookup_organization function constructs a request to the /organization resource index using the customer
name as a search parameter. The customer name is URL encoded to handle names that include spaces:
Creating Entities
The create_entity function is designed to create an entity using the resource index URI for that entity and an array
of field/value pairs for the entity.
l The first array value (array index 0) is a boolean that indicates whether the entity was created successfully.
l The second array value (array index 1) is a string. On success, the string is the URI of the created entity. On
failure, the string is an error message.
The create_entity function uses the perform_request function to create the entity. The perform_request
function handles the conversion of the PHP array to JSON format and the options required to perform a
POST request:
If the request was successful (the HTTP status code is 201), the function returns TRUE at array index 0 and the
contents of the "Location" header at array index 1, which contains the relative URI of the created element:
if($response['http_code'] == 201) {
return array(TRUE, $response['headers']['Location']);
}
else {
$error_message = "Could not create " . substr($entity_uri, 1) . ". ";
if(array_key_exists("error", $response)) {
$error_message .= $response['error'];
}
return array(FALSE, $error_message);
}
}
Deleting Entities
The multi_delete function is designed to delete multiple entities.
The multi_delete function initializes $bad_entities as an array. The $bad_entities array is used to track entities
that could not be deleted:
If the input is valid ($entities is an array), the multi_delete function iterates through each element in the array.
For each element, if the element is an array that contains the key "URI", the function performs a delete request
using the value that corresponds to the key "URI". If the element was not an array, did not contain the key "URI", or
the delete request fails, the element is added to the $bad_entities array:
if(is_array($entities)) {
foreach($entities as $entity) {
if(is_array($entity) AND array_key_exists('URI', $entity)) {
$response = perform_request($base_uri, $entity['URI'], "DELETE");
if($response['http_code'] >= 400) {
$bad_entities[] = $entity;
}
}
else {
$bad_entities[] = $entity;
}
}
if(count($bad_entities) == 0) {
return NULL;
}
If one or more elements in the $entities array could not be deleted, an error message is constructed by
concatenating the contents of each element in $entities that could not be deleted. Instead of determining the
data type of each element, the print_r function is used to output the human-readable string for the element:
else {
$error_message = "Could not delete: ";
foreach($bad_entities as $entity) {
$error_message .= print_r($entity, TRUE) . ". ";
}
return $error_message;
}
}
else {
return "Must pass an array of entities";
}
}
The configure_credentials function returns an array of credential URIs on success or an error message on
failure.
The configure_credentials function uses the array_walk PHP function when the list of community strings is
parsed. The array_walk function takes the name of a function as a parameter and applies that function to each
value in the array. In our example code, the array_walk applies the trim_value function to each value in the
array. The trim_value function is included in the utils.php file and removes leading and trailing whitespace from
each value passed in the parameter:
function trim_value(&$value) {
$value = trim($value);
}
All credentials created by the configure_credentials function are named "customer: community string". The
configure_credentials function performs a request for all credentials associated with the specified customer by
searching for credential names that include the string $customer:
$resource = "/api/credential/snmp?limit=1000&snmp_version=2&hide_
filterinfo=1&filter.cred_name.contains=" . rawurlencode($customer);
$existing_credentials = perform_request($base_uri, $resource, "GET");
If the request for existing credentials is successful, the response is processed using the following arrays:
l $existing_credentials. The response to the request for all credentials currently associated with the
organization specified in $customer.
l $community_array. The array of community strings passed in the $community_strings parameter.
l $existing_communities. Initialized to an empty array. As the function iterates through $existing_
credentials, the community string for each existing credential that matches a community string that was
passed in the $community_strings parameter is added to this array.
l $credentials. Initialized to an empty array. If a community string for an existing credential matches a
community string that was passed in the $community_strings parameter, the URI for that credential is
added to this array.
if($existing_credentials['http_code'] == 200) {
$credentials = array();
$existing_communities = array();
The configure_credenetials function iterates through the existing credentials for the organization in the
$existing_credentials array. The community string is parsed from the name of the existing credential based on
the standard naming scheme. If the community string matches a value in $community_array, the community
string is added to the $existing_communities array and the URI is added to the $credentials array:
$error_message = "";
$diff = array_diff($community_array, $existing_communities);
If $diff is empty, i.e. no additional credentials need to be created, processing is complete. If new credentials need
to be created, the variable $organization is initialized to the URI of the organization record associated with
$customer:
if(count($diff) > 0) {
$organization = lookup_organization($base_uri, $customer);
If the organization URI is returned by the lookup_organization function, the configure_credentials function
iterates through the community strings in $diff. For each community string, the credential name is constructed
using the customer name and the community string:
The variable $cred_post_array is initialized to an array that represents the content that will be used to create the
credential. When the credential is created, the create_entity function encodes this array in JSON format. The
array includes the following field/value pairs that are applicable to /credential/snmp resources:
(
['cred_name'] => The name of the credential.
['cred_host'] => The hostname associated with the credential. Always set to an
empty string.
['cred_port'] => The port associated with the credential. Always set to the
standard SNMP port, 161.
['cred_timeout'] => The timeout for the credential. Always set to a default
timeout of 1500ms.
['all_orgs'] => This setting specifies whether the credential is visible to all
organizations (1) or is restricted to specific organizations (0). All credentials
created by the provisioning system are aligned only with the specific organization
for which they are created, so this value is always set to 0.
['snmp_version'] => The SNMP version. For simplicity, this example creates only
SNMP v2 credentials.
['snmp_ro_community'] =>The SNMP community string.
['aligned_organizations'] => A list of organizations to which the credential is
visible. A list element in JSON is represented as an array in the equivalent PHP
structure.
)
The create_entity function returns an array of two values. Index 0 in the returned array is a boolean that
indicates whether the entity was created successfully. Index 1 in the returned array is the URI of the created entity
on success or an error message on failure. If the credential was created successfully, the URI of the new credential
is added to the $credentials array. If the credential was not created, the error message from the create_entity
function is appended to $error_message:
if($cred_response[0]) {
$credentials[] = $cred_response[1];
}
else {
$error_message .= $cred_response[1];
}
}
}
If no organization URI was returned by the lookup_organization function, an error message is appended to
$error_message:
else {
$error_message .= "Could not find organization record for customer: " .
$customer . ". ";
}
}
}
If the request for existing credentials is not successful, an the $error_message variable is set to an error message
that includes the error message constructed by the perform_request function, if available:
else {
$error_message = "Could not get list of existing credentials. ";
if(array_key_exists("error", $existing_credentials)) {
$error_message .= $existing_credentials['error'] . ". ";
}
}
if(strlen($error_message) == 0) {
return $credentials;
}
else {
return $error_message;
}
}
(
['status'] => An integer that specifies the result of the get_discovery_result
function:
0 = The specified discovery session has completed and get_discovery_
result was able to return a list of devices discovered by the
discovery session.
1 = The specified discovery session is currently running and get_
discovery_result was able to return a list of devices discovered by
the discovery session.
2 = The specified discovery session has never been run.
3 = An error occurred in a request made by the get_discovery_result
function.
l $new_only. If TRUE is passed in this parameter, the list of devices returned by the function will include only
newly discovered devices from the discovery session. By default, the function returns all discovered devices,
both new and existing, from the discovery session.
do {
$response = perform_request($base_uri, $log_uri . $offset, "GET");
If the request for logs in this iteration of the do-while loop successfully returns logs, the returned logs are added to
the $discovery_logs array:
If the request for logs is successful but does not return any logs, the function must determine whether the discovery
session was never started or if the discovery session is running but has not yet generated any logs. To do this, the
URI of the discovery session is manipulated to determine the equivalent /api/discovery_session_active URI:
The function performs a GET request on the /discovery_session_active URI for the specified discovery session. If
the response includes an HTTP status code of 200, the discovery session is currently running. The output array
($result) is initialized with a status of 1 (running) with an empty array of devices:
if($active_check['http_code'] == 200) {
$result = array("status" => 1, "devices" => array());
}
If the response includes an HTTP status code of 303 (See Other), the discovery session exists but is not currently
running. The output array ($result) is initialized with a status of 2 (never run) and an appropriate error message:
elseif($active_check['http_code'] == 303) {
If the response includes an HTTP status code other than 200 or 303, an error occurred with the request. The
output array ($result) is initialized with a status of 3 (error) and an appropriate error message:
else {
$result = array("status" => 3, "error" => "Could not determine status of
discovery session. ");
if(array_key_exists("error", $active_check)) {
$result['error'] .= $active_check['error'];
}
}
}
If the request for discovery session logs fails (HTTP status code is not 200), the output array ($result) is initialized
with a status of 3 (error) and an appropriate error message:
else {
$result = array("status" => 3, "error" => "Could not get discovery session
logs ");
if(array_key_exists("error", $response)) {
$result['error'] .= $response['error'];
}
}
The offset is increased for the next iteration for the do-while loop. The loop continues if the output array ($result)
has not been initialized, i.e. the request for logs was successful and returned one or more logs, and if more logs
are available. The "total_matched" value from the previous response indicates the total number of logs that can
be returned; more logs are available if the current offset value is lower than "total_matched"":
If the output array ($result) has not been initialized, all requests performed in the do-while loop were successful
and one or more logs were returned. In this case, the status returned by the get_discovery_result function will be
either 0 (logs were successfully returned and the discovery session is complete) or 1 (logs were successfully
returned and the discovery session is still running). The function iterates through the array of returned log
messages:
if(!isset($result)) {
$result = array("devices" => array());
foreach($discovery_logs as $log) {
l 125. Associated with the log message that indicates the discovery session is complete.
l 500. Associated with the log message that is generated when an existing device is found by the discovery
session.
l 501. Associated with the log message that is generated when a new device is found by the discovery
session.
The "msg_id" field is used in a switch statement, which includes cases for the three values:
switch($log['msg_id']) {
If the log message indicates the discovery session is complete, the status key in the output array is set to 0:
case 125:
$result['status'] = 0;
break;
If the log message indicates an existing device is found and the $new_only parameter is set to FALSE, the device
is added to the device array:
case 500:
if(!$new_only) {
$result['devices'][] = array("ip" => $log['ip'], "name" => $log
['name'], "uri" => $log['device'], "new" => FALSE);
}
break;
case 501:
$result['devices'][] = array("ip" => $log['ip'], "name" => $log['name'],
"uri" => $log['device'], "new" => TRUE);
break;
}
}
if(!array_key_exists("status", $result)) {
$result['status'] = 1;
}
}
return $result;
}
l The first array value (array index 0) is a boolean that indicates whether an appropriate appliance resource
was found.
l The second array value (array index 1) is a string. On success, the string is the URI of an appropriate
appliance. On failure, the string is an error message.
For systems that include All-In-One Appliances, the function returns the URI of the currently active All-In-One
Appliance. For distributed systems, the function returns the URI of a Data Collector in a collector group.
An initial request is made on the /appliance resource index. The request includes filter criteria that specifies that
only All-In-One Appliances (type = "ao") that are currently active (ha_status = 1) should be returned:
$resource = "/api/appliance?limit=100&filter.type=ao&filter.ha_status=1&hide_
filterinfo=1";
$response = perform_request($base_uri, $resource, "GET");
If the response includes at least one appliance, the URI of that appliance is returned:
If the initial request is successful, but does not return any appliances, a request is made for all collector groups in
the system using the extended fetch option:
else {
$resource = "/api/collector_group?limit=100&hide_filterinfo=1&extended_fetch=1";
$response = perform_request($base_uri, $resource, "GET");
If the request for collector groups is successful and at least one collector group is returned, the function iterates
through the array of returned collector groups. For each collector group, the function checks the data_collectors
field. If a collector group includes at least one Data Collector, the URI of the first Data Collector in that collector
group is returned:
If the request for collector groups is not successful (the HTTP Status Code in the response is not 200), an
appropriate error message is returned. If an error message was returned by the perform_request function, it is
included in the error message:
elseif($response['http_code'] != 200) {
$error_message = "Request for list of collector groups failed. ";
if(array_key_exists("error", $response)) {
$error_message .= $response['error'];
}
return array(FALSE, $error_message);
}
If the request for collector groups is successful but does not return any collector groups, an appropriate error
message is returned:
else {
return array(FALSE, "No collector groups configured on system.");
}
}
}
The field used in the filter clause must be passed in the $right_join_field parameter. In this case, $right_
join_field is "class_type".
The get_join_resources function returns an array of entities on success or an error message on failure. If no
referenced entities are found, the returned array is empty.
The get_join_resources function initializes $in as an array. The $in array is used to track the ID values of the
entities that must be requested:
l $join_uri. Initialized to an array that contains each section of the URI (delimited by the "/" character) as an
element. The specific resource ID is removed from the end of the array using the array_pop function;
therefore, when the foreach loop completes, $join_uri is an array that contains each section of the URI for
the resource index of the referenced entity.
For example, if the URI of the referenced entity is /credential/snmp/1, the$join_uri array looks like this
when the foreach loop completes:
(
[0] => "credential"
[1] => "snmp"
)
l $in. An element in this array is set to the ID value of the referenced entity.
foreach($entity_list as $entity) {
if(array_key_exists($left_join_field, $entity)) {
$join_uri = explode("/", $entity[$left_join_field]);
$in[] = array_pop($join_uri);
}
}
If at least one entity ID exists in the $in array, the get_join_resources function constructs a URI for the resource
index of the referenced entities using:
l The $join_uri array, which contains the base resource index URI.
l The value in $right_join_field, which is the field in the referenced entity that contains the ID values for that
entity.
l The $in array, which contains the ID values of each referenced entity from the list of entities that was passed
in the $entity_list array.
if(count($in) > 0) {
$uri = implode("/", $join_uri) . "?extended_fetch=1&filter." . $right_join_field
. ".in=" . implode(",", $in);
$join_list = get_all($base_uri, $uri);
The get_all function returns an array or entities on success and an error message on failure. Because the get_all
function returns the same values as the get_join_resourcesfunction, the result of the get_all function can be
returned without additional processing:
return $join_list;
}
else {
return array();
}
}
User Interface
The example provisioning system comprises the following front-end files to display the user interface:
l index.php. Provides a user interface for provisioning a new customer and discovering additional devices for
an existing customer.
l devices.php. Provides a user interface for configuring customer devices that have been discovered in SL1.
l remove.php. Provides a user interface for removing a customer from SL1.
l header.php. Includes the common elements used by all three user interface pages.
l provisioning.css. Includes style information for the user interface pages. In this example, minimal style is
applied to the user interface pages. You can customize the user interface pages by adding style information
to this file.
header.php
The header.php file is required in all user interface PHP files. The header.php file outputs links to each user
interface page, includes utils.php, and outputs messages from the back-end PHP files:
if(isset($_SESSION['message'])) {
echo "<p>" . $_SESSION['message'] . "</p>";
unset($_SESSION['message']);
}
else {
echo "<p> </p>";
}
?>
<html>
<head>
<title>Provision Customer</title>
<link href="provisioning.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
require_once 'header.php';
?>
<form action="provision_customer.php" method="post">
Customer Name:<br />
<input type="text" name="customer" /><br />
Device IP List (Comma-separated):<br />
<input type="text" name="ip_addresses" /><br />
SNMP v2 Community Strings:<br />
<input type="text" name="community_strings" /><br />
<input type="checkbox" name="non_snmp" value="yes" /> Discover Non-SNMP
Devices<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
When you enter customer information and select the [Submit] button, the provision_customer.php script
performs the required tasks for provisioning that customer.
When you enter a customer name and select the [Show Devices] button, the configure_devices.php script
returns a list of devices that are then displayed in the devices.php page. For each device in the list of devices, the
devices.php page displays a drop-down list of all device templates in the Service Level column. The last device
template that was applied to the device is selected by default:
<html>
<head>
<title>Configure Devices</title>
<link href="provisioning.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
require_once 'header.php';
if(isset($_SESSION['customer'])) {
$customer = $_SESSION['customer'];
unset($_SESSION['customer']);
}
else {
$customer = "";
}
if(isset($_SESSION['dev_type'])) {
$dev_type = $_SESSION['dev_type'];
unset($_SESSION['dev_type']);
}
else {
$dev_type = "";
}
?>
<p>Devices To Configure:</p>
<form action="configure_devices.php" method="post">
Customer Name:
<input type="text" name="customer" value="<?php echo $customer; ?>" /><br />
<input type="radio" name="dev_type" value="new_disc" <?php if($dev_type == "new_
disc") echo checked; ?> /> New Devices from last Discovery<br />
<input type="radio" name="dev_type" value="all_disc" <?php if($dev_type == "all_
disc") echo checked; ?> /> All Devices from last Discovery<br />
<input type="radio" name="dev_type" value="all_org" <?php if($dev_type == "all_
org") echo checked; ?> /> All Devices in Organization<br />
<input type="submit" value="Show Devices" />
If the configure_devices.php script sets session variables for an array of one or more devices, an array of device
classes, and an array of device templates, the devices.php page displays a table of devices:
<?php
if(isset($_SESSION['dev_list']) AND isset($_SESSION['class_list']) AND count
($_SESSION['dev_list']) > 0 AND isset($_SESSION['templates'])) {
$templates = $_SESSION['templates'];
The variable $table is used to build the HTML that will display the table of devices. A foreach loop iterates
through each device in the array of devices:
The Device Name and Device IP columns are populated using the appropriate values from the $device array.
The Device Type column is populated using values from the array of device classes ($_SESSION['class_list']).
The keys in the array of device classes are the device class URIs; the field from the device resource that references
the associated device class (class_type) is used to look up the device class for this device. The class and
description fields from the device class are combined to populate the Device Type column:
$table .= "<tr>";
$table .= "<td>" . $device['name'] . "</td>";
$table .= "<td>" . $device['ip'] . "</td>";
$table .= "<td>" . $_SESSION['class_list'][$device['class_type']]
['class'] . " " . $_SESSION['class_list'][$device['class_type']]
['description'] . "</td>";
The drop-down list in the Service Level column is constructed using the array of device templates ($templates).
The name of the drop-down list (which will appear as a key in the $_POST array) is set to the URI of the current
device (the current array key from $_SESSION['dev_list']):
A drop-down list option is added for each device template. The last template that was applied to the device
($service_level) is selected as the default option. If the last template that was applied to the device is selected
when the form is submitted, the value of the drop-down list is set to NULL so that it can be skipped by the
configure_devices.php script:
foreach($templates as $template) {
if($service_level == $template['URI']) {
$table .= "<option value=NULL selected=\"selected\">" . $template
['description'] . "</option>";
}
For all other device templates, the value of the drop-down list is set to the URI of the device template:
else {
$table .= "<option value=\"" . $template['URI'] . "\">" . $template
['description'] . "</option>";
}
The HTML for the table is completed and outputted. To prevent an error in the next execution of configure_
devices.php from producing erroneous results in this page, the session variables that contain the array of
devices, the array of device classes, and the array of device templates are unset:
elseif(isset($_SESSION['dev_list'])) {
echo "<p>No Devices Discovered</p>";
unset($_SESSION['dev_list']);
unset($_SESSION['class_list']);
}
?>
</form>
</body>
</html>
remove.php
The remove.php file provides a user interface for removing a customer from the system:
<html>
<head>
<title>Remove Customer</title>
<link href="provisioning.css" rel="stylesheet" type="text/css">
When you enter a customer name and select the [Submit] button, the delete_customer.php script deletes all
devices, credentials, and discovery sessions associated with that customer's organization record; deletes the
organization record; and then returns a status message to remove.php.
provisioning.css
The provisioning.css file includes style information for the user interface pages. In this example, minimal style is
applied to the user interface pages. You can customize the user interface pages by adding style information to
this file:
l If an organization record does not currently exist for the customer, creates an organization record for the
customer.
l Ensures that SNMP credentials are configured for each supplied SNMP community string.
l Creates a discovery session for the customer using the configured SNMP credentials and the supplied list of
IP addresses.
l Runs the discovery session.
If all of these tasks are successful, the script redirects to configure_devices.php. configure_devices.phpwill
return a list of discovered devices to the devices.php page. If a provisioning task is unsuccessful, provision_
customer.php returns an error message to index.php.
The provision_customer.php script starts by initializing the session, requiring utils.php, and initializing $base_
uri to the URL of an Administration Portal, Database Server, or All-In-One Appliance:
<?php
session_start();
require_once 'utils.php';
$base_uri = get_admin_uri();
The provision_customer.php script validates the input to ensure that a customer name, IP address list, and either
a community string list or the discover Non-SNMP flag were supplied:
The provision_customer.php script attempts to lookup the URI of the organization record associated with the
customer name supplied in the input form. If no organization record is found, the script creates a new
organization record using the create_entity function. The array of fields for the new organization record includes
only the name of the organization:
If the request to create an organization record is successful (the create_entity function returns TRUE at array
index 0), the $organization variable is set to the URI of the organization:
if($org_response[0]) {
$organization = $org_response[1];
}
If the request to create an organization fails, the $message variable is set to an appropriate error message:
else {
$message = "Failed to create org: " . $org_response[1];
}
}
else {
$uri = "/api/discovery_session?limit=10&hide_
filterinfo=1&filter.organization=" . array_pop(explode("/", $organization));
$response = perform_request($base_uri, $uri, "GET");
If the request for a list of discovery sessions is successful, the multi_delete function is called to delete the
discovery sessions in the response. The multi_delete function returns NULL if all the supplied entities are deleted
or an error message if one or more supplied entities are not deleted. If the request for the list of discovery sessions
fails or if multi_delete did not return null, the $message variable is set to an appropriate error message:
if($response['http_code'] == 200) {
$error = multi_delete($base_uri, $response['content']);
}
else {
$error = "Could not clean up existing discovery sessions for
organization.";
}
if(!is_null($error)) {
$message = $error;
}
}
If no error message has been set in the $message variable, the provision_customer.php script continues with
the provisioning process:
if(!isset($message)) {
If a list of community strings was supplied in the input form, the configure_credentials function is used to get an
array of credential URIs for those community strings:
If a list of community strings was not supplied in the input form, i.e. the discovery session will be configured to
discover only non-SNMP devices, the $credentials variable is initialized as an empty array:
else {
$credentials = array();
If the $credentials variable is an array, i.e. no error message was returned by the configure_credentials
function or the discovery session will be configured to discover only non-SNMP devices, the script explodes the
supplied list of IP addresses in to an array:
if(is_array($credentials)) {
$ip_array = explode(",", $_POST['ip_addresses']);
To create a discovery session using the API, the JSON content must include a list of IP address ranges. Each IP
address range must specify a start address and an end address. In PHP array format, the array that contains the
discovery session fields must include an "ip_lists" key that points to an array that has the following structure:
(
[0] => array (
['start_ip'] =>
['end_ip'] =>
)
.
.
.
[N] => array (
['start_ip'] =>
['end_ip'] =>
)
)
The script initializes the variable $ip_lists, which will contain this structure. For each IP address in the array of
IP addresses supplied in the input form, an element is added to $ip_lists. Each IP address is used as both the start
and end address for each IP address "range":
$ip_lists = array();
foreach($ip_array as $address) {
$ip_lists[] = array('start_ip' => $address, 'end_ip' => $address);
}
The script then uses the get_collector_id function to get the URI of an appliance on which the discovery session
can run:
$collector = get_collector_id($base_uri);
The get_collector_id returns an array. The boolean value at array index 0 indicates whether an appliance URI
was successfully returned. The value at array index 1 is either an appliance URI or an error message. If an
appliance URI was returned, a discovery session is created using the following field values:
if($collector[0]) {
$disc_post_array = array('organization' => $organization,
'aligned_collector' => $collector[1],
'aligned_device_template' => get_base_template(),
'initial_scan_level' => 0,
'ip_lists' => $ip_lists,
'credentials' => $credentials);
The create_entity function returns an array. The boolean value at array index 0 indicates whether the entity was
successfully created. The value at array index 1 is either the entity URI or an error message. If the discovery
session was created successfully, the discovery session is started by applying the URI of the discovery session to
the /discovery_session_active resource index:
if($disc_response[0]) {
$run_discovery = perform_request($base_uri, "/api/discovery_session_
active", "APPLY", $disc_response[1]);
If the response from the request to start the discovery session includes HTTP status code 202, the discovery
session started correctly. If the discovery session starts correctly, the script redirects to the configure_devices.php
script. The configure_devices.php script requires the customer name as input, either in the $_POST or $_
SESSION array. In this case, the customer name is set as a session variable:
if($run_discovery['http_code'] == 202) {
$_SESSION['customer'] = $_POST['customer'];
header("Location: configure_devices.php");
}
If the request to start the discovery session failed, i.e. the HTTP status code in the response is not 202, the
$message variable is set to an appropriate error message:
else {
$message = "Failed to run discovery session: " . $run_discovery
['http_code'];
}
}
else {
$message = "Failed to create discovery session: " . $disc_response[1];
}
}
If an error was returned by the get_collector_id function, the $message variable is set to an appropriate error
message:
else {
$message = $collector[1];
}
}
If $credentials is not an array, i.e. the configure_credentials function returned an error message, the
$message variable is set to an appropriate error message:
else {
$message = "Failed to configure credentials: " . $credentials;
}
}
}
If the values supplied in the input form fail validation, the $message variable is set to an appropriate error
message:
else {
$message = "Form Incomplete";
}
If the $message variable is set, a failure occurred in the provision_customer.php script. The error is set in a
session variable and the script redirects back to index.php:
if(isset($message)) {
$_SESSION['message'] = $message;
header("Location: index.php");
}
?>
Additionally, if a user selects the [Configure Devices] button in the devices.php page, the configure_
devices.php script applies the device templates selected by the user to the specified devices.
l Use PHP session variables to return values to the user interface files.
l Use the functions defined in the utils.php file.
l Use the URL of an Administration Portal, Database Server, or All-In-One Appliance.
The script starts by initializing the session, requiring utils.php, and initializing $base_uri to the URL of an
Administration Portal, Database Server, or All-In-One Appliance:
<?php
session_start();
require_once 'utils.php';
$base_uri = get_admin_uri();
For each displayed device, the devices.php page displays a drop-down list that contains all device templates in
the system. To populate the drop-down list, the devices.php page must be supplied a list of device templates. An
array of all device templates is set as a session variable. Because the list of device templates is assumed to be
static, the array of device templates is set only once per session and is never explicitly unset by the provisioning
code. The code that creates the array of device templates is located in configure_devices.php because the script
is always run before devices are displayed in devices.php.
If the templates variable is not currently set in the session variables, the script gets a list of all device templates
using the get_all function. The get_all function returns an array of entities on success, or an error message on
failure. If the return value is an array, that array is set as a session variable. If the return value is not an array, the
$message variable is assigned the returned error message:
if(!isset($_SESSION['templates'])) {
$templates = get_all($base_uri, "/api/device_template?link_disp_field=template_
name");
if(is_array($templates)) {
$_SESSION['templates'] = $templates;
}
else {
$message = $templates;
}
}
If an organization URI is found for the supplied customer name, an error message has not been set, and the user
selected the [Configure Devices] button ("config" is a key in the post data), the block of code that applies device
templates to devices is executed:
The variable $dev_type is initialized with the value from the radio buttons on the devices.php page. Later in the
execution of the configure_devices.php script, $dev_type is used to set a session variable that the devices.php
page uses as the default value of the radio buttons:
if(isset($_POST['dev_type'])) {
$dev_type = $_POST['dev_type'];
}
The script iterates through all values supplied by the input form. The variable $devices_updated is initialized to
track the number of devices to which device templates are applied. The variable $in is initialized as an array,
which will be used to track the device ID values for all devices that were previously displayed on devices.php. The
$in array will be used to return the same list of devices to devices.php:
$in = array();
$devices_updated = 0;
foreach($_POST as $device => $template) {
The $_POST array includes all values supplied by the input form. This block of code must operate only on the
values from the drop-down list for each device. Each drop-down list is named using the URI of the associated
device; therefore, it is assumed that if a key in the $_POST array begins with a slash character ("/"), the array
element represents a drop-down list:
The device ID of all devices that were displayed on devices.php is added to the $in array:
if($template != "NULL") {
To apply a device template to a device, the script uses the perform_request function with a $type parameter of
"APPLY":
If the request to apply a device template to a device is successful (the response includes a HTTP status code of
200), the script must update the device resource with the new value for the c-last_dev_tpl field. To do this, the
device resource is requested:
if($apply_template['http_code'] == 200) {
$dev = perform_request($base_uri, $device, "GET");
If the request for the device resource is successful, the new value of "c-last_dev_tpl" field is set in the array of
attributes for that device and the array of attributes is POSTed back to the same device resource:
if($dev['http_code'] == 200) {
$dev['content']['c-last_dev_tpl'] = $template;
If the request to update a device resource fails, the variable $message is initialized with an error message:
if($update_device['http_code'] != 200) {
$message = "Could not update template status of " . $device . ".
";
if(array_key_exists("error", $update_device)) {
$message .= $update_device['error'];
}
}
If the request to update a device resource is successful, the number of devices that have been updated is
incremented:
else {
$devices_updated++;
}
}
else {
$message = "Could not get information to update template status of "
. $device . ". ";
if(array_key_exists("error", $udev)) {
$message .= $dev['error'];
}
}
}
If the request to apply a device template to a device fails, the variable $message is initialized with an error
message:
else {
$message = "Could not apply " . $template . " to " . $device . ". ";
if(array_key_exists("error", $apply_template)) {
$message .= $apply_template['error'];
}
}
}
}
}
The $in array, which includes the device IDs of all devices that were previously displayed in devices.php, is used
to re-request the list of devices:
If the request for the list of devices is successful, the script requests a list of device classes for those devices:
if(is_array($device_list)) {
$class_list = get_join_resources($base_uri, $device_list, "class_type",
"class_type");
If the request for a list of device classes is successful, the array of devices and the array of device classes are
passed back to devices.php in session variables:
if(is_array($class_list)) {
$_SESSION['class_list'] = $class_list;
$_SESSION['dev_list'] = $device_list;
}
If the request for the list of device classes fails, the variable $message is initialized with the error message
returned by the get_join_resources function:
else {
$message = $class_list;
}
}
else {
$message = $device_list;
}
If the $message variable has not yet been initialized, all requests were successful and the $message variable is
initialized with a success message:
if(!isset($message)) {
$message = $devices_updated . " Device(s) Updated.";
}
}
If the block of code that configures devices is not executed, but an organization URI has been found for the
customer and an error message has not been set, the block of code that returns a list of devices is executed:
The variable $org_id is initialized with the ID of the organization for which a list of devices has been requested:
If a value has been supplied from the radio buttons on the devcies.php page, the variable $dev_type is
initialized with that value. If no value has been supplied, e.g. the script was called by provision_customer.php,
the script defaults to returning a list of new devices from the last discovery session:
if(isset($_POST['dev_type'])) {
$dev_type = $_POST['dev_type'];
}
else {
$dev_type = "new_disc";
}
The following block of code returns a list of all devices associated with the specified organization:
if($dev_type == "all_org") {
The organization ID is used as the filter criteria to request a list of devices. The get_all function will return an array
of all devices that match the filter criteria:
if(is_array($device_list)) {
$class_list = get_join_resources($base_uri, $device_list, "class_type",
"class_type");
If the request for a list of device classes is successful, the array of devices and the array of device classes are
passed back to devices.php in session variables:
if(is_array($class_list)) {
$_SESSION['class_list'] = $class_list;
$_SESSION['dev_list'] = $device_list;
}
If the request for the list of device classes fails, the variable $message is initialized with the error message
returned by the get_join_resources function:
else {
$message = $class_list;
}
}
If the request for the list of devices fails, the variable $message is initialized with the error message returned by
the get_all function:
else {
$message = $device_list;
}
}
If the block of code that returns a list of all devices associated with the specified organization is not executed, the
script executes a block of code that returns a list of devices from the last discovery session:
else {
The organization ID is used as the filter criteria to request the discovery session for the customer:
The status code of the get_discovery_result is used in a switch statement that performs the required actions of
each possible result:
switch($device_list['status']) {
A status code of 1 indicates that a list of devices has been returned, but the discovery session is still running. If the
discovery session is still running, the $message variable is initialized to an appropriate status message. The
required actions for a status code of 0 must also be performed if the status code is 1, so no break statement is
included for case 1:
case 1:
$message = "Note: Discovery Session is not complete, additional devices
might be discovered.";
A status code of 0 indicates that a list of devices has been returned and the discovery session is complete. If the
array of devices is not empty, the $in variable is initialized as an array that will be used to track the device IDs of
all devices in the array of devices:
case 0:
if(count($device_list['devices']) > 0) {
$in = array();
The script iterates through the array of devices. For each device, the device ID is derived from the device URI and
is added to the $in array:
foreach($device_list['devices'] as $device) {
$in[] = array_pop(explode("/", $device['uri']));
}
A URI to request all devices is constructed using the device IDs in the $in array. The get_all function is used to
request all the devices:
if(is_array($device_list)) {
$class_list = get_join_resources($base_uri, $device_list, "class_
type", "class_type");
If the request for a list of device classes is successful, the array of devices and the array of device classes are
passed back to devices.php in session variables:
if(is_array($class_list)) {
$_SESSION['class_list'] = $class_list;
$_SESSION['dev_list'] = $device_list;
}
If the request for the list of device classes fails, the variable $message is initialized with the error message
returned by the get_join_resources function:
else {
$message = $class_list;
}
}
If the request for the list of devices fails, the variable $message is initialized with the error message returned by
the get_all function:
else {
$message = $device_list;
}
}
If the get_discovery_result function returned an empty array of devices, an empty array of devices is passed to
devices.php in a session variable:
else {
$_SESSION['dev_list'] = array();
}
break;
If the get_discovery_result returns status 2 (discovery session has never been run), status 3 (error), or a status
other than 0, 1, 2, or 3, script sets the $message variable to an appropriate error message:
case 2:
$message = $device_list['error'];
break;
case 3:
$message = $device_list['error'];
break;
default:
$message = "Error occurred retrieving discovery logs.";
}
}
elseif($discovery_search['http_code'] == 200) {
$message = "No discovery session exists for customer.";
}
If the request for a discovery session returned an HTTP status code other than 200, the script sets the $message
variable to an appropriate error message:
else {
$message = "Error finding discovery session for customer. ";
if(array_key_exists("error", $discovery_search)) {
$message .= $discovery_search['error'];
}
}
}
}
If no organization URI was found for the supplied customer name, the script sets the $message variable to an
appropriate error message:
elseif(!isset($message)){
$message = "Could not find customer record." ;
}
If the $message and/or $dev_type variables have been set during the execution of the script, they are passed to
devices.php using session variables. The script always redirects back to devices.php:
if(isset($message)) {
$_SESSION['message'] = $message;
}
if(isset($dev_type)) {
$_SESSION['dev_type'] = $dev_type;
}
header("Location: devices.php");
?>
The script starts by initializing the session, requiring utils.php, and initializing $base_uri to the URL of an
Administration Portal, Database Server, or All-In-One Appliance:
<?php
session_start();
require_once 'utils.php';
$base_uri = get_admin_uri();
If a customer name was supplied in the input form, the script looks up the URI for the organization record
associated with that customer name. If no organization record is found, the $message variable is set to an error
message:
If an organization record exists for the customer, the ID for that organization record is parsed from the URI:
else {
$org_id = array_pop(explode("/", $organization));
An array of resource index URIs is constructed. The script will iterate through this array and delete all entities
returned by each URI. The organization ID is used as filter criteria in each URI. If a request fails, the array keys are
used to indicate the entity type where the problem occurred. To delete additional entities associated with the
customer organization, for example, asset records, you can add additional URIs to this array:
The script iterates through the array of URIs. For each URI:
if(!is_null($error)) {
break;
}
}
To delete an organization record from SL1, the organization must be "empty", that is, have no entities associated
with it. If no error was generated when the other entities were deleted, the organization is deleted:
if(is_null($error)) {
$response = perform_request($base_uri, $organization, "DELETE");
if($response['http_code'] == 200) {
$message = "Customer removed";
}
If the request to delete the organization failed with a 400 HTTP status code, the organization is not empty and an
error message is set in the $message variable:
elseif($response['http_code'] == 400) {
$message = "Could not delete organization because organization is not
empty.";
}
If the request to delete the organization failed with a different HTTP status code, a generic error message is set in
the $message variable:
else {
$message = "Could not delete organization. ";
if(array_key_exists("error", $response)) {
$message .= $response['error'];
}
}
}
If the $error variable has already been set because deleting an entity other than the organization failed,
$message is set to the value of $error:
else {
$message = $error;
}
}
If no customer name is specified in the input form, an appropriate error message is set in the $message variable:
else {
$message = "Form Incomplete";
}
If the $message variable has been set, its value is returned to remove.php using a session variable:
if(isset($message)) {
$_SESSION['message'] = $message;
}
header("Location: remove.php");
?>
A
Available Actions
Overview
This appendix lists all actions that can be performed through the API, organized by ScienceLogic entity. Each
table includes the HTTP method and URI you should use to perform the action. The URIs in this list include "X",
which signifies where the ID number of a specific entity must be inserted.
Accounts 203
Account Lockouts 203
Alerts 204
Appliances 204
Assets 204
CBQoS Metrics 206
CBQoS Objects 207
CBQoS Object Types 207
Cleared Events 207
Collection Labels 207
Collection Label Groups 208
Collector Groups 208
Credentials 209
Custom Attributes 210
Dashboards 212
Devices 213
201
Device Categories 216
Device Classes 216
Device Groups 217
Device Relationships 217
Device Relationship Types 217
Device Templates 218
Discovery Sessions 220
Dynamic Applications 221
Events 235
Event Categories 235
External Contacts 235
File Uploads 236
Interfaces 236
Interface Metrics 237
Interface Tags 237
Monitors 237
Organizations 239
Performance Data 241
PowerPacks 242
Product SKUs 243
Scale Values 243
Schedules 243
Streamer Push Proxy 244
System Patches 244
System Settings 245
System Thresholds 245
Tasks 245
Themes 246
Threshold Overrides 246
Tickets 247
Ticket Categories 248
Ticket Chargeback 249
Ticket Logs 249
Ticket Notes 249
202
Ticket Queues 250
Ticket States 250
Unit Values 250
User Policies 251
Vendors 251
Accounts
View the list of access hooks that have been /account/X/access_hooks GET
granted to a user account.
Account Lockouts
Accounts 203
Alerts
Appliances
Assets
204 Alerts
Action URI Method
Assets 205
Action URI Method
CBQoS Metrics
Cleared Events
Collection Labels
Collector Groups
To enable multi-tenancy for collector groups, the database setting "master.system_settings_ core.enable_cug_
orgs" must be set to 1. When multi-tenancy is enabled, an administrative user can update all collector groups
using the new fields. Non-administrative users can update all collector groups for which the "all_orgs" field is set
to 1. Otherwise, these users can only update credentials and collector groups within their aligned organizations.
Be aware that you might encounter a situation where a device is not aligned to a collector group if you do not
properly configure these actions.
Credentials 209
Action URI Method
Custom Attributes
Dashboards
212 Dashboards
Action URI Method
Devices
Devices 213
Action URI Method
214 Devices
Action URI Method
Devices 215
Action URI Method
Device Categories
Device Classes
Device Relationships
Discovery Sessions
Dynamic Applications
Event Categories
External Contacts
Events 235
File Uploads
Interfaces
Interface Tags
Monitors
238 Monitors
Action URI Method
Organizations
Organizations 239
Action URI Method
240 Organizations
Performance Data
PowerPacks
242 PowerPacks
Product SKUs
Scale Values
Schedules
System Patches
Stage a patch file that has been registered /system_patch_stage Post a /system_
in the system. patch resource.
System Thresholds
Tasks
Threshold Overrides
246 Themes
Tickets
Tickets 247
Action URI Method
Ticket Categories
Ticket Logs
Ticket Notes
Ticket States
Unit Values
Vendors
252 Vendors
© 2003 - 2022, ScienceLogic, Inc.
All rights reserved.
LIMITATION OF LIABILITY AND GENERAL DISCLAIMER
ALL INFORMATION AVAILABLE IN THIS GUIDE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESS OR IMPLIED. SCIENCELOGIC™ AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES,
EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.
Although ScienceLogic™ has attempted to provide accurate information on this Site, information on this Site
may contain inadvertent technical inaccuracies or typographical errors, and ScienceLogic™ assumes no
responsibility for the accuracy of the information. Information may be changed or updated without notice.
ScienceLogic™ may also make improvements and / or changes in the products or services described in this
Site at any time without notice.
Other
If any provision of this agreement shall be unlawful, void, or for any reason unenforceable, then that
provision shall be deemed severable from this agreement and shall not affect the validity and enforceability
of any remaining provisions. This is the entire agreement between the parties relating to the matters
contained herein.
In the U.S. and other jurisdictions, trademark owners have a duty to police the use of their marks. Therefore,
if you become aware of any improper use of ScienceLogic Trademarks, including infringement or
counterfeiting by third parties, report them to Science Logic’s legal department immediately. Report as much
detail as possible about the misuse, including the name of the party, contact information, and copies or
photographs of the potential misuse to: [email protected]
800-SCI-LOGIC (1-800-724-5644)
International: +1-703-354-1010