Hi Michael,
Thanks.
But I think it will be better if you could integrate both "fping"'s into the same functions.
Using the function: get_config_option("os") you will be able to tell if its a Unix host or a Windows host.
We could also use the size parameter for the unix fping.
Javier
Meyers, Michael wrote:
I have finished a simple "port" for reachability (RTT/PL) so that you can now get basic reachability results on a win32 box running JFFNMS.
Javier, please check these out and make any modifications you think are necessary. Could we put these in future version of JFFNMS?
Here's how:
Prerequisites: download fping-win32 from http://www.kwakkelflap.com/downloads.html - you will need to copy the fping.exe file to to same place as the rest of you jffnms files (mine is under c:\jffnms\bin) then make sure to modify the jffnms configuration for fping to poing to c:\jffnms\bin\fping.exe etc...
Then: 1) modify/replace the reachability_start.php, reachability_values.php, and reachability_wait.php under %JFFNMS%\engine\pollers with the updated scripts below:
2) These scripts also require the a Size (Internal Name "size") field to be added under (Internal Configuration --> Polling and Discovery --> Interface Types --> Reachability -->Fields).
Replace the eachability_values.php with this one: <? function poller_reachability_values ($options) {
$rtt_pattern = "/Average\s+=\s+(\d+)/i"; $ptx_pattern = "/Sent\s+=\s+(\d+)/i"; $prx_pattern = "/Received\s+=\s+(\d+)/i";
$temp = get_config_option ("engine_temp_path");
$buffer = $GLOBALS["session_vars"]["poller_buffer"];
$uniq = $buffer["ping-".$options["interface_id"]]; //get file id from reachability_start
$filename = "$temp/$uniq.log";
unset ($temp); unset ($buffer); unset ($uniq);
$which_value = $options["poller_parameters"]; //Poller Parameter specifies which value to return $value = 0;
$pl = "";
$rtt = 0;
$ptx = 0;
$prx = 0;
$lines = 0;
if (file_exists($filename)) {
$lines = count(file($filename)); // COUNT NUM LINES IN FILE $data = file($filename); // READ FILE INTO ARRAY $pl = $data[$lines - 3]; // READ PACKET LOSS LINE FROM DATA ARRAY $rtt = $data[$lines - 1]; // READ ROUND TRIP TIME AVERAGES FROM DATA ARRAY
if (preg_match($rtt_pattern,$rtt,$plparts)) $rtt = $plparts[1]; if (preg_match($ptx_pattern,$pl,$plparts)) $ptx = $plparts[1]; if (preg_match($prx_pattern,$pl,$plparts)) $prx = $plparts[1];
switch ($which_value) {
case "rtt": $value = $rtt; // RTT Average
break;
case "pl": $value = $ptx - $prx; // Lost Packets = Sent Packets - Recv Packets break;
} }
unset ($data); unset ($parts); unset ($which_value); unset ($fping_pattern); unset ($rtt); unset ($ptx); unset ($prx); unset ($pl); unset ($lines);
return $value;
}
?>
Next, edit the reachability_wait.php (changed the wait so that it waits for a "," not a ":"): while (($i++ < 100) && (strpos(trim(end(file($filename))),",") === false)) //wait 100 seconds or untuil the last line of filename have a ,
Then finally, replace the reachability_start (just a few changes actually):
<?
function poller_reachability_start ($options) {
$fping = get_config_option ("fping_executable");
$temp = get_config_option ("engine_temp_path");
$ip = gethostbyname($options["host_ip"]);
$num_ping = $options["pings"]; $interval = $options["interval"]; $size = 0; $size = $options["size"];
if (($ip != -1) && file_exists($fping) && ($num_ping > 0) && ($interval > 10)) {
$uniq = uniqid("");
$filename = "$temp/$uniq.log";
$command = "$fping $ip -n $num_ping -t $interval -s $size > $filename 2>&1 &";
exec($command); //FIXME check if it is running
unset ($command);
unset ($filename);
}
unset ($fping);
unset ($temp);
unset ($ip);
unset ($num_ping);
unset ($interval);
unset ($size);
return $uniq;
}
?>
Basic troubleshooting: make sure that the temp files are getting created under %JFFNMSPATH%\engine\temp. If not, then check your fping path and make sure you also have added the size field (no error checking, sorry).
Tip: The longer you ping, the longer the polling process takes. I just send out 10 pings with a delay between pings of 300ms, so it takes about 3 seconds to poll each host with reachability.
Hope this helps everyone out there, -Mike
------------------------------------------------------- This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com _______________________________________________ jffnms-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jffnms-users
-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Javier Szyszlican, Project Leader, JFFNMS [EMAIL PROTECTED]
I hope JFFNMS or I were helpful to you, if you can, please donate at http://jffnms.org/donate
------------------------------------------------------- This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com _______________________________________________ jffnms-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jffnms-users
