4 Replies Latest reply on Oct 27, 2010 11:23 AM by hemlock

    ipMonitor SOAP - Suspend Monitor

      I believe this was asked awhile back, pre v8.5, but can't remember the answer. Through the UI, the end-user has the ability to "suspend" a monitor for a determined period of time.  It appears that the SOAP interface doesn't have the ability to "suspend" monitors, only enable/disable.  Our process is to always modify the monitor and set the enabled flag appropriately.  Querying the monitor through the Status interface shows that the monitor is disabled.  When a suspended monitor is queried, it shows a status of suspended.  Is this just something that is only available through the UI or is there a way of modifying the monitor to put into a suspended state?


        • Re: ipMonitor SOAP - Suspend Monitor

          Hello hemlock,

          Suspend isn’t a feature that’s part of the SOAP interface. You can do this programmatically if you have an http client stack that supports digest authentication.


          • GET /cfg/cgi?sid=challenge&area=self&action=edit&
          • Parse response for the sid using Regex.  [/]cfg[/]cgi[?]sid=(-?[0-9]+)&
          • POST /cfg/cgi?sid=newsid&area=monitors&action=suspend&duration=60
          • For each monitor you want suspended, add “id=monitorid&” in the post data.
          • To unsuspend, set duration (number of seconds) to zero.
          • GET /cfg/cgi?sid=newsid&area=self&action=logout&
            • Re: ipMonitor SOAP - Suspend Monitor

              Hello Peter,

              inspired by your post i have written a small PHP function using CURL to suspend a monitor. I had to adjust your regex pattern a bit and the post string. You must put the monitor id in the ost data and not into the url otherwise it does not work.



              # enter your ipmonitor url e.g. 'https://ipmon.mydomain.com'
              $my_baseurl = '';

              # enter your ipmonitor username
              $my_user = '';

              # enter the password for your username
              $my_password = '';

              # enter the ID of the monitor to be suspended (can be retrieved with nuSoap ... i have posted a code in this forum)
              $my_monid = '';

              # enter the amount of time in seconds for the suspention; 0 to unsuspend
              $my_duration = '';

              suspend_mon($my_baseurl, $my_user, $my_password, $my_monid, $my_duration);

              function suspend_mon($baseurl, $user, $password, $monid, $duration){
                  # init first connect to ipmonitor to get sid
                  $ch = curl_init();
                  $urlparams = '/cfg/cgi?sid=challenge&area=self&action=edit&';
                  $options = array(
                                       CURLOPT_URL => $baseurl . $urlparams,
                                       CURLOPT_HEADER => 1,
                                       CURLOPT_VERBOSE => 1,
                                       CURLOPT_HTTPGET => 1,
                                       CURLOPT_RETURNTRANSFER => 1,
                                       CURLOPT_SSL_VERIFYPEER => 0,
                                       CURLOPT_HTTPAUTH => CURLAUTH_DIGEST,
                                       CURLOPT_USERPWD => $user . ':' . $password,
                                       CURLOPT_UNRESTRICTED_AUTH => 1,
                                       CURLOPT_FOLLOWLOCATION => 0,
                                       CURLOPT_FORBID_REUSE => 0
                  curl_setopt_array($ch, $options);
                  # execute first connect
                  $output = curl_exec($ch);
                  # extract SID from response
                  $pattern = '/\/cfg\/cgi\?sid=(-?[0-9]+)&/';
                  preg_match($pattern, $output, $newsid);
                  $sid = $newsid[1];
                  # init second connect to suspend monitor
                  # set id of monitor into the postdata
                  # change protocol to POST
                  # and modify url parameters
                  $postdata= array('id' => $monid );
                  $urlparams = '/cfg/cgi?sid='.$sid.'&area=monitors&action=suspend&duration='.$duration;
                  $options = array(
                                      CURLOPT_URL => $baseurl . $urlparams,
                                      CURLOPT_POST => 1,
                                      CURLOPT_POSTFIELDS => $postdata
                  curl_setopt_array($ch, $options);
                  # execute second connect
                  $input = curl_exec($ch);
                  $info = curl_getinfo($ch);
                  # init third connect to logout from ipmonitor
                  $urlparams = '/cfg/cgi?sid='.$sid.'&area=self&action=logout&';
                  $options = array(
                                      CURLOPT_URL => $baseurl . $urlparams,
                                      CURLOPT_HTTPGET => 1
                  curl_setopt_array($ch, $options);
                  # execute third connect and logout
                  $logout = curl_exec($ch);
                  # close the connection


              This script does not do any error handling and does not give any return codes. But this can easyly be added (see the vars $output, $input, $info and $logout for the returned data from ipmonitor). Feel free to use it as an idea how to get this suspension done. If you improve the code please drop me a note or post the code here again.




                • Re: ipMonitor SOAP - Suspend Monitor

                  Has anyone here had any success using the MonitorAdd or MonitorEdit methods of the configuration API? 

                  I can successfully use the API to extract data from IP Monitor but I've yet to be successful adding or editing existing monitors due to the vague nature of the 'Settings' parameter these two method call use.

                  Any insight would be appreciated!

                    • Re: ipMonitor SOAP - Suspend Monitor


                      If I may ask, what programming language are you using?  And for your successful use of the API to extract data, I assume you are using the MonitorView() function along with the ID to select?  I dont believe ipMonitor version is needed as I've used the same logic since 7.x.


                      As you may know, the MonitorView() returns XML nodes with your monitor settings.  In return, to use the MonitorEdit() function, this same XML node structure should be used.  Take this for example, to update an existing monitors Notify Failures & Testing configuration.  Depending on your programming language of choice, traversing the returned XML node data may be different.  My examples below are loosely based on C#/.NET.

                      # Let's select your Monitor data by ID

                      XMLData = ipMonitor.MonitorView(012345)

                      # Set the appropriate values in your returned XML node data

                      XMLData.notifyfailures = "3"

                      XMLData.testing.warn = "60"

                      XMLData.testing.down = "60"

                      XMLData.testing.lost = "60"

                      # After XML node data is updated, let's call the function to modify our monitoring within ipMonitor


                      The returned boolean value will help you determine if the MonitorEdit was successful.


                      The XML structure of each monitor "type" within ipMonitor is fairly consistent but there are slight differences.  If you view a particular monitor's configuration, depending on version, you should see a "Pop-up XML" button on the UI's toolbar.  This will help you navigate the XML structure.

                      For adding a new monitor, this is done through the MonitorAdd() function.  The easiest way I've found to do this is by saving a copy of the XML structure to a file, import the blank XML node information and begin setting the values as we did in the MonitorEdit example.  Then you can perform the MonitorAdd(XMLData) call.  If successful, the new monitor's ID will be returned.  One thing to note about the MonitorAdd, the monitor.id is not needed as a new one will be assigned.  And depending on the monitor "type", take special notice of the monitor.typeid value.  The example below is for an HTML/ASP monitor.




                      Hope this helps.  If any questions, let me know.