{"action":"created","issue":{"url":"https://api.github.com/repos/schweikert/fping/issues/105","repository_url":"https://api.github.com/repos/schweikert/fping","labels_url":"https://api.github.com/repos/schweikert/fping/issues/105/labels{/name}","comments_url":"https://api.github.com/repos/schweikert/fping/issues/105/comments","events_url":"https://api.github.com/repos/schweikert/fping/issues/105/events","html_url":"https://github.com/schweikert/fping/pull/105","id":183239926,"number":105,"title":"added option -N to allow fping output statistics in the format expected by netdata","user":{"login":"ktsaou","id":2662304,"avatar_url":"https://avatars.githubusercontent.com/u/2662304?v=3","gravatar_id":"","url":"https://api.github.com/users/ktsaou","html_url":"https://github.com/ktsaou","followers_url":"https://api.github.com/users/ktsaou/followers","following_url":"https://api.github.com/users/ktsaou/following{/other_user}","gists_url":"https://api.github.com/users/ktsaou/gists{/gist_id}","starred_url":"https://api.github.com/users/ktsaou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktsaou/subscriptions","organizations_url":"https://api.github.com/users/ktsaou/orgs","repos_url":"https://api.github.com/users/ktsaou/repos","events_url":"https://api.github.com/users/ktsaou/events{/privacy}","received_events_url":"https://api.github.com/users/ktsaou/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2016-10-15T23:52:19Z","updated_at":"2016-11-02T21:38:03Z","closed_at":"2016-11-01T08:23:24Z","pull_request":{"url":"https://api.github.com/repos/schweikert/fping/pulls/105","html_url":"https://github.com/schweikert/fping/pull/105","diff_url":"https://github.com/schweikert/fping/pull/105.diff","patch_url":"https://github.com/schweikert/fping/pull/105.patch"},"body":"Hi,\n\nI am the founder of firehol.org and https://github.com/firehol/netdata (http://my-netdata.io).\n\nThis PR adds the option `-N` to `fping` to allow it output statistics in a netdata friendly format.\n\n**For each host** given, netdata will create 3 charts, like that:\n\n![image](https://cloud.githubusercontent.com/assets/2662304/19414082/df38e2c6-934a-11e6-9097-159db1e14425.png)\n\nA wrapper script (`/usr/libexec/netdata/plugins.d/fping.plugin`) is required only for passing the valid options to fping. It is shown below and I'll add it to the netdata repo:\n\n``` sh\n#!/usr/bin/env bash\n\nme=\"${0}\"\n\n# the frequency to send info to netdata\n# passed by netdata as the first parameter\nupdate_every=\"${1-1}\"\n\n# the netdata configuration directory\n# passed by netdata as an environment variable\nNETDATA_CONFIG_DIR=\"${NETDATA_CONFIG_DIR-/etc/netdata}\"\n\n# -----------------------------------------------------------------------------\n# configuration options\n# can be overwritten at /etc/netdata/fping.conf\n\n# the fping binary to use\n# we need one that can output netdata friendly info\nfping=\"$(which fping || command -v fping)\"\n\n# a space separated list of hosts to fping\nhosts=\"\"\n\n# the time in milliseconds (1 sec = 1000 ms)\n# to ping the hosts - by default 2 pings per iteration\nping_every=\"$((update_every * 1000 / 2))\"\n\n# how many retries to make if a host does not respond\nretries=1\n\n# -----------------------------------------------------------------------------\n\n# load the configuration file\nif [ ! -f \"${NETDATA_CONFIG_DIR}/fping.conf\" ]\nthen\n    echo >&2 \"${me}: configuration file '${NETDATA_CONFIG_DIR}/fping.conf' not found - nothing to do.\"\n    echo \"DISABLE\"\n    exit 1\nfi\n\nsource \"${NETDATA_CONFIG_DIR}/fping.conf\"\n\nif [ -z \"${hosts}\" ]\nthen\n    echo >&2 \"${me}: no hosts configued in '${NETDATA_CONFIG_DIR}/fping.conf' - nothing to do.\"\n    echo \"DISABLE\"\n    exit 1\nfi\n\nif [ -z \"${fping}\" -o ! -x \"${fping}\" ]\nthen\n    echo >&2 \"${me}: command '${fping}' is not executable - cannot proceed.\"\n    echo \"DISABLE\"\n    exit 1\nfi\n\n# the fping options we will use\noptions=( -N -l -R -Q ${update_every} -p ${ping_every} -r ${retries} ${hosts} )\n\n# execute fping\nexec \"${fping}\" \"${options[@]}\"\n\n# if we cannot execute fping, stop\necho >&2 \"${me}: command '${fping} ${options[@]}' failed to be executed.\"\necho \"DISABLE\"\nexit 1\n```\n\ncc: https://github.com/firehol/netdata/issues/1122\n"},"comment":{"url":"https://api.github.com/repos/schweikert/fping/issues/comments/258006989","html_url":"https://github.com/schweikert/fping/pull/105#issuecomment-258006989","issue_url":"https://api.github.com/repos/schweikert/fping/issues/105","id":258006989,"user":{"login":"ktsaou","id":2662304,"avatar_url":"https://avatars.githubusercontent.com/u/2662304?v=3","gravatar_id":"","url":"https://api.github.com/users/ktsaou","html_url":"https://github.com/ktsaou","followers_url":"https://api.github.com/users/ktsaou/followers","following_url":"https://api.github.com/users/ktsaou/following{/other_user}","gists_url":"https://api.github.com/users/ktsaou/gists{/gist_id}","starred_url":"https://api.github.com/users/ktsaou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktsaou/subscriptions","organizations_url":"https://api.github.com/users/ktsaou/orgs","repos_url":"https://api.github.com/users/ktsaou/repos","events_url":"https://api.github.com/users/ktsaou/events{/privacy}","received_events_url":"https://api.github.com/users/ktsaou/received_events","type":"User","site_admin":false},"created_at":"2016-11-02T21:38:03Z","updated_at":"2016-11-02T21:38:03Z","body":"The problem is that because the received count is one less (artificially discarded), this line:\r\n\r\nhttps://github.com/schweikert/fping/blob/2cb0860ec67798bfa5c2c44d3eb48a6a58a3b48f/src/fping.c#L1360\r\n\r\ndoes the wrong calculation: `h->total_time_i` includes the discarded packet, but `h->num_recv_i` does not."}}
{"actor":{"display_login":"ktsaou"}}