0,0 → 1,48 |
#!/usr/bin/php |
<?php |
|
# --- PLEASE MODIFY: |
|
# To which daemon server should the alarm be sent? |
$url = "http://127.0.0.1:8085"; |
|
# Which targets should be reported? |
$targets = array( |
"1.3.6.1.4.1.37476.2.4.2.0", // Any |
"1.3.6.1.4.1.37476.2.4.2.1002", // Motion, camera |
"1.3.6.1.4.1.37476.1.2.1.1" // PRIVATE: Webcam of Daniel Marschall |
); |
|
# --- DON'T MODIFY AFTER THIS LINE |
|
$fields = array(); |
$fields[] = "action=server_alert"; // 1.3.6.1.4.1.37476.2.4.1.2 |
foreach ($targets as $target) { |
// Note: We are not using http_build_query(), because it sends targets[0]=...&targets[1]=..., |
// which is not what we need. We want targets=...&targets=... |
$fields[] = "targets=".urlencode($target); |
} |
$fields_string = implode('&', $fields); |
|
echo urldecode($fields_string)."\n"; |
|
$ch = curl_init(); |
curl_setopt($ch, CURLOPT_URL, $url); |
curl_setopt($ch, CURLOPT_POST, true); |
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
$result = curl_exec($ch); |
|
echo $result; |
|
// Note: We are not using Python to send the alert, because the "import" command is extremely |
// slow, and we need to send an alarm withhin milliseconds! |
/* |
import requests |
d = {"action": "server_alert", "targets": [ |
"...", |
"..." |
]} |
requests.post("http://127.0.0.1:8085", data=d) |
*/ |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |