sflow / host-sflow

host-sflow agent
http://sflow.net
Other
146 stars 55 forks source link

not building on Darwin #18

Closed paralax closed 7 years ago

paralax commented 7 years ago

versions: host-sflow-2.0.7-4, Darwin Kernel Version 15.6.0: Thu Sep 1 15:01:16 PDT 2016; root:xnu-3248.60.11~2/RELEASE_X86_64 x86_64

compiler:

Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

getting a compile time error on Darwin. a missing field in a struct.

PLATFORM=`uname`; \
    MYVER=`./getVersion`; \
        MYREL=`./getRelease`; \
        cd src/$PLATFORM; /Library/Developer/CommandLineTools/usr/bin/make VERSION=$MYVER RELEASE=$MYREL
gcc -std=gnu99 -I. -I../sflow -O3 -DNDEBUG -Wall -D_GNU_SOURCE -c hsflowconfig.c
hsflowconfig.c:532:56: error: no member named 'ipAddr' in 'struct _SFLAdaptor'
         if(sp->sFlow->agentDevice && sp->sFlow->agentDevice->ipAddr.addr) {
                                      ~~~~~~~~~~~~~~~~~~~~~~  ^
hsflowconfig.c:534:65: error: no member named 'ipAddr' in 'struct _SFLAdaptor'
            sp->sFlow->agentIP.address.ip_v4 = sp->sFlow->agentDevice->ipAddr;
                                               ~~~~~~~~~~~~~~~~~~~~~~  ^
hsflowconfig.c:542:29: error: no member named 'ipAddr' in 'struct _SFLAdaptor'
            if(adaptor && adaptor->ipAddr.addr) {
                          ~~~~~~~  ^
hsflowconfig.c:544:53: error: no member named 'ipAddr' in 'struct _SFLAdaptor'
               sp->sFlow->agentIP.address.ip_v4 = adaptor->ipAddr;
                                                  ~~~~~~~  ^
4 errors generated.
make[1]: *** [hsflowconfig.o] Error 1
make: *** [hsflowd] Error 2

in the struct the agentDevice is of type SFLAdaptor. the reference to the ipAddr field makes me wonder if it was intended to be a HSPCollector instead.

building on Darwin is presently unable to complete.

sflow commented 7 years ago

The Darwin port has fallen too far behind. I'm looking at bringing it up to date with the framework in the Linux port. I'll report back to this thread when I have something running (on macOS Sierra, compiling with XCode).

sflow commented 7 years ago

I checked in changes to the master branch that bring the Darwin port up to date with the Linux port. It was good to see how many files compiled with no changes. You should find that "make" builds the src/Darwin/hsflowd executable with modules mod_dnssd, mod_json and mod_pcap built in, so that you can specify /etc/hsflowd.conf like this:

sflow { DNS-SD { } json { udpPort = 36343 } pcap { dev = en0 } }

or like this:

sflow { sampling = 400 polling = 20 collector { ip = 10.1.2.3 } json { udpPort = 36343 } pcap { dev = en0 } }

The pcap {} module does not install kernel-based sampling like it does on newer Linux systems, so it may use some cpu if the network is busy.

There are gaps in the data. These could be filled by invoking iostat(1) vm_stat(1) and netstat(1), perhaps using EVBusExec() + EVSocketReadLines(), but it would probably be better to find lower-level calls (sysctl) for getting the same numbers if we can.

There is still no .plist file to go in /Library/LaunchDaemons, and no script to build a .dmg installer image. If you make a .plist file for launchd then you will need to invoke hsflowd with arg "-d" to stop it from daemonizing itself. If you do any of this then please send me a pull request.

paralax commented 7 years ago

thank you. i was able to get it building from the current HEAD of the master branch with a few small changes. i had to pull in the definitions around clock_gettime from this project: https://github.com/lorrden/darwin-posix-rt

a diff to enable this is enclosed.

your speedy turnaround was most impressive by the way!

using sflowtool's csv output i can confirm it's working. thank you very much!

FLOW,192.168.1.149,0,0,f45c898cf75d,0c5101e31213,0x0800,0,0,192.168.1.149,xxx.xxx.45.5,6,0x00,64,60112,443,0x10,72,54,1
CNTR,192.168.1.149,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
paralax commented 7 years ago

hs.diff.txt

sflow commented 7 years ago

I changed src/Darwin/evbus.c to use that SYSTEM_CLOCK directly. Let me know if that works. We can worry later about whether evbus.c (and maybe util.c) can become portable and shared across more platforms.

I also added an "sudo make install" that sets up net.sflow.hsflowd as a system daemon under launchctl control. See commit comment for details.

Please consider contributing a .dmg builder or adding code to populate more of the standard metrics. For example: do we really have to call out to "iostat(1)" (probably using util.c:myExec()) or is there a better way of getting those numbers on MacOS?

sflow commented 7 years ago

I'm going to assume this is OK and close the issue. Please open another if it doesn't work.

paralax commented 7 years ago

apologies for the silence.

with the notes i shared earlier it works like a champ. i used it to test an sFlow collection system i was prototyping. i don't think i can get to building a .pkg, to be honest.

thank you!

On Mon, Jan 16, 2017 at 1:07 PM, sflow notifications@github.com wrote:

Closed #18 https://github.com/sflow/host-sflow/issues/18.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sflow/host-sflow/issues/18#event-924695535, or mute the thread https://github.com/notifications/unsubscribe-auth/AFW90VvdD1lFo38mU5MRVI41_dNnFlxBks5rS7HsgaJpZM4LQ4ob .

-- jose nazario For Privacy Act and Paperwork Reduction Act Notice, see page 2