Advertisement
Guest User

LoadWHM

a guest
Mar 1st, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. // heberth ardila
  3. // Script verificar carga WHM
  4. // instalar php-curl como dependencia
  5.  
  6. $whmusername = "server-ip";
  7. $whmpassword = "password-server";
  8. $query = "https://server1.com:2087/json-api/loadavg?api.version=1";
  9. $curl = curl_init(); // Create Curl Object
  10. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0); // Allow self-signed certs
  11. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0); // Allow certs that do not match the hostname
  12. curl_setopt($curl, CURLOPT_HEADER,0); // Do not include header in output
  13. curl_setopt($curl, CURLOPT_RETURNTRANSFER,1); // Return contents of transfer on curl_exec
  14. $header[0] = "Authorization: Basic " . base64_encode($whmusername.":".$whmpassword) . "\n\r";
  15. curl_setopt($curl, CURLOPT_HTTPHEADER, $header); // set the username and password
  16. curl_setopt($curl, CURLOPT_URL, $query); // execute the query
  17. $result = curl_exec($curl);
  18. if ($result == false) {
  19. error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
  20. // log error if curl exec fails
  21. }
  22. curl_close($curl);
  23.  
  24. print $result;
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement