zabbix_export: version: '7.0' template_groups: - uuid: c2c162144c2d4c5491c8801193af4945 name: Templates/Cloud templates: - uuid: e8f89476695848e99ba900a5664d290b template: 'Oracle Cloud Object Storage by HTTP' name: 'Oracle Cloud Object Storage by HTTP' description: | This template monitors Oracle Cloud Infrastructure (OCI) object storage resources. This template is not meant to be used independently, but together with Oracle Cloud by HTTP as a template for LLD host prototypes. Read the template documentation prior to using this template. You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback Generated by official Zabbix template tool "Templator" vendor: name: Zabbix version: 7.0-3 groups: - name: Templates/Cloud items: - uuid: 8a216ff99ea84e169ba24305a5501b45 name: 'Client-side error count' type: DEPENDENT key: oci.obj.storage.client.errors delay: '0' value_type: FLOAT description: 'The total number of 4xx errors for requests made in a bucket.' preprocessing: - type: JSONPATH parameters: - $.ClientErrors - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1h master_item: key: oci.obj.storage.metrics.frequent.get tags: - tag: component value: storage - uuid: 3d41eed5ab23438d9f2a87c48bb3def4 name: 'First byte latency time' type: DEPENDENT key: oci.obj.storage.latency.byte delay: '0' value_type: FLOAT units: s description: 'The per-request time measured from the time Object Storage receives the complete request to when Object Storage returns the first byte of the response.' preprocessing: - type: JSONPATH parameters: - $.FirstByteLatency - type: MULTIPLIER parameters: - '0.001' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1h master_item: key: oci.obj.storage.metrics.frequent.get tags: - tag: component value: storage - uuid: a47bb44ccb35489e965432c332bd8892 name: 'Overall latency time' type: DEPENDENT key: oci.obj.storage.latency.overall delay: '0' value_type: FLOAT units: s description: | The per-request time from the first byte received by Object Storage to the last byte sent from Object Storage. preprocessing: - type: JSONPATH parameters: - $.TotalRequestLatency - type: MULTIPLIER parameters: - '0.001' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1h master_item: key: oci.obj.storage.metrics.frequent.get tags: - tag: component value: storage - uuid: 5463c35f2c48408997532001025989fa name: 'Get frequent metrics' type: SCRIPT key: oci.obj.storage.metrics.frequent.get 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; }; } function validateZabbixParams(requiredParams, allParams) { requiredParams.forEach(function (field) { if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') { throw 'Required param is not set: ' + field + '.'; } }); } function OCI(service, action, params) { this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]'; this.tls = new CTlsConfig(params.tls_verify); this.request = new HttpRequest(this.tls.options); this.hash = function (string) { return sha256(string); }; this.sign = function (string) { return sign('sha256', params['private_key'], string); }; this.encode = function (hash) { const hexArr = hash.match(/.{1,2}/g); var uInt8Array = new Uint8Array(hexArr.length); hexArr.forEach(function (hex, idx) { uInt8Array[idx] = parseInt(hex, 16); }); return btoa(uInt8Array); }; this.getDate = function () { const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; const today = new Date(); return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT'; }; this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) { var headers = '(request-target) date host'; const contentTypeHeader = 'content-type: application/json'; const dateHeader = 'date: ' + this.getDate(); const hostHeader = 'host: ' + params['api_host']; const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams; var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader; var reqHeaders = [contentTypeHeader, dateHeader]; if (httpMethod === 'post') { var body = JSON.stringify({ 'namespace': namespace, 'query': mql }); headers = headers + ' x-content-sha256 content-type content-length'; const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body)); const bodyLengthHeader = 'content-length: ' + body.length; signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader; reqHeaders.push(bodyHeader, bodyLengthHeader); } const signature = this.encode(this.sign(signingString)); reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"'); for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) { this.request.addHeader(reqHeaders[header]); } if (params['http_proxy']) { this.request.setProxy(params['http_proxy']); Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']); } if (httpMethod === 'post') { var apiRateLimitExceeded = false; do { const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body); try { if (JSON.parse(response)['code'] === 'TooManyRequests') { apiRateLimitExceeded = true; Zabbix.sleep(1000); } else { apiRateLimitExceeded = false; } } catch (error) { Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response)); throw 'Could not parse the response. See logs for more information.'; } } while (apiRateLimitExceeded); } else { const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams); } this.request.clearHeader(); if (this.request.getStatus() === parseInt(params['http_status_code'])) { return response; } else { Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus()); throw 'Unexpected HTTP response code: ' + this.request.getStatus(); } }; this.extractData = function (httpMethod, data, keys, compartment) { try { data = JSON.parse(data); } catch (error) { Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data); throw 'Could not parse received JSON object. See logs for more information.'; } if (typeof keys == 'object') { var returnBuffer = []; for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) { var objectBuffer = {}; for (var key = 0, keysLength = keys.length; key < keysLength; key++) { if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) { objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]]; } else { Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj])); throw 'Received an unexpected JSON object. See logs for more information.'; } } if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment; returnBuffer.push(objectBuffer); } return returnBuffer; } try { if (httpMethod === 'get') { return data[keys]; } else { if (data.length === 0) { return 0; } data = data[0][keys]; return data[data.length - 1]['value']; } } catch (error) { Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data)); throw 'Could not find required key in JSON object. See logs for more information.'; } }; } function buildMql(id, metrics, defaultStatistic, resourceType) { resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType; this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.'; for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) { const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic])); metrics[i] = [metric[0], this.query + metric[1]]; } } const params = JSON.parse(value); validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'bucket_name', 'http_status_code', 'req_interval', 'compartment_id'], params); var oci = new OCI('Object storage', 'Get metrics ' + params['req_interval'] + 'm', params); const metrics = [ 'AllRequests', 'ClientErrors', 'FirstByteLatency', 'PostRequests', 'PutRequests', 'TotalRequestLatency' ]; buildMql(params['bucket_name'], metrics, 'mean', 'resourceDisplayName'); var result = {}; for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) { result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_objectstorage'), 'aggregatedDatapoints'); } return JSON.stringify(result); description: 'Gets all metrics related to a specific bucket that have frequent update time (100 milliseconds).' timeout: 30s parameters: - name: api_host value: '{$OCI.API.TELEMETRY.HOST}' - name: bucket_name value: '{$OCI.OBJECT.STORAGE.BUCKET}' - name: compartment_id value: '{$OCI.OBJECT.STORAGE.COMPARTMENT.ID}' - name: fingerprint value: '{$OCI.API.FINGERPRINT}' - name: http_proxy value: '{$OCI.HTTP.PROXY}' - name: http_status_code value: '{$OCI.HTTP.RETURN.CODE.OK}' - name: private_key value: '{$OCI.API.PRIVATE.KEY}' - name: req_interval value: '1' - name: tenancy_ocid value: '{$OCI.API.TENANCY}' - name: tls_verify value: '{$HTTP.TLS.VERIFY:"Oracle Cloud Object Storage"}' - name: user_ocid value: '{$OCI.API.USER}' tags: - tag: component value: raw - uuid: 4a12f1c73e8f40be9136a095ad147775 name: 'Get hourly metrics' type: SCRIPT key: oci.obj.storage.metrics.hourly.get delay: 1h 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; }; } function validateZabbixParams(requiredParams, allParams) { requiredParams.forEach(function (field) { if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') { throw 'Required param is not set: ' + field + '.'; } }); } function OCI(service, action, params) { this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]'; this.tls = new CTlsConfig(params.tls_verify); this.request = new HttpRequest(this.tls.options); this.hash = function (string) { return sha256(string); }; this.sign = function (string) { return sign('sha256', params['private_key'], string); }; this.encode = function (hash) { const hexArr = hash.match(/.{1,2}/g); var uInt8Array = new Uint8Array(hexArr.length); hexArr.forEach(function (hex, idx) { uInt8Array[idx] = parseInt(hex, 16); }); return btoa(uInt8Array); }; this.getDate = function () { const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; const today = new Date(); return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT'; }; this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) { var headers = '(request-target) date host'; const contentTypeHeader = 'content-type: application/json'; const dateHeader = 'date: ' + this.getDate(); const hostHeader = 'host: ' + params['api_host']; const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams; var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader; var reqHeaders = [contentTypeHeader, dateHeader]; if (httpMethod === 'post') { var body = JSON.stringify({ 'namespace': namespace, 'query': mql }); headers = headers + ' x-content-sha256 content-type content-length'; const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body)); const bodyLengthHeader = 'content-length: ' + body.length; signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader; reqHeaders.push(bodyHeader, bodyLengthHeader); } const signature = this.encode(this.sign(signingString)); reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"'); for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) { this.request.addHeader(reqHeaders[header]); } if (params['http_proxy']) { this.request.setProxy(params['http_proxy']); Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']); } if (httpMethod === 'post') { var apiRateLimitExceeded = false; do { const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body); try { if (JSON.parse(response)['code'] === 'TooManyRequests') { apiRateLimitExceeded = true; Zabbix.sleep(1000); } else { apiRateLimitExceeded = false; } } catch (error) { Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response)); throw 'Could not parse the response. See logs for more information.'; } } while (apiRateLimitExceeded); } else { const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams); } this.request.clearHeader(); if (this.request.getStatus() === parseInt(params['http_status_code'])) { return response; } else { Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus()); throw 'Unexpected HTTP response code: ' + this.request.getStatus(); } }; this.extractData = function (httpMethod, data, keys, compartment) { try { data = JSON.parse(data); } catch (error) { Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data); throw 'Could not parse received JSON object. See logs for more information.'; } if (typeof keys == 'object') { var returnBuffer = []; for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) { var objectBuffer = {}; for (var key = 0, keysLength = keys.length; key < keysLength; key++) { if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) { objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]]; } else { Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj])); throw 'Received an unexpected JSON object. See logs for more information.'; } } if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment; returnBuffer.push(objectBuffer); } return returnBuffer; } try { if (httpMethod === 'get') { return data[keys]; } else { if (data.length === 0) { return 0; } data = data[0][keys]; return data[data.length - 1]['value']; } } catch (error) { Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data)); throw 'Could not find required key in JSON object. See logs for more information.'; } }; } function buildMql(id, metrics, defaultStatistic, resourceType) { resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType; this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.'; for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) { const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic])); metrics[i] = [metric[0], this.query + metric[1]]; } } const params = JSON.parse(value); validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'bucket_name', 'http_status_code', 'req_interval', 'compartment_id'], params); var oci = new OCI('Object storage', 'Get metrics ' + params['req_interval'] + 'm', params); const metrics = [ 'ObjectCount', 'StoredBytes', 'UncommittedParts' ]; buildMql(params['bucket_name'], metrics, 'mean', 'resourceDisplayName') var result = {}; for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) { result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_objectstorage'), 'aggregatedDatapoints'); } return JSON.stringify(result); description: 'Gets all metrics related to specific bucket that have update time of 1 hour.' timeout: 30s parameters: - name: api_host value: '{$OCI.API.TELEMETRY.HOST}' - name: bucket_name value: '{$OCI.OBJECT.STORAGE.BUCKET}' - name: compartment_id value: '{$OCI.OBJECT.STORAGE.COMPARTMENT.ID}' - name: fingerprint value: '{$OCI.API.FINGERPRINT}' - name: http_proxy value: '{$OCI.HTTP.PROXY}' - name: http_status_code value: '{$OCI.HTTP.RETURN.CODE.OK}' - name: private_key value: '{$OCI.API.PRIVATE.KEY}' - name: req_interval value: '60' - name: tenancy_ocid value: '{$OCI.API.TENANCY}' - name: tls_verify value: '{$HTTP.TLS.VERIFY:"Oracle Cloud Object Storage"}' - name: user_ocid value: '{$OCI.API.USER}' tags: - tag: component value: raw - uuid: 5bb5ba3011e94e43bb1fdc79668c9537 name: 'Get enabled object lifecycle management' type: SCRIPT key: oci.obj.storage.metrics.olm.get delay: 3h 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; }; } function validateZabbixParams(requiredParams, allParams) { requiredParams.forEach(function (field) { if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') { throw 'Required param is not set: ' + field + '.'; } }); } function OCI(service, action, params) { this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]'; this.tls = new CTlsConfig(params.tls_verify); this.request = new HttpRequest(this.tls.options); this.hash = function (string) { return sha256(string); }; this.sign = function (string) { return sign('sha256', params['private_key'], string); }; this.encode = function (hash) { const hexArr = hash.match(/.{1,2}/g); var uInt8Array = new Uint8Array(hexArr.length); hexArr.forEach(function (hex, idx) { uInt8Array[idx] = parseInt(hex, 16); }); return btoa(uInt8Array); }; this.getDate = function () { const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; const today = new Date(); return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT'; }; this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) { var headers = '(request-target) date host'; const contentTypeHeader = 'content-type: application/json'; const dateHeader = 'date: ' + this.getDate(); const hostHeader = 'host: ' + params['api_host']; const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams; var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader; var reqHeaders = [contentTypeHeader, dateHeader]; if (httpMethod === 'post') { var body = JSON.stringify({ 'namespace': namespace, 'query': mql }); headers = headers + ' x-content-sha256 content-type content-length'; const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body)); const bodyLengthHeader = 'content-length: ' + body.length; signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader; reqHeaders.push(bodyHeader, bodyLengthHeader); } const signature = this.encode(this.sign(signingString)); reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"'); for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) { this.request.addHeader(reqHeaders[header]); } if (params['http_proxy']) { this.request.setProxy(params['http_proxy']); Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']); } if (httpMethod === 'post') { var apiRateLimitExceeded = false; do { const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body); try { if (JSON.parse(response)['code'] === 'TooManyRequests') { apiRateLimitExceeded = true; Zabbix.sleep(1000); } else { apiRateLimitExceeded = false; } } catch (error) { Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response)); throw 'Could not parse the response. See logs for more information.'; } } while (apiRateLimitExceeded); } else { const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams); } this.request.clearHeader(); if (this.request.getStatus() === parseInt(params['http_status_code'])) { return response; } else { Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus()); throw 'Unexpected HTTP response code: ' + this.request.getStatus(); } }; this.extractData = function (httpMethod, data, keys, compartment) { try { data = JSON.parse(data); } catch (error) { Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data); throw 'Could not parse received JSON object. See logs for more information.'; } if (typeof keys == 'object') { var returnBuffer = []; for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) { var objectBuffer = {}; for (var key = 0, keysLength = keys.length; key < keysLength; key++) { if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) { objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]]; } else { Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj])); throw 'Received an unexpected JSON object. See logs for more information.'; } } if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment; returnBuffer.push(objectBuffer); } return returnBuffer; } try { if (httpMethod === 'get') { return data[keys]; } else { if (data.length === 0) { return 0; } data = data[0][keys]; return data[data.length - 1]['value']; } } catch (error) { Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data)); throw 'Could not find required key in JSON object. See logs for more information.'; } }; } const params = JSON.parse(value); validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'bucket_name', 'http_status_code', 'req_interval', 'compartment_id'], params); var oci = new OCI('Object storage', 'Get metrics ' + params['req_interval'] + 'm', params); const mql = 'EnabledOLM[' + params['req_interval'] + 'm]{resourceDisplayName=' + params['bucket_name'] + '}.mean()'; return JSON.stringify(oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), mql, 'oci_objectstorage'), 'aggregatedDatapoints')); description: | Indicates whether a bucket has any executable Object Lifecycle Management policies configured. `EnabledOLM` emits: 1 - if policies are configured 0 - if no policies are configured preprocessing: - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1d timeout: 10s parameters: - name: api_host value: '{$OCI.API.TELEMETRY.HOST}' - name: bucket_name value: '{$OCI.OBJECT.STORAGE.BUCKET}' - name: compartment_id value: '{$OCI.OBJECT.STORAGE.COMPARTMENT.ID}' - name: fingerprint value: '{$OCI.API.FINGERPRINT}' - name: http_proxy value: '{$OCI.HTTP.PROXY}' - name: http_status_code value: '{$OCI.HTTP.RETURN.CODE.OK}' - name: private_key value: '{$OCI.API.PRIVATE.KEY}' - name: req_interval value: '180' - name: tenancy_ocid value: '{$OCI.API.TENANCY}' - name: tls_verify value: '{$HTTP.TLS.VERIFY:"Oracle Cloud Object Storage"}' - name: user_ocid value: '{$OCI.API.USER}' tags: - tag: component value: storage triggers: - uuid: 5d9652a8736247c2bcac15cf02012824 expression: 'last(/Oracle Cloud Object Storage by HTTP/oci.obj.storage.metrics.olm.get,#1)<>last(/Oracle Cloud Object Storage by HTTP/oci.obj.storage.metrics.olm.get,#2) and length(last(/Oracle Cloud Object Storage by HTTP/oci.obj.storage.metrics.olm.get))>0' name: 'OCI Object Storage: Object lifecycle management policy has changed' priority: INFO description: 'The object lifecycle management policy configuration has changed.' tags: - tag: scope value: notice - uuid: 867aa1736d4c40a18a4f660023d117f4 name: 'Number of objects' type: DEPENDENT key: oci.obj.storage.objects delay: '0' value_type: FLOAT description: 'The count of objects in the bucket, excluding any multipart upload parts that have not been discarded (aborted) or committed.' preprocessing: - type: JSONPATH parameters: - $.ObjectCount - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 12h master_item: key: oci.obj.storage.metrics.hourly.get tags: - tag: component value: storage - uuid: a3d83de1735d4c409192d187d793f7b2 name: 'All requests count' type: DEPENDENT key: oci.obj.storage.requests delay: '0' value_type: FLOAT description: 'The total number of all HTTP requests made in a bucket.' preprocessing: - type: JSONPATH parameters: - $.AllRequests - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1h master_item: key: oci.obj.storage.metrics.frequent.get tags: - tag: component value: storage - uuid: 2baef7eb0b1348499eda8fb9fd11e0c8 name: 'Post object request count' type: DEPENDENT key: oci.obj.storage.requests.post delay: '0' value_type: FLOAT description: 'The total number of HTTP `POST` requests made in a bucket.' preprocessing: - type: JSONPATH parameters: - $.PostRequests - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1h master_item: key: oci.obj.storage.metrics.frequent.get tags: - tag: component value: storage - uuid: 1853b681b5e64a0f9c172e6166a430ae name: 'Put object request count' type: DEPENDENT key: oci.obj.storage.requests.put delay: '0' value_type: FLOAT description: 'The total number of `PutObject` requests made in a bucket.' preprocessing: - type: JSONPATH parameters: - $.PutRequests - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1h master_item: key: oci.obj.storage.metrics.frequent.get tags: - tag: component value: storage - uuid: 61901f89399c413186c9df957760c2d5 name: 'Bucket size' type: DEPENDENT key: oci.obj.storage.size delay: '0' value_type: FLOAT units: B description: 'The size of the bucket, excluding any multipart upload parts that have not been discarded (aborted) or committed.' preprocessing: - type: JSONPATH parameters: - $.StoredBytes - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 12h master_item: key: oci.obj.storage.metrics.hourly.get tags: - tag: component value: storage - uuid: a4dc04db6b294aef865d137e5fdd0dc2 name: 'Incomplete multipart upload size' type: DEPENDENT key: oci.obj.storage.size.incomplete delay: '0' value_type: FLOAT units: B description: 'The size of any multipart upload parts that have not been discarded (aborted) or committed.' preprocessing: - type: JSONPATH parameters: - $.UncommittedParts - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 12h master_item: key: oci.obj.storage.metrics.hourly.get tags: - tag: component value: storage tags: - tag: class value: cloud - tag: target value: oci - tag: target value: oracle-cloud-infrastructure macros: - 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 "Oracle Cloud Object Storage", e.g. {$HTTP.TLS.VERIFY:"Oracle Cloud Object Storage"}.' - macro: '{$OCI.HTTP.PROXY}' description: 'Set an HTTP proxy for OCI API requests if needed.' - macro: '{$OCI.HTTP.RETURN.CODE.OK}' value: '200' description: 'Set the HTTP return code that represents an OK response from the API. The default is "200", but can vary, for example, if a proxy is used.' dashboards: - uuid: 6dd3714db62046249cf3ff50a09091e2 name: 'OCI Object Storage: Overview' pages: - name: Overview display_period: '30' widgets: - type: item name: 'Overall latency time' width: '30' height: '5' hide_header: 'YES' fields: - type: STRING name: bg_color value: 6C00D9 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'Overall Latency Time' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.latency.overall - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: item name: 'Bucket Size' 'y': '5' width: '15' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: 00D936 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'Bucket Size' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.size - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: item name: 'Client-side error count' 'y': '8' width: '15' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: FF0000 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'Client-side Error Count' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.client.errors - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: item name: 'Number of objects' x: '15' 'y': '5' width: '15' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: 00D936 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'Number of Objects' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.objects - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: item name: 'Incomplete multipart upload size' x: '15' 'y': '8' width: '15' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: FF0000 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'Incomplete Multipart Upload Size' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.size.incomplete - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: item name: 'First byte latency time' x: '30' width: '30' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: 6C00D9 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'First Byte Latency Time' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.latency.byte - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: item name: 'All requests' x: '30' 'y': '3' width: '18' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: 2196F3 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'All Requests' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.requests - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: graph name: Requests x: '30' 'y': '6' width: '42' height: '5' fields: - type: GRAPH name: graphid.0 value: host: 'Oracle Cloud Object Storage by HTTP' name: 'OCI Object Storage: Requests' - type: STRING name: reference value: AAAAA - type: item name: 'Post object requests' x: '48' 'y': '3' width: '12' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: 2196F3 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'Post Object Requests' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.requests.post - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: item name: 'OLM status' x: '60' width: '12' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: 6C00D9 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'OLM Status' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.metrics.olm.get - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: item name: 'Put object requests' x: '60' 'y': '3' width: '12' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: 2196F3 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'Post Object Requests' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.requests.post - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - name: Latency display_period: '30' widgets: - type: item name: 'Overall latency time' width: '36' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: 6C00D9 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'Overall Latency Time' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.latency.overall - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: graph name: 'Overall latency' 'y': '3' width: '36' height: '8' fields: - type: GRAPH name: graphid.0 value: host: 'Oracle Cloud Object Storage by HTTP' name: 'OCI Object Storage: Overall latency' - type: STRING name: reference value: ABAAA - type: item name: 'First byte latency time' x: '36' width: '36' height: '3' hide_header: 'YES' fields: - type: STRING name: bg_color value: 6C00D9 - type: INTEGER name: decimal_size value: '45' - type: STRING name: description value: 'First Byte Latency Time' - type: STRING name: desc_color value: FFFFFF - type: INTEGER name: desc_v_pos value: '0' - type: ITEM name: itemid.0 value: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.latency.byte - type: INTEGER name: show.0 value: '2' - type: INTEGER name: show.1 value: '1' - type: STRING name: units_color value: FFFFFF - type: INTEGER name: units_size value: '25' - type: STRING name: value_color value: FFFFFF - type: graph name: 'First byte latency' x: '36' 'y': '3' width: '36' height: '8' fields: - type: GRAPH name: graphid.0 value: host: 'Oracle Cloud Object Storage by HTTP' name: 'OCI Object Storage: First byte latency' - type: STRING name: reference value: ABAAB graphs: - uuid: fa3fab6874614a3cbea45dee87660253 name: 'OCI Object Storage: Bucket size' graph_items: - color: 199C0D item: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.size - sortorder: '1' color: F63100 yaxisside: RIGHT item: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.objects - uuid: 2c32d269e0274b26a40b0b5069abda7c name: 'OCI Object Storage: Client-side error count' graph_items: - color: 199C0D item: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.client.errors - uuid: 445af3dbf17e4046b5350fd1b4b3734b name: 'OCI Object Storage: First byte latency' graph_items: - color: 199C0D item: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.latency.byte - uuid: 15fb3f080d6244a48d1a7c98f69a2793 name: 'OCI Object Storage: Incomplete multipart upload size' graph_items: - color: 199C0D item: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.size.incomplete - uuid: 0f71c9aa038d437fa28312c58d417ad1 name: 'OCI Object Storage: Overall latency' graph_items: - color: 199C0D item: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.latency.overall - uuid: 49c9abb27e194d1788ee1c62688ff57b name: 'OCI Object Storage: Requests' graph_items: - color: 199C0D item: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.requests - sortorder: '1' color: F63100 item: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.requests.post - sortorder: '2' color: 00611C item: host: 'Oracle Cloud Object Storage by HTTP' key: oci.obj.storage.requests.put