docs:tips_n_tricks:nagios:using_http_for_passive_checks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
docs:tips_n_tricks:nagios:using_http_for_passive_checks [22.10.2012 16:36 CEST] – peter | docs:tips_n_tricks:nagios:using_http_for_passive_checks [23.10.2012 10:54 CEST] (current) – peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Using HTTP for passive checks ====== | ====== Using HTTP for passive checks ====== | ||
+ | ===== Using cmd.cgi ===== | ||
This description is valid for //Nagios 3//. | This description is valid for //Nagios 3//. | ||
Line 41: | Line 42: | ||
Of course, in a large environment with appropriate security needs, you would write a PHP script that is restricted to write passive checks. | Of course, in a large environment with appropriate security needs, you would write a PHP script that is restricted to write passive checks. | ||
+ | |||
+ | ===== Using PHP ===== | ||
+ | If you prefer a separate PHP script, this may serve as a skeleton: | ||
+ | |||
+ | <?php | ||
+ | $state_str=array( 0 => ' | ||
+ | 1 => ' | ||
+ | 2 => ' | ||
+ | 3 => ' | ||
+ | $nsca_host=" | ||
+ | $send_nsca="/ | ||
+ | ?> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | <?php | ||
+ | $log_fh=fopen("/ | ||
+ | fwrite($log_fh,' | ||
+ | ?>< | ||
+ | while (list ($key, $val) = each ($_REQUEST)) { | ||
+ | print htmlentities(" | ||
+ | | ||
+ | } | ||
+ | | ||
+ | $host = $_REQUEST[' | ||
+ | $service = $_REQUEST[' | ||
+ | $state | ||
+ | $msg = $_REQUEST[' | ||
+ | ?>< | ||
+ | $nsca_fh=popen($send_nsca.' | ||
+ | fwrite($nsca_fh, | ||
+ | fwrite($log_fh, | ||
+ | printf("< | ||
+ | "< | ||
+ | pclose($nsca_fh); | ||
+ | | ||
+ | fwrite($log_fh,' | ||
+ | fclose($log_fh); | ||
+ | ?> | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | {{tag> | ||
+ | {{entry> | ||
+ | {{entry> |
docs/tips_n_tricks/nagios/using_http_for_passive_checks.1350916606.txt.gz · Last modified: 22.10.2012 16:36 CEST by peter