-
Notifications
You must be signed in to change notification settings - Fork 11
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
Sapcontrol gatherer #270
Sapcontrol gatherer #270
Conversation
} | ||
|
||
// Trick to keep the SIDs as capital letter | ||
result := &entities.FactValueMap{Value: make(map[string]entities.FactValue)} |
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.
I need to apply this "trick" to keep the SIDs as capital letter. All the other gatherers have them with this format.
Other solution (with more code) would be to have internal data structs that are almost identical with the ones coming from sapcontrolapi
but with snake_case json output
@arbulu89 the For me, what really matters, is whether is running or not . An I make a note to discuss this with them in our next call. |
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.
Good job, nothing to address about the implementation/logic
Just some readability style comments
cachedFact, cacheHit := cachedFacts[factReq.Argument] | ||
|
||
switch { | ||
case len(factReq.Argument) == 0: |
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.
We can move this case to an if statement on line 119 before initializing the webmethod etc..
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.
I have moved the conditions to use if/continues
instead of the switch, so we don't need to initialize variables needlesly.
webmethod, ok := whitelistedSapControlArguments[factReq.Argument] | ||
cachedFact, cacheHit := cachedFacts[factReq.Argument] | ||
|
||
switch { |
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.
Could you please add {}
around the cases? So we don't use only the indent but we have a clear barrier of the case structure, so it's easier to follow and read
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.
I have removed the switch
at the end, so no need for this
|
||
if factValue, err := outputToFactValue(sapControlMap); err != nil { | ||
gatheringError := SapcontrolDecodingError.Wrap(err.Error()) | ||
log.Error(gatheringError) |
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.
Could we add more info here, like the argument
sapControlMap := make(SapControlMap) | ||
for sid, instances := range foundSystems { | ||
sapControlInstance := []SapControlInstance{} | ||
for _, instanceData := range instances { |
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.
could we extract instanceData[0] and [1] to variables, it's used in more places, it's easier to read
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.
LGTM
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.
LGTM!
sapcontrol
gatherer.It supports the
GetProcessList
,GetSystemInstanceList
,GetVersionInfo
,HACheckConfig
andHAGetFailoverConfig
webmethods.It caches the outputs of the commands so they are executed only once.
I have taken the autogenerated code from sap_host_exporter
Only the strictly required fields. More info about the auto generated code here
Find here the
sapcontrol
api: https://www.sap.com/documents/2016/09/0a40e60d-8b7c-0010-82c7-eda71af511fa.htmlBy now, I have not included the
CheckHostAgent
, as it is not available in the public API. In fact, I think we could leverage thesaphostctrl
gathererPing
function. I know it is not 100% the same, but I think it would validate what we need. Wdyt @abravosuse ?Anyway, if it is 100% needed, i would include it in a future PR.