Forum Discussion
How do I read the send string for a monitor using powershell icontrol?
I have an (unknown) number of monitors that look at an asp page. I need to create an equivalent monitor for each of these that looks at the new htm page. My thought was to script this using powershell and icontrol. I want to look at all the send string on each monitor on an LTM, if the send string contains the name of the asp page, create a new monitor based on that monitor name referencing the new htm page.
But I can't seem to pull the send string off the monitor. I've googled around and i see examples for listing, adding and removing monitors - but not listing the details of a monitor.
I'm currently (failing) using the following:
$sv = New-Object -TypeName iControl.LocalLBMonitorStringValue
$sv.type = 'STYPE_SEND'
$monitorname = 'rollout'
$Control.locallbmonitor.get_template_user_defined_string_property(@($monitorname),@($sv.type))
I get the following error:
Exception calling "get_template_user_defined_string_property" with "2" argument(s): "Exception caught in
LocalLB::urn:iControl:LocalLB/Monitor::get_template_user_defined_string_property()
Exception: Common::OperationFailed
primary_error_code : 16908342 (0x01020036)
secondary_error_code : 0
error_string : 01020036:3: The requested monitor parameter (rollout_HTTPS 1 STYPE_SEND=) was not found."
At line:1 char:89
+ ... lout_HTTPS"),@($sv.type))
+ ~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SoapHeaderException
- bonny_11145Historic F5 Account
Hi Robbie,
Are you open to use another scripting approach? If so, I'd recommend using iControlREST. It's rather easy, reasonably documented and can be used to accomplish most automation tasks.
It's easy to get started with it using curl and/or the postman plugin for chrome. You can then use something like python to automate...
For your query the iControlREST query can be performed using the following command:
curl -s -k -u admin:admin -H "Content-Type: application/json" -X GET https://a.b.c.d/mgmt/tm/ltm/monitor/http?$select=name,send
This returns the following sample output for me:
{ "kind": "tm:ltm:monitor:http:httpcollectionstate", "selfLink": "https://localhost/mgmt/tm/ltm/monitor/http?$select=name%2Csend&ver=11.6.0", "items": [ { "name": "http", "send": "GET /\\r\\n" }, { "name": "http_head_f5", "send": "HEAD / HTTP/1.0\\r\\n\\r\\n" }, { "name": "m_http", "send": "GET /\\r\\n" } ] }
In the above, m_http is a custom http monitor I created. You can clearly see the monitor name and send string.
Hope this helps,
Cheers,
Bonny
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com