<?php $starttime = microtime(true); $start=0; // $ndstatus = "all"; $ndsearchred = ""; $ndqueueid = ""; ################## #SETTINGS // $default_log = "/mnt/WD1600BEVT/SYSLOG/syslog-dfl.log"; // $default_limit = 200; #END SETTINGS ################## if(isset($_GET["limit"])) $end = $_GET["limit"]; else $end = $default_limit; if(isset($_GET["logfilename"])) $logfilename = $_GET["logfilename"]; else $logfilename = $default_log; if(isset($_GET["queue"])) $ndqueueid = $_GET["queue"]; if(isset($_GET["ndsearchred"])) $ndsearchred = $_GET["ndsearchred"]; if(isset($_GET["status"])) $ndstatus = $_GET["status"]; // - $readlimit = false; if($ndstatus!=="errors" && $ndsearchred=="") $readlimit = true; $first=true; // $monthfrom = date("m"); $monthto = date("m"); $dayfrom = date("d"); $dayto = date("d"); $ndtimefrom = mktime(0,0,0); $ndtimeto = time(); // if(isset($_GET["monthfrom"])) $monthfrom = $_GET["monthfrom"]; if(isset($_GET["monthto"])) $monthto = $_GET["monthto"]; // if(isset($_GET["dayfrom"])) $dayfrom = $_GET["dayfrom"]; if(isset($_GET["dayto"])) $dayto = $_GET["dayto"]; // unixtime if(isset($_GET["timefrom"])) { if(strlen($_GET["timefrom"])>0) $ndtimefrom = mktime($_GET["timefrom"],0,0,$_GET["monthfrom"],$_GET["dayfrom"]); } if(isset($_GET["timeto"])) { if(strlen($_GET["timeto"])>0) $ndtimeto = mktime($_GET["timeto"],0,0,$_GET["monthto"],$_GET["dayto"]); } elseif(isset($_GET["monthto"])) { if(strlen($_GET["monthto"])>0) $ndtimeto = mktime(23,59,59,$_GET["monthto"],$_GET["dayto"]); } ?> <html> <head> <script>function open_win1(){var myWin=window.open("help.txt","Window","scrollbars=yes, resizable=yes,width=1360, height=655")}</script> <script>function open_win2(){var myWin=window.open("NetDefendOS_2.27.03_Log_Reference_Guide.pdf","Window","scrollbars=yes, resizable=yes,width=1360, height=655")}</script> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title> syslog D-Link DFL-860e </title> <style> body, td { font-family:Tahoma,Verdana,Sans serif; font-size:13px; } .queue { border:1px #ccc solid; margin:5px; padding:5px; } small { color:#999; } a.email:link, a.email:visited { cursor:pointer; border-bottom:1px #000 dotted; text-decoration:none; color:#000; } </style> </head> <body> <form name="filterform"> <table border="0" cellpadding="5" cellspacing="5"> <tr> <td colspan="2"> <a name="begin" /></a> <h3> syslog D-Link DFL-860e </h3> </td> </tr> <tr> <td width="200px"> syslog : <br/><small> log </small> </td> <td> <input type="text" name="logfilename" value="<?=$logfilename; ?>" size="12" /> </td> </tr> <tr> <td width="200px"> : <br/><small> .<br/> CONN PPTP ALG ...</small> </td> <td> <input type="text" name="queue" value="<?=$ndqueueid; ?>" size="12" /> <input type="button" title="6 (CONN) State engine, / " value="CONN" OnClick="document.filterform.queue.value='CONN'" /> <input type="button" title="27 (PPTP) PPTP-" value="PPTP" OnClick="document.filterform.queue.value='PPTP'" /> <input type="button" title="2 (ALG) Application Layer Gateways" value="ALG" OnClick="document.filterform.queue.value='ALG'" /> <input type="button" title="32 (SYSTEM) : , .." value="SYSTEM" OnClick="document.filterform.queue.value='SYSTEM'" /> <input type="button" title="42 (IGMP) IGMP" value="IGMP" OnClick="document.filterform.queue.value='IGMP'" /> <input type="button" title="33 (TCP_FLAG) , TCP" value="TCP_FLAG" OnClick="document.filterform.queue.value='TCP_FLAG'" /> <input type="button" title="9 (DHCPSERVER) DHCP-" value="DHCPSERVER" OnClick="document.filterform.queue.value='DHCPSERVER'" /> <input type="button" title="3 (ARP) ARP" value="ARP" OnClick="document.filterform.queue.value='ARP'" /> <input type="button" title="49 (SESMGR) " value="SESMGR" OnClick="document.filterform.queue.value='SESMGR'" /> <input type="button" title="34 (TCP_OPT) , TCP" value="TCP_OPT" OnClick="document.filterform.queue.value='TCP_OPT'" /> <input type="button" title="60 (RULE) , " value="RULE" OnClick="document.filterform.queue.value='RULE'" /> <input type="button" title="70 (IP_PROTO) IP-" value="IP_PROTO" OnClick="document.filterform.queue.value='IP_PROTO'" /> <input type="button" title="18 (IPSEC) IPsec (VPN)" value="IPSEC" OnClick="document.filterform.queue.value='IPSEC'" /> <input type="button" title="37 (USERAUTH) (, RADIUS)" value="USERAUTH" OnClick="document.filterform.queue.value='USERAUTH'" /> <input type="button" title="35 (TIMESYNC) " value="TIMESYNC" OnClick="document.filterform.queue.value='TIMESYNC'" /> <input type="button" title="25 (PPP) PPP-" value="PPP" OnClick="document.filterform.queue.value='PPP'" /> <input type="button" title="31 (SNMP) SNMP" value="SNMP" OnClick="document.filterform.queue.value='SNMP'" /> <input type="button" title="41 (RFO) Route fail over" value="RFO" OnClick="document.filterform.queue.value='RFO'" /> </td> </tr> <tr> <td> / ( ) : <br/><small> </small> </td> <td> <input type="text" name="dayfrom" value="<?=$dayfrom; ?>" size="3" /> <input type="text" name="monthfrom" value="<?=$monthfrom; ?>" size="3" /> - <input type="text" name="dayto" value="<?=$dayto;?>" size="3" /> <input type="text" name="monthto" value="<?=$monthto; ?>" size="3" /> </td> </tr> <tr> <td> ( ) : <br/><small> 00-24</small> </td> <td> <input type="text" name="timefrom" value="<?php if(!isset($_GET["timefrom"])){echo "00";}else{echo $_GET["timefrom"];} ?>" size="3" /> - <input type="text" name="timeto" value="<?php if(isset($_GET["timeto"])) echo $_GET["timeto"]; ?>" size="3" /> </td> </tr> <tr> <td> : <br/><small> </small> </td> <td> <input type="text" name="ndsearchred" value="<?=$ndsearchred; ?>" size="12" /> </td> </tr> <tr> <td> : </td> <td> <input type="text" name="limit" value="<?php echo $end; ?>" size="4" /> </td> </tr> <tr> <td colspan="2"> <input type="submit" value=" " /> <input type="button" value=" " OnClick="window.location.href='index.php'" /> <input type="button" value=" " onclick="open_win1()"> <input type="button" value="NetDefendOS_2.27.03_Log_Reference_Guide.pdf" onclick="open_win2()"> </td> </tr> </table> </form> <?php if($ndtimefrom>$ndtimeto){die("Error: Invalid time period");} $filearray = @file($logfilename); if(!$filearray){die("Error: Can't open file. Check permissions.");} // krsort($filearray); reset($filearray); $array = array(); // foreach($filearray as $string) { // QUEUEID $regexp = "'.+: ([0-9_A-Z]*): (.+)$'"; // QUEUEID if(strlen($ndqueueid)>0){$regexp = "'^(.+): (".$ndqueueid."[0-9_A-Z]*): (.+)$'";} // if(preg_match($regexp,$string)) { $time = trim(preg_replace("'^(\w*)\s*(\d*) (\d\d:\d\d:\d\d).+$'","$1 $2 $3",$string)); $unixtime = strtotime($time); // if($unixtime<$ndtimefrom)break; // if($unixtime>$ndtimeto)continue; $queueid = trim(preg_replace("'^(.+): ([0-9_A-Z]*): (.+)$'","$2",$string)); $mess = htmlspecialchars(preg_replace("'(.+)($queueid):(.+)'","$3",$string)); if(!isset($array["$queueid"]["message"])) $array["$queueid"]["message"] =""; $array["$queueid"]["time"]= $unixtime; $array["$queueid"]["message"]= $time.$mess."<br/>".$array["$queueid"]["message"]; // if($first==true){$endperiod = $unixtime; $first=false;} $startperiod = $unixtime; // if($readlimit){if(count($array)>=$end){break;}} } } // if(count($array)==0){die(" log , .");} // arsort($array); reset($array); // echo "<b> : ".count($array)."</b><br/>"; echo "<b> : ".$end."</b><br/>"; printf("<b> log : %.2f Kb</b><br/>",filesize($logfilename)/1024); echo "<b> : ".date("dM H:i",$startperiod)." - ".date("dM H:i",$endperiod)."</b><br/>"; // foreach($array as $k => $sarray) { $process = " :"; // if(strlen($ndsearchred)>0) { if(!stripos($array[$k]["message"],$ndsearchred)){continue;} else $array[$k]["message"] = str_ireplace($ndsearchred,"<font color=\"#DB8040\">$ndsearchred</font>",$array[$k]["message"]); } // $array[$k]["message"] = preg_replace("'srcip='","<font color=\"green\">srcip=</font>",$array[$k]["message"]); $array[$k]["message"] = preg_replace("'destip'","<font color=\"green\">destip</font>",$array[$k]["message"]); $array[$k]["message"] = preg_replace("'srcport='","<font color=\"green\">srcport=</font>",$array[$k]["message"]); $array[$k]["message"] = preg_replace("'destport='","<font color=\"green\">destport=</font>",$array[$k]["message"]); $array[$k]["message"] = preg_replace("'action=reject'","<font color=\"#DBBE00\">action=reject</font>",$array[$k]["message"]); $array[$k]["message"] = preg_replace("'user='","<font color=\"blue\">user=</font>",$array[$k]["message"]); $array[$k]["message"] = preg_replace("'remotegw='","<font color=\"blue\">remotegw=</font>",$array[$k]["message"]); $array[$k]["message"] = preg_replace("'uptime='","<font color=\"green\">uptime=</font>",$array[$k]["message"]); $start++; echo "<div class=\"queue\"><b>$process ".$k." </b><br/>\n"; // echo $array[$k]["time"]."<br/>".$array[$k]["message"]."<br/>\n"; echo "</div>"; if($start>=$end){break;} } printf("<script>document.title='Time %.2f s'</script>",microtime(true)-$starttime); ?> </body> </html>
1 () , 2 (ALG) Application Layer Gateways 3 (ARP) ARP 4 (BIGPOND) BigPond 5 (BUFFERS) , 6 (CONN) State engine,, / 7 (DHCP) DHCP- 8 (DHCPRELAY) DHCP relayer 9 (DHCPSERVER) DHCP- 10 () / 11 () 12 (HA) High Availability 13 (IDP) / 14 (IDP) IDP 15 (IP_) , - / IP- 16 (IP_) , IP- 17 (IP_OPT) , IP- 18 (IPSEC) IPsec (VPN) 19 (IP_) IP- 20 (FRAG) 21 (FWD) , 22 (GRE) GRE 23 (NETCON) Netcon ( -) 24 (OSPF) OSPF 25 (PPP) PPP- 26 (PPPOE) PPPoE- 27 (PPTP) PPTP- 28 (L2TP) L2TP- 29 (SLB) SLB 30 (SMTPLOG) SMTPLOG 31 (SNMP) SNMP 32 (SYSTEM) : , .. 33 (TCP_FLAG) , TCP 34 (TCP_OPT) , TCP 35 (TIMESYNC) 36 () : , .. 37 (USERAUTH) (, RADIUS) 38 (ZONEDEFENSE) ZoneDefense 39 (IFACEMON) 40 (HWM) 41 (RFO) Route fail over 42 (IGMP) IGMP 44 (TRANSPARENCY) , Transparent Mode 46 (BLACKLIST) 47 (SSHD) SSH- 48 (REASSEMBLY) , 49 (SESMGR) 50 (AVUPDATE) 51 (AVSE) 52 (VFS) VFS 53 (THRESHOLD) 56 (NATPOOL) , NAT 58 (ANTIVIRUS) , 59 (ANTISPAM) , 60 (RULE) , 70 (IP_PROTO) IP-
input type="text" name="queue" value="<?=$ndqueueid; ?>" size="12" /> <input type="button" title="6 (CONN) State engine, / " value="CONN" OnClick="document.filterform.queue.value='CONN'" />
Source: https://habr.com/ru/post/219795/
All Articles