Forum Discussion
irule to write to file (not local, not syslog)
Ok so here we go.
First you need an iRule that passes the client IP address into iRules LX (you'll want to put the LX call in a catch for a prod environment)
when CLIENT_ACCEPTED {
set rpcHandle [ILX::init "fs-pl" "fs-ex"]
set result [ILX::call $rpcHandle "writeFile" "[IP::client_addr]"]
log local0. "$result"
}Then this is a simple iRules LX script that will write out a test file with the value of the IP you passed in.
It will write out the file to the extension folder which will vary.. it will also change slightly each time it executes
For example, my file was located here:
/var/sdm/plugin_store/plugins/:Common:fs-pl_83750_4/extensions/fs-ex/test.txt
the next time, it was located here:
/var/sdm/plugin_store/plugins/:Common:fs-pl_83750_5/extensions/fs-ex/test.txt
var f5 = require('f5-nodejs');
var ilx = new f5.ILXServer();
var fs = require('fs');
function writeFile(req, res) {
var ip = req.params()[0];
fs.writeFile('test.txt', ip, function (err) {
if (err) {
res.reply(err);
} else {
res.reply("file written successfully");
}
});
}
ilx.addMethod('writeFile', writeFile);
ilx.listen();Hope that helps
Lee
- Andy_McGrathMay 23, 2019
Cumulonimbus
Nice solution, glad I could help :D
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
