[FX.php List] Making sure servers are responding to FX queries

David W Vaklyes dwv-fmp at wmc-worldwide.com
Wed Sep 25 14:29:13 MDT 2013


I have a piece of FX.php code on my web pages which reads a text field in the database which contains some random text (e.g. "xw3m7ZtLHbFR3xvRoevX") and puts that string into an HTML comment line, so it is hidden from the casual user.

I have a server script (AppleScript) running every few minutes which uses CURL to read the web page into a text field, then I search that field for the string. If the string is not there the WPE is not returning anything, and I restart the WPE, write to the log and send email with time of restart. If nothing is returned the web server is not working, but that is a different issue.

Dave

On Sep 25, 2013, at 10:15 AM, Steven Thoms <sthoms at wavecomm.com> wrote:

> That is nice, but it seems that it answers the question 'is port 80 open?', not specifically, 'is the wpe running?'
> 
> The version I used with the DBNames call was really fast and accurate.
> 
> Maybe if Chris is lurking, he could look into that specific call;)
> 
> Steve
> 207 798-0171
> 
> On Sep 25, 2013, at 12:50 PM, Bob Patin wrote:
> 
>> I found Webko's example, which I added here:
>> 
>> if( !fsockopen ($server, 80, $errno, $errstr, 2) ){
>> 		$color = "#FFADA7";
>> 		$body = $machine." IS NOT RESPONDING.";
>> }else{
>> 	/* DO A QUERY NOW */
>> }
>> 
>> Works great... not sure why I never implemented it before now... :)
>> 
>> BP
>> 
>> Bob Patin
>> Longterm Solutions LLC
>> bob at longtermsolutions.com
>> 615-333-6858
>> http://www.longtermsolutions.com
>> FileMaker 9, 10, 11& 12 Certified Developer
>> Member of FileMaker Business Alliance and FileMaker TechNet
>> --
>> Twitter: bobpatin
>> AIM: longterm1954
>> iChat: bobpatin
>> --
>> Expert FileMaker Consulting 
>> FileMaker Hosting for all versions of FileMaker
>> 
>> On Sep 25, 2013, at 10:32 AM, Steven Thoms <sthoms at wavecomm.com> wrote:
>> 
>>> Bob,
>>> 
>>> The simplest solution I have found is to test each required file with a -findany request.
>>> If you get an error, the server isn't responding.
>>> 
>>> Before version 11, I think, but maybe sooner the FMDBNames() stopped working in FX. But I used to use this code to test and it was very quick and worked a charm:
>>> 
>>> 
>>> // confirmDatabases
>>> $strError = '';
>>> $resultError = 0;
>>> $query = fmConnect(); // does not require a dbname, for obvious reasons; see below...
>>> $result = $query -> FMDBNames();
>>> //print_r($result);
>>> if ( $query->lastErrorCode != 0 ) {
>>>  AddError("The databases are not available.<br />The Web Publishing Engine is not responding. ErrorCode:" . $query->lastErrorCode , $strError);
>>> } else {
>>>  $searchDbs  = explode("," , REQUIRED_DBS);
>>>  $dataString = serialize($result['data']);
>>>  foreach ( $searchDbs as $key=>$dbName ) {
>>>      if ( strpos($dataString , $dbName) === false ) {
>>>          $newError = "The " .  $dbName . " database was not available.";
>>>          AddError($newError , $strError);
>>>      }
>>>  }
>>> }
>>> if ( $strError != '' )
>>>  include_once "{$AppLoc}src/error.php";
>>> 
>>> 
>>> With these settings at the top of the page...
>>> 
>>> // db access files
>>> require_once "{$_SERVER['DOCUMENT_ROOT']}/FX/FX.php";
>>> require_once "{$_SERVER['DOCUMENT_ROOT']}/FX/FM_Errors.php";
>>> require_once "{$_SERVER['DOCUMENT_ROOT']}/FX/FX_Error.php";
>>> require_once "{$_SERVER['DOCUMENT_ROOT']}/FX/server_data.php";
>>> 
>>> // db defaults
>>> define ("REQUIRED_DBS", "File1, File2, etc.");
>>> define ("GROUP_SIZE", "all");
>>> define ("ERROR_SPACE", "<br />&nbsp;&nbsp;&nbsp;");
>>> 
>>> // fx interface functions
>>> 
>>> function fmConnect($layout = '' , $groupSize = GROUP_SIZE, $responseLayout='') {
>>>  $query = new FX(FM_IP, FM_PORT, FM_VERSION);
>>>  if ( $layout != '' )
>>>      $query -> SetDBData(FMDB, $layout, $groupSize, $responseLayout);
>>>  $query -> SetDBUserPass(FM_USERNAME, FM_PASSWORD);
>>>  return $query;
>>> }
>>> 
>>> I hope that helps,
>>> 
>>> Steve
>>> 
>>> 
>>> On Sep 25, 2013, at 11:03 AM, Bob Patin wrote:
>>> 
>>>> A while back someone posted their code for monitoring whether a web server is responding to FX queries. 
>>>> 
>>>> I have a little test database on each of my FM servers and wrote a page that does a quick query every N minutes, but I don't think it's really telling me the truth.
>>>> 
>>>> I say that because I retired one of my FM servers, and yet my page still reports that it's functioning normally... :)
>>>> 
>>>> I'd love to get a copy of that code; I think it might've been Webko?
>>>> 
>>>> Thanks,
>>>> 
>>>> Bob Patin


More information about the FX.php_List mailing list