Esempio n. 1
0
    def sendV3Data(self, sock, address, value):
        if time.time() - self.lastMetadataSendTime >= self.metadataInterval:
            self.sendMetadata(sock, address)

        packer = Packer()
        packer.pack_enum(self.formatIDs[self.type])
        packer.pack_string(self.hostname)
        packer.pack_string(self.name)
        packer.pack_bool(False)  # spoof = false
        packer.pack_string(self.format)
        self.packValue(packer, value)

        sock.sendto(packer.get_buffer(), address)
Esempio n. 2
0
    def sendV2Data(self, sock, address, value):
        packer = Packer()
        packer.pack_enum(0)  # metric_user_defined
        packer.pack_string(self.type)
        packer.pack_string(self.name)
        packer.pack_string(str(value))
        packer.pack_string(self.units)
        if self.slope == 'zero':
            slope = 0
        else:
            slope = 3  # both
        packer.pack_uint(slope)
        packer.pack_uint(self.tmax)
        packer.pack_uint(self.dmax)

        sock.sendto(packer.get_buffer(), address)
Esempio n. 3
0
    def sendMetadata(self, sock, address):
        self.lastMetadataSendTime = time.time()
        packer = Packer()
        packer.pack_enum(self.formatIDs['full'])
        packer.pack_string(self.hostname)
        packer.pack_string(self.name)
        packer.pack_bool(False)  # spoof = false
        packer.pack_string(self.type)
        packer.pack_string(self.name)
        packer.pack_string(self.units)
        if self.slope == 'zero':
            slope = 0
        else:
            slope = 3
        packer.pack_uint(slope)
        packer.pack_uint(self.tmax)
        packer.pack_uint(self.dmax)

        packer.pack_uint(len(self.meta))  # array length
        for name, value in self.meta.items():
            packer.pack_string(name)
            packer.pack_string(value)

        sock.sendto(packer.get_buffer(), address)
Esempio n. 4
0
def _rpcPacket():			#Build RPC portmap call
        
    data = Packer()
    data.pack_uint(int(random() * 0xffffffff))       # Transaction Identifier (xid)
    data.pack_enum(CALL)                                    # Message Type
    data.pack_uint(2)                                       # RPC version
    data.pack_enum(PORTMAP)                                 # Program 
    data.pack_uint(2)                                       # Program Version
    data.pack_enum(GETPORT)                                 # Process
    data.pack_enum(AUTH_NULL)                               # Credentials
    data.pack_uint(0)                                       # Credentials length
    data.pack_enum(AUTH_NULL)                               # Verifier 
    data.pack_uint(0)                                       # Verifier Length
    data.pack_enum(VXI11_CORE)                              # Called Program
    data.pack_uint(1)                                       # Program Version
    data.pack_enum(TCP)                                     # Program Protocol
    data.pack_uint(0)                                       # Port
    
    return data.get_buffer()