Advertisement
Guest User

LoadWHM

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