-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into main_perf_package
- Loading branch information
Showing
7 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package iperf | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/threefoldtech/zos/pkg/zinit" | ||
) | ||
|
||
const ( | ||
zinitService = "iperf" | ||
// IperfPort is the port for the iperf service | ||
IperfPort = 300 | ||
) | ||
|
||
// Ensure creates an iperf zinit service and monitors it | ||
func Ensure(z *zinit.Client) error { | ||
if _, err := z.Status(zinitService); err == nil { | ||
return nil | ||
} | ||
|
||
_, err := exec.LookPath("iperf") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cmd := fmt.Sprintf("ip netns exec public iperf -s -p %d", IperfPort) | ||
|
||
err = zinit.AddService(zinitService, zinit.InitService{ | ||
Exec: cmd, | ||
After: []string{ | ||
"networkd", | ||
}, | ||
}) | ||
|
||
if err != nil { | ||
return errors.Wrap(err, "failed to add iperf service") | ||
} | ||
|
||
return z.Monitor(zinitService) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters