Skip to content
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

refactor: Added the Nvidia SM average as app_status #7671

Merged
merged 8 commits into from Nov 8, 2017
Merged

refactor: Added the Nvidia SM average as app_status #7671

merged 8 commits into from Nov 8, 2017

Conversation

tim427
Copy link
Contributor

@tim427 tim427 commented Nov 7, 2017

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

@CLAassistant
Copy link

CLAassistant commented Nov 7, 2017

CLA assistant check
All committers have signed the CLA.

$gpus=0;
$sm_total=0;
while (isset($gpuArray[$gpus])) {
$sm_total = $sm_total+explode(",", $gpuArray[$gpus])[3];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do:

foreach ($gpuArray as $gpu) {
    $stats = explode(",", $gpu);
    $sm_total += $stats[3];
}
$sm_average = ($sm_total ? 0 : ($sm_total / count($gpuArray));

Can't reference an array like that in php 5.3 :-)
Need to avoid divide by zero too.

@tim427 tim427 changed the title Added the Nvidia SM average as app_status refactor: Added the Nvidia SM average as app_status Nov 8, 2017
}
$sm_average = ($sm_total ? 0 : ($sm_total / count($gpuArray)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be the other way around, if $sm_total evaluates to true, it should calculate the average.

@scrutinizer-notifier
Copy link

The inspection completed: 1 new issues

@laf laf merged commit 24a0ee9 into librenms:master Nov 8, 2017
@lock
Copy link

lock bot commented May 17, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

@lock lock bot locked as resolved and limited conversation to collaborators May 17, 2018
@tim427 tim427 deleted the nvidia-sm-average branch September 28, 2023 07:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants