-
Notifications
You must be signed in to change notification settings - Fork 1
Add netgear plugin #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
base: main
Are you sure you want to change the base?
Conversation
Happens, I guess (: @DsgnrFH: By having a new PR, all my old comments are now kinda void. Could you nevertheless comment under each of my comments in the other PR #4 if you have addressed it? I am going to take a closer look at this PR within this week, most likely tomorrow. |
I believe I have addressed everything you suggested |
yhabteab
left a comment
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.
@oxzi these are my last review comments, so you can also have look at this, I won't intervene further :-)
| addPerfSubcheck("IN", inLoss, inStatus) | ||
| addPerfSubcheck("OUT", outLoss, outStatus) |
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.
| addPerfSubcheck("IN", inLoss, inStatus) | |
| addPerfSubcheck("OUT", outLoss, outStatus) | |
| if err := addPerfSubcheck("IN", inLoss, inStatus); err != nil { | |
| return nil, err | |
| } | |
| if err := addPerfSubcheck("OUT", outLoss, outStatus); err != nil { | |
| return nil, err | |
| } |
| hidetemp := flag.Bool("notemp", false, "Hide the Temperature info") | ||
| hidefans := flag.Bool("nofans", false, "Hide the Fans info") | ||
|
|
||
| var mode stringSliceFlag = []string{"basic"} |
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.
| var mode stringSliceFlag = []string{"basic"} | |
| mode := stringSliceFlag{"basic"} |
| statsWarn := flag.Float64("stats-warning", 5, "Port stats warning threshold") | ||
| statsCrit := flag.Float64("stats-critical", 20, "Port stats critical threshold") | ||
|
|
||
| var portsToCheck intSliceFlag = []int{1, 2, 3, 4, 5, 6, 7, 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.
| var portsToCheck intSliceFlag = []int{1, 2, 3, 4, 5, 6, 7, 8} | |
| portsToCheck := intSliceFlag{1, 2, 3, 4, 5, 6, 7, 8} |
| cpuUsage, _ := netgear.StringPercentToFloat(deviceInfo.DeviceInfo.Cpu[0].Usage) | ||
| memUsage, _ := netgear.StringPercentToFloat(deviceInfo.DeviceInfo.Memory[0].Usage) |
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.
You're still ignoring errors.
| if *help || *username == "" || *password == "" { | ||
| flag.Usage() | ||
| return | ||
| } |
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 would split these up in two cases. If someone request the help, it's okay. However, if someone forgets to set credentials - or they somehow get lost along the way -, it is an error.
| if *help || *username == "" || *password == "" { | |
| flag.Usage() | |
| return | |
| } | |
| if *help { | |
| flag.Usage() | |
| return | |
| } | |
| if *username == "" || *password == "" { | |
| fmt.Println("Both username and password are required") | |
| os.Exit(check.Unknown) | |
| } |
| upTime := deviceInfo.DeviceInfo.Details[0].Uptime | ||
| cpuUsage, _ := netgear.StringPercentToFloat(deviceInfo.DeviceInfo.Cpu[0].Usage) | ||
| memUsage, _ := netgear.StringPercentToFloat(deviceInfo.DeviceInfo.Memory[0].Usage) | ||
| fan := deviceInfo.DeviceInfo.Fan[0].Details[0] | ||
| fanName := fan.Description | ||
| fanSpeed := fan.Speed | ||
| sensorDetails := deviceInfo.DeviceInfo.Sensor[0].Details |
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.
Are you sure that there is always an element at index 0? What if the API slightly changes or something along the way has a bad day.
Please consider checking if the slice is long enough before accessing something. Otherwise, if you say that this MUST work, consider adding a deferred recover() call, which prints the error and exits with UNKNOWN.
| tempPartial, err := checks.CheckTemperature(sensorDetails, *tempWarn, *tempCrit) | ||
| if err != nil { | ||
| errRes := result.NewPartialResult() | ||
| errRes.Output = fmt.Sprintf("Temperatuer check error: %v", err) |
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.
| errRes.Output = fmt.Sprintf("Temperatuer check error: %v", err) | |
| errRes.Output = fmt.Sprintf("Temperature check error: %v", err) |
| const defaultPageIndex = 1 | ||
| const defaultPageSize = 25 | ||
|
|
||
| u := n.baseUrl.JoinPath("port_statistics") | ||
| q := u.Query() | ||
| q.Set("type", statType) | ||
| q.Set("indexPage", strconv.Itoa(defaultPageIndex)) | ||
| q.Set("pageSize", strconv.Itoa(defaultPageSize)) |
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.
As commented in the old PR, this pagination looks a bit weird.
What about ports on page 2? Can there be a second page? Does this mean we are only getting information about 25 ports? If so, lots of switches would miss information.
| func NewNetgear(hostName, username, password string) (*Netgear, error) { | ||
| u, err := url.Parse(strings.TrimSpace(hostName)) |
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.
| func NewNetgear(hostName, username, password string) (*Netgear, error) { | |
| u, err := url.Parse(strings.TrimSpace(hostName)) | |
| func NewNetgear(baseUrl, username, password string) (*Netgear, error) { | |
| u, err := url.Parse(strings.TrimSpace(baseUrl)) |
Squashed commits from main and from before