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

app-benchmarks/ioping: bump to v1.1 and introduce netdata USE #13411

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app-benchmarks/ioping/Manifest
@@ -1,2 +1,3 @@
DIST ioping-0.9.tar.gz 23695 BLAKE2B 41b37ad8dabd2c2e16f26798d878807c38e0d03bc4964a001f8800d0f398ba48335b1187e1f04cd235a980c5dce7e864c471fce8d46ca24a65f2022847eb8ebd SHA512 609e19c31a16a5961be0e468255f2853311162ad988d07404a8198042bec1e20cab37e192ad148536a0772efe8034a94d594671ec6fde7d37badee859796de1c
DIST ioping-1.0.tar.gz 28824 BLAKE2B bb0f28e560419167450b27846650ff131c9cbb23c5df7f518afa8cea6a83bd97142d7ad8920b9ec86754deea0dcbf36af923223c78df6488f3623f2df852b59c SHA512 a6763ac800e98c819a74af80634ac723f413ffa183297918389e1e1f5fc83713b683d53b594f5bd20f11d168c21de5da9d42a215d78531ee8b619aff8b9b0b84
DIST ioping-1.1.tar.gz 29251 BLAKE2B 2f0ec642c3545b8e603f90187f48bf44e1ef665a99bc04af4d5e6441016c9509875e8e05c1cc8715fd080c8a498c7374cf5db562a3203d7075edbe85683ccdbb SHA512 67802a6ab552ad1fdb8894f4d814601c2f66154f4bfc50fa0001d881694864c1a70882b4ba2d0f50cbd484472dc649a22b312f802a3bacc3317671971bdc0201
141 changes: 141 additions & 0 deletions app-benchmarks/ioping/files/ioping-1.1-netdata.patch
@@ -0,0 +1,141 @@
From 43d15a5f7b4e3f03cb3ae2b4efca9442834e2a98 Mon Sep 17 00:00:00 2001
From: Vladimir Kobal <vlad@prokk.net>
Date: Thu, 28 Mar 2019 20:36:20 +0200
Subject: [PATCH 1/1] Add support for netdata

---
ioping.1 | 5 ++++-
ioping.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/ioping.1 b/ioping.1
index 9c66997..534fc61 100644
--- a/ioping.1
+++ b/ioping.1
@@ -3,7 +3,7 @@
ioping \- simple disk I/O latency monitoring tool
.SH SYNOPSYS
.SY ioping
-.OP \-ABCDLRWGYykq
+.OP \-ABCDLRWGYykqN
.OP \-c count
.OP \-i interval
.OP \-l speed
@@ -107,6 +107,9 @@ Keep and reuse temporary working file "ioping.tmp" (only for directory target).
.B \-q
Suppress periodical human-readable output.
.TP
+.B \-N
+Use output format compatible with netdata.
+.TP
.B \-h
Display help message and exit.
.TP
diff --git a/ioping.c b/ioping.c
index 1742d96..41790c4 100644
--- a/ioping.c
+++ b/ioping.c
@@ -327,6 +327,7 @@ void usage(void)
" -y use data sync I/O (O_DSYNC)\n"
" -k keep and reuse temporary file (ioping.tmp)\n"
" -q suppress human-readable output\n"
+ " -N use output format compatible with netdata\n"
" -h display this message and exit\n"
" -v display version and exit\n"
"\n"
@@ -487,6 +488,7 @@ int fd;
void *buf;

int quiet = 0;
+int netdata_output = 0;
int batch_mode = 0;
int direct = 0;
int cached = 0;
@@ -531,7 +533,7 @@ void parse_options(int argc, char **argv)
exit(1);
}

- while ((opt = getopt(argc, argv, "hvkALRDCWGYBqyi:t:T:w:s:S:c:o:p:P:l:")) != -1) {
+ while ((opt = getopt(argc, argv, "hvkALRDCWGYBNqyi:t:T:w:s:S:c:o:p:P:l:")) != -1) {
switch (opt) {
case 'h':
usage();
@@ -608,6 +610,9 @@ void parse_options(int argc, char **argv)
case 'q':
quiet = 1;
break;
+ case 'N':
+ netdata_output = 1;
+ break;
case 'B':
quiet = 1;
batch_mode = 1;
@@ -629,6 +634,19 @@ void parse_options(int argc, char **argv)
if (optind < argc-1)
errx(1, "more than one destination specified");
path = argv[optind];
+
+ if (netdata_output) {
+ if (stop_at_request || custom_deadline || period_request || period_time || custom_deadline || write_read_test)
+ errx(1, "-c, -w, -p, -P, -R, and -G options are incompatible with netdata output (-N)");
+
+ if (interval < NSEC_PER_SEC) {
+ interval = NSEC_PER_SEC;
+ warnx("the minimal interval for netdata is 1 second");
+ } else {
+ interval = roundl(interval / NSEC_PER_SEC) * NSEC_PER_SEC;
+ warnx("round interval to %lld seconds", interval / NSEC_PER_SEC);
+ }
+ }
}

#ifdef __linux__
@@ -1152,6 +1170,34 @@ static void dump_statistics(struct statistics *s) {
(unsigned long)s->load_time);
}

+void print_netdata(ssize_t ret_size, long long time_now, long long this_time) {
+ static int sent_chart = 0;
+ static long long time_prev = 0;
+
+ fflush(stdout);
+
+ if (!sent_chart) {
+ printf("CHART 'ioping.%s_", path);
+ print_size(ret_size);
+ printf("_%s_latency' '' '%s Latency for %s' microseconds '%s' ioping.latency line 110030 %lld '' ioping.plugin\n"
+ , write_test ? "write" : "read"
+ , write_test ? "Write" : "Read"
+ , path
+ , path
+ , interval / NSEC_PER_SEC);
+ printf("DIMENSION latency '' absolute 1 1000\n");
+ sent_chart = 1;
+ }
+
+ printf("BEGIN 'ioping.%s_", path);
+ print_size(ret_size);
+ printf("_%s_latency' %lld\n", write_test ? "write" : "read", time_prev ? (time_now - time_prev) / 1000 : 0);
+ time_prev = time_now;
+
+ printf("SET latency %lld\n", this_time);
+ printf("END\n");
+}
+
int main (int argc, char **argv)
{
ssize_t ret_size;
@@ -1391,7 +1437,9 @@ skip_preparation:
add_statistics(&part, this_time);
}

- if (!quiet) {
+ if (netdata_output) {
+ print_netdata(ret_size, time_now, this_time);
+ } else if (!quiet) {
print_size(ret_size);
printf(" %s %s (%s %s", write_test ? ">>>" : "<<<",
path, fstype, device);
--
2.23.0

30 changes: 30 additions & 0 deletions app-benchmarks/ioping/ioping-1.1.ebuild
@@ -0,0 +1,30 @@
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit toolchain-funcs

DESCRIPTION="Simple disk I/0 latency measuring tool"
HOMEPAGE="https://github.com/koct9i/ioping"
SRC_URI="https://github.com/koct9i/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

SLOT="0"
LICENSE="GPL-3"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
IUSE="netdata"

src_prepare() {
use netdata && eapply "${FILESDIR}/${P}-netdata.patch"
eapply_user
}

src_configure() {
tc-export CC
}

src_install() {
emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" install

dodoc changelog README.md
}
3 changes: 3 additions & 0 deletions app-benchmarks/ioping/metadata.xml
Expand Up @@ -12,4 +12,7 @@
<remote-id type="google-code">ioping</remote-id>
<remote-id type="github">koct9i/ioping</remote-id>
</upstream>
<use>
<flag name="netdata">Add support for netdata</flag>
</use>
</pkgmetadata>