#!/usr/bin/php 1)) { Help(); die("\n\n"); } exec ("traceroute $hostname", $out, $output); system ("killall -q traceroute", $errorvar); // Kill all traceroute processes in case of a stall. Or can use echo traceroute to execute without shell // Go through each line of output and see if $searchfor is in there $result = 0; foreach ($out as $output) { $pos = strpos($output, $searchfor); //if ($pos === true) if ($pos) { //echo "Setting result to True\n"; $result = $result+1; } } if ($result>0) { echo "OK. $searchfor found in traceroute to $hostname.\n"; exit(0); } else { echo "CRITICAL. $searchfor not found in traceroute to $hostname.\n"; exit(2); } ?>