The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Charset From Shell For PHP Script.

Discussion in 'General Discussion' started by dkz, Aug 4, 2005.

  1. dkz

    dkz Well-Known Member

    Joined:
    Sep 10, 2004
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    16
    Hello,

    I have been having a problem that my dedicated IP's go down and become unreachable. I have no idea why or the time so I created a script that checks a website on a dedicated IP every 5 minutes and if found down it restarts IP alias. This will at least keep the sites up and give me an idea of when this is happening. The problem is I have the script output the details from the restart but they are in a diffrent charset. Any idea what charset I should use? Here is the script (in case someone needs it or if anyone has any suggestions for it and the output.


    Script
    PHP:
    #!/usr/bin/php
    <?
    //Don't Forget To Add An Address Below.  Do Not Include http://
    $address = "INSERT ADDRESS HERE";
    $sock = @fopen("http://$address", 'r');
    $time =date("g:i:s F j Y");

    if (!$sock) {
        $ip = shell_exec("/etc/init.d/ipaliases restart");
        $subject="IP Down...";
        $msg="The IP's Went Down at $time.  They should have been restarted.<br>
        Here is the output.<br><br>
        $ip";
        $mailheaders="From:  server";
        $email = "dustin@smarter-hosting.com";
        $headers  = 'From: Server <root@netonenetworks.com>' . "\r\n";
        $headers .= 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        mail ($email, $subject, $msg, $headers);
        //echo "$ip";
    }
    ?>

    Output
    Code:
    The IP's Went Down at 10:20:37 August 4 2005. They should have been restarted.
    Here is the output.
    
    Shutting down eth0:1 [ OK ] UnRouting 216.32.90.219 SIOCDELRT: No such device [FAILED] Shutting down eth0:2 SIOCSIFFLAGS: Cannot assign requested address [FAILED] UnRouting 216.32.90.221 SIOCDELRT: No such device [FAILED] Shutting down eth0:3 SIOCSIFFLAGS: Cannot assign requested address [FAILED] UnRouting 216.32.90.222 SIOCDELRT: No such device [FAILED] Shutting down eth0:4 SIOCSIFFLAGS: Cannot assign requested address [FAILED] UnRouting 216.32.90.220 SIOCDELRT: No such device [FAILED] Bringing up eth0:1 [ OK ] Routing 216.32.90.219 [ OK ] Bringing up eth0:2 [ OK ] Routing 216.32.90.221 [ OK ] Bringing up eth0:3 [ OK ] Routing 216.32.90.222 [ OK ] Bringing up eth0:4 [ OK ] Routing 216.32.90.220 [ OK ] 
    
    Thanks For The Help!
     
    #1 dkz, Aug 4, 2005
    Last edited: Aug 4, 2005
Loading...

Share This Page