Created
January 20, 2012 14:03
-
-
Save manoot/1647497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| ////////// | |
| // THIS FILE DUMPS THE DATA TO DATA FILE | |
| // (c) Travis Mathis - travisdmathis@gmail.com | |
| // Zabbix Report Generator v0.1 | |
| // | |
| // ERROR REPORTING | |
| error_reporting(E_ALL); | |
| set_time_limit(1800); | |
| // VARIABLES | |
| $timeperiod = $_GET['timePeriod']; | |
| $site = $_GET['siteList']; | |
| //CONFIGURATION | |
| $z_server = 'https://url/zabbix/'; | |
| $z_user = 'user'; | |
| $z_pass = 'pass'; | |
| //NON CONFIGUREABLE | |
| $z_tmp_cookies = ""; | |
| $z_url_index = $z_server ."index.php"; | |
| $z_url_graph = $z_server ."chart2.php"; | |
| $z_url_api = $z_server ."api_jsonrpc.php"; | |
| // FUNCTIONS | |
| function getGraphImageById ($graphid, $period = 3600) { global $z_server, $z_user, $z_pass, $z_tmp_cookies, $z_url_index, $z_url_graph, $z_url_api; | |
| // cookie name | |
| $filename_cookie = $z_tmp_cookies ."zabbix_cookie_" .$graphid .".txt"; | |
| //setup curl | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $z_url_index); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| curl_setopt($ch, CURLOPT_POST, true); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | |
| $post_data = array('name' => $z_user, 'password' => $z_pass, 'enter' => 'Enter'); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); | |
| curl_setopt($ch, CURLOPT_COOKIEJAR, $filename_cookie); | |
| curl_setopt($ch, CURLOPT_COOKIEFILE, $filename_cookie); | |
| // login | |
| curl_exec($ch); | |
| // get graph image | |
| curl_setopt($ch, CURLOPT_URL, $z_url_graph ."?graphid=" .$graphid ."&width=450&period=" .$period); | |
| $output = curl_exec($ch); | |
| // close | |
| curl_close($ch); | |
| // delete cookie | |
| unlink($filename_cookie); | |
| //save image | |
| return $output; | |
| } | |
| // Header | |
| echo "<b>Host: </b>" .$site ."</br>"; | |
| echo "<b>Time Period: </b>" .$timeperiod ."</br></br>"; | |
| echo "<b><center> Please wait while I generate your report, you will be forwarded automatically upon completion </b></center>"; | |
| // Format Data into the Data file | |
| if($site == 'All' and $timeperiod == 'Day'){ | |
| getGraphImageById('424','86400'); | |
| } | |
| ?> | |
| # ERROR | |
| Warning: unlink(zabbix_cookie_424.txt): No such file or directory in /usr/local/share/zabbix/custom_pages/generatereport.php on line 53 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment