Skip to content

Monitor parent appears to be incorrectly used in URL during CreateMonitor #39

@zlesnr

Description

@zlesnr

In AddMonitor, the post adds the ParentMonitor to the end of the URL, which I don't think is correct. What looks to be missing here is a notion of what type of monitor is being created, but this information is not to be added to the JSON post, but only appended to the URL. This matches what the documentation in this project here:

CreateMonitor adds a new monitor to the BIG-IP system. <parent> must be one of "http", "https", "icmp", "gateway icmp", or "tcp".

So this should mean that if a MonitorType were an attribute of Monitor, it should be limited to the above http, https, icmp, etc, where the call url should be /monitor/http or /monitor/https. This is independent from the ParentMonitor which should be included as defaultsFrom in the JSON.

Any help here would be much appreciated. I took a stab at solving this locally, but I'm still getting familiar with the layout of this project. If someone can point me in the right direction, or if its quick patch the issue, I'd appreciate it.

Here is what I have locally.

diff --git a/ltm.go b/ltm.go
index fdd1acd..a4e024f 100644
--- a/ltm.go
+++ b/ltm.go
@@ -728,6 +728,7 @@ type Monitor struct {
        Interval       int
        IPDSCP         int
        ManualResume   bool
+       MonitorType    string
        Password       string
        ReceiveString  string
        ReceiveDisable string
@@ -1421,7 +1422,7 @@ func (b *BigIP) Monitors() ([]Monitor, error) {

 // CreateMonitor adds a new monitor to the BIG-IP system. <parent> must be one of "http", "https",
 // "icmp", "gateway icmp", or "tcp".
-func (b *BigIP) CreateMonitor(name, parent string, interval, timeout int, send, receive string) error {
+func (b *BigIP) CreateMonitor(name, parent string, interval, timeout int, send, receive, monitortype string) error {
        config := &Monitor{
                Name:          name,
                ParentMonitor: parent,
@@ -1429,6 +1430,7 @@ func (b *BigIP) CreateMonitor(name, parent string, interval, timeout int, send,
                Timeout:       timeout,
                SendString:    send,
                ReceiveString: receive,
+               MonitorType:   monitortype,
        }

        return b.AddMonitor(config)
@@ -1440,7 +1442,7 @@ func (b *BigIP) AddMonitor(config *Monitor) error {
                config.ParentMonitor = "gateway_icmp"
        }

-       return b.post(config, uriLtm, uriMonitor, config.ParentMonitor)
+       return b.post(config, uriLtm, uriMonitor, config.MonitorType)
 }

 // GetVirtualServer retrieves a monitor by name. Returns nil if the monitor does not exist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions