Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cd /root
- cat > kimsufi.php <<EOF
- #!/usr/bin/php
- <?php
- $url = "http://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2";
- $f = file_get_contents($url);
- $a = json_decode($f);
- $avail = $a->answer->availability;
- foreach($avail as $s) {
- if($s->reference==='142sk1') {
- $z = $s->zones;
- foreach($z as $zone) {
- if($zone->availability!=='unavailable') {
- //echo $s->reference . " is " . $zone->availability . " in " . $zone->zone . "\n";
- $from = "Kimsufi daemon";
- $to = "your@email.address";
- $subject = "Disponibilidad en Kimsufi KS-1 zona ".$z;
- $body = "Disponibilidad en zona ".$z." http://www.kimsufi.com/ie/#servers";
- include("manda_email.php");
- }
- //else { echo "No availability"; }
- }
- break;
- }
- }
- ?>
- EOF
- cat > manda_email.php <<EOF
- <?php
- require_once "Mail.php";
- $host = "smtp.gmail.com";
- $username = "your@mail.com";
- $password = "password";
- $headers = array ('From' => $from,
- 'To' => $to,
- 'Subject' => $subject);
- $smtp = Mail::factory('smtp',
- array ('host' => $host,
- 'auth' => true,
- 'username' => $username,
- 'password' => $password));
- $mail = $smtp->send($to, $headers, $body);
- file_put_contents($log_email,date("Y-m-d-H:i:s | ").$mensaje."\n",FILE_APPEND);
- ?>
- EOF
- cat >> /etc/crontab <<EOF
- */1 * * * * root /usr/bin/php /root/kimsufi.php
- EOF
- service cron restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement