简体   繁体   English

用php收集路由器日志

[英]Collect router logs with php

I am a newbie in PHP. 我是PHP的新手。 I just want to know how to how to collect router logs and display it in a webpage? 我只想知道如何收集路由器日志并将其显示在网页中? Interface should be written in PHP. 接口应该用PHP编写。 Please help me. 请帮我。

In general it is not a good idea to write something like that, because it is important to secure this really well. 通常,写这样的东西不是一个好主意,因为真正做到这一点很重要。 There are many steps involved (like login to router, get the files to the webserver, have some layout for the webpage, create login, storing files, etc), so it is not just a simple script... Instead have a look at splunk.com , it might be what you want. 涉及许多步骤(例如登录到路由器,将文件获取到Web服务器,为网页进行一些布局,创建登录名,存储文件等),因此它不仅仅是一个简单的脚本...而是看看splunk.com,这可能是您想要的。

If your router supports SSH you can use phpseclib to login and get the logs via ssh commands then use it in your PHP application 如果您的路由器支持SSH,则可以使用phpseclib登录并通过ssh命令获取日志,然后在PHP应用程序中使用它

Here is a snippet that shows how to connect to SSH via phpseclib: 这是显示如何通过phpseclib连接到SSH的代码段:

<?php
include('Net/SSH2.php');

$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM