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:20 CEST] – created 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 6: | Line 7: | ||
* Allowed to access nagios by your webserver, normally accomplished with //Basic Auth// and // | * Allowed to access nagios by your webserver, normally accomplished with //Basic Auth// and // | ||
- | * Allowed to view all services/ | + | |
- | * Allowed to submit commands for all services/ | + | * via dedicated permissions on the host(s) and service(s) in question\\ |
+ | or | ||
+ | | ||
+ | * Allowed to submit commands for all services/ | ||
+ | |||
+ | At least if you are going to use dedicated permissions, | ||
+ | |||
+ | define contact{ | ||
+ | contact_name | ||
+ | alias | ||
+ | service_notification_period | ||
+ | host_notification_period | ||
+ | service_notification_options | ||
+ | host_notification_options | ||
+ | service_notification_commands | ||
+ | host_notification_commands | ||
+ | } | ||
Assuming you have your credentionals for the account // | Assuming you have your credentionals for the account // | ||
wget -O - \ | wget -O - \ | ||
- | | + | |
| | ||
| | ||
Line 24: | Line 41: | ||
'& | '& | ||
- | 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.1350915612.txt.gz · Last modified: 22.10.2012 16:20 CEST by peter