[rt-users] Retrieving the computer name automatically

Dirk Pape pape-rt at inf.fu-berlin.de
Tue Nov 11 03:19:03 EST 2008


Hello,

--Am 11. November 2008 08:45:59 +0100 schrieb Dirk Pape 
<pape-rt at inf.fu-berlin.de>:

> I can provide the patch and the configuration line in the template for
> ECFV  later this day.

ok. This is ot so much later :-)

The patch can be found at 
<http://page.mi.fu-berlin.de/pape/rt3/patches/rt/web_xremoteip.patch>. It 
ist for RT 3.6 und must probably be adapted for 3.8

It uses $Message->head->replace('X-REMOTE-IP',$ENV{'REMOTE_ADDR'});
to add the REMOTE_ADDR from the environment to a header X-REMOTE-IP. This 
is - in our local case - the same header the SMTP-Server writes into each 
email message it receives.

You can change X-REMOTE-IP to your own X-Header.

If you look at my latest ECFV at 
<http://page.mi.fu-berlin.de/pape/rt3/ExtractCustomFieldValues.tgz> (there 
is also a cpan version done by Kevin Falcone or Alex Vandiver 
<http://search.cpan.org/~alexmv/RT-Extension-ExtractCustomFieldValues-1.8/>) 
you find a line in the shipped template reading

# scan the Header X-REMOTE-IP for an IP-Address and get the hostname out of 
it
host|X-REMOTE-IP|\d+\.\d+\.\d+\.\d+|use Socket; ($_) = 
gethostbyaddr(inet_aton($_),AF_INET); $_ = "$_ (remote-ip)";

this resolves the hostname from the IP in the header into a (global) ticket 
custom field "host". You may just adopt it to use your own X-Header.

You can also read the IP into another customfield by adding to the template:

hostip|X-REMOTE-IP|\d+\.\d+\.\d+\.\d+|

you may add |q to the end of each line, if you don't like the transaction 
to be logged in RT (I recommend this).

So you have the two lines

host|X-REMOTE-IP|\d+\.\d+\.\d+\.\d+|use Socket; ($_) = 
gethostbyaddr(inet_aton($_),AF_INET); $_ = "$_ (remote-ip)";|q

hostip|X-REMOTE-IP|\d+\.\d+\.\d+\.\d+||q

If you don't have ECFV already installed there is a README and some hints 
in the wiki.

I hope this helps.

Regards,
Dirk.



More information about the rt-users mailing list