How to convert ip4addr to string

Tags:

#1 Little_Rock

the following context is my Input configuration and i get a functong from the manual doc,  but the return value of hos_ip() is ip4addr, and I want to convert the return value to string, I have try the string() function, but it does not work at all. Is there any way to convert the return value to string so i can and a new filed of the Input configuration.

ip4addr host_ip();
description Return the first non-loopback IP address the hostname resolves to.
return type ip4addr

 

<Input 59dcb7a6dd48cb088969e300>
        Module im_file
        File '/usr/local/nginx_raw/logs/access.log'
        PollInterval 1
        SavePos True
        ReadFromLast True
        Recursive True
        RenameCheck False
        Exec $FileName = file_name(); # Send file name with each message
        Exec $HOSTIP = host_ip();
</Input>

 

#2 b0ti Nxlog ✓
#1 Little_Rock
the following context is my Input configuration and i get a functong from the manual doc,  but the return value of hos_ip() is ip4addr, and I want to convert the return value to string, I have try the string() function, but it does not work at all. Is there any way to convert the return value to string so i can and a new filed of the Input configuration. ip4addr host_ip(); description Return the first non-loopback IP address the hostname resolves to. return type ip4addr   <Input 59dcb7a6dd48cb088969e300>         Module im_file         File '/usr/local/nginx_raw/logs/access.log'         PollInterval 1         SavePos True         ReadFromLast True         Recursive True         RenameCheck False         Exec $FileName = file_name(); # Send file name with each message         Exec $HOSTIP = host_ip(); </Input>  

> I have try the string() function, but it does not work at all.

The term "does not work" should be banned. If you expect others to help you, at least try to provide details.

BTW, I tried it and it does work.