X-Git-Url: http://git.pjr.cc/?p=glcas.git;a=blobdiff_plain;f=plugins%2Fhosts.php;fp=plugins%2Fhosts.php;h=d2222b69bdbf3f3fcfc46a88cc461364bcb3d913;hp=5b521cf6499f042a5a49b00ac27965f23f6a344c;hb=e842b9e98acbc69ea55e655130b68df06f25b3cd;hpb=e81521d3926c7dff1484e5c86a02dcfd8dc93b8e diff --git a/plugins/hosts.php b/plugins/hosts.php index 5b521cf..d2222b6 100644 --- a/plugins/hosts.php +++ b/plugins/hosts.php @@ -63,6 +63,8 @@ class GLCASHosts { $nhosts = 0; $group_to_do = null; $ngroups = 0; + $ping_host = null; + $nping = 0; // first check if nogroup is selected if(isset($_REQUEST["nonegroup-selected"])) { @@ -70,7 +72,7 @@ class GLCASHosts { $nogroup = true; } - foreach($groups as $key=>$val) { + if($groups !== false) foreach($groups as $key=>$val) { $grpname = $val["category"]; if(isset($_REQUEST["$grpname-selectgroup"])) { $group_to_do[$ngroups++] = $grpname; @@ -114,9 +116,28 @@ class GLCASHosts { if($operation == "delete") { $this->config->delData("hosts", "$hname", "$hip", "$hg"); } + if($operation == "ping") { + $ping_host[$nping++] = $hip; + } } } + if($operation == "ping") { + foreach($ping_host as $lip) { + $ips .= " $lip"; + } + + error_log("ping helper is going with $ips"); + + global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL; + if(file_exists("$WEB_ROOT_FS/../bin/scanhelper.php")) { + $scall = "/usr/bin/php $WEB_ROOT_FS/../bin/pinghelper.php $ips > /tmp/ping 2>&1 &"; + system($scall); + } else { + error_log("cant find download helper... dieing"); + } + + } /*echo "total to do:
";
 		print_r($hosts_to_do);
 		print_r($_REQUEST);
@@ -247,6 +268,7 @@ class GLCASHosts {
 		echo "Selected hosts operation: ";
 		echo "Group HostIPLast SeenControl";
+		echo "";
 		foreach($hosts as $key => $val) {
 			$hname = $val["category"];
 			$hip = $val["name"];
 			$hg = $val["val"];
 			if($hg == "") $hg = "-";
 			if($hg=="-") {
+				$lastping_v = $this->config->getData("ping", $hip);
+				$lastping_o = $lastping_v[0];
+				if(!$lastping_v) $lastping = "None";
+				else {
+					if($lastping_o["val"] == "failed") {
+						$lastp_time = glcas_tdiffToAgo(time()-$lastping_o["name"]);
+						$lastping = "$lastp_time - Failed";
+					} else {
+						$lastp_time = glcas_tdiffToAgo(time()-$lastping_o["name"]);
+						$lping_delay = $lastping_o["val"];
+						$lastping = "$lastp_time - $lping_delay ms";
+					}
+				}
 				$lastseen = glcas_getLastSeen($hip, $this->config->getData("lastseen", "$hip"));
-				echo "";
+				echo "";
 			}
 		}
 		echo "
HostIPLast SeenLast PingControl
$hname$hip$lastseenDelete
$hname$hip$lastseen$lastpingDelete
"; @@ -285,15 +320,29 @@ class GLCASHosts { echo ""; $grpname = $val["category"]; echo "

Host Group: $grpname Delete


"; - echo ""; + echo "
HostIPLast SeenControl
"; if($hosts != false) foreach($hosts as $key => $val) { $hname = $val["category"]; $hip = $val["name"]; $hg = $val["val"]; if($hg == "") $hg = "-"; if($hg==$grpname) { + $lastping_v = $this->config->getData("ping", $hip); + $lastping_o = $lastping_v[0]; + if(!$lastping_v) $lastping = "None"; + else { + if($lastping_o["val"] == "failed") { + $lastp_time = glcas_tdiffToAgo(time()-$lastping_o["name"]); + $lastping = "$lastp_time - Failed"; + } else { + $lastp_time = glcas_tdiffToAgo(time()-$lastping_o["name"]); + $lping_delay = $lastping_o["val"]; + $lastping = "$lastp_time - $lping_delay ms"; + } + } + $lastseen = glcas_getLastSeen($hip, $this->config->getData("lastseen", "$hip")); - echo ""; + echo ""; } } echo "
HostIPLast SeenLast PingControl
$hname$hip$lastseenDelete
$hname$hip$lastseen$lastpingDelete
";