3650 lines
147 KiB
YAML
3650 lines
147 KiB
YAML
zabbix_export:
|
|
version: '7.0'
|
|
template_groups:
|
|
- uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
|
|
name: Templates/Applications
|
|
templates:
|
|
- uuid: 11144543d1144a3693aa0b97a1c20dac
|
|
template: 'GitHub repository by HTTP'
|
|
name: 'GitHub repository by HTTP'
|
|
description: |
|
|
This template is designed for the effortless deployment of GitHub repository monitoring by Zabbix via GitHub REST API and doesn't require any external scripts.
|
|
|
|
For more details about GitHub REST API, refer to the official documentation:
|
|
https://docs.github.com/en/rest?apiVersion=2022-11-28
|
|
|
|
Setup:
|
|
|
|
1. Create an access token for monitoring
|
|
|
|
One of the simplest ways to send authenticated requests is to use a personal access token - either a classic or a fine-grained one:
|
|
https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api?apiVersion=2022-11-28#authenticating-with-a-personal-access-token
|
|
|
|
Classic personal access token
|
|
|
|
You can create a new classic personal access token by following the instructions in the official documentation:
|
|
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic
|
|
|
|
For public repositories, no additional permission scopes are required. For monitoring to work on private repositories, the "repo" scope must be set to have full control of private repositories.
|
|
|
|
Additional information about OAuth scopes is available in the official documentation:
|
|
https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps#available-scopes
|
|
|
|
Note that authenticated users must have admin access to the repository and the "repo" scope must be set to get information about self-hosted runners:
|
|
https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository
|
|
|
|
Fine-grained personal access token
|
|
|
|
Alternatively, you can use a fine-grained personal access token:
|
|
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token
|
|
|
|
In order to use fine-grained tokens to monitor organization-owned repositories, organizations must opt in to fine-grained personal access tokens and set up a personal access token policy:
|
|
https://docs.github.com/en/organizations/managing-programmatic-access-to-your-organization/setting-a-personal-access-token-policy-for-your-organization
|
|
|
|
The fine-grained token needs to have the following permissions set to provide access to the repository resources:
|
|
- "Actions" repository permissions (read);
|
|
- "Administration" repository permissions (read);
|
|
- "Contents" repository permissions (read);
|
|
- "Issues" repository permissions (read);
|
|
- "Metadata" repository permissions (read);
|
|
- "Pull requests" repository permissions (read).
|
|
|
|
2. Set the access token that you've created in step 1 in the "{$GITHUB.API.TOKEN}" macro
|
|
3. Change the API URL in the "{$GITHUB.API.URL}" macro if needed (for self-hosted installations)
|
|
4. Set the repository owner name in the "{$GITHUB.REPO.OWNER}" macro
|
|
5. Set the repository name in the "{$GITHUB.REPO.NAME}" macro
|
|
6. Set the LLD rule filters if needed (you may want to use it to also stay within rate limits as on large repositories, LLD rules may generate a lot of script items)
|
|
|
|
Note: Update intervals and timeouts for script items can be changed individually via "{$GITHUB.INTERVAL}" and "{$GITHUB.TIMEOUT}" macros with context. Depending on the repository being monitored, it can be adjusted if needed (if you are exceeding rate limits, you can increase update intervals for some script items to stay within per hour request limits). But be aware that it may also affect the triggers (check whether the item is used in triggers and adjust thresholds and/or evaluation periods if needed).
|
|
|
|
Generated by official Zabbix template tool "Templator"
|
|
vendor:
|
|
name: Zabbix
|
|
version: 7.0-2
|
|
groups:
|
|
- name: Templates/Applications
|
|
items:
|
|
- uuid: e348ae4bd2c04b5c88df2f5cb422eb61
|
|
name: 'Get branches'
|
|
type: SCRIPT
|
|
key: github.repo.branches.get
|
|
delay: '{$GITHUB.INTERVAL:"get_branches"}'
|
|
history: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var github = {
|
|
params: {},
|
|
|
|
setParams: function (params, required) {
|
|
required = required || [];
|
|
required.concat(['api_url', 'user_agent', 'api_version', 'repo_owner', 'repo_name', 'pagination_required', 'api_token']).forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined'
|
|
|| params[field] === '') {
|
|
throw 'Required parameter is not set: "' + field + '".';
|
|
}
|
|
});
|
|
|
|
github.params = params;
|
|
|
|
if (typeof github.params.api_url === 'string' && !github.params.api_url.endsWith('/')) {
|
|
github.params.api_url += '/';
|
|
}
|
|
|
|
github.tls = new CTlsConfig(params.tls_verify);
|
|
github.tls.checkURL(github.params.api_url);
|
|
},
|
|
|
|
apiRequest: function (url, pagination_required) {
|
|
const next_pattern = /<([^>]+)>;\s*rel="next"/i;
|
|
var request = new HttpRequest(github.tls.options),
|
|
response,
|
|
headers,
|
|
final_data = {
|
|
headers: {},
|
|
data: []
|
|
};
|
|
|
|
pagination_required = (typeof pagination_required !== 'undefined') ? pagination_required : 'true';
|
|
|
|
request.addHeader('User-Agent: ' + github.params.user_agent);
|
|
request.addHeader('Accept: application/vnd.github+json');
|
|
request.addHeader('X-GitHub-Api-Version: ' + github.params.api_version);
|
|
request.addHeader('Authorization: Bearer ' + github.params.api_token);
|
|
|
|
if (typeof github.params.http_proxy !== 'undefined' && github.params.http_proxy !== '') {
|
|
request.setProxy(github.params.http_proxy);
|
|
Zabbix.log(4, '[ GitHub Repo ] Using HTTP proxy: ' + github.params.http_proxy);
|
|
}
|
|
|
|
while (url) {
|
|
Zabbix.log(4, '[ GitHub Repo ] Sending request: ' + url);
|
|
|
|
response = request.get(url);
|
|
|
|
Zabbix.log(4, '[ GitHub Repo ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from API. Check debug log for more information.';
|
|
}
|
|
|
|
var parsed_data = github.parseData(response);
|
|
final_data.data = final_data.data.concat(parsed_data);
|
|
|
|
headers = request.getHeaders();
|
|
|
|
var link_header = github.getHeader(headers, 'Link');
|
|
url = ((link_header || '').match(next_pattern) || [])[1];
|
|
|
|
if (pagination_required === 'false') {
|
|
url = '';
|
|
}
|
|
}
|
|
|
|
final_data.headers = request.getHeaders();
|
|
|
|
delete request;
|
|
|
|
return final_data;
|
|
},
|
|
|
|
parseData: function (response_data) {
|
|
if (!response_data) {
|
|
return [];
|
|
}
|
|
|
|
const normalization_required = "total_count" in response_data && !("url" in response_data);
|
|
if (!normalization_required) return response_data;
|
|
|
|
delete response_data.incomplete_results;
|
|
delete response_data.repository_selection;
|
|
delete response_data.total_count;
|
|
|
|
const namespaceKey = Object.keys(response_data)[0];
|
|
response_data = response_data[namespaceKey];
|
|
|
|
return response_data;
|
|
},
|
|
|
|
itemsCount: function (response_data) {
|
|
const last_page_number = /<[^>]+page=(\d+)>;\s*rel="last"/i;
|
|
|
|
if (response_data.headers.link){
|
|
return response_data.headers.link.match(last_page_number)[1];
|
|
}
|
|
|
|
return response_data.data.length;
|
|
},
|
|
|
|
getHeader: function (headers, name) {
|
|
if (!headers || typeof headers !== 'object') {
|
|
return null;
|
|
}
|
|
|
|
var target = name.toLowerCase();
|
|
|
|
for (var key in headers) {
|
|
if (key.toLowerCase() === target) {
|
|
return headers[key];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
try {
|
|
github.setParams(JSON.parse(value), ['api_query']);
|
|
|
|
var result = github.apiRequest(github.params.api_url + github.params.api_query + '?' + github.params.query_params || '', github.params.pagination_required);
|
|
|
|
return JSON.stringify(result);
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ GitHub Repo ] ERROR: ' + error);
|
|
return JSON.stringify({ error: error });
|
|
}
|
|
description: |
|
|
Get the repository branches.
|
|
|
|
Information about endpoint:
|
|
https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#list-branches
|
|
preprocessing:
|
|
- type: CHECK_REGEX_ERROR
|
|
parameters:
|
|
- 'API rate limit exceeded'
|
|
- \0
|
|
error_handler: DISCARD_VALUE
|
|
timeout: '{$GITHUB.TIMEOUT:"get_branches"}'
|
|
parameters:
|
|
- name: api_query
|
|
value: 'repos/{$GITHUB.REPO.OWNER}/{$GITHUB.REPO.NAME}/branches'
|
|
- name: api_token
|
|
value: '{$GITHUB.API.TOKEN}'
|
|
- name: api_url
|
|
value: '{$GITHUB.API.URL}'
|
|
- name: api_version
|
|
value: '{$GITHUB.API_VERSION}'
|
|
- name: http_proxy
|
|
value: '{$GITHUB.HTTP_PROXY}'
|
|
- name: pagination_required
|
|
value: 'true'
|
|
- name: query_params
|
|
value: 'per_page={$GITHUB.RESULTS_PER_PAGE:"branches_discovery"}'
|
|
- name: repo_name
|
|
value: '{$GITHUB.REPO.NAME}'
|
|
- name: repo_owner
|
|
value: '{$GITHUB.REPO.OWNER}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GitHub"}'
|
|
- name: user_agent
|
|
value: '{$GITHUB.USER_AGENT}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- uuid: 3b4799f0efc64f91836eb081b66f3e3b
|
|
name: 'Number of closed issues'
|
|
type: DEPENDENT
|
|
key: github.repo.issues.closed
|
|
delay: '0'
|
|
description: 'The number of closed issues in the repository.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.issues.closed
|
|
master_item:
|
|
key: github.repo.issues.get
|
|
tags:
|
|
- tag: component
|
|
value: issues
|
|
- uuid: f88f02dc593844a89eb601e833a1a19c
|
|
name: 'Get issue count'
|
|
type: SCRIPT
|
|
key: github.repo.issues.get
|
|
delay: '{$GITHUB.INTERVAL:"get_issues_count"}'
|
|
history: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var github = {
|
|
params: {},
|
|
|
|
setParams: function (params, required) {
|
|
required = required || [];
|
|
required.concat(['api_url', 'user_agent', 'api_version', 'repo_owner', 'repo_name', 'pagination_required', 'api_token']).forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined'
|
|
|| params[field] === '') {
|
|
throw 'Required parameter is not set: "' + field + '".';
|
|
}
|
|
});
|
|
|
|
github.params = params;
|
|
|
|
if (typeof github.params.api_url === 'string' && !github.params.api_url.endsWith('/')) {
|
|
github.params.api_url += '/';
|
|
}
|
|
|
|
github.tls = new CTlsConfig(params.tls_verify);
|
|
github.tls.checkURL(github.params.api_url);
|
|
},
|
|
|
|
apiRequest: function (url, pagination_required) {
|
|
const next_pattern = /<([^>]+)>;\s*rel="next"/i;
|
|
var request = new HttpRequest(github.tls.options),
|
|
response,
|
|
headers,
|
|
final_data = {
|
|
headers: {},
|
|
data: []
|
|
};
|
|
|
|
pagination_required = (typeof pagination_required !== 'undefined') ? pagination_required : 'true';
|
|
|
|
request.addHeader('User-Agent: ' + github.params.user_agent);
|
|
request.addHeader('Accept: application/vnd.github+json');
|
|
request.addHeader('X-GitHub-Api-Version: ' + github.params.api_version);
|
|
request.addHeader('Authorization: Bearer ' + github.params.api_token);
|
|
|
|
if (typeof github.params.http_proxy !== 'undefined' && github.params.http_proxy !== '') {
|
|
request.setProxy(github.params.http_proxy);
|
|
Zabbix.log(4, '[ GitHub Repo ] Using HTTP proxy: ' + github.params.http_proxy);
|
|
}
|
|
|
|
while (url) {
|
|
Zabbix.log(4, '[ GitHub Repo ] Sending request: ' + url);
|
|
|
|
response = request.get(url);
|
|
|
|
Zabbix.log(4, '[ GitHub Repo ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from API. Check debug log for more information.';
|
|
}
|
|
|
|
var parsed_data = github.parseData(response);
|
|
final_data.data = final_data.data.concat(parsed_data);
|
|
|
|
headers = request.getHeaders();
|
|
|
|
var link_header = github.getHeader(headers, 'Link');
|
|
url = ((link_header || '').match(next_pattern) || [])[1];
|
|
|
|
if (pagination_required === 'false') {
|
|
url = '';
|
|
}
|
|
}
|
|
|
|
final_data.headers = request.getHeaders();
|
|
|
|
delete request;
|
|
|
|
return final_data;
|
|
},
|
|
|
|
parseData: function (response_data) {
|
|
if (!response_data) {
|
|
return [];
|
|
}
|
|
|
|
const normalization_required = "total_count" in response_data && !("url" in response_data);
|
|
if (!normalization_required) return response_data;
|
|
|
|
delete response_data.incomplete_results;
|
|
delete response_data.repository_selection;
|
|
delete response_data.total_count;
|
|
|
|
const namespaceKey = Object.keys(response_data)[0];
|
|
response_data = response_data[namespaceKey];
|
|
|
|
return response_data;
|
|
},
|
|
|
|
itemsCount: function (response_data) {
|
|
const last_page_number = /<[^>]+page=(\d+)>;\s*rel="last"/i;
|
|
|
|
if (response_data.headers.link){
|
|
return response_data.headers.link.match(last_page_number)[1];
|
|
}
|
|
|
|
return response_data.data.length;
|
|
},
|
|
|
|
getHeader: function (headers, name) {
|
|
if (!headers || typeof headers !== 'object') {
|
|
return null;
|
|
}
|
|
|
|
var target = name.toLowerCase();
|
|
|
|
for (var key in headers) {
|
|
if (key.toLowerCase() === target) {
|
|
return headers[key];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
try {
|
|
github.setParams(JSON.parse(value));
|
|
|
|
var issues_count,
|
|
issues_count_result = {
|
|
issues: {
|
|
total: 0,
|
|
open: 0,
|
|
closed: 0
|
|
},
|
|
pr: {
|
|
total: 0,
|
|
open: 0,
|
|
closed: 0
|
|
}
|
|
};
|
|
|
|
issues_count = github.apiRequest(github.params.api_url + 'repos/' + github.params.repo_owner + '/' + github.params.repo_name + '/pulls?state=all&per_page=1', github.params.pagination_required);
|
|
issues_count_result.pr.total = github.itemsCount(issues_count);
|
|
|
|
issues_count = github.apiRequest(github.params.api_url + 'repos/' + github.params.repo_owner + '/' + github.params.repo_name + '/pulls?state=open&per_page=1', github.params.pagination_required);
|
|
issues_count_result.pr.open = github.itemsCount(issues_count);
|
|
|
|
issues_count_result.pr.closed = issues_count_result.pr.total - issues_count_result.pr.open;
|
|
|
|
|
|
issues_count = github.apiRequest(github.params.api_url + 'repos/' + github.params.repo_owner + '/' + github.params.repo_name + '/issues?state=all&per_page=1', github.params.pagination_required);
|
|
issues_count_result.issues.total = github.itemsCount(issues_count) - issues_count_result.pr.total;
|
|
|
|
issues_count = github.apiRequest(github.params.api_url + 'repos/' + github.params.repo_owner + '/' + github.params.repo_name + '/issues?state=open&per_page=1', github.params.pagination_required);
|
|
issues_count_result.issues.open = github.itemsCount(issues_count) - issues_count_result.pr.open;
|
|
|
|
issues_count_result.issues.closed = issues_count_result.issues.total - issues_count_result.issues.open;
|
|
|
|
return JSON.stringify(issues_count_result);
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ GitHub Repo ] ERROR: ' + error);
|
|
return JSON.stringify({ error: error });
|
|
}
|
|
description: |
|
|
Get the count of issues and pull requests in the repository (total, open, closed).
|
|
|
|
Information about endpoint for issues:
|
|
https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#list-repository-issues
|
|
|
|
Information about endpoint for pull requests:
|
|
https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests
|
|
preprocessing:
|
|
- type: CHECK_REGEX_ERROR
|
|
parameters:
|
|
- 'API rate limit exceeded'
|
|
- \0
|
|
error_handler: DISCARD_VALUE
|
|
timeout: '{$GITHUB.TIMEOUT:"get_issues_count"}'
|
|
parameters:
|
|
- name: api_token
|
|
value: '{$GITHUB.API.TOKEN}'
|
|
- name: api_url
|
|
value: '{$GITHUB.API.URL}'
|
|
- name: api_version
|
|
value: '{$GITHUB.API_VERSION}'
|
|
- name: http_proxy
|
|
value: '{$GITHUB.HTTP_PROXY}'
|
|
- name: pagination_required
|
|
value: 'false'
|
|
- name: repo_name
|
|
value: '{$GITHUB.REPO.NAME}'
|
|
- name: repo_owner
|
|
value: '{$GITHUB.REPO.OWNER}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GitHub repository"}'
|
|
- name: user_agent
|
|
value: '{$GITHUB.USER_AGENT}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- uuid: 7ea663eb6d4b40688115e0cb2ab03424
|
|
name: 'Number of open issues'
|
|
type: DEPENDENT
|
|
key: github.repo.issues.open
|
|
delay: '0'
|
|
description: 'The number of open issues in the repository.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.issues.open
|
|
master_item:
|
|
key: github.repo.issues.get
|
|
tags:
|
|
- tag: component
|
|
value: issues
|
|
- uuid: f60f12d72f90461d8eeda2c2719cf94d
|
|
name: 'Number of issues'
|
|
type: DEPENDENT
|
|
key: github.repo.issues.total
|
|
delay: '0'
|
|
description: 'The total number of issues in the repository.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.issues.total
|
|
master_item:
|
|
key: github.repo.issues.get
|
|
tags:
|
|
- tag: component
|
|
value: issues
|
|
triggers:
|
|
- uuid: 9a146a900ced45b09a09b402daae6f94
|
|
expression: 'last(/GitHub repository by HTTP/github.repo.issues.total)>last(/GitHub repository by HTTP/github.repo.issues.total,#2)'
|
|
name: 'GitHub: The total number of issues has increased'
|
|
priority: WARNING
|
|
description: 'The total number of issues has increased which means that either a new issue (or multiple) has been opened.'
|
|
type: MULTIPLE
|
|
tags:
|
|
- tag: scope
|
|
value: notice
|
|
- uuid: 6c02d2fecace4bf4b94a06a923668938
|
|
name: 'Number of closed PRs'
|
|
type: DEPENDENT
|
|
key: github.repo.pr.closed
|
|
delay: '0'
|
|
description: 'The number of closed pull requests in the repository.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pr.closed
|
|
master_item:
|
|
key: github.repo.issues.get
|
|
tags:
|
|
- tag: component
|
|
value: pull-requests
|
|
- uuid: a1782ae22188416c8d2399fba2a1768c
|
|
name: 'Number of open PRs'
|
|
type: DEPENDENT
|
|
key: github.repo.pr.open
|
|
delay: '0'
|
|
description: 'The number of open pull requests in the repository.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pr.open
|
|
master_item:
|
|
key: github.repo.issues.get
|
|
tags:
|
|
- tag: component
|
|
value: pull-requests
|
|
- uuid: a20eda1b6c754b95b2bec1e449b681f5
|
|
name: 'Number of PRs'
|
|
type: DEPENDENT
|
|
key: github.repo.pr.total
|
|
delay: '0'
|
|
description: 'The total number of pull requests in the repository.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pr.total
|
|
master_item:
|
|
key: github.repo.issues.get
|
|
tags:
|
|
- tag: component
|
|
value: pull-requests
|
|
triggers:
|
|
- uuid: 7d834276726941cf9952c820e478ccf0
|
|
expression: 'last(/GitHub repository by HTTP/github.repo.pr.total)>last(/GitHub repository by HTTP/github.repo.pr.total,#2)'
|
|
name: 'GitHub: The total number of PRs has increased'
|
|
priority: INFO
|
|
description: 'The total number of pull requests has increased which means that either a new pull request (or multiple) has been opened.'
|
|
type: MULTIPLE
|
|
tags:
|
|
- tag: scope
|
|
value: notice
|
|
- uuid: 0098bfc3ed5c4181a7dcd1eceb8e7251
|
|
name: 'Number of releases'
|
|
type: SCRIPT
|
|
key: github.repo.releases.count
|
|
delay: '{$GITHUB.INTERVAL:"get_releases_count"}'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var github = {
|
|
params: {},
|
|
|
|
setParams: function (params, required) {
|
|
required = required || [];
|
|
required.concat(['api_url', 'user_agent', 'api_version', 'repo_owner', 'repo_name', 'pagination_required', 'api_token']).forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined'
|
|
|| params[field] === '') {
|
|
throw 'Required parameter is not set: "' + field + '".';
|
|
}
|
|
});
|
|
|
|
github.params = params;
|
|
|
|
if (typeof github.params.api_url === 'string' && !github.params.api_url.endsWith('/')) {
|
|
github.params.api_url += '/';
|
|
}
|
|
|
|
github.tls = new CTlsConfig(params.tls_verify);
|
|
github.tls.checkURL(github.params.api_url);
|
|
},
|
|
|
|
apiRequest: function (url, pagination_required) {
|
|
const next_pattern = /<([^>]+)>;\s*rel="next"/i;
|
|
var request = new HttpRequest(github.tls.options),
|
|
response,
|
|
headers,
|
|
final_data = {
|
|
headers: {},
|
|
data: []
|
|
};
|
|
|
|
pagination_required = (typeof pagination_required !== 'undefined') ? pagination_required : 'true';
|
|
|
|
request.addHeader('User-Agent: ' + github.params.user_agent);
|
|
request.addHeader('Accept: application/vnd.github+json');
|
|
request.addHeader('X-GitHub-Api-Version: ' + github.params.api_version);
|
|
request.addHeader('Authorization: Bearer ' + github.params.api_token);
|
|
|
|
if (typeof github.params.http_proxy !== 'undefined' && github.params.http_proxy !== '') {
|
|
request.setProxy(github.params.http_proxy);
|
|
Zabbix.log(4, '[ GitHub Repo ] Using HTTP proxy: ' + github.params.http_proxy);
|
|
}
|
|
|
|
while (url) {
|
|
Zabbix.log(4, '[ GitHub Repo ] Sending request: ' + url);
|
|
|
|
response = request.get(url);
|
|
|
|
Zabbix.log(4, '[ GitHub Repo ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from API. Check debug log for more information.';
|
|
}
|
|
|
|
var parsed_data = github.parseData(response);
|
|
final_data.data = final_data.data.concat(parsed_data);
|
|
|
|
headers = request.getHeaders();
|
|
|
|
var link_header = github.getHeader(headers, 'Link');
|
|
url = ((link_header || '').match(next_pattern) || [])[1];
|
|
|
|
if (pagination_required === 'false') {
|
|
url = '';
|
|
}
|
|
}
|
|
|
|
final_data.headers = request.getHeaders();
|
|
|
|
delete request;
|
|
|
|
return final_data;
|
|
},
|
|
|
|
parseData: function (response_data) {
|
|
if (!response_data) {
|
|
return [];
|
|
}
|
|
|
|
const normalization_required = "total_count" in response_data && !("url" in response_data);
|
|
if (!normalization_required) return response_data;
|
|
|
|
delete response_data.incomplete_results;
|
|
delete response_data.repository_selection;
|
|
delete response_data.total_count;
|
|
|
|
const namespaceKey = Object.keys(response_data)[0];
|
|
response_data = response_data[namespaceKey];
|
|
|
|
return response_data;
|
|
},
|
|
|
|
itemsCount: function (response_data) {
|
|
const last_page_number = /<[^>]+page=(\d+)>;\s*rel="last"/i;
|
|
|
|
if (response_data.headers.link){
|
|
return response_data.headers.link.match(last_page_number)[1];
|
|
}
|
|
|
|
return response_data.data.length;
|
|
},
|
|
|
|
getHeader: function (headers, name) {
|
|
if (!headers || typeof headers !== 'object') {
|
|
return null;
|
|
}
|
|
|
|
var target = name.toLowerCase();
|
|
|
|
for (var key in headers) {
|
|
if (key.toLowerCase() === target) {
|
|
return headers[key];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
try {
|
|
github.setParams(JSON.parse(value), ['api_query']);
|
|
|
|
var result = github.apiRequest(github.params.api_url + github.params.api_query + '?' + github.params.query_params || '', github.params.pagination_required);
|
|
|
|
return github.itemsCount(result);
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ GitHub Repo ] ERROR: ' + error);
|
|
return JSON.stringify({ error: error });
|
|
}
|
|
description: |
|
|
The number of releases in the repository. Note that this number also includes draft releases.
|
|
|
|
Information about endpoint:
|
|
https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#list-releases
|
|
preprocessing:
|
|
- type: CHECK_REGEX_ERROR
|
|
parameters:
|
|
- 'API rate limit exceeded'
|
|
- \0
|
|
error_handler: DISCARD_VALUE
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 6h
|
|
timeout: '{$GITHUB.TIMEOUT:"get_releases_count"}'
|
|
parameters:
|
|
- name: api_query
|
|
value: 'repos/{$GITHUB.REPO.OWNER}/{$GITHUB.REPO.NAME}/releases'
|
|
- name: api_token
|
|
value: '{$GITHUB.API.TOKEN}'
|
|
- name: api_url
|
|
value: '{$GITHUB.API.URL}'
|
|
- name: api_version
|
|
value: '{$GITHUB.API_VERSION}'
|
|
- name: http_proxy
|
|
value: '{$GITHUB.HTTP_PROXY}'
|
|
- name: pagination_required
|
|
value: 'false'
|
|
- name: query_params
|
|
value: per_page=1
|
|
- name: repo_name
|
|
value: '{$GITHUB.REPO.NAME}'
|
|
- name: repo_owner
|
|
value: '{$GITHUB.REPO.OWNER}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GitHub"}'
|
|
- name: user_agent
|
|
value: '{$GITHUB.USER_AGENT}'
|
|
tags:
|
|
- tag: component
|
|
value: releases
|
|
- uuid: 72a596dd573e4237a1fde665477bdfb5
|
|
name: 'Repository forks'
|
|
type: DEPENDENT
|
|
key: github.repo.repository.forks.count
|
|
delay: '0'
|
|
description: 'The number of repository forks.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data..forks_count.first()
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: repository
|
|
- uuid: 37e94a93bf924d84bb6609eec47ff081
|
|
name: 'Get repository'
|
|
type: SCRIPT
|
|
key: github.repo.repository.get
|
|
delay: '{$GITHUB.INTERVAL:"get_repo"}'
|
|
history: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var github = {
|
|
params: {},
|
|
|
|
setParams: function (params, required) {
|
|
required = required || [];
|
|
required.concat(['api_url', 'user_agent', 'api_version', 'repo_owner', 'repo_name', 'pagination_required', 'api_token']).forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined'
|
|
|| params[field] === '') {
|
|
throw 'Required parameter is not set: "' + field + '".';
|
|
}
|
|
});
|
|
|
|
github.params = params;
|
|
|
|
if (typeof github.params.api_url === 'string' && !github.params.api_url.endsWith('/')) {
|
|
github.params.api_url += '/';
|
|
}
|
|
|
|
github.tls = new CTlsConfig(params.tls_verify);
|
|
github.tls.checkURL(github.params.api_url);
|
|
},
|
|
|
|
apiRequest: function (url, pagination_required) {
|
|
const next_pattern = /<([^>]+)>;\s*rel="next"/i;
|
|
var request = new HttpRequest(github.tls.options),
|
|
response,
|
|
headers,
|
|
final_data = {
|
|
headers: {},
|
|
data: []
|
|
};
|
|
|
|
pagination_required = (typeof pagination_required !== 'undefined') ? pagination_required : 'true';
|
|
|
|
request.addHeader('User-Agent: ' + github.params.user_agent);
|
|
request.addHeader('Accept: application/vnd.github+json');
|
|
request.addHeader('X-GitHub-Api-Version: ' + github.params.api_version);
|
|
request.addHeader('Authorization: Bearer ' + github.params.api_token);
|
|
|
|
if (typeof github.params.http_proxy !== 'undefined' && github.params.http_proxy !== '') {
|
|
request.setProxy(github.params.http_proxy);
|
|
Zabbix.log(4, '[ GitHub Repo ] Using HTTP proxy: ' + github.params.http_proxy);
|
|
}
|
|
|
|
while (url) {
|
|
Zabbix.log(4, '[ GitHub Repo ] Sending request: ' + url);
|
|
|
|
response = request.get(url);
|
|
|
|
Zabbix.log(4, '[ GitHub Repo ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from API. Check debug log for more information.';
|
|
}
|
|
|
|
var parsed_data = github.parseData(response);
|
|
final_data.data = final_data.data.concat(parsed_data);
|
|
|
|
headers = request.getHeaders();
|
|
|
|
var link_header = github.getHeader(headers, 'Link');
|
|
url = ((link_header || '').match(next_pattern) || [])[1];
|
|
|
|
if (pagination_required === 'false') {
|
|
url = '';
|
|
}
|
|
}
|
|
|
|
final_data.headers = request.getHeaders();
|
|
|
|
delete request;
|
|
|
|
return final_data;
|
|
},
|
|
|
|
parseData: function (response_data) {
|
|
if (!response_data) {
|
|
return [];
|
|
}
|
|
|
|
const normalization_required = "total_count" in response_data && !("url" in response_data);
|
|
if (!normalization_required) return response_data;
|
|
|
|
delete response_data.incomplete_results;
|
|
delete response_data.repository_selection;
|
|
delete response_data.total_count;
|
|
|
|
const namespaceKey = Object.keys(response_data)[0];
|
|
response_data = response_data[namespaceKey];
|
|
|
|
return response_data;
|
|
},
|
|
|
|
itemsCount: function (response_data) {
|
|
const last_page_number = /<[^>]+page=(\d+)>;\s*rel="last"/i;
|
|
|
|
if (response_data.headers.link){
|
|
return response_data.headers.link.match(last_page_number)[1];
|
|
}
|
|
|
|
return response_data.data.length;
|
|
},
|
|
|
|
getHeader: function (headers, name) {
|
|
if (!headers || typeof headers !== 'object') {
|
|
return null;
|
|
}
|
|
|
|
var target = name.toLowerCase();
|
|
|
|
for (var key in headers) {
|
|
if (key.toLowerCase() === target) {
|
|
return headers[key];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
try {
|
|
github.setParams(JSON.parse(value), ['api_query']);
|
|
|
|
var repo_data = github.apiRequest(github.params.api_url + github.params.api_query);
|
|
|
|
if (repo_data.data[0].fork === false) {
|
|
var repo_community_profile = github.apiRequest(github.params.api_url + github.params.api_query + '/community/profile');
|
|
|
|
repo_data.data[0].zbx_community_profile = repo_community_profile.data[0];
|
|
}
|
|
|
|
return JSON.stringify(repo_data);
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ GitHub Repo ] ERROR: ' + error);
|
|
return JSON.stringify({ error: error });
|
|
}
|
|
description: |
|
|
Get the general repository information. If the repository is not a fork, the community profile metrics are also retrieved.
|
|
|
|
Information about endpoint:
|
|
https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#get-a-repository
|
|
|
|
Information about community profile metrics:
|
|
https://docs.github.com/en/rest/metrics/community?apiVersion=2022-11-28#get-community-profile-metrics
|
|
timeout: '{$GITHUB.TIMEOUT:"get_repo"}'
|
|
parameters:
|
|
- name: api_query
|
|
value: 'repos/{$GITHUB.REPO.OWNER}/{$GITHUB.REPO.NAME}'
|
|
- name: api_token
|
|
value: '{$GITHUB.API.TOKEN}'
|
|
- name: api_url
|
|
value: '{$GITHUB.API.URL}'
|
|
- name: api_version
|
|
value: '{$GITHUB.API_VERSION}'
|
|
- name: http_proxy
|
|
value: '{$GITHUB.HTTP_PROXY}'
|
|
- name: pagination_required
|
|
value: 'false'
|
|
- name: repo_name
|
|
value: '{$GITHUB.REPO.NAME}'
|
|
- name: repo_owner
|
|
value: '{$GITHUB.REPO.OWNER}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GitHub repository"}'
|
|
- name: user_agent
|
|
value: '{$GITHUB.USER_AGENT}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- uuid: 4bc2b485d4f546a0b390288d48bc179d
|
|
name: 'Get repository data check'
|
|
type: DEPENDENT
|
|
key: github.repo.repository.get.check
|
|
delay: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
description: 'Data collection check.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.error
|
|
error_handler: CUSTOM_VALUE
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: status
|
|
triggers:
|
|
- uuid: fea49679a888491c96516b421703131b
|
|
expression: 'length(last(/GitHub repository by HTTP/github.repo.repository.get.check))>0'
|
|
name: 'GitHub: There are errors in requests to API'
|
|
priority: AVERAGE
|
|
description: 'Errors have been received in response to API requests. Check the latest values for details.'
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- uuid: c0e4cf3a4f654f5b82d29db43aeaa6eb
|
|
name: 'Repository is a fork'
|
|
type: DEPENDENT
|
|
key: github.repo.repository.is_fork
|
|
delay: '0'
|
|
description: 'Indicates whether the repository is a fork.'
|
|
valuemap:
|
|
name: Boolean
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data..fork.first()
|
|
- type: BOOL_TO_DECIMAL
|
|
parameters:
|
|
- ''
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 6h
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: repository
|
|
- uuid: ece3996cba7e4561a6629df40299579f
|
|
name: 'Repository size'
|
|
type: DEPENDENT
|
|
key: github.repo.repository.size
|
|
delay: '0'
|
|
units: B
|
|
description: 'The size of the repository.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data..size.first()
|
|
- type: MULTIPLIER
|
|
parameters:
|
|
- '1024'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: repository
|
|
- uuid: 2e329b0973aa4f2abf94bf10554d776c
|
|
name: 'Repository stargazers'
|
|
type: DEPENDENT
|
|
key: github.repo.repository.stargazers
|
|
delay: '0'
|
|
description: 'The number of GitHub users who have starred the repository.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data..stargazers_count.first()
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: repository
|
|
- uuid: 488ff6c6217d4d51a7cb8fd278996435
|
|
name: 'Repository watchers'
|
|
type: DEPENDENT
|
|
key: github.repo.repository.watchers
|
|
delay: '0'
|
|
description: 'The number of GitHub users who are subscribed to the repository.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data..subscribers_count.first()
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: repository
|
|
- uuid: 1166ecf4aa624b469805406da0b1f552
|
|
name: 'Request limit'
|
|
type: DEPENDENT
|
|
key: github.repo.requests.limit
|
|
delay: '0'
|
|
description: |
|
|
API request limit.
|
|
|
|
Information about request limits in GitHub REST API documentation:
|
|
https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.headers[''x-ratelimit-limit'']'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: request-limits
|
|
- uuid: a0c4165547f942a789deee0703c1f284
|
|
name: 'Requests used'
|
|
type: DEPENDENT
|
|
key: github.repo.requests.used
|
|
delay: '0'
|
|
description: |
|
|
The number of used API requests.
|
|
|
|
Information about request limits in GitHub REST API documentation:
|
|
https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.headers[''x-ratelimit-used'']'
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: request-limits
|
|
- uuid: e4b52ac7188944298fd6ca306ed4f8b8
|
|
name: 'Request limit utilization, in %'
|
|
type: DEPENDENT
|
|
key: github.repo.requests.util
|
|
delay: '0'
|
|
value_type: FLOAT
|
|
units: '%'
|
|
description: |
|
|
The calculated utilization of the API request limit in %.
|
|
|
|
Information about request limits in GitHub REST API documentation:
|
|
https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28
|
|
preprocessing:
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
const data = JSON.parse(value);
|
|
|
|
const requests_limit = data.headers['x-ratelimit-limit'],
|
|
requests_used = data.headers['x-ratelimit-used'];
|
|
|
|
return requests_used / requests_limit * 100;
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: request-limits
|
|
triggers:
|
|
- uuid: 621ef82bf8f74f09a8c30b8a38085e9d
|
|
expression: 'max(/GitHub repository by HTTP/github.repo.requests.util,1h)>{$GITHUB.REQUESTS.UTIL.WARN}'
|
|
recovery_mode: RECOVERY_EXPRESSION
|
|
recovery_expression: 'max(/GitHub repository by HTTP/github.repo.requests.util,1h)>{$GITHUB.REQUESTS.UTIL.WARN}-5'
|
|
name: 'GitHub: API request limit utilization is high'
|
|
event_name: 'GitHub: API request limit utilization is high (usage is > {$GITHUB.REQUESTS.UTIL.WARN})'
|
|
priority: WARNING
|
|
description: |
|
|
The API request limit utilization is high. It can be lowered by increasing the update intervals for script items (by setting up higher values in corresponding context macros).
|
|
|
|
The trigger will be resolved automatically if the limit usage drops 5% below the trigger threshold.
|
|
|
|
Information about request limits in GitHub REST API documentation:
|
|
https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28
|
|
dependencies:
|
|
- name: 'GitHub: API request limit utilization is very high'
|
|
expression: 'max(/GitHub repository by HTTP/github.repo.requests.util,1h)>{$GITHUB.REQUESTS.UTIL.HIGH}'
|
|
recovery_expression: 'max(/GitHub repository by HTTP/github.repo.requests.util,1h)>{$GITHUB.REQUESTS.UTIL.HIGH}-5'
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- tag: scope
|
|
value: capacity
|
|
- uuid: 9783018b6c394397aa093b4f8a1a4067
|
|
expression: 'max(/GitHub repository by HTTP/github.repo.requests.util,1h)>{$GITHUB.REQUESTS.UTIL.HIGH}'
|
|
recovery_mode: RECOVERY_EXPRESSION
|
|
recovery_expression: 'max(/GitHub repository by HTTP/github.repo.requests.util,1h)>{$GITHUB.REQUESTS.UTIL.HIGH}-5'
|
|
name: 'GitHub: API request limit utilization is very high'
|
|
event_name: 'GitHub: API request limit utilization is very high (usage is > {$GITHUB.REQUESTS.UTIL.HIGH})'
|
|
priority: AVERAGE
|
|
description: |
|
|
The API request limit utilization is very high. It can be lowered by increasing the update intervals for script items (by setting up higher values in corresponding context macros).
|
|
|
|
The trigger will be resolved automatically if the limit usage drops 5% below the trigger threshold.
|
|
|
|
Information about request limits in GitHub REST API documentation:
|
|
https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- tag: scope
|
|
value: capacity
|
|
- uuid: a0ca909d3c734d859594771985a5c302
|
|
name: 'Get self-hosted runners'
|
|
type: SCRIPT
|
|
key: github.repo.runners.get
|
|
delay: '{$GITHUB.INTERVAL:"get_runners"}'
|
|
history: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var github = {
|
|
params: {},
|
|
|
|
setParams: function (params, required) {
|
|
required = required || [];
|
|
required.concat(['api_url', 'user_agent', 'api_version', 'repo_owner', 'repo_name', 'pagination_required', 'api_token']).forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined'
|
|
|| params[field] === '') {
|
|
throw 'Required parameter is not set: "' + field + '".';
|
|
}
|
|
});
|
|
|
|
github.params = params;
|
|
|
|
if (typeof github.params.api_url === 'string' && !github.params.api_url.endsWith('/')) {
|
|
github.params.api_url += '/';
|
|
}
|
|
|
|
github.tls = new CTlsConfig(params.tls_verify);
|
|
github.tls.checkURL(github.params.api_url);
|
|
},
|
|
|
|
apiRequest: function (url, pagination_required) {
|
|
const next_pattern = /<([^>]+)>;\s*rel="next"/i;
|
|
var request = new HttpRequest(github.tls.options),
|
|
response,
|
|
headers,
|
|
final_data = {
|
|
headers: {},
|
|
data: []
|
|
};
|
|
|
|
pagination_required = (typeof pagination_required !== 'undefined') ? pagination_required : 'true';
|
|
|
|
request.addHeader('User-Agent: ' + github.params.user_agent);
|
|
request.addHeader('Accept: application/vnd.github+json');
|
|
request.addHeader('X-GitHub-Api-Version: ' + github.params.api_version);
|
|
request.addHeader('Authorization: Bearer ' + github.params.api_token);
|
|
|
|
if (typeof github.params.http_proxy !== 'undefined' && github.params.http_proxy !== '') {
|
|
request.setProxy(github.params.http_proxy);
|
|
Zabbix.log(4, '[ GitHub Repo ] Using HTTP proxy: ' + github.params.http_proxy);
|
|
}
|
|
|
|
while (url) {
|
|
Zabbix.log(4, '[ GitHub Repo ] Sending request: ' + url);
|
|
|
|
response = request.get(url);
|
|
|
|
Zabbix.log(4, '[ GitHub Repo ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from API. Check debug log for more information.';
|
|
}
|
|
|
|
var parsed_data = github.parseData(response);
|
|
final_data.data = final_data.data.concat(parsed_data);
|
|
|
|
headers = request.getHeaders();
|
|
|
|
var link_header = github.getHeader(headers, 'Link');
|
|
url = ((link_header || '').match(next_pattern) || [])[1];
|
|
|
|
if (pagination_required === 'false') {
|
|
url = '';
|
|
}
|
|
}
|
|
|
|
final_data.headers = request.getHeaders();
|
|
|
|
delete request;
|
|
|
|
return final_data;
|
|
},
|
|
|
|
parseData: function (response_data) {
|
|
if (!response_data) {
|
|
return [];
|
|
}
|
|
|
|
const normalization_required = "total_count" in response_data && !("url" in response_data);
|
|
if (!normalization_required) return response_data;
|
|
|
|
delete response_data.incomplete_results;
|
|
delete response_data.repository_selection;
|
|
delete response_data.total_count;
|
|
|
|
const namespaceKey = Object.keys(response_data)[0];
|
|
response_data = response_data[namespaceKey];
|
|
|
|
return response_data;
|
|
},
|
|
|
|
itemsCount: function (response_data) {
|
|
const last_page_number = /<[^>]+page=(\d+)>;\s*rel="last"/i;
|
|
|
|
if (response_data.headers.link){
|
|
return response_data.headers.link.match(last_page_number)[1];
|
|
}
|
|
|
|
return response_data.data.length;
|
|
},
|
|
|
|
getHeader: function (headers, name) {
|
|
if (!headers || typeof headers !== 'object') {
|
|
return null;
|
|
}
|
|
|
|
var target = name.toLowerCase();
|
|
|
|
for (var key in headers) {
|
|
if (key.toLowerCase() === target) {
|
|
return headers[key];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
try {
|
|
github.setParams(JSON.parse(value), ['api_query']);
|
|
|
|
var result = github.apiRequest(github.params.api_url + github.params.api_query + '?' + github.params.query_params || '', github.params.pagination_required);
|
|
|
|
return JSON.stringify(result);
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ GitHub Repo ] ERROR: ' + error);
|
|
return JSON.stringify({ error: error });
|
|
}
|
|
description: |
|
|
Get the self-hosted runners of the repository.
|
|
|
|
Note that admin access to the repository is required to use this endpoint:
|
|
https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository
|
|
preprocessing:
|
|
- type: CHECK_REGEX_ERROR
|
|
parameters:
|
|
- 'API rate limit exceeded'
|
|
- \0
|
|
error_handler: DISCARD_VALUE
|
|
timeout: '{$GITHUB.TIMEOUT:"get_runners"}'
|
|
parameters:
|
|
- name: api_query
|
|
value: 'repos/{$GITHUB.REPO.OWNER}/{$GITHUB.REPO.NAME}/actions/runners'
|
|
- name: api_token
|
|
value: '{$GITHUB.API.TOKEN}'
|
|
- name: api_url
|
|
value: '{$GITHUB.API.URL}'
|
|
- name: api_version
|
|
value: '{$GITHUB.API_VERSION}'
|
|
- name: http_proxy
|
|
value: '{$GITHUB.HTTP_PROXY}'
|
|
- name: pagination_required
|
|
value: 'true'
|
|
- name: query_params
|
|
value: 'per_page={$GITHUB.RESULTS_PER_PAGE:"get_runners"}'
|
|
- name: repo_name
|
|
value: '{$GITHUB.REPO.NAME}'
|
|
- name: repo_owner
|
|
value: '{$GITHUB.REPO.OWNER}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GitHub"}'
|
|
- name: user_agent
|
|
value: '{$GITHUB.USER_AGENT}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- uuid: 35507c347ff44527a7deb3aaf4846d33
|
|
name: 'Get self-hosted runner check'
|
|
type: DEPENDENT
|
|
key: github.repo.runners.get.check
|
|
delay: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
description: 'Carry out a self-hosted runners data collection check.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.error
|
|
error_handler: CUSTOM_VALUE
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: github.repo.runners.get
|
|
tags:
|
|
- tag: component
|
|
value: status
|
|
triggers:
|
|
- uuid: 30877fea1bd14e22b8b5c4a040001bb5
|
|
expression: 'find(/GitHub repository by HTTP/github.repo.runners.get.check,,"iregexp","Must have admin rights to Repository")=1'
|
|
name: 'GitHub: No access to repository self-hosted runners'
|
|
priority: AVERAGE
|
|
description: |
|
|
Admin access to the repository is required to use this endpoint:
|
|
https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository
|
|
- uuid: 49d81fc72a6a455ebee7304592056930
|
|
name: 'Number of tags'
|
|
type: SCRIPT
|
|
key: github.repo.tags.count
|
|
delay: '{$GITHUB.INTERVAL:"get_tags_count"}'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var github = {
|
|
params: {},
|
|
|
|
setParams: function (params, required) {
|
|
required = required || [];
|
|
required.concat(['api_url', 'user_agent', 'api_version', 'repo_owner', 'repo_name', 'pagination_required', 'api_token']).forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined'
|
|
|| params[field] === '') {
|
|
throw 'Required parameter is not set: "' + field + '".';
|
|
}
|
|
});
|
|
|
|
github.params = params;
|
|
|
|
if (typeof github.params.api_url === 'string' && !github.params.api_url.endsWith('/')) {
|
|
github.params.api_url += '/';
|
|
}
|
|
|
|
github.tls = new CTlsConfig(params.tls_verify);
|
|
github.tls.checkURL(github.params.api_url);
|
|
},
|
|
|
|
apiRequest: function (url, pagination_required) {
|
|
const next_pattern = /<([^>]+)>;\s*rel="next"/i;
|
|
var request = new HttpRequest(github.tls.options),
|
|
response,
|
|
headers,
|
|
final_data = {
|
|
headers: {},
|
|
data: []
|
|
};
|
|
|
|
pagination_required = (typeof pagination_required !== 'undefined') ? pagination_required : 'true';
|
|
|
|
request.addHeader('User-Agent: ' + github.params.user_agent);
|
|
request.addHeader('Accept: application/vnd.github+json');
|
|
request.addHeader('X-GitHub-Api-Version: ' + github.params.api_version);
|
|
request.addHeader('Authorization: Bearer ' + github.params.api_token);
|
|
|
|
if (typeof github.params.http_proxy !== 'undefined' && github.params.http_proxy !== '') {
|
|
request.setProxy(github.params.http_proxy);
|
|
Zabbix.log(4, '[ GitHub Repo ] Using HTTP proxy: ' + github.params.http_proxy);
|
|
}
|
|
|
|
while (url) {
|
|
Zabbix.log(4, '[ GitHub Repo ] Sending request: ' + url);
|
|
|
|
response = request.get(url);
|
|
|
|
Zabbix.log(4, '[ GitHub Repo ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from API. Check debug log for more information.';
|
|
}
|
|
|
|
var parsed_data = github.parseData(response);
|
|
final_data.data = final_data.data.concat(parsed_data);
|
|
|
|
headers = request.getHeaders();
|
|
|
|
var link_header = github.getHeader(headers, 'Link');
|
|
url = ((link_header || '').match(next_pattern) || [])[1];
|
|
|
|
if (pagination_required === 'false') {
|
|
url = '';
|
|
}
|
|
}
|
|
|
|
final_data.headers = request.getHeaders();
|
|
|
|
delete request;
|
|
|
|
return final_data;
|
|
},
|
|
|
|
parseData: function (response_data) {
|
|
if (!response_data) {
|
|
return [];
|
|
}
|
|
|
|
const normalization_required = "total_count" in response_data && !("url" in response_data);
|
|
if (!normalization_required) return response_data;
|
|
|
|
delete response_data.incomplete_results;
|
|
delete response_data.repository_selection;
|
|
delete response_data.total_count;
|
|
|
|
const namespaceKey = Object.keys(response_data)[0];
|
|
response_data = response_data[namespaceKey];
|
|
|
|
return response_data;
|
|
},
|
|
|
|
itemsCount: function (response_data) {
|
|
const last_page_number = /<[^>]+page=(\d+)>;\s*rel="last"/i;
|
|
|
|
if (response_data.headers.link){
|
|
return response_data.headers.link.match(last_page_number)[1];
|
|
}
|
|
|
|
return response_data.data.length;
|
|
},
|
|
|
|
getHeader: function (headers, name) {
|
|
if (!headers || typeof headers !== 'object') {
|
|
return null;
|
|
}
|
|
|
|
var target = name.toLowerCase();
|
|
|
|
for (var key in headers) {
|
|
if (key.toLowerCase() === target) {
|
|
return headers[key];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
try {
|
|
github.setParams(JSON.parse(value), ['api_query']);
|
|
|
|
var result = github.apiRequest(github.params.api_url + github.params.api_query + '?' + github.params.query_params || '', github.params.pagination_required);
|
|
|
|
return github.itemsCount(result);
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ GitHub Repo ] ERROR: ' + error);
|
|
return JSON.stringify({ error: error });
|
|
}
|
|
description: |
|
|
The number of tags in the repository.
|
|
|
|
Information about endpoint:
|
|
https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-repository-tags
|
|
preprocessing:
|
|
- type: CHECK_REGEX_ERROR
|
|
parameters:
|
|
- 'API rate limit exceeded'
|
|
- \0
|
|
error_handler: DISCARD_VALUE
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 6h
|
|
timeout: '{$GITHUB.TIMEOUT:"get_tags_count"}'
|
|
parameters:
|
|
- name: api_query
|
|
value: 'repos/{$GITHUB.REPO.OWNER}/{$GITHUB.REPO.NAME}/tags'
|
|
- name: api_token
|
|
value: '{$GITHUB.API.TOKEN}'
|
|
- name: api_url
|
|
value: '{$GITHUB.API.URL}'
|
|
- name: api_version
|
|
value: '{$GITHUB.API_VERSION}'
|
|
- name: http_proxy
|
|
value: '{$GITHUB.HTTP_PROXY}'
|
|
- name: pagination_required
|
|
value: 'false'
|
|
- name: query_params
|
|
value: per_page=1
|
|
- name: repo_name
|
|
value: '{$GITHUB.REPO.NAME}'
|
|
- name: repo_owner
|
|
value: '{$GITHUB.REPO.OWNER}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GitHub"}'
|
|
- name: user_agent
|
|
value: '{$GITHUB.USER_AGENT}'
|
|
tags:
|
|
- tag: component
|
|
value: tags
|
|
- uuid: d45dbcb0493d4258ac2cdba10648b3b3
|
|
name: 'Get workflows'
|
|
type: SCRIPT
|
|
key: github.repo.workflows.get
|
|
delay: '{$GITHUB.INTERVAL:"get_workflows"}'
|
|
history: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var github = {
|
|
params: {},
|
|
|
|
setParams: function (params, required) {
|
|
required = required || [];
|
|
required.concat(['api_url', 'user_agent', 'api_version', 'repo_owner', 'repo_name', 'pagination_required', 'api_token']).forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined'
|
|
|| params[field] === '') {
|
|
throw 'Required parameter is not set: "' + field + '".';
|
|
}
|
|
});
|
|
|
|
github.params = params;
|
|
|
|
if (typeof github.params.api_url === 'string' && !github.params.api_url.endsWith('/')) {
|
|
github.params.api_url += '/';
|
|
}
|
|
|
|
github.tls = new CTlsConfig(params.tls_verify);
|
|
github.tls.checkURL(github.params.api_url);
|
|
},
|
|
|
|
apiRequest: function (url, pagination_required) {
|
|
const next_pattern = /<([^>]+)>;\s*rel="next"/i;
|
|
var request = new HttpRequest(github.tls.options),
|
|
response,
|
|
headers,
|
|
final_data = {
|
|
headers: {},
|
|
data: []
|
|
};
|
|
|
|
pagination_required = (typeof pagination_required !== 'undefined') ? pagination_required : 'true';
|
|
|
|
request.addHeader('User-Agent: ' + github.params.user_agent);
|
|
request.addHeader('Accept: application/vnd.github+json');
|
|
request.addHeader('X-GitHub-Api-Version: ' + github.params.api_version);
|
|
request.addHeader('Authorization: Bearer ' + github.params.api_token);
|
|
|
|
if (typeof github.params.http_proxy !== 'undefined' && github.params.http_proxy !== '') {
|
|
request.setProxy(github.params.http_proxy);
|
|
Zabbix.log(4, '[ GitHub Repo ] Using HTTP proxy: ' + github.params.http_proxy);
|
|
}
|
|
|
|
while (url) {
|
|
Zabbix.log(4, '[ GitHub Repo ] Sending request: ' + url);
|
|
|
|
response = request.get(url);
|
|
|
|
Zabbix.log(4, '[ GitHub Repo ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from API. Check debug log for more information.';
|
|
}
|
|
|
|
var parsed_data = github.parseData(response);
|
|
final_data.data = final_data.data.concat(parsed_data);
|
|
|
|
headers = request.getHeaders();
|
|
|
|
var link_header = github.getHeader(headers, 'Link');
|
|
url = ((link_header || '').match(next_pattern) || [])[1];
|
|
|
|
if (pagination_required === 'false') {
|
|
url = '';
|
|
}
|
|
}
|
|
|
|
final_data.headers = request.getHeaders();
|
|
|
|
delete request;
|
|
|
|
return final_data;
|
|
},
|
|
|
|
parseData: function (response_data) {
|
|
if (!response_data) {
|
|
return [];
|
|
}
|
|
|
|
const normalization_required = "total_count" in response_data && !("url" in response_data);
|
|
if (!normalization_required) return response_data;
|
|
|
|
delete response_data.incomplete_results;
|
|
delete response_data.repository_selection;
|
|
delete response_data.total_count;
|
|
|
|
const namespaceKey = Object.keys(response_data)[0];
|
|
response_data = response_data[namespaceKey];
|
|
|
|
return response_data;
|
|
},
|
|
|
|
itemsCount: function (response_data) {
|
|
const last_page_number = /<[^>]+page=(\d+)>;\s*rel="last"/i;
|
|
|
|
if (response_data.headers.link){
|
|
return response_data.headers.link.match(last_page_number)[1];
|
|
}
|
|
|
|
return response_data.data.length;
|
|
},
|
|
|
|
getHeader: function (headers, name) {
|
|
if (!headers || typeof headers !== 'object') {
|
|
return null;
|
|
}
|
|
|
|
var target = name.toLowerCase();
|
|
|
|
for (var key in headers) {
|
|
if (key.toLowerCase() === target) {
|
|
return headers[key];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
try {
|
|
github.setParams(JSON.parse(value), ['api_query']);
|
|
|
|
var repo_data = github.apiRequest(github.params.api_url + github.params.api_query);
|
|
|
|
if (repo_data.data[0].fork === false) {
|
|
var repo_community_profile = github.apiRequest(github.params.api_url + github.params.api_query + '/community/profile');
|
|
|
|
repo_data.data[0].zbx_community_profile = repo_community_profile.data[0];
|
|
}
|
|
|
|
return JSON.stringify(repo_data);
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ GitHub Repo ] ERROR: ' + error);
|
|
return JSON.stringify({ error: error });
|
|
}
|
|
description: |
|
|
Get the repository workflows.
|
|
|
|
Information about endpoint:
|
|
https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#list-repository-workflows
|
|
preprocessing:
|
|
- type: CHECK_REGEX_ERROR
|
|
parameters:
|
|
- 'API rate limit exceeded'
|
|
- \0
|
|
error_handler: DISCARD_VALUE
|
|
timeout: '{$GITHUB.TIMEOUT:"get_workflows"}'
|
|
parameters:
|
|
- name: api_query
|
|
value: 'repos/{$GITHUB.REPO.OWNER}/{$GITHUB.REPO.NAME}/actions/workflows'
|
|
- name: api_token
|
|
value: '{$GITHUB.API.TOKEN}'
|
|
- name: api_url
|
|
value: '{$GITHUB.API.URL}'
|
|
- name: api_version
|
|
value: '{$GITHUB.API_VERSION}'
|
|
- name: http_proxy
|
|
value: '{$GITHUB.HTTP_PROXY}'
|
|
- name: pagination_required
|
|
value: 'true'
|
|
- name: query_params
|
|
value: 'per_page={$GITHUB.RESULTS_PER_PAGE:"workflows_discovery"}'
|
|
- name: repo_name
|
|
value: '{$GITHUB.REPO.NAME}'
|
|
- name: repo_owner
|
|
value: '{$GITHUB.REPO.OWNER}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GitHub"}'
|
|
- name: user_agent
|
|
value: '{$GITHUB.USER_AGENT}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
discovery_rules:
|
|
- uuid: 8142a17a53f44cd9b3d3991b9e3da91d
|
|
name: 'Branch discovery'
|
|
type: DEPENDENT
|
|
key: github.repo.branches.discovery
|
|
delay: '0'
|
|
filter:
|
|
evaltype: AND
|
|
conditions:
|
|
- macro: '{#BRANCH_NAME}'
|
|
value: '{$GITHUB.BRANCH.NAME.MATCHES}'
|
|
formulaid: A
|
|
- macro: '{#BRANCH_NAME}'
|
|
value: '{$GITHUB.BRANCH.NAME.NOT_MATCHES}'
|
|
operator: NOT_MATCHES_REGEX
|
|
formulaid: B
|
|
description: |
|
|
Discovers repository branches.
|
|
|
|
Information about endpoint:
|
|
https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#list-branches
|
|
item_prototypes:
|
|
- uuid: 927ef4806cc4460a8882c204a9e94817
|
|
name: 'Branch [{#BRANCH_NAME}]: Number of commits'
|
|
type: SCRIPT
|
|
key: 'github.repo.branches.commits.total[{#BRANCH_NAME}]'
|
|
delay: '{$GITHUB.INTERVAL:"get_commits_count:{#BRANCH_NAME}"}'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var github = {
|
|
params: {},
|
|
|
|
setParams: function (params, required) {
|
|
required = required || [];
|
|
required.concat(['api_url', 'user_agent', 'api_version', 'repo_owner', 'repo_name', 'pagination_required', 'api_token']).forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined'
|
|
|| params[field] === '') {
|
|
throw 'Required parameter is not set: "' + field + '".';
|
|
}
|
|
});
|
|
|
|
github.params = params;
|
|
|
|
if (typeof github.params.api_url === 'string' && !github.params.api_url.endsWith('/')) {
|
|
github.params.api_url += '/';
|
|
}
|
|
|
|
github.tls = new CTlsConfig(params.tls_verify);
|
|
github.tls.checkURL(github.params.api_url);
|
|
},
|
|
|
|
apiRequest: function (url, pagination_required) {
|
|
const next_pattern = /<([^>]+)>;\s*rel="next"/i;
|
|
var request = new HttpRequest(github.tls.options),
|
|
response,
|
|
headers,
|
|
final_data = {
|
|
headers: {},
|
|
data: []
|
|
};
|
|
|
|
pagination_required = (typeof pagination_required !== 'undefined') ? pagination_required : 'true';
|
|
|
|
request.addHeader('User-Agent: ' + github.params.user_agent);
|
|
request.addHeader('Accept: application/vnd.github+json');
|
|
request.addHeader('X-GitHub-Api-Version: ' + github.params.api_version);
|
|
request.addHeader('Authorization: Bearer ' + github.params.api_token);
|
|
|
|
if (typeof github.params.http_proxy !== 'undefined' && github.params.http_proxy !== '') {
|
|
request.setProxy(github.params.http_proxy);
|
|
Zabbix.log(4, '[ GitHub Repo ] Using HTTP proxy: ' + github.params.http_proxy);
|
|
}
|
|
|
|
while (url) {
|
|
Zabbix.log(4, '[ GitHub Repo ] Sending request: ' + url);
|
|
|
|
response = request.get(url);
|
|
|
|
Zabbix.log(4, '[ GitHub Repo ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from API. Check debug log for more information.';
|
|
}
|
|
|
|
var parsed_data = github.parseData(response);
|
|
final_data.data = final_data.data.concat(parsed_data);
|
|
|
|
headers = request.getHeaders();
|
|
|
|
var link_header = github.getHeader(headers, 'Link');
|
|
url = ((link_header || '').match(next_pattern) || [])[1];
|
|
|
|
if (pagination_required === 'false') {
|
|
url = '';
|
|
}
|
|
}
|
|
|
|
final_data.headers = request.getHeaders();
|
|
|
|
delete request;
|
|
|
|
return final_data;
|
|
},
|
|
|
|
parseData: function (response_data) {
|
|
if (!response_data) {
|
|
return [];
|
|
}
|
|
|
|
const normalization_required = "total_count" in response_data && !("url" in response_data);
|
|
if (!normalization_required) return response_data;
|
|
|
|
delete response_data.incomplete_results;
|
|
delete response_data.repository_selection;
|
|
delete response_data.total_count;
|
|
|
|
const namespaceKey = Object.keys(response_data)[0];
|
|
response_data = response_data[namespaceKey];
|
|
|
|
return response_data;
|
|
},
|
|
|
|
itemsCount: function (response_data) {
|
|
const last_page_number = /<[^>]+page=(\d+)>;\s*rel="last"/i;
|
|
|
|
if (response_data.headers.link){
|
|
return response_data.headers.link.match(last_page_number)[1];
|
|
}
|
|
|
|
return response_data.data.length;
|
|
},
|
|
|
|
getHeader: function (headers, name) {
|
|
if (!headers || typeof headers !== 'object') {
|
|
return null;
|
|
}
|
|
|
|
var target = name.toLowerCase();
|
|
|
|
for (var key in headers) {
|
|
if (key.toLowerCase() === target) {
|
|
return headers[key];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
try {
|
|
github.setParams(JSON.parse(value), ['api_query']);
|
|
|
|
var result = github.apiRequest(github.params.api_url + github.params.api_query + '?' + github.params.query_params || '', github.params.pagination_required);
|
|
|
|
return github.itemsCount(result);
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ GitHub Repo ] ERROR: ' + error);
|
|
return JSON.stringify({ error: error });
|
|
}
|
|
description: |
|
|
Get the number of commits in the branch.
|
|
|
|
Information about endpoint:
|
|
https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits
|
|
preprocessing:
|
|
- type: CHECK_REGEX_ERROR
|
|
parameters:
|
|
- 'API rate limit exceeded'
|
|
- \0
|
|
error_handler: DISCARD_VALUE
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 6h
|
|
timeout: '{$GITHUB.TIMEOUT:"get_commits_count:{#BRANCH_NAME}"}'
|
|
parameters:
|
|
- name: api_query
|
|
value: 'repos/{$GITHUB.REPO.OWNER}/{$GITHUB.REPO.NAME}/commits'
|
|
- name: api_token
|
|
value: '{$GITHUB.API.TOKEN}'
|
|
- name: api_url
|
|
value: '{$GITHUB.API.URL}'
|
|
- name: api_version
|
|
value: '{$GITHUB.API_VERSION}'
|
|
- name: http_proxy
|
|
value: '{$GITHUB.HTTP_PROXY}'
|
|
- name: pagination_required
|
|
value: 'false'
|
|
- name: query_params
|
|
value: 'sha={#BRANCH_NAME}&per_page=1'
|
|
- name: repo_name
|
|
value: '{$GITHUB.REPO.NAME}'
|
|
- name: repo_owner
|
|
value: '{$GITHUB.REPO.OWNER}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GitHub"}'
|
|
- name: user_agent
|
|
value: '{$GITHUB.USER_AGENT}'
|
|
tags:
|
|
- tag: branch
|
|
value: '{#BRANCH_NAME}'
|
|
- tag: component
|
|
value: branch
|
|
- tag: component
|
|
value: commit
|
|
graph_prototypes:
|
|
- uuid: 369c8e6bf49b4b348258d77126386769
|
|
name: 'Branch [{#BRANCH_NAME}]: Number of commits'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: 'github.repo.branches.commits.total[{#BRANCH_NAME}]'
|
|
master_item:
|
|
key: github.repo.branches.get
|
|
lld_macro_paths:
|
|
- lld_macro: '{#BRANCH_NAME}'
|
|
path: $.name
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data
|
|
- uuid: 8a3dbc58ccd845bbb92a671997a3bbec
|
|
name: 'Discovery of community profile metrics'
|
|
type: DEPENDENT
|
|
key: github.repo.community_profile.discovery
|
|
delay: '0'
|
|
description: |
|
|
Discovers community profile metrics (the repository must not be a fork).
|
|
|
|
Information about community profile metrics:
|
|
https://docs.github.com/en/rest/metrics/community?apiVersion=2022-11-28#get-community-profile-metrics
|
|
item_prototypes:
|
|
- uuid: 8babff453a0a4df597436d3c9dd3112f
|
|
name: 'Health percentage score'
|
|
type: DEPENDENT
|
|
key: 'github.repo.repository.health[{#SINGLETON}]'
|
|
delay: '0'
|
|
units: '%'
|
|
description: |
|
|
The health percentage score is defined as a percentage of how many of the recommended community health files are present.
|
|
|
|
For more information, see the documentation:
|
|
https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/about-community-profiles-for-public-repositories
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data..zbx_community_profile.health_percentage.first()
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
tags:
|
|
- tag: component
|
|
value: health
|
|
graph_prototypes:
|
|
- uuid: d3234c15dc844899ae1bdd473229279f
|
|
name: 'Health percentage score{#SINGLETON}'
|
|
ymin_type_1: FIXED
|
|
ymax_type_1: FIXED
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: 'github.repo.repository.health[{#SINGLETON}]'
|
|
master_item:
|
|
key: github.repo.repository.get
|
|
preprocessing:
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
return JSON.stringify(JSON.parse(value).data[0].zbx_community_profile
|
|
? [{'{#SINGLETON}': ''}] : []);
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 6h
|
|
- uuid: b77b33e77ddb457d9fd7912f97f179fd
|
|
name: 'Self-hosted runner discovery'
|
|
type: DEPENDENT
|
|
key: github.repo.runners.discovery
|
|
delay: '0'
|
|
filter:
|
|
evaltype: AND
|
|
conditions:
|
|
- macro: '{#RUNNER_NAME}'
|
|
value: '{$GITHUB.RUNNER.NAME.MATCHES}'
|
|
formulaid: A
|
|
- macro: '{#RUNNER_NAME}'
|
|
value: '{$GITHUB.RUNNER.NAME.NOT_MATCHES}'
|
|
operator: NOT_MATCHES_REGEX
|
|
formulaid: B
|
|
- macro: '{#RUNNER_OS}'
|
|
value: '{$GITHUB.RUNNER.OS.MATCHES}'
|
|
formulaid: C
|
|
- macro: '{#RUNNER_OS}'
|
|
value: '{$GITHUB.RUNNER.OS.NOT_MATCHES}'
|
|
operator: NOT_MATCHES_REGEX
|
|
formulaid: D
|
|
description: |
|
|
Discovers self-hosted runners of the repository.
|
|
|
|
Note that admin access to the repository is required to use this endpoint:
|
|
https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository
|
|
item_prototypes:
|
|
- uuid: 6cf4664f14744eb88eaee6e82330cd79
|
|
name: 'Runner [{#RUNNER_NAME}]: Busy'
|
|
type: DEPENDENT
|
|
key: 'github.repo.runners.busy[{#RUNNER_NAME}]'
|
|
delay: '0'
|
|
trends: '0'
|
|
description: 'Indicates whether the runner is currently executing a job.'
|
|
valuemap:
|
|
name: Boolean
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.data[?(@.id == "{#RUNNER_ID}")].busy.first()'
|
|
- type: BOOL_TO_DECIMAL
|
|
parameters:
|
|
- ''
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: github.repo.runners.get
|
|
tags:
|
|
- tag: component
|
|
value: runner
|
|
- tag: os
|
|
value: '{#RUNNER_OS}'
|
|
- tag: runner
|
|
value: '{#RUNNER_NAME}'
|
|
- uuid: 7594ae484e72433ca4259bebc9044031
|
|
name: 'Runner [{#RUNNER_NAME}]: Online'
|
|
type: DEPENDENT
|
|
key: 'github.repo.runners.online[{#RUNNER_NAME}]'
|
|
delay: '0'
|
|
trends: '0'
|
|
description: 'Indicates whether the runner is connected to GitHub and is ready to execute jobs.'
|
|
valuemap:
|
|
name: Boolean
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.data[?(@.id == "{#RUNNER_ID}")].status.first()'
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
const idx = [
|
|
'offline',
|
|
'online'
|
|
].indexOf(value);
|
|
|
|
return idx !== -1 ? idx : 10;
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: github.repo.runners.get
|
|
tags:
|
|
- tag: component
|
|
value: runner
|
|
- tag: os
|
|
value: '{#RUNNER_OS}'
|
|
- tag: runner
|
|
value: '{#RUNNER_NAME}'
|
|
trigger_prototypes:
|
|
- uuid: 3759039884e6486fb92f2a5abf7b1133
|
|
expression: 'last(/GitHub repository by HTTP/github.repo.runners.online[{#RUNNER_NAME}],#2)=1 and last(/GitHub repository by HTTP/github.repo.runners.online[{#RUNNER_NAME}])=0'
|
|
name: 'GitHub: Runner [{#RUNNER_NAME}]: The runner has become offline'
|
|
priority: WARNING
|
|
description: 'The runner was online previously, but is currently not connected to GitHub. This could be because the machine is offline, the self-hosted runner application is not running on the machine, or the self-hosted runner application cannot communicate with GitHub.'
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
master_item:
|
|
key: github.repo.runners.get
|
|
lld_macro_paths:
|
|
- lld_macro: '{#RUNNER_ID}'
|
|
path: $.id
|
|
- lld_macro: '{#RUNNER_NAME}'
|
|
path: $.name
|
|
- lld_macro: '{#RUNNER_OS}'
|
|
path: $.os
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data
|
|
error_handler: DISCARD_VALUE
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
var runners = JSON.parse(value);
|
|
|
|
result = runners.map(function (runner) {
|
|
return {
|
|
'name': runner.name,
|
|
'id': runner.id,
|
|
'os': runner.os
|
|
};
|
|
});
|
|
|
|
return JSON.stringify(result);
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
- uuid: df2e23b12f914d7d89c182ff451da054
|
|
name: 'Workflow discovery'
|
|
type: DEPENDENT
|
|
key: github.repo.workflows.discovery
|
|
delay: '0'
|
|
filter:
|
|
evaltype: AND
|
|
conditions:
|
|
- macro: '{#WORKFLOW_NAME}'
|
|
value: '{$GITHUB.WORKFLOW.NAME.MATCHES}'
|
|
formulaid: A
|
|
- macro: '{#WORKFLOW_NAME}'
|
|
value: '{$GITHUB.WORKFLOW.NAME.NOT_MATCHES}'
|
|
operator: NOT_MATCHES_REGEX
|
|
formulaid: B
|
|
- macro: '{#WORKFLOW_STATE}'
|
|
value: '{$GITHUB.WORKFLOW.STATE.MATCHES}'
|
|
formulaid: C
|
|
- macro: '{#WORKFLOW_STATE}'
|
|
value: '{$GITHUB.WORKFLOW.STATE.NOT_MATCHES}'
|
|
operator: NOT_MATCHES_REGEX
|
|
formulaid: D
|
|
description: |
|
|
Discovers repository workflows. By default, only the active workflows are discovered.
|
|
|
|
Information about endpoint:
|
|
https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#list-repository-workflows
|
|
item_prototypes:
|
|
- uuid: f9941fc67aca404ebd4eddd80d6066cb
|
|
name: 'Workflow [{#WORKFLOW_NAME}]: Last run conclusion'
|
|
type: DEPENDENT
|
|
key: 'github.repo.workflows.last_run.conclusion[{#WORKFLOW_NAME}]'
|
|
delay: '0'
|
|
trends: '0'
|
|
description: |
|
|
The conclusion of the last workflow run. Possible values:
|
|
|
|
0 - success
|
|
1 - failure
|
|
2 - neutral
|
|
3 - cancelled
|
|
4 - skipped
|
|
5 - timed_out
|
|
6 - action_required
|
|
10 - unknown
|
|
valuemap:
|
|
name: 'Workflow run conclusion'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.conclusion
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
if (value !== 'null') {
|
|
const idx = [
|
|
'success',
|
|
'failure',
|
|
'neutral',
|
|
'cancelled',
|
|
'skipped',
|
|
'timed_out',
|
|
'action_required',
|
|
].indexOf(value);
|
|
|
|
return idx !== -1 ? idx : 10;
|
|
}
|
|
|
|
return null;
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: 'github.repo.workflows.last_run.get[{#WORKFLOW_NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: health
|
|
- tag: component
|
|
value: workflow
|
|
- tag: workflow
|
|
value: '{#WORKFLOW_NAME}'
|
|
trigger_prototypes:
|
|
- uuid: 4a32968c1bf14ac8a47f8f398ce43ea3
|
|
expression: 'last(/GitHub repository by HTTP/github.repo.workflows.last_run.conclusion[{#WORKFLOW_NAME}])=1'
|
|
name: 'GitHub: Workflow [{#WORKFLOW_NAME}]: The workflow has failed'
|
|
priority: WARNING
|
|
description: 'The last workflow run has returned a "failure" conclusion.'
|
|
tags:
|
|
- tag: scope
|
|
value: performance
|
|
- uuid: 8653f8c233af44a7857b8ae58086edf3
|
|
name: 'Workflow [{#WORKFLOW_NAME}]: Last run duration'
|
|
type: DEPENDENT
|
|
key: 'github.repo.workflows.last_run.duration[{#WORKFLOW_NAME}]'
|
|
delay: '0'
|
|
units: s
|
|
description: 'The duration of the last workflow run.'
|
|
preprocessing:
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
const data = JSON.parse(value);
|
|
|
|
const start_date = Math.floor(new Date(data.run_started_at) / 1000),
|
|
update_date = Math.floor(new Date(data.updated_at) / 1000);
|
|
|
|
return (update_date - start_date);
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: 'github.repo.workflows.last_run.get[{#WORKFLOW_NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: workflow
|
|
- tag: workflow
|
|
value: '{#WORKFLOW_NAME}'
|
|
- uuid: 32311fa69236401388321fad4ae183d6
|
|
name: 'Workflow [{#WORKFLOW_NAME}]: Get last run'
|
|
type: SCRIPT
|
|
key: 'github.repo.workflows.last_run.get[{#WORKFLOW_NAME}]'
|
|
delay: '{$GITHUB.INTERVAL:"get_last_run:{#WORKFLOW_NAME}"}'
|
|
history: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var github = {
|
|
params: {},
|
|
|
|
setParams: function (params, required) {
|
|
required = required || [];
|
|
required.concat(['api_url', 'user_agent', 'api_version', 'repo_owner', 'repo_name', 'pagination_required', 'api_token']).forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined'
|
|
|| params[field] === '') {
|
|
throw 'Required parameter is not set: "' + field + '".';
|
|
}
|
|
});
|
|
|
|
github.params = params;
|
|
|
|
if (typeof github.params.api_url === 'string' && !github.params.api_url.endsWith('/')) {
|
|
github.params.api_url += '/';
|
|
}
|
|
|
|
github.tls = new CTlsConfig(params.tls_verify);
|
|
github.tls.checkURL(github.params.api_url);
|
|
},
|
|
|
|
apiRequest: function (url, pagination_required) {
|
|
const next_pattern = /<([^>]+)>;\s*rel="next"/i;
|
|
var request = new HttpRequest(github.tls.options),
|
|
response,
|
|
headers,
|
|
final_data = {
|
|
headers: {},
|
|
data: []
|
|
};
|
|
|
|
pagination_required = (typeof pagination_required !== 'undefined') ? pagination_required : 'true';
|
|
|
|
request.addHeader('User-Agent: ' + github.params.user_agent);
|
|
request.addHeader('Accept: application/vnd.github+json');
|
|
request.addHeader('X-GitHub-Api-Version: ' + github.params.api_version);
|
|
request.addHeader('Authorization: Bearer ' + github.params.api_token);
|
|
|
|
if (typeof github.params.http_proxy !== 'undefined' && github.params.http_proxy !== '') {
|
|
request.setProxy(github.params.http_proxy);
|
|
Zabbix.log(4, '[ GitHub Repo ] Using HTTP proxy: ' + github.params.http_proxy);
|
|
}
|
|
|
|
while (url) {
|
|
Zabbix.log(4, '[ GitHub Repo ] Sending request: ' + url);
|
|
|
|
response = request.get(url);
|
|
|
|
Zabbix.log(4, '[ GitHub Repo ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from API. Check debug log for more information.';
|
|
}
|
|
|
|
var parsed_data = github.parseData(response);
|
|
final_data.data = final_data.data.concat(parsed_data);
|
|
|
|
headers = request.getHeaders();
|
|
|
|
var link_header = github.getHeader(headers, 'Link');
|
|
url = ((link_header || '').match(next_pattern) || [])[1];
|
|
|
|
if (pagination_required === 'false') {
|
|
url = '';
|
|
}
|
|
}
|
|
|
|
final_data.headers = request.getHeaders();
|
|
|
|
delete request;
|
|
|
|
return final_data;
|
|
},
|
|
|
|
parseData: function (response_data) {
|
|
if (!response_data) {
|
|
return [];
|
|
}
|
|
|
|
const normalization_required = "total_count" in response_data && !("url" in response_data);
|
|
if (!normalization_required) return response_data;
|
|
|
|
delete response_data.incomplete_results;
|
|
delete response_data.repository_selection;
|
|
delete response_data.total_count;
|
|
|
|
const namespaceKey = Object.keys(response_data)[0];
|
|
response_data = response_data[namespaceKey];
|
|
|
|
return response_data;
|
|
},
|
|
|
|
itemsCount: function (response_data) {
|
|
const last_page_number = /<[^>]+page=(\d+)>;\s*rel="last"/i;
|
|
|
|
if (response_data.headers.link){
|
|
return response_data.headers.link.match(last_page_number)[1];
|
|
}
|
|
|
|
return response_data.data.length;
|
|
},
|
|
|
|
getHeader: function (headers, name) {
|
|
if (!headers || typeof headers !== 'object') {
|
|
return null;
|
|
}
|
|
|
|
var target = name.toLowerCase();
|
|
|
|
for (var key in headers) {
|
|
if (key.toLowerCase() === target) {
|
|
return headers[key];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
try {
|
|
github.setParams(JSON.parse(value), ['api_query']);
|
|
|
|
var result = github.apiRequest(github.params.api_url + github.params.api_query + '?' + github.params.query_params || '', github.params.pagination_required);
|
|
|
|
return JSON.stringify(result);
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ GitHub Repo ] ERROR: ' + error);
|
|
return JSON.stringify({ error: error });
|
|
}
|
|
description: |
|
|
Get the data about the last workflow run.
|
|
|
|
Information about endpoint:
|
|
https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow
|
|
preprocessing:
|
|
- type: CHECK_REGEX_ERROR
|
|
parameters:
|
|
- 'API rate limit exceeded'
|
|
- \0
|
|
error_handler: DISCARD_VALUE
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data.first()
|
|
timeout: '{$GITHUB.TIMEOUT:"get_last_run:{#WORKFLOW_NAME}"}'
|
|
parameters:
|
|
- name: api_query
|
|
value: 'repos/{$GITHUB.REPO.OWNER}/{$GITHUB.REPO.NAME}/actions/workflows/{#WORKFLOW_ID}/runs'
|
|
- name: api_token
|
|
value: '{$GITHUB.API.TOKEN}'
|
|
- name: api_url
|
|
value: '{$GITHUB.API.URL}'
|
|
- name: api_version
|
|
value: '{$GITHUB.API_VERSION}'
|
|
- name: http_proxy
|
|
value: '{$GITHUB.HTTP_PROXY}'
|
|
- name: pagination_required
|
|
value: 'false'
|
|
- name: query_params
|
|
value: per_page=1
|
|
- name: repo_name
|
|
value: '{$GITHUB.REPO.NAME}'
|
|
- name: repo_owner
|
|
value: '{$GITHUB.REPO.OWNER}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GitHub"}'
|
|
- name: user_agent
|
|
value: '{$GITHUB.USER_AGENT}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- tag: component
|
|
value: workflow
|
|
- tag: workflow
|
|
value: '{#WORKFLOW_NAME}'
|
|
- uuid: f8bebdb8345b41c48cfd7be9554d82bf
|
|
name: 'Workflow [{#WORKFLOW_NAME}]: Last run start date'
|
|
type: DEPENDENT
|
|
key: 'github.repo.workflows.last_run.start_date[{#WORKFLOW_NAME}]'
|
|
delay: '0'
|
|
trends: '0'
|
|
units: unixtime
|
|
description: 'The date when the last workflow run was started.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.run_started_at
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- 'return Math.floor(new Date(value) / 1000);'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: 'github.repo.workflows.last_run.get[{#WORKFLOW_NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: workflow
|
|
- tag: workflow
|
|
value: '{#WORKFLOW_NAME}'
|
|
- uuid: e23ba9f5d20541d594748d01491a7ea7
|
|
name: 'Workflow [{#WORKFLOW_NAME}]: Last run status'
|
|
type: DEPENDENT
|
|
key: 'github.repo.workflows.last_run.status[{#WORKFLOW_NAME}]'
|
|
delay: '0'
|
|
trends: '0'
|
|
description: |
|
|
The status of the last workflow run. Possible values:
|
|
|
|
0 - queued
|
|
1 - in_progress
|
|
2 - completed
|
|
10 - unknown
|
|
valuemap:
|
|
name: 'Workflow run status'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.status
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
const idx = [
|
|
'queued',
|
|
'in_progress',
|
|
'completed'
|
|
].indexOf(value);
|
|
|
|
return idx !== -1 ? idx : 10;
|
|
master_item:
|
|
key: 'github.repo.workflows.last_run.get[{#WORKFLOW_NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: health
|
|
- tag: component
|
|
value: workflow
|
|
- tag: workflow
|
|
value: '{#WORKFLOW_NAME}'
|
|
trigger_prototypes:
|
|
- uuid: d89658cb7d8c4b75a8f526dee6dcf43f
|
|
expression: 'last(/GitHub repository by HTTP/github.repo.workflows.last_run.status[{#WORKFLOW_NAME}])=1 and changecount(/GitHub repository by HTTP/github.repo.workflows.last_run.status[{#WORKFLOW_NAME}],{$GITHUB.WORKFLOW.STATUS.IN_PROGRESS.THRESH:"workflow_in_progress:{#WORKFLOW_NAME}"})=0'
|
|
name: 'GitHub: Workflow [{#WORKFLOW_NAME}]: The workflow has been in progress for too long'
|
|
event_name: 'GitHub: Workflow [{#WORKFLOW_NAME}]: The workflow has been in progress for too long (over {$GITHUB.WORKFLOW.STATUS.IN_PROGRESS.THRESH:"workflow_in_progress:{#WORKFLOW_NAME}"})'
|
|
priority: WARNING
|
|
description: 'The last workflow run has been in the "in_progress" status for too long. The default threshold is provided as an example and can be adjusted for relevant workflows with context macros.'
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- tag: scope
|
|
value: performance
|
|
- uuid: f98d0332c53a453bb737f436a4f0d2c0
|
|
expression: 'last(/GitHub repository by HTTP/github.repo.workflows.last_run.status[{#WORKFLOW_NAME}])=0 and changecount(/GitHub repository by HTTP/github.repo.workflows.last_run.status[{#WORKFLOW_NAME}],{$GITHUB.WORKFLOW.STATUS.QUEUED.THRESH:"workflow_queued:{#WORKFLOW_NAME}"})=0'
|
|
name: 'GitHub: Workflow [{#WORKFLOW_NAME}]: The workflow has been in the queue for too long'
|
|
event_name: 'GitHub: Workflow [{#WORKFLOW_NAME}]: The workflow has been in the queue for too long (over {$GITHUB.WORKFLOW.STATUS.QUEUED.THRESH:"workflow_queued:{#WORKFLOW_NAME}"})'
|
|
priority: WARNING
|
|
description: 'The last workflow run has been in the "queued" status for too long. This may mean that it has failed to be assigned to a runner. The default threshold is provided as an example and can be adjusted for relevant workflows with context macros.'
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- tag: scope
|
|
value: performance
|
|
- uuid: a187f9ea480341288b422168f6345784
|
|
name: 'Workflow [{#WORKFLOW_NAME}]: Last run update date'
|
|
type: DEPENDENT
|
|
key: 'github.repo.workflows.last_run.update_date[{#WORKFLOW_NAME}]'
|
|
delay: '0'
|
|
trends: '0'
|
|
units: unixtime
|
|
description: 'The date when the last workflow run was updated.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.updated_at
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- 'return Math.floor(new Date(value) / 1000);'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
master_item:
|
|
key: 'github.repo.workflows.last_run.get[{#WORKFLOW_NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: workflow
|
|
- tag: workflow
|
|
value: '{#WORKFLOW_NAME}'
|
|
master_item:
|
|
key: github.repo.workflows.get
|
|
lld_macro_paths:
|
|
- lld_macro: '{#WORKFLOW_ID}'
|
|
path: $.id
|
|
- lld_macro: '{#WORKFLOW_NAME}'
|
|
path: $.name
|
|
- lld_macro: '{#WORKFLOW_STATE}'
|
|
path: $.state
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.data
|
|
tags:
|
|
- tag: class
|
|
value: application
|
|
- tag: target
|
|
value: github
|
|
- tag: target
|
|
value: repository
|
|
macros:
|
|
- macro: '{$GITHUB.API.TOKEN}'
|
|
type: SECRET_TEXT
|
|
description: 'Set the access token here.'
|
|
- macro: '{$GITHUB.API.URL}'
|
|
value: 'https://api.github.com/'
|
|
description: 'Set the API URL here.'
|
|
- macro: '{$GITHUB.API_VERSION}'
|
|
value: '2022-11-28'
|
|
description: 'The API version that is used in headers for HTTP requests.'
|
|
- macro: '{$GITHUB.BRANCH.NAME.MATCHES}'
|
|
value: .+
|
|
description: 'The repository branch name regex filter to use in branch-related metric discovery - for including.'
|
|
- macro: '{$GITHUB.BRANCH.NAME.NOT_MATCHES}'
|
|
value: CHANGE_IF_NEEDED
|
|
description: 'The repository branch name regex filter to use in branch-related metric discovery - for excluding.'
|
|
- macro: '{$GITHUB.HTTP_PROXY}'
|
|
description: 'The HTTP proxy for script items (set if needed). If the macro is empty, then no proxy is used.'
|
|
- macro: '{$GITHUB.INTERVAL}'
|
|
value: 1m
|
|
description: 'The update interval for the script items that retrieve data from the API. Can be used with context if needed (check the context values in relevant items).'
|
|
- macro: '{$GITHUB.INTERVAL:"get_(branches|workflows)"}'
|
|
value: 1h
|
|
description: 'The update interval for the script items that retrieve the branches and workflows. Used only for related metric discovery.'
|
|
- macro: '{$GITHUB.INTERVAL:"get_repo"}'
|
|
value: 15m
|
|
description: 'The update interval for the script item that retrieves the repository information.'
|
|
- macro: '{$GITHUB.INTERVAL:"get_runners"}'
|
|
value: 15m
|
|
description: 'The update interval for the script item that retrieves the information about self-hosted runners.'
|
|
- macro: '{$GITHUB.INTERVAL:regex:"get_(tags|releases|issues)_count"}'
|
|
value: 1h
|
|
description: 'The update interval for the script items that retrieve the number of tags, releases, issues, and pull requests (total, open, closed).'
|
|
- macro: '{$GITHUB.INTERVAL:regex:"get_commits_count:.+"}'
|
|
value: 1h
|
|
description: 'The update interval for the script items that retrieve the commits count in discovered branches.'
|
|
- macro: '{$GITHUB.INTERVAL:regex:"get_last_run:.+"}'
|
|
value: 15m
|
|
description: 'The update interval for the script items that retrieve the information about the last workflow run results.'
|
|
- macro: '{$GITHUB.REPO.NAME}'
|
|
value: '<SET THE REPO NAME>'
|
|
description: 'Set the repository name here.'
|
|
- macro: '{$GITHUB.REPO.OWNER}'
|
|
value: '<SET THE REPO OWNER>'
|
|
description: 'Set the repository owner here.'
|
|
- macro: '{$GITHUB.REQUESTS.UTIL.HIGH}'
|
|
value: '90'
|
|
description: 'The threshold percentage of utilized API requests in a High trigger expression.'
|
|
- macro: '{$GITHUB.REQUESTS.UTIL.WARN}'
|
|
value: '80'
|
|
description: 'The threshold percentage of utilized API requests in a Warning trigger expression.'
|
|
- macro: '{$GITHUB.RESULTS_PER_PAGE}'
|
|
value: '100'
|
|
description: 'The number of results to fetch per page. Can be used with context and adjusted if needed (check the context values in script parameters of relevant items).'
|
|
- macro: '{$GITHUB.RUNNER.NAME.MATCHES}'
|
|
value: .+
|
|
description: 'The repository self-hosted runner name regex filter to use in discovering metrics related to the self-hosted runner - for including.'
|
|
- macro: '{$GITHUB.RUNNER.NAME.NOT_MATCHES}'
|
|
value: CHANGE_IF_NEEDED
|
|
description: 'The repository self-hosted runner name regex filter to use in discovering metrics related to the self-hosted runner - for excluding.'
|
|
- macro: '{$GITHUB.RUNNER.OS.MATCHES}'
|
|
value: .+
|
|
description: 'The repository self-hosted runner OS regex filter to use in discovering metrics related to the self-hosted runner - for including.'
|
|
- macro: '{$GITHUB.RUNNER.OS.NOT_MATCHES}'
|
|
value: CHANGE_IF_NEEDED
|
|
description: 'The repository self-hosted runner OS regex filter to use in discovering metrics related to the self-hosted runner - for excluding.'
|
|
- macro: '{$GITHUB.TIMEOUT}'
|
|
value: 15s
|
|
description: 'The timeout threshold for the script items that retrieve data from the API. Can be used with context if needed (check the context values in relevant items).'
|
|
- macro: '{$GITHUB.USER_AGENT}'
|
|
value: Zabbix/7.0
|
|
description: 'The user agent that is used in headers for HTTP requests.'
|
|
- macro: '{$GITHUB.WORKFLOW.NAME.MATCHES}'
|
|
value: .+
|
|
description: 'The repository workflow name regex filter to use in workflow-related metric discovery - for including.'
|
|
- macro: '{$GITHUB.WORKFLOW.NAME.NOT_MATCHES}'
|
|
value: CHANGE_IF_NEEDED
|
|
description: 'The repository workflow name regex filter to use in workflow-related metric discovery - for excluding.'
|
|
- macro: '{$GITHUB.WORKFLOW.STATE.MATCHES}'
|
|
value: active
|
|
description: 'The repository workflow state regex filter to use in workflow-related metric discovery - for including.'
|
|
- macro: '{$GITHUB.WORKFLOW.STATE.NOT_MATCHES}'
|
|
value: CHANGE_IF_NEEDED
|
|
description: 'The repository workflow state regex filter to use in workflow-related metric discovery - for excluding.'
|
|
- macro: '{$GITHUB.WORKFLOW.STATUS.IN_PROGRESS.THRESH}'
|
|
value: 24h
|
|
description: 'The time threshold used in the trigger of a workflow run that has been in the queue for too long. Can be used with context if needed.'
|
|
- macro: '{$GITHUB.WORKFLOW.STATUS.QUEUED.THRESH}'
|
|
value: 1h
|
|
description: 'The time threshold used in the trigger of a workflow run that has been in the queue for too long. Can be used with context if needed.'
|
|
- macro: '{$HTTP.TLS.VERIFY}'
|
|
value: full
|
|
description: 'TLS certificate verification for script items: "none" - disabled, "peer" - verify the certificate chain and expiration, "full" - full verification. Any other value enables full verification. To override the setting for this template only, define the macro with the context "GitHub repository", e.g. {$HTTP.TLS.VERIFY:"GitHub repository"}.'
|
|
dashboards:
|
|
- uuid: 09870c778f4740da8430b1383225b2c6
|
|
name: 'Repository overview'
|
|
auto_start: 'NO'
|
|
pages:
|
|
- name: 'Repository statistics'
|
|
widgets:
|
|
- type: item
|
|
name: Size
|
|
width: '10'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: STRING
|
|
name: description
|
|
value: Size
|
|
- type: INTEGER
|
|
name: desc_bold
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.repository.size
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: units_bold
|
|
value: '0'
|
|
- type: item
|
|
name: Releases
|
|
'y': '2'
|
|
width: '10'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: STRING
|
|
name: description
|
|
value: Releases
|
|
- type: INTEGER
|
|
name: desc_bold
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.releases.count
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: units_show
|
|
value: '0'
|
|
- type: item
|
|
name: Stargazers
|
|
'y': '4'
|
|
width: '10'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: STRING
|
|
name: description
|
|
value: Stargazers
|
|
- type: INTEGER
|
|
name: desc_bold
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.repository.stargazers
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: units_show
|
|
value: '0'
|
|
- type: item
|
|
name: 'Open issues'
|
|
'y': '6'
|
|
width: '10'
|
|
height: '4'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: STRING
|
|
name: description
|
|
value: 'Open issues'
|
|
- type: INTEGER
|
|
name: desc_bold
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.issues.open
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.2
|
|
value: '4'
|
|
- type: INTEGER
|
|
name: units_show
|
|
value: '0'
|
|
- type: item
|
|
name: 'Open PRs'
|
|
'y': '10'
|
|
width: '10'
|
|
height: '4'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: STRING
|
|
name: description
|
|
value: 'Open PRs'
|
|
- type: INTEGER
|
|
name: desc_bold
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.pr.open
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.2
|
|
value: '4'
|
|
- type: INTEGER
|
|
name: units_show
|
|
value: '0'
|
|
- type: svggraph
|
|
name: 'Requests limit usage'
|
|
'y': '14'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: STRING
|
|
name: ds.0.color.0
|
|
value: FF465C
|
|
- type: STRING
|
|
name: ds.0.color.1
|
|
value: 4CAF50
|
|
- type: INTEGER
|
|
name: ds.0.dataset_type
|
|
value: '0'
|
|
- type: ITEM
|
|
name: ds.0.itemids.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.requests.limit
|
|
- type: ITEM
|
|
name: ds.0.itemids.1
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.requests.used
|
|
- type: INTEGER
|
|
name: ds.0.missingdatafunc
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: ds.0.width
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: legend_lines
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: legend_statistic
|
|
value: '1'
|
|
- type: STRING
|
|
name: reference
|
|
value: RHXEN
|
|
- type: INTEGER
|
|
name: righty
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: working_time
|
|
value: '1'
|
|
- type: graphprototype
|
|
'y': '19'
|
|
width: '72'
|
|
height: '5'
|
|
fields:
|
|
- type: INTEGER
|
|
name: columns
|
|
value: '1'
|
|
- type: GRAPH_PROTOTYPE
|
|
name: graphid.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
name: 'Health percentage score{#SINGLETON}'
|
|
- type: STRING
|
|
name: reference
|
|
value: QXEXC
|
|
- type: item
|
|
name: Forks
|
|
x: '10'
|
|
width: '9'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: STRING
|
|
name: description
|
|
value: Forks
|
|
- type: INTEGER
|
|
name: desc_bold
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.repository.forks.count
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: units_show
|
|
value: '0'
|
|
- type: item
|
|
name: Tags
|
|
x: '10'
|
|
'y': '2'
|
|
width: '9'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: STRING
|
|
name: description
|
|
value: Tags
|
|
- type: INTEGER
|
|
name: desc_bold
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.tags.count
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: units_show
|
|
value: '0'
|
|
- type: item
|
|
name: Watchers
|
|
x: '10'
|
|
'y': '4'
|
|
width: '9'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: STRING
|
|
name: description
|
|
value: Watchers
|
|
- type: INTEGER
|
|
name: desc_bold
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.repository.watchers
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: units_show
|
|
value: '0'
|
|
- type: svggraph
|
|
name: Issues
|
|
x: '10'
|
|
'y': '6'
|
|
width: '62'
|
|
height: '4'
|
|
fields:
|
|
- type: STRING
|
|
name: ds.0.color.0
|
|
value: FFD54F
|
|
- type: STRING
|
|
name: ds.0.color.1
|
|
value: FF465C
|
|
- type: STRING
|
|
name: ds.0.color.2
|
|
value: 4CAF50
|
|
- type: INTEGER
|
|
name: ds.0.dataset_type
|
|
value: '0'
|
|
- type: ITEM
|
|
name: ds.0.itemids.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.issues.total
|
|
- type: ITEM
|
|
name: ds.0.itemids.1
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.issues.open
|
|
- type: ITEM
|
|
name: ds.0.itemids.2
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.issues.closed
|
|
- type: INTEGER
|
|
name: ds.0.missingdatafunc
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: ds.0.width
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: legend_lines
|
|
value: '3'
|
|
- type: INTEGER
|
|
name: legend_statistic
|
|
value: '1'
|
|
- type: STRING
|
|
name: reference
|
|
value: NDLZO
|
|
- type: INTEGER
|
|
name: righty
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: working_time
|
|
value: '1'
|
|
- type: svggraph
|
|
name: PRs
|
|
x: '10'
|
|
'y': '10'
|
|
width: '62'
|
|
height: '4'
|
|
fields:
|
|
- type: STRING
|
|
name: ds.0.color.0
|
|
value: FFD54F
|
|
- type: STRING
|
|
name: ds.0.color.1
|
|
value: FF465C
|
|
- type: STRING
|
|
name: ds.0.color.2
|
|
value: 4CAF50
|
|
- type: INTEGER
|
|
name: ds.0.dataset_type
|
|
value: '0'
|
|
- type: ITEM
|
|
name: ds.0.itemids.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.pr.total
|
|
- type: ITEM
|
|
name: ds.0.itemids.1
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.pr.open
|
|
- type: ITEM
|
|
name: ds.0.itemids.2
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.pr.closed
|
|
- type: INTEGER
|
|
name: ds.0.missingdatafunc
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: ds.0.width
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: legend_lines
|
|
value: '3'
|
|
- type: INTEGER
|
|
name: legend_statistic
|
|
value: '1'
|
|
- type: STRING
|
|
name: reference
|
|
value: SCQDP
|
|
- type: INTEGER
|
|
name: righty
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: working_time
|
|
value: '1'
|
|
- type: itemnavigator
|
|
name: Branches
|
|
x: '19'
|
|
width: '12'
|
|
height: '6'
|
|
fields:
|
|
- type: STRING
|
|
name: items.0
|
|
value: 'Branch [*]: Number of commits'
|
|
- type: STRING
|
|
name: reference
|
|
value: YXPRE
|
|
- type: item
|
|
name: 'Number of commits'
|
|
x: '31'
|
|
width: '17'
|
|
height: '6'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: STRING
|
|
name: itemid._reference
|
|
value: YXPRE._itemid
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: svggraph
|
|
name: 'Requests limit utilization, in %'
|
|
x: '36'
|
|
'y': '14'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: STRING
|
|
name: ds.0.color.0
|
|
value: 4CAF50
|
|
- type: INTEGER
|
|
name: ds.0.dataset_type
|
|
value: '0'
|
|
- type: ITEM
|
|
name: ds.0.itemids.0
|
|
value:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.requests.util
|
|
- type: INTEGER
|
|
name: ds.0.missingdatafunc
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: ds.0.width
|
|
value: '2'
|
|
- type: STRING
|
|
name: lefty_max
|
|
value: '100'
|
|
- type: STRING
|
|
name: lefty_min
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: legend_statistic
|
|
value: '1'
|
|
- type: STRING
|
|
name: reference
|
|
value: MTFRC
|
|
- type: INTEGER
|
|
name: righty
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: simple_triggers
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: working_time
|
|
value: '1'
|
|
- type: problems
|
|
x: '48'
|
|
width: '24'
|
|
height: '6'
|
|
fields:
|
|
- type: STRING
|
|
name: reference
|
|
value: UDUDX
|
|
- name: 'Self-hosted runners'
|
|
widgets:
|
|
- type: honeycomb
|
|
name: 'Runners online'
|
|
width: '72'
|
|
height: '7'
|
|
fields:
|
|
- type: STRING
|
|
name: items.0
|
|
value: 'Runner [*]: Online'
|
|
- type: STRING
|
|
name: primary_label
|
|
value: '{ITEM.NAME}'
|
|
- type: STRING
|
|
name: reference
|
|
value: YSQRZ
|
|
- type: INTEGER
|
|
name: secondary_label_decimal_places
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: secondary_label_units_show
|
|
value: '0'
|
|
- type: STRING
|
|
name: thresholds.0.color
|
|
value: FF465C
|
|
- type: STRING
|
|
name: thresholds.0.threshold
|
|
value: '0'
|
|
- type: STRING
|
|
name: thresholds.1.color
|
|
value: 4CAF50
|
|
- type: STRING
|
|
name: thresholds.1.threshold
|
|
value: '1'
|
|
- type: honeycomb
|
|
name: 'Runners busy'
|
|
'y': '7'
|
|
width: '72'
|
|
height: '7'
|
|
fields:
|
|
- type: STRING
|
|
name: items.0
|
|
value: 'Runner [*]: Busy'
|
|
- type: STRING
|
|
name: primary_label
|
|
value: '{ITEM.NAME}'
|
|
- type: STRING
|
|
name: reference
|
|
value: ZYVGW
|
|
- type: INTEGER
|
|
name: secondary_label_decimal_places
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: secondary_label_units_show
|
|
value: '0'
|
|
- type: STRING
|
|
name: thresholds.0.color
|
|
value: D2D2D2
|
|
- type: STRING
|
|
name: thresholds.0.threshold
|
|
value: '0'
|
|
- type: STRING
|
|
name: thresholds.1.color
|
|
value: 29B6F6
|
|
- type: STRING
|
|
name: thresholds.1.threshold
|
|
value: '1'
|
|
valuemaps:
|
|
- uuid: 21844e435a364b2f92d675f0967e115a
|
|
name: Boolean
|
|
mappings:
|
|
- value: '0'
|
|
newvalue: 'false'
|
|
- value: '1'
|
|
newvalue: 'true'
|
|
- uuid: 9175771d066042c49ac1583c0e8689c6
|
|
name: 'Workflow run conclusion'
|
|
mappings:
|
|
- value: '0'
|
|
newvalue: success
|
|
- value: '1'
|
|
newvalue: failure
|
|
- value: '2'
|
|
newvalue: neutral
|
|
- value: '3'
|
|
newvalue: cancelled
|
|
- value: '4'
|
|
newvalue: skipped
|
|
- value: '5'
|
|
newvalue: timed_out
|
|
- value: '6'
|
|
newvalue: action_required
|
|
- value: '10'
|
|
newvalue: unknown
|
|
- uuid: 9b86b16774094f5e9c06286b27f6f440
|
|
name: 'Workflow run status'
|
|
mappings:
|
|
- value: '0'
|
|
newvalue: queued
|
|
- value: '1'
|
|
newvalue: in_progress
|
|
- value: '2'
|
|
newvalue: completed
|
|
- value: '10'
|
|
newvalue: unknown
|
|
graphs:
|
|
- uuid: 774218efca844a978b61077f0e253ddf
|
|
name: 'Number of issues'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.issues.total
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.issues.open
|
|
- sortorder: '2'
|
|
color: 00611C
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.issues.closed
|
|
- uuid: a6de9d61e5f74a5f97946792c7c101fe
|
|
name: 'Number of PRs'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.pr.total
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.pr.open
|
|
- sortorder: '2'
|
|
color: 00611C
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.pr.closed
|
|
- uuid: 794cb86105c14f1aab297634292d8b67
|
|
name: 'Number of releases and tags'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.releases.count
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.tags.count
|
|
- uuid: 94173b91d3bf40a6a9188f0efecaabdd
|
|
name: 'Requests limit usage'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.requests.limit
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.requests.used
|
|
- uuid: 7e33e0dd5faa45418defd8e5e7f07e49
|
|
name: 'Requests limit utilization, in %'
|
|
ymin_type_1: FIXED
|
|
ymax_type_1: FIXED
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GitHub repository by HTTP'
|
|
key: github.repo.requests.util
|