---
title: "Utility Functions"
component: "pytigergraph"
version: "1.8"
module: "core-functions"
html_url: "/pytigergraph/1.8/core-functions/utils"
canonical_url: "https://www.tigergraph.com/docs/pytigergraph/1.8/core-functions/utils"
markdown_url: "https://www.tigergraph.com/docs/pytigergraph/1.8/core-functions/utils.md"
---

[View as HTML](https://www.tigergraph.com/docs/pytigergraph/1.8/core-functions/utils)

# Utility Functions

Utility functions for pyTigerGraph. All functions in this module are called as methods on a [TigerGraphConnection object](https://www.tigergraph.com/docs/pytigergraph/1.8/core-functions/base.md).

## Methods

### echo()

`echo(usePost: bool = False) → str`

Pings the database.

#### Parameter:

* `usePost`: Use POST instead of GET

#### Returns:

"Hello GSQL" if everything was OK.

#### Endpoint:

* `GET /echo`
* `POST /echo`See [Echo](https://www.tigergraph.com/docs/tigergraph-server/4.3/API/built-in-endpoints.md#_echo)

### getLicenseInfo()

`getLicenseInfo() → dict`

Returns the expiration date and remaining days of the license.

#### Returns:

Returns license details. For an evaluation/trial deployment, returns an information message and -1 remaining days.

### ping()

`ping() → dict`

Public health check endpoint.

#### Returns:

Returns a JSON object with a key of "message" and a value of "pong"

### getSystemMetrics()

`getSystemMetrics(from_ts: int = None, to_ts: int = None, latest: int = None, what: str = None, who: str = None, where: str = None)`

Monitor system usage metrics.

#### Parameters:

* `from_ts (int, optional)`: The epoch timestamp that indicates the start of the time filter.
* `to_ts (int, optional)`: The epoch timestamp that indicates the end of the time filter.
* `latest (int, optional)`: Number of datapoints to return. If provided, `from_ts` and `to_ts` will be ignored.
* `what (str, optional)`: Name of the metric to filter for. Possible choices are:  
   * "cpu": Percentage of CPU usage by component  
   * "mem": Memory usage in megabytes by component  
   * "diskspace": Disk usage in megabytes by directory  
   * "network": Network traffic in bytes since the service started  
   * "qps": Number of requests per second by endpoint  
   * "servicestate": The state of the service, either online 1 or offline 0 (Only avaliable in version <4.1)  
   * "connection": Number of open TCP connections (Only avaliable in version <4.1)
* `who (str, optional)`: Name of the component that reported the datapoint. (Only avaliable in version <4.1)
* `where (str, optional)`: Name of the node that reported the datapoint.

#### Returns:

JSON object of datapoints collected. Note: Output format differs between 3.x and 4.x versions of TigerGraph.

#### Endpoints:

* `GET /ts3/api/datapoints` (In TigerGraph versions 3.x) See xref:tigergraph-server:API:built-in-endpoints.adoc#\_monitor\_system\_metrics\_ts3\_deprecated
* `POST /informant/metrics/get/{metrics_category}` (In TigerGraph versions 4.x) See xref:tigergraph-server:API:built-in-endpoints.adoc#\_monitor\_system\_metrics\_by\_category

### getQueryPerformance()

`getQueryPerformance(seconds: int = 10)`

Returns real-time query performance statistics over the given time period, as specified by the seconds parameter.

#### Parameter:

* `seconds (int, optional)`: Seconds are measured up to 60, so the seconds parameter must be a positive integer less than or equal to 60\. Defaults to 10.

### getServiceStatus()

`getServiceStatus(request_body: dict)`

Returns the status of the TigerGraph services specified in the request. Supported on databases versions 3.4 and above.

#### Parameter:

* `request_body (dict)`: Must be formatted as specified here: <https://www.tigergraph.com/docs/tigergraph-server/current/api/built-in-endpoints#%5Fshow%5Fservice%5Fstatus>

### rebuildGraph()

`rebuildGraph(threadnum: int = None, vertextype: str = "", segid: str = "", path: str = "", force: bool = False)`

Rebuilds the graph engine immediately.   
See [this](https://www.tigergraph.com/docs/tigergraph-server/current/api/built-in-endpoints#_rebuild_graph_engine) for more details. for more information.

#### Parameters:

threadnum (int, optional): Number of threads to execute the rebuild. \* `vertextype (str, optional)`: Vertex type to perform the rebuild for. Will perform for all vertex types if not specified. \* `segid (str, optional)`: Segment ID of the segments to rebuild. If not provided, all segments will be rebuilt. In general, it is recommneded not to provide this parameter and rebuild all segments. \* `path (str, optional)`: Path to save the summary of the rebuild to. If not provided, the default path is "/tmp/rebuildnow". \* `force (bool, optional)`: Boolean value that indicates whether to perform rebuilds for segments for which there are no records of new data. Normally, a rebuild would skip such segments, but if force is set true, the segments will not be skipped.

#### Returns:

JSON response with message containing the path to the summary file.
