Hello Kai, Thank you for your reply!
At this stage it looks we will be parsing the status file (only worry is that the status file is updated in a non-atomic way, so will probably write a daemon with inotify watch on "close_write". A second question: is the status file updated atomically? Thank you very much! I hoped there is an "official" way to achieve this. Sergei. On 29 April 2015 at 19:19, Kai Nothdurft <[email protected]> wrote: > Hi Sergei, > > before I forget, you should not use ".'~'.$hostName.'" in the two > fwrite-lines of the script. This is for our special environment only. > > rgds > Kai > > > >>> On 29.04.2015 at 09:10, "Kai Nothdurft" <[email protected]> > wrote: > > Hello Sergei, > > > > at first, I was missing the "obsess over services/hosts" as well. As > a > > workaround I wrote a little cronjob, which parses the status.dat and > creates > > a command‑file from it. The script generates a > > "PROCESS_HOST|SERVICE_CHECK_RESULT" for ALL host‑ and service‑stati. > You have > > to filter on the hosts/services, you are interested in, transfer the > > > COMMAND_FILE to your Nagios 3.x‑host and pipe it into the > command‑pipe. Be sure > > that the feature "statusdata" is enabled (icinga2 feature list). > > > > hth > > Kai > > > > ‑‑‑‑ cut here ‑‑‑‑ > > #!/usr/bin/php > > <?php > > > > define("STATUS_FILE", "/var/cache/icinga2/status.dat"); > > define("COMMAND_FILE", "/YOUR/PATH/TO/status.upd"); > > > > if (file_exists(STATUS_FILE)) { > > $status_file_handle = fopen(STATUS_FILE, "r"); > > if ($status_file_handle) { > > $command_file_handle = fopen(COMMAND_FILE, "w"); > > if ($command_file_handle) { > > while (!feof($status_file_handle)) { > > $line = fgets($status_file_handle); > > switch ($line) { > > case "hoststatus {\n": > > $hostName = ''; > > $status = 3; > > $pluginOutput = ''; > > $performanceData = ''; > > $checkSource = ''; > > $lastCheck = ''; > > $line = fgets($status_file_handle); > > while (!feof($status_file_handle) && trim($line)!= "}") > { > > list ($param, $value) = explode('=',trim($line),2); > > switch ($param) { > > case "host_name": > > $hostName = $value; > > break; > > case "current_state": > > $state = $value; > > break; > > case "plugin_output": > > $pluginOutput = $value; > > break; > > case "performance_data": > > $performanceData = $value; > > break; > > case "check_source": > > $checkSource = $value; > > break; > > case "last_check": > > $lastCheck = $value; > > break; > > } > > $line = fgets($status_file_handle); > > } > > fwrite($command_file_handle,"[$lastCheck] > > > > PROCESS_HOST_CHECK_RESULT;".$checkSource.'~'.$hostName.';'.$state.';'.$plugin > > Output.'|'.$performanceData."\n"); > > break; > > > > case "servicestatus {\n": > > $hostName = ''; > > $serviceDescription = ''; > > $status = 3; > > $pluginOutput = ''; > > $performanceData = ''; > > $checkSource = ''; > > $lastCheck = ''; > > $line = fgets($status_file_handle); > > while (!feof($status_file_handle) && trim($line)!= "}") > { > > list ($param, $value) = explode('=',trim($line),2); > > switch ($param) { > > case "host_name": > > $hostName = $value; > > break; > > case "service_description": > > $serviceDescription = $value; > > break; > > case "current_state": > > $state = $value; > > break; > > case "plugin_output": > > $pluginOutput = $value; > > break; > > case "performance_data": > > $performanceData = $value; > > break; > > case "check_source": > > $checkSource = $value; > > break; > > case "last_check": > > $lastCheck = $value; > > break; > > } > > $line = fgets($status_file_handle); > > } > > fwrite($command_file_handle,"[$lastCheck] > > > > PROCESS_SERVICE_CHECK_RESULT;".$checkSource.'~'.$hostName.';'.$serviceDescrip > > tion.';'.$state.';'.$pluginOutput.'|'.$performanceData."\n"); > > break; > > } > > } > > } > > fclose($status_file_handle); > > } > > } > > ?> > > > > > >>>> On 29.04.2015 at 06:49, Sergei Franco <[email protected]> > wrote: > >> Hello there, > >> > >> Is there a way to push passive results via nsca from Icinga 2 (which > does > >> active checking) to Nagios 3.x? > >> It looks like the "obsess over services/hosts" and ochp/ocsp config > items > >> are missing from Icinga 2. > >> > >> The nagios machine (that receives the passive checks) *cannot* be > >> "upgraded" to icinga2 so none of the distributed monitoring > documentation > >> applies.... > >> > >> Regards. > >> > >> > >> Sergei. > > _______________________________________________ > > icinga‑users mailing list > > icinga‑[email protected] > > https://lists.icinga.org/mailman/listinfo/icinga‑users > _______________________________________________ > icinga-users mailing list > [email protected] > https://lists.icinga.org/mailman/listinfo/icinga-users >
_______________________________________________ icinga-users mailing list [email protected] https://lists.icinga.org/mailman/listinfo/icinga-users
