You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by randerzander <gi...@git.apache.org> on 2016/12/07 07:26:13 UTC

[GitHub] nifi-minifi-cpp pull request #27: MINIFI-159: Create AppendHostInfo processo...

GitHub user randerzander opened a pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/27

    MINIFI-159: Create AppendHostInfo processor

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/randerzander/nifi-minifi-cpp master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi-minifi-cpp/pull/27.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #27
    
----
commit 7557ebb1e7ce09d73d4af1332e221241eff48aaa
Author: Randy Gelhausen <rg...@gmail.com>
Date:   2016-12-07T07:24:14Z

    MINIFI-159: Create AppendHostInfo processor

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi-minifi-cpp pull request #27: MINIFI-159: Create AppendHostInfo processo...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/nifi-minifi-cpp/pull/27


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi-minifi-cpp issue #27: MINIFI-159: Create AppendHostInfo processor

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on the issue:

    https://github.com/apache/nifi-minifi-cpp/pull/27
  
    reviewing


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi-minifi-cpp issue #27: MINIFI-159: Create AppendHostInfo processor

Posted by randerzander <gi...@git.apache.org>.
Github user randerzander commented on the issue:

    https://github.com/apache/nifi-minifi-cpp/pull/27
  
    I believe the CI failure is due to broken appveyor build configuration


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi-minifi-cpp pull request #27: MINIFI-159: Create AppendHostInfo processo...

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/27#discussion_r92680161
  
    --- Diff: libminifi/src/AppendHostInfo.cpp ---
    @@ -0,0 +1,89 @@
    +/**
    + * @file AppendHostInfo.cpp
    + * AppendHostInfo class implementation
    + *
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +#include <set>
    +#include <sys/time.h>
    +#include <string.h>
    +#include "AppendHostInfo.h"
    +#include "ProcessContext.h"
    +#include "ProcessSession.h"
    +
    +#include <netdb.h>
    +#include <netinet/in.h>
    +#include <sys/socket.h>
    +#include <sys/ioctl.h>
    +#include <net/if.h>
    +#include <arpa/inet.h>
    +
    +const std::string AppendHostInfo::ProcessorName("AppendHostInfo");
    +Property AppendHostInfo::InterfaceName("Network Interface Name", "Network interface from which to read an IP v4 address", "eth0");
    +Property AppendHostInfo::HostAttribute("Hostname Attribute", "Flowfile attribute to used to record the agent's hostname", "source.hostname");
    +Property AppendHostInfo::IPAttribute("IP Attribute", "Flowfile attribute to used to record the agent's IP address", "source.ipv4");
    +Relationship AppendHostInfo::Success("success", "success operational on the flow record");
    +
    +void AppendHostInfo::initialize()
    +{
    +	//! Set the supported properties
    +	std::set<Property> properties;
    +	properties.insert(InterfaceName);
    +	properties.insert(HostAttribute);
    +	properties.insert(IPAttribute);
    +	setSupportedProperties(properties);
    +
    +	//! Set the supported relationships
    +	std::set<Relationship> relationships;
    +	relationships.insert(Success);
    +	setSupportedRelationships(relationships);
    +}
    +
    +void AppendHostInfo::onTrigger(ProcessContext *context, ProcessSession *session)
    +{
    +	FlowFileRecord *flow = session->get();
    +	if (!flow)
    +	  return;
    +
    +	//Get Hostname
    +	char hostname[1024];
    +	hostname[1023] = '\0'; 
    +	gethostname(hostname, 1023);
    +	struct hostent* h;
    +	h = gethostbyname(hostname);
    +  std::string hostAttribute;
    +  context->getProperty(HostAttribute.getName(), hostAttribute);
    +	flow->addAttribute(hostAttribute.c_str(), h->h_name);
    +
    +	//Get IP address for the specified interface
    +  std::string iface;
    --- End diff --
    
    What is the appropriate path if the interface specified does not exist?  Before adjusting, this currently returns 1.0.0.0.  Would it make sense, should the interface not be found, to omit the inclusion of the attribute and value?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi-minifi-cpp pull request #27: MINIFI-159: Create AppendHostInfo processo...

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/27#discussion_r92678796
  
    --- Diff: libminifi/src/AppendHostInfo.cpp ---
    @@ -0,0 +1,89 @@
    +/**
    + * @file AppendHostInfo.cpp
    + * AppendHostInfo class implementation
    + *
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +#include <set>
    +#include <sys/time.h>
    +#include <string.h>
    +#include "AppendHostInfo.h"
    +#include "ProcessContext.h"
    +#include "ProcessSession.h"
    +
    +#include <netdb.h>
    +#include <netinet/in.h>
    +#include <sys/socket.h>
    +#include <sys/ioctl.h>
    +#include <net/if.h>
    +#include <arpa/inet.h>
    +
    +const std::string AppendHostInfo::ProcessorName("AppendHostInfo");
    +Property AppendHostInfo::InterfaceName("Network Interface Name", "Network interface from which to read an IP v4 address", "eth0");
    +Property AppendHostInfo::HostAttribute("Hostname Attribute", "Flowfile attribute to used to record the agent's hostname", "source.hostname");
    +Property AppendHostInfo::IPAttribute("IP Attribute", "Flowfile attribute to used to record the agent's IP address", "source.ipv4");
    +Relationship AppendHostInfo::Success("success", "success operational on the flow record");
    +
    +void AppendHostInfo::initialize()
    +{
    +	//! Set the supported properties
    +	std::set<Property> properties;
    +	properties.insert(InterfaceName);
    +	properties.insert(HostAttribute);
    +	properties.insert(IPAttribute);
    +	setSupportedProperties(properties);
    +
    +	//! Set the supported relationships
    +	std::set<Relationship> relationships;
    +	relationships.insert(Success);
    +	setSupportedRelationships(relationships);
    +}
    +
    +void AppendHostInfo::onTrigger(ProcessContext *context, ProcessSession *session)
    +{
    +	FlowFileRecord *flow = session->get();
    +	if (!flow)
    +	  return;
    +
    +	//Get Hostname
    +	char hostname[1024];
    --- End diff --
    
    Is there a reason 1024 is used?  By spec, it is no more than 255 but may be lower depending on OS implementation.  limits.h has a HOST_NAME_MAX that contains this to get more precision on this instantiation


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi-minifi-cpp issue #27: MINIFI-159: Create AppendHostInfo processor

Posted by apiri <gi...@git.apache.org>.
Github user apiri commented on the issue:

    https://github.com/apache/nifi-minifi-cpp/pull/27
  
    Hey @randerzander. Changes look good.  Will get this merged in.  Thanks for the contrib, definitely seems like it would be helpful.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---