5 Replies Latest reply on Aug 27, 2019 9:50 AM by Brendan Murray

    Remote monitoring RestAPI example

    Pablo Ramirez
      Share This:

      Hi

       

      I would like to know if someone has an example to create a Remote monitoring policy (windows or Linux) using TS APIs).

      The only example I've found documented is related to Blackout policies.

       

      Thanks

        • 1. Re: Remote monitoring RestAPI example
          Josh Reynolds

          The best way to do things like this is to use TSPS to create the Remote Monitoring policy you'd like, then use the RestAPI to download the json of what that policy looks like.

           

          Now you know what is required for your policy creation. Adjust accordingly!

          • 2. Re: Remote monitoring RestAPI example
            Brendan Murray

            I agree, but I would add that when you retrieve a monitoring policy with the REST API, you will get a lot of JSON data that is not actually required by the create API call. It takes some experimentation, but I usually find I can trim the create request down significantly.

             

            Regards,

             

            Brendan

            • 3. Re: Remote monitoring RestAPI example
              Pablo Ramirez

              Thanks both!!!

               

              I’ll try it

              • 4. Re: Remote monitoring RestAPI example
                Pablo Ramirez

                It's working:

                 

                Example of the API REST Body more Linux remote Policy named "remota1" using the bdc, a remote Linux host (bdc-006.bmc.com) and root/password as credentials:

                 

                {

                "monitoringPolicy": {

                "id": "e6c09a44-e8d8-448a-b632-bf5fac4392cc",

                "name": "remota1",

                "type": "monitoring",

                "description": "remota",

                "tenant": {

                "name": "*",

                "id": "*"

                },

                "precedence": 900,

                "agentSelectionCriteria": "agentOS CONTAINS \"Linux\" ",

                "associatedUserGroup": "Administrator",

                "owner": "Allen",

                "monitorConfiguration": {

                "configurations": [

                {

                "solutionName": "nuk",

                "solutionVersion": "1.2.00.01",

                "monitoringProfile": "NUK_LINUX_REMOTE",

                "monitors": [

                {

                "monitorType": "NUK_LINUX_REMOTE_CONT",

                "configuration": [

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "sshPortNumber",

                "value": "22",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/sshPortNumber": "22"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/sshPortNumber": "22"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "remUserName",

                "value": "root",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/remUserName": "root"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/remUserName": "root"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "remUsePwdAuth",

                "value": "1",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/remUsePwdAuth": "1"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/remUsePwdAuth": "1"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "SudoMode",

                "value": "1",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/SudoMode": "1"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/SudoMode": "1"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "MonitoringType",

                "value": "1",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/MonitoringType": "1"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/MonitoringType": "1"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "CPU_Active",

                "value": "1",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/CPU_Active": "1"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/CPU_Active": "1"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "Memory_Active",

                "value": "1",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/Memory_Active": "1"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/Memory_Active": "1"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "Kernel_Active",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/Kernel_Active": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/Kernel_Active": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "NFS_Active",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/NFS_Active": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/NFS_Active": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "Network_Active",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/Network_Active": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/Network_Active": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "Users_Active",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/Users_Active": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/Users_Active": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "SwapFile_Active",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/SwapFile_Active": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/SwapFile_Active": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "Process_Active",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/Process_Active": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/Process_Active": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "FileSystem_Active",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/FileSystem_Active": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/FileSystem_Active": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "includeFsString",

                "value": "^/$,^/tmp$,^/usr$,^/home$",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/includeFsString": "^/$,^/tmp$,^/usr$,^/home$"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/includeFsString": "^/$,^/tmp$,^/usr$,^/home$"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "nfsFilterEnabled",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/nfsFilterEnabled": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/nfsFilterEnabled": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "cdfsFilterEnabled",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/cdfsFilterEnabled": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/cdfsFilterEnabled": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "procFilterEnabled",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/procFilterEnabled": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/procFilterEnabled": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "customFilterEnabled",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/customFilterEnabled": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/customFilterEnabled": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "nfsPersistenceEnabled",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/nfsPersistenceEnabled": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/nfsPersistenceEnabled": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "cdfsPersistenceEnabled",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/cdfsPersistenceEnabled": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/cdfsPersistenceEnabled": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "procPersistenceEnabled",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/procPersistenceEnabled": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/procPersistenceEnabled": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "customPersistenceEnabled",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/customPersistenceEnabled": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/customPersistenceEnabled": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "Disk_Active",

                "value": "0",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/Disk_Active": "0"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/Disk_Active": "0"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "includeDiskRegEx",

                "value": ".*",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/includeDiskRegEx": ".*"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/includeDiskRegEx": ".*"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "remHostName",

                "value": "bdc-007.calbro.net",

                "details": null,

                "secure": false,

                "mapDetails": {

                "/remHostName": "bdc-007.calbro.net"

                }

                }

                ],

                "secure": false,

                "mapDetails": {

                "/HOSTS/1/remHostName": "bdc-007.calbro.net"

                }

                },

                {

                "id": "HOSTS",

                "value": "1",

                "details": [

                {

                "id": "remPwd",

                "value": "fX19fX19fX19fQAAAAgXmsnX97QjDgAAABBcUOY4mR4W9+QgrYUDVQPwAAAAFOFtCORup6Xj8dmX11Q/jDilUn+h",

                "details": null,

                "secure": true,

                "mapDetails": {

                "/remPwd": "fX19fX19fX19fQAAAAgXmsnX97QjDgAAABBcUOY4mR4W9+QgrYUDVQPwAAAAFOFtCORup6Xj8dmX11Q/jDilUn+h"

                }

                }

                ],

                "secure": true,

                "mapDetails": {

                "/HOSTS/1/remPwd": "fX19fX19fX19fQAAAAgXmsnX97QjDgAAABBcUOY4mR4W9+QgrYUDVQPwAAAAFOFtCORup6Xj8dmX11Q/jDilUn+h"

                }

                }

                ]

                }

                ],

                "defaultMonitoring": false

                }

                ]

                },

                "enabled": true,

                "shared": false

                }

                }

                1 of 1 people found this helpful
                • 5. Re: Remote monitoring RestAPI example
                  Brendan Murray

                  Thanks, Pablo. A few comments.

                   

                  1.  I don't believe the policy id is required by the create request. I believe the id will be assigned by TSOM when the policy is created.

                   

                  2. The list policy request returns all attributes of the policy, whether they were defined by the user or not. I have not tested this recently, but I am pretty sure you only need to supply the attributes you want to set. The other attributes will be set to their default values. There are, of course, some attributes that are mandatory. I usually experiment to try to determine what those are.

                   

                  3. I am pretty sure you can omit the mapDetails attributes from the create request, e.g.

                   

                  "mapDetails": {

                  "/remHostName": "bdc-007.calbro.net"

                  }

                   

                  DISCLAIMER: What I say above is from memory. I believe it to be correct, but I have not tested it lately. If you determine that anything is not correct, please let us know.

                   

                  Regards,

                   

                  Brendan