cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Checking Sharepoint (up/down)

From: Chris Gralike <Chris.Gralike_at_AMIS.nl>
Date: Tue, 4 Apr 2006 18:42:10 +0200

Kind readers,

Im trying to create a script to check based on keywords if our
"sharepoint" intranet is running, and if succesfull introduce it as a
plugin for Nagios. The only problem is that username/password is
required and sharepoint doesn't seem to allow this for some reason,
Maybe some of you can lend me a moment?

**the header**

* Connected to amisnt15.amis.nl (10.252.252.15) port 443
* error setting certificate verify locations, continuing anyway:
* CAfile: /usr/share/curl/curl-ca-bundle.crt
  CApath: none
* SSL connection using RC4-MD5
* Server certificate:
* subject:
/C=NL/2.5.4.17=3439MN/ST=Utrecht/L=Nieuwegein/2.5.4.9=Edisonbaan
15/O=AMIS Services BV/OU=DIS/OU=InstantSSL/CN=my.amis.nl
* start date: 2005-12-23 00:00:00 GMT
* expire date: 2008-12-22 23:59:59 GMT
* common name: my.amis.nl (matched)
* issuer: /C=SE/O=AddTrust AB/OU=AddTrust External TTP
Network/CN=AddTrust External CA Root
* SSL certificate verify result: 20, continuing anyway.
* Server auth using Basic with user 'SECRET ;)'
> GET / HTTP/1.1
Authorization: Basic YW1pc1xjaHJpc19nOk00M3IwMQ==
Host: my.amis.nl
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

< HTTP/1.1 401 Unauthorized
< Content-Length: 1656
< Content-Type: text/html
< Server: Microsoft-IIS/6.0
< WWW-Authenticate: NTLM
< X-Powered-By: ASP.NET
< MicrosoftSharePointTeamServices: 12.0.0.3417
< Date: Tue, 04 Apr 2006 15:56:55 GMT
* Connection #0 left intact
* Closing connection #0

** The Script **

<?php
$args = $_SERVER['argv'];

$url = $args['1'];
$str = $args['2'];
$auth= $args['3'].":".$args['4'];

function get_site($url, $auth){
        $ch = curl_init("$url");

        //debugging//
        curl_setopt($ch, CURLOPT_VERBOSE, TRUE);

        //std funct//
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);

        //check http / https//
        if(strpos($url, "s") === 4){
                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        }

        //check if authentication is required//
        if(trlen($auth) >= 1 ){
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
                curl_setopt($ch, CURLOPT_USERPWD, $auth);
        }

        $haystack = curl_exec($ch);
        curl_close($ch);
        return($haystack);
        unset($haystack);
}

/* Fetch the website */
$content = get_site($url, $auth);

echo "$content";
?>

The script is being run from the CLI with the arguments given. Example :

/usr/local/php -f curl.php https://www.somesite.com
(reserved_keyword(s)) username password

Thank you for your time.

Kind regards Chris.

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-04-04