Tag Archives: Server

8 kärnor i aktivitetshanteraren

Med åtta kärnor börjar det bli svårt att se vad som händer i aktivitetshanteraren….

Share
Posted in Hårdvara, Roligt | Tagged , , | Leave a comment

Att köra Word på en server

Att automatisera Word och köra det på en server för att enkelt skapa dokument utifrån innehållet i en databas kan vara ganska praktiskt. Jag har varit med om flera projekt där man tillämpat just detta. När man läser i Microsofts knowledge base så kan man nästan få intrycket att Microsoft inte tycker det är en riktigt lika bra idé. Detta trots att de tillämpar licensmodellen att om en servertjänst skapar Word-dokument så måste alla klienter som använder server-tjänsten ha en Word-licens.

Skrivet på rätt sätt kan Word dock med fördel användas på en server. Om man exempelvis endast använder förutbestämda mallar som fungerar på servern riskerar man inte att få in strulande macro eller andra olägenheter.

Share
Posted in Programmering | Tagged , , , , , | Leave a comment

Using PHP to check response time of HTTP-server

I must start off with admiting that my PHP skills are very limited, however being a very experienced Perl hacker this is very similar to me.

I needed a script that checked for a normal HTTP response from another server, a status script to see if the other server(s) where behaving as they should.

The resources on-line for PHP are great and I quickly found the code needed to retrieve a remote page and read the contents. I also found some tutorials describing how to use this code. My version ended up looking like this (thanks phptoys.com for the tutorial!):

<?php
// check responsetime for a webbserver
function pingDomain($domain){
    $starttime = microtime(true);
    $file      = fsockopen ($domain, 80, $errno, $errstr, 10);
    $stoptime  = microtime(true);
    $status    = 0;

    if (!$file){
        $status = -1;  // Site is down
    }
    else{
        fclose($file);
        $status = ($stoptime - $starttime) * 1000;
        $status = floor($status);
    }
    return $status;
}
?>

This code works just fine as long as the server is up, but fsockopen generates an error message when the server is down. Here is the problem: the code is intended to verify that the server is up and take action when it is not and therefore I do not want to display the error message (as I half expect it).

I’ve tried to find a way to supress this error message (that I know will occur at some point) but could find no on-line resource describing it. In lack of a proper solution I instead made a hack innovative solution. I know when the error message will show up and that it will be written to output, to avoid this I simply put the function call in an “invisible” space of HTML:

<div style="display:none;">
<?php
$status = pingDomain('www.fireflake.com');
?>
</div>

Sure, it will still show up in the code but after this code is run you will have the response time in the $status variable and the possible error message will only be visible to someone who inspects the code! If $status is -1 the server is unreachable and 0 and up is the response time.

Also, due to the fact that DNS servers usually return a “search engine” response when a domain is unknown, you are better of using IP-numbers for checking that servers are truly on-line or not (I hope they have a fixed IP!). If not you would have to read a file from the server and make sure it has the contents you expect to be sure you are on the right server and your DNS isn’t fooling you.

EDIT:  Thx for adding the tip to use @ to supress error messages. Just use @fsockopen to supress the inevitable error message.

Share
Posted in Programmering | Tagged , , , , , , , , , , | 2 Comments

IIS easy restart

One annoying thing about the Microsoft Internet Information Server (IIS) is that it’s quite a few clicks in order to restart it through the normal GUI. If you use it as a development environment and happen to make an infinite loop or some other bad thing it’s annoying to have to go through all those steps every time.

To save some time here is a simple tip, since the IIS run as a normal service simply make a file called “kick iis.bat” (at least that is what I call it) and enter the following:

net stop w3svc
net start w3svc

This should work for the standard installation of IIS. This will take the server down and then back up again, faster than the GUI just double click the file. I keep it on my dekstop… that might give you an idea of how often I trash the IIS hehe.

Share
Posted in Tips | Tagged , , , , , , , , | Leave a comment