Forum Discussion
Can I read a remote file contents from an iRule?
Hi all, I don't know if this is possible or not, but I am trying to find out if it is possible to set an iRule variable with the contents of a remote file (this will be a number), and then check it against a preset variable within the iRule to see if they match.
Thanks in advance, Anthony
- nitassEmployee
i think it depends on how remote file is published.
e.g. CSV Tabular Data Sideband Importer by George Watkins
- Kevin_StewartEmployee
If I may add, it depends on a few factors, most importantly the static/dynamic nature of the remote value (does it change often), and the ways in which it can be accessed.
For example, if the value doesn't change often, you could use a management plane process to fetch the value and store it locally in a data group (checking periodically for changes). If you need more real-time (in-line) access to something that changes frequently, then you'd probably need to use something like a sideband call within an iRule. Take note though that this will certainly add some latency. Which brings me to the second factor - how the value is accessed. If it can be fetched via an HTTP call, then a real-time sideband iRule is fairly straight forward. Other protocols and access methods will vary your approach. If you can touch the value with LDAP or RADIUS, then you could use the Access Policy Manager module. Sideband is really tuned for HTTP but can potentially support other protocols. In the shell, you have cURL, Perl, Python, Bash, and a few other ways to grab remote data. You could even, potentially, reach into a remote file system (I believe), but that'd be a management side process and generally not something you could do real-time (unless you exposed that file system through a remote web service, pretty easy to do with something like PHP, in which case you could access it via sideband).
- AnthonyNimbostratus
Thanks for your responses guys.
This is how I have managed it so far - however I am always willing to try something different if this raises issues.
I have created an iFile which references a static file in /var/tmp and the iRule reads a value from here. I have a cronjob running every minute on a remote server which overwrites this file contents with a number of hits to a specific URI, and a cronjob running every minute on the LTM with modifies the iFile with this new file.
Its clunky, and not sure how it will perform in a production environment but mechanically it is doing what I need.
Regards, Anthony
- AnthonyNimbostratus
I completely revisited this yesterday afternoon and seeing as all we were wanting to do was throttle the availability of a URL depending on how busy a specific server is, we have used a health monitor to check for an open/closed flag within a file on the server and then mark the specified pool member down in the health pool, this leaves the other traffic unaffected.
The previous version using sessions and cronjobs etc etc was quite CPU hungry on our production environment, even on a quiet day where as this one seems to be un-noticable on the Dashboard graph.
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