def run(self, kwargs={}):
        try:
            sock = util.open_htcp_socket(kwargs.get('host', ""), kwargs.get('port', 4827))
        
            # Join a multicast group if requested
            if 'multicast_group' in kwargs:
                debug('Joining multicast group ' + kwargs['multicast_group'])
                util.join_multicast_group(sock, kwargs['multicast_group'])

            # Set sys.stdout to None; ganglia will do so anyway, and we
            # can detect this in htcpseqcheck.

            # Start receiving HTCP packets
            htcpseqcheck.receive_htcp(sock)
        except socket.error, msg:
            print >> sys.stderr, msg[1]
            sys.exit(1)
Example #2
0
            util.debugging = True

    try:
        # Change uid and gid
        try:
            if group: os.setgid(grp.getgrnam(group).gr_gid)
            if user: os.setuid(pwd.getpwnam(user).pw_uid)
        except:
            print "Error: Could not change uid or gid."
            sys.exit(-1)

        # Become a daemon
        if daemon:
            util.createDaemon()

        sock = util.open_htcp_socket(host, portnr)
        
        # Join a multicast group if requested
        if multicast_group is not None:
            debug('Joining multicast group ' + multicast_group)
            util.join_multicast_group(sock, multicast_group)

        # Start receiving HTCP packets
        receive_htcp(sock)
    except socket.error, msg:
        print msg[1];
    except KeyboardInterrupt:
        pass


# Ganglia gmond module support