-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Powershell + code refactoring #71
base: master
Are you sure you want to change the base?
Conversation
scom/stackstate_checks/scom/scom.py
Outdated
type_response = (session.post('http://'+ scom_ip +'/OperationsManager/data/scomObjects',auth=HttpNtlmAuth(domain + '\\' + username, password),json=type_data["criteria"])).json() | ||
self.requests_counter +=1 | ||
self.log.debug("Number of requets: "+str(self.requests_counter)) | ||
component_type = type_response.get("scopeDatas")[0].get("className").lower().replace(" ","-") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type_response.get("scopeDatas")[0].get("className").lower().replace(" ","-")
This will fail if we get something unsuspected, can we add some guards around it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the response is always something like
{
"scopeDatas": [
{
"id": "e4750a18-1ae2-7a66-c54a-d0ab8caa1c85",
"displayName": "Exchange Back End",
"className": "IIS 10 Web Site",
"path": "EX01.stackstate.lab",
"fullName": "Microsoft.Windows.InternetInformationServices.10.0.WebSite:EX01.stackstate.lab;W3SVC/2"
}
]
}
what i do is just some string manipulation to convert "IIS 10 Web Site" to "iis-10-web-site" and add it as the type of the component
how can we add some guards around it ? check if scopeDatas as well as className exist ?
properties_list = dict() | ||
relations_list = [] | ||
for detail in properties: | ||
properties_list.update({str(detail.get("name").encode('utf-8')):str(detail.get("value").encode('utf-8'))}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure we actually have name
and value
for the detail object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the response i parse:
"monitoringObjectProperties": [
{
"name": "Application Pool Name",
"value": "DefaultAppPool"
},
{
"name": "Failed Request Tracing Enabled",
"value": "False"
},
{
"name": "Failed Request Tracing Directory",
"value": "C:\inetpub\logs\FailedReqLogFiles"
},
{
"name": "Start Automatically",
"value": "True"
},
{
"name": "Connection Time-out (seconds)",
"value": "120"
},
{
"name": "Maximum Concurrent Connections",
"value": ""
},
{
"name": "Maximum Bandwidth (Bytes/second)",
"value": ""
},
{
"name": "ID",
"value": "2"
},
{
"name": "Key",
"value": "W3SVC/2"
},
{
"name": "Description",
"value": "Exchange Back End"
},
{
"name": "Server Bindings",
"value": ":81:"
},
{
"name": "Secure Bindings",
"value": ":444:"
},
{
"name": "Folder path",
"value": "C:\Program Files\Microsoft\Exchange Server\V15\ClientAccess"
},
{
"name": "Log File Directory",
"value": "C:\inetpub\logs\LogFiles\W3SVC2"
},
{
"name": "LogfileType",
"value": "4"
},
{
"name": "BITS",
"value": ""
},
{
"name": "Log File Pattern",
"value": "u_ex??????.log"
},
{
"name": "Logging Enabled",
"value": "True"
},
{
"name": "Anonymous Username",
"value": "IUSR"
},
{
"name": "Cache ISAPI",
"value": "False"
},
{
"name": "Allow Keep Alive",
"value": "True"
},
{
"name": "URL",
"value": "http://EX01.stackstate.lab:81;https://EX01.stackstate.lab:444;"
},
{
"name": "Perf Counter Instance Name",
"value": "Exchange Back End"
},
{
"name": "Object Status",
"value": "System.ConfigItem.ObjectStatusEnum.Active"
},
{
"name": "Asset Status",
"value": ""
},
{
"name": "Notes",
"value": ""
},
{
"name": "Display Name",
"value": "Exchange Back End"
},
{
"name": "Path",
"value": "EX01.stackstate.lab"
}
]
name and value will always be there. should i add a couple of lines to always check for them ?
relations_list = [] | ||
for detail in properties: | ||
properties_list.update({str(detail.get("name").encode('utf-8')):str(detail.get("value").encode('utf-8'))}) | ||
name = str(response["displayName"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few things here that can potentially fail, make sure that all these values are there or use some defaults if possible
Fix class name
# Conflicts: # scom/stackstate_checks/scom/scom.py
Encoding fix + url changes
…ent-integrations into STAC-0-AXASCOM2
Step 1: Link to Jira issue
Step 2: Description of changes
Step 3: Did you add / update tests for your changes in the right area?
Step 4: I'm confident that everything is properly tested:
I got a PO / QA Approval by:
Step 5: Can we ship this feature to production?