Esta é uma tradução da página de documentação original em inglês. Ajude-nos a torná-la melhor.

mediatype.get

Descrição

integer/array mediatype.get(object parameters)

O método permite recuperar tipos de mídia de acordo com os parâmetros fornecidos.

Este método está disponível para usuários de qualquer tipo. As permissões para chamar o método podem ser revogadas nas configurações de função do usuário. Consulte Funções de usuário para obter mais informações.

Parâmetros

(object) Parâmetros que definem a saída desejada.

O método suporta os seguintes parâmetros.

Parâmetro Tipo Descrição
mediatypeids string/array Retorne apenas os tipos de mídia com os IDs fornecidos.
mediaids string/array Retorna apenas os tipos de mídia usados ​​pela mídia fornecida.
userids string/array Retornar apenas os tipos de mídia usados ​​por determinados usuários.
selectMessageTemplates query Retorna uma propriedade message_templates com uma matriz de mensagens de tipo de mídia.
selectUsers query Retornar uma propriedade users com os usuários que usam o tipo de mídia.
sortfield string/array Classifique o resultado pelas propriedades fornecidas.

Os valores possíveis são: mediatypeid.
countOutput boolean Esses parâmetros sendo comuns para todos os métodos get são descritos em detalhes em comentário de referência.
editable boolean
excludeSearch boolean
filter object
limit integer
output query
preservekeys boolean
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

Valores de retorno

(integer/array) Retorna:

  • uma matriz de objetos;
  • a contagem de objetos recuperados, se o parâmetro countOutput foi usado.

Exemplos

Recuperando tipos de mídia

Recupere todos os tipos de mídia configurados

Request:

{
           "jsonrpc": "2.0",
           "method": "mediatype.get",
           "params": {
               "output": "extend",
               "selectMessageTemplates": "extend"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "mediatypeid": "1",
                   "type": "0",
                   "name": "Email",
                   "smtp_server": "mail.example.com",
                   "smtp_helo": "example.com",
                   "smtp_email": "[email protected]",
                   "exec_path": "",
                   "gsm_modem": "",
                   "username": "",
                   "passwd": "",
                   "status": "0",
                   "smtp_port": "25",
                   "smtp_security": "0",
                   "smtp_verify_peer": "0",
                   "smtp_verify_host": "0",
                   "smtp_authentication": "0",
                   "exec_params": "",
                   "maxsessions": "1",
                   "maxattempts": "3",
                   "attempt_interval": "10s",
                   "content_type": "0",
                   "script": "",
                   "timeout": "30s",
                   "process_tags": "0",
                   "show_event_menu": "1",
                   "event_menu_url": "",
                   "event_menu_name": "",
                   "description": "",
                   "message_templates": [
                       {
                           "eventsource": "0",
                           "recovery": "0",
                           "subject": "Problem: {EVENT.NAME}",
                           "message": "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\nHost: {HOST.NAME}\r\nSeverity: {EVENT.SEVERITY}\r\nOperational data: {EVENT.OPDATA}\r\nOriginal problem ID: {EVENT.ID}\r\n{TRIGGER.URL}"
                       },
                       {
                           "eventsource": "0",
                           "recovery": "1",
                           "subject": "Resolved: {EVENT.NAME}",
                           "message": "Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}\r\nProblem name: {EVENT.NAME}\r\nHost: {HOST.NAME}\r\nSeverity: {EVENT.SEVERITY}\r\n\r\nOriginal problem ID: {EVENT.ID}\r\n{TRIGGER.URL}"
                       },
                       {
                           "eventsource": "0",
                           "recovery": "2",
                           "subject": "Updated problem: {EVENT.NAME}",
                           "message": "{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.\r\n{EVENT.UPDATE.MESSAGE}\r\n\r\nCurrent problem status is {EVENT.STATUS}, acknowledged: {EVENT.ACK.STATUS}."
                       },
                       {
                           "eventsource": "1",
                           "recovery": "0",
                           "subject": "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}",
                           "message": "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}\r\nDevice DNS: {DISCOVERY.DEVICE.DNS}\r\nDevice status: {DISCOVERY.DEVICE.STATUS}\r\nDevice uptime: {DISCOVERY.DEVICE.UPTIME}\r\n\r\nDevice service name: {DISCOVERY.SERVICE.NAME}\r\nDevice service port: {DISCOVERY.SERVICE.PORT}\r\nDevice service status: {DISCOVERY.SERVICE.STATUS}\r\nDevice service uptime: {DISCOVERY.SERVICE.UPTIME}"
                       },
                       {
                           "eventsource": "2",
                           "recovery": "0",
                           "subject": "Autoregistration: {HOST.HOST}",
                           "message": "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}"
                       }
                   ],
                   "parameters": []
               },
               {
                   "mediatypeid": "3",
                   "type": "2",
                   "name": "SMS",
                   "smtp_server": "",
                   "smtp_helo": "",
                   "smtp_email": "",
                   "exec_path": "",
                   "gsm_modem": "/dev/ttyS0",
                   "username": "",
                   "passwd": "",
                   "status": "0",
                   "smtp_port": "25",
                   "smtp_security": "0",
                   "smtp_verify_peer": "0",
                   "smtp_verify_host": "0",
                   "smtp_authentication": "0",
                   "exec_params": "",
                   "maxsessions": "1",
                   "maxattempts": "3",
                   "attempt_interval": "10s",
                   "content_type": "1",
                   "script": "",
                   "timeout": "30s",
                   "process_tags": "0",
                   "show_event_menu": "1",
                   "event_menu_url": "",
                   "event_menu_name": "",
                   "description": "",
                   "message_templates": [
                       {
                           "eventsource": "0",
                           "recovery": "0",
                           "subject": "",
                           "message": "{EVENT.SEVERITY}: {EVENT.NAME}\r\nHost: {HOST.NAME}\r\n{EVENT.DATE} {EVENT.TIME}"
                       },
                       {
                           "eventsource": "0",
                           "recovery": "1",
                           "subject": "",
                           "message": "RESOLVED: {EVENT.NAME}\r\nHost: {HOST.NAME}\r\n{EVENT.DATE} {EVENT.TIME}"
                       },
                       {
                           "eventsource": "0",
                           "recovery": "2",
                           "subject": "",
                           "message": "{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}"
                       },
                       {
                           "eventsource": "1",
                           "recovery": "0",
                           "subject": "",
                           "message": "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}"
                       },
                       {
                           "eventsource": "2",
                           "recovery": "0",
                           "subject": "",
                           "message": "Autoregistration: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}"
                       }
                   ],
                   "parameters": []
               }
           ],
           "id": 1
       }

Retrieving media types as Admin

As an Admin type user, retrieve all media types that are enabled, with users that use these media types. The following example returns two media types:

  • email media type with one user (since Zabbix 6.0.34, only Admin type user's own user);
  • SMS media type with no users.

Request:

{
           "jsonrpc": "2.0",
           "method": "mediatype.get",
           "params": {
               "output": "extend",
               "filter": {
                   "status": 0
               },
               "selectUsers": "extend"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": [
               {
                   "mediatypeid": "1",
                   "type": "0",
                   "name": "Email",
                   "status": "0",
                   "description": "",
                   "maxattempts": "3",
                   "users": [
                       {
                           "userid": "3",
                           "username": "database-admin",
                           "name": "John",
                           "surname": "Doe",
                           "url": "",
                           "autologin": "0",
                           "autologout": "0",
                           "lang": "default",
                           "refresh": "30s",
                           "theme": "default",
                           "attempt_failed": "0",
                           "attempt_ip": "",
                           "attempt_clock": "0",
                           "rows_per_page": "50",
                           "timezone": "default",
                           "roleid": "2"
                       }
                   ]
               },
               {
                   "mediatypeid": "3",
                   "type": "2",
                   "name": "SMS",
                   "status": "0",
                   "description": "",
                   "maxattempts": "3",
                   "users": []
               }
           ],
           "id": 1
       }

Veja também

Fonte

CMediaType::get() in ui/include/classes/api/services/CMediaType.php.