PHP doing SNMP walk on remote devices/clients? - php

I am trying to create a new application for our company to do an SNMP walk.
Here's what I am trying to achieve. The customer logs into our website. Clicks a button saying "Do SNMP Walk" and a PHP script will do a walk, and parse the data into the MySQL DB, and that's it.
Is this possible to do with PHP?
I was reading on http://php.net/manual/en/function.snmpwalk.php and I seen that it looks like it is, but I wasn't sure because the clients wouldn't be on the same network as the server the script is running from (we'd be using godaddy.)
Thanks!

If you're trying to SNMP walk devices in the client's network from your GoDaddy server, then the answer is no: you won't be able to do it.
SNMP is typically not passed through firewalls, so you would need to deploy your PHP code on the same network as the client.

This is wrong... snmp, is passed like any other data packets, unless the router is specifically configured to block it. I frequently use it to access routers across the internet to different providers and such.
Its possible that GoDaddy has blocks on that, but I have never seen this. You may want to install a copy of snmp on your computer and do an snmpwalk from the commandline.

Related

How to get network traffic info and display it in PHP

i have server ubuntu . I want to show network traffic upload & download in php .
A command is in the terminal for monitoring traffic: enter link description here
How can I use command nload -mon php.
Like this :
i have no idia about it
The simplest solution is:
to call this function in PHP file via exec().
to parse the output from this function and prepare the markup to present those values (total input/output) on the page.
Better solutions depend on how often this info should be retrieved and how pretty it should be rendered in the browser.
It compiles php to apache and apache simply does not access network uses. There are several ways for this;
1-) shell_exec;
In ubuntu you can prepare a console command that will output the network data as json, then you can run this console command in ubuntu using shell_exec in php.
2-) third part programming;
For example, you can develop scripts on platforms such as python, node js, etc. and access network usage. Again, with the software you have developed, you can instantly print the network usages to the database. In another option, you can access network information with software such as phton and show them on socket, and you can get data from php with socket. Finally, you can develop an api for this on pyhton.

How to perform serial communication using PHP on IIS on Windows 10

I'm looking for a way to read/write a PC's serial com port using PHP/IIS on Windows 10. I've experimented for a few days now, but every attempt failed.
I tried to use php_dio.php, only to find out this dll misses some essential implementation on Windows. Through StackOverflow I also read that it would impossible for PHP on Windows to do this.
I can use Powershell on Windows to perform the tasks I want using scripts, but I'm not able to gets it output. Also, I fail to start this from PHP using exec or shell_exec.
So, at the moment, I'm stuck. My goal is to create a PHP-file which is able to receive requests from the web. That request would than be translated into a command which I would send to a device which is connected on my com-port. The response on the com-port would then be sent back to the server which did the request. It's just simple serial I/O, like 9600 bd, No parity etc. The setup works, but like I said, every attempt to use PHP to access the com port fails.
Is there a way?
Suggestions are appreciated.
Thanks.
Tried php_dio, exec, shell_exec

Phased transition from php to node server

I am working on a site that is hosted on
goDaddy, through cPanel
The client wants to transition from their old PHP server to a node.js system.
They would like to implement new code in phases while leaving the old site up and running. The old and new code would be running on the same server.
I have a good break point for phase 1, but am not sure how to allow the PHP and node code to run simultaneously and listening for requests on the same server. I am familiar with node, but not as much with PHP.
In short- Can I have PHP and Node.js running simultaneously on the same server? If so, what considerations need to be made?
Thank you in advance!
You will most likely want to make it to where you migrate to the node.js service one endpoint at a time. That way you can test, debug, and fix things quickly without too much work. I recommend you use express for your router and whatever database connector you want. You will want to canary test between the two as well.

How to run python on a Godaddy shared server with cpanel?

Let me start off by saying that I know this is not the preferred way to run python, but I have had this website for several years and am looking to add additional functionality. If I try to move the site to a new host and server setup, I am afraid I will mess everything up.
I am using Godaddy shared server for my website, and I access it using cpanel. The website is a Wordpress blog but also has a few tools I built using PHP and SQL database to store the output. I want to create a chatbot using Python but from what I understand, I can't use Django on a shared Godaddy server.
Is there a way for me to run Python scripts given my limitations?
Is the best alternative for me to start a second server and build an API to process the conversation and send it back to my current website?
Shared hosting solutions tend to limit the software that can run on then. The last time I used GoDaddy, they had only a php stack, so probably no, you won't be able to use Python there.
But that's fine, you shouldn't!
If you plan on using Python, I recommend you to get a Vps, or switch to a cloud service, like Openshift.
You can find cheap and reliable Vps servers nowadays, so go for it.

Website to computer communications

I am working on my senior project at university and I have a question. My advisor and other workers don't know much more on the matter so I thought I would toss it out to SO and see if you could help.
We want to make a website that will be hosted on a server that we are configuring. That website will have buttons on it, and when visitors of that website click a certain button we want to register an event on the server. We plan on doing this with PHP.
Once that event is registered (this is where we get lost), we want to communicate with a serial device on a remote computer. We are confident we can set up the PHP event/listener for the button press, but once we have that registered, how do we signal to the remote computer(connected via T1 line/routers) to communicate with the serial device? What is this sequence of events referred to as? The hardest thing for us (when researching it) is that we are not certain what to search for!
We have a feeling that a python script could be running on the server, get signals from the PHP listener, and then communicate with the remote PC. The remote PC could also be running a python script that then will communicate with our serial device. Again, most of this makes sense, but we are not clear on how we communicate between Python and PHP on the web server (or if this is possible).
If any one could give me some advice on what to search for, or similar projects I would really appreciate it. Thanks,
Both php and python can communicate via sockets, so I guess that is a good bet.
In PHP, when you receive the signal from the click button, open a socket to your python app with socket_create.
In python, you would need to implement a server socket (SocketServer) that listens for a connection.
Try reading up on sockets communication in general and socket programming in php and python specifically.
You can set up a web server also on the remote computer, perhaps using the same software as on the public server, so you do not need to learn another technology. The public server can make HTTP requests and the remote server responds by communicating with the serial device.

Categories