开发者

Best design for PHP/ASP application that makes calls to remote servers

We run multiple Windows/IIS/.Net sites (up to 30+ sites per server). Each site is customized for the individual customer via a configuration开发者_StackOverflow file that contains the settings.

I am tasked with writing a small tool that will 'grep' all of the config files on a certain server for a particular config setting (or settings) and return the values for a nice tabled web page display. It will save many groups lots of time, especially since most groups don't have access to production servers, but they need to know how a customer is currently configured.

I have working code that finds all .config files from a starting path, I can easily extend this to do my grep'ing. Here are the challenges:

  1. I want to aggregate this data from MULTIPLE servers. That means, the tool will be hosted on its own server -- and will make calls to a list of servers.
  2. I'm limited to using .NET/ASP on the actual servers (they won't install PHP on IIS), but I'm writing the tool in PHP.

PROPOSED DESIGN: From my vantage point, I'm thinking the best way to accomplish this is to write my PHP tool and have it make AJAX or CURL requests to ASP scripts that live on each server in the list. Each ASP script could do the recursive directory parsing to find the config files and individually grep the files for the data, and return it in the RESPONSE.

Is that the best way to accomplish this? Should the ASP or PHP side do the 'heavy lifting'? Is their a recommended data format I should be using to pass the data.

Any ideas or samples would be great. If you need more info, I can provide!

Thanks!

Update: Here's an example of a config. Its a basic ASP file that gets included in other scripts.

custConfig1         = " 8,9,6:5:5 "
custConfig2         = " On "


I think you're bang on using PHP for the "receiving" script, and pretty sure you have that in hand.

Based on the format of your example config file, you could use ExecuteGlobal in classic ASP to load each file as you loop through them in your recursive directory lookup. Then you can use the custConfig1 et al. names in your script. e.g. (pseudo)

for each file
    output("custConfig1") = custConfig1
next

Return what you need as JSON using a handy library and then do all the "hard" work of collating it and outputting it in PHP.


Yes, "grep" (if by that you mean importing a text file and using reg expressions to navigate it) isn't the best solution, in my humble opinion, use either JSON or XML as the format, and use PHP's built in XML or JSON tools.

JSON: http://php.net/manual/en/book.json.php

XML: http://php.net/manual/en/book.simplexml.php

You could use the DOM to navigate XML alternatively to SimpleXML, but SimpleXML is easier to learn (again, in my opinion) and will work for your needs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜