fastforward
03-13-2002, 10:00 PM
This little daemon will listen on a given IP/port and simply dump the load average and mysql processes to any TCP connection that connects to the listening port. The MySQL process list is also sent if a mysql username and password is specified using the --mysql-user and --mysql-pwd options.
Output is sent as 'as is' with no formatting. The first line is the load average as shown by /proc/loadavg. Everything following, is the is the output of 'mysqladmin processlist'. You will need to parse the output yourself using PHP or whatever client language you happen to use.
To limit output to a specific IP, you should add additional rules to your firewall configuration. By default, this daemon listens on all IP addresses and port 6666.
Usage: loadsock [OPTION]...
Example: loadsock --ip db.host.com --port 1287 --mysql-user paul --mysql-pwd topsecretword
loadsock with no parameters will listen on all IP addresses on port 6666
--ip IP Address on which to listen
(defaults to all available addresses)
Can be numerical IP or hostname
--port Port on which to listen (defaults to 6666)
--mysql-user MySQL username if you want to include the mysql process
list in the output.
--mysql-pwd MySQL password if necessary.
Below is some example client PHP code that connects and echoes the output:
<?php
$remote_ip = "your.db_server.com";
$remote_port = "6666"; // or whatever port you daemon is on
$fp = fsockopen($remote_ip, $remote_port, $errno, $errstr, 30);
if ($fp) {
while (!feof($fp)) {
echo $line; // change this to process the output and do what you need
echo $line;
}
fclose($fp);
}
?>
Output is sent as 'as is' with no formatting. The first line is the load average as shown by /proc/loadavg. Everything following, is the is the output of 'mysqladmin processlist'. You will need to parse the output yourself using PHP or whatever client language you happen to use.
To limit output to a specific IP, you should add additional rules to your firewall configuration. By default, this daemon listens on all IP addresses and port 6666.
Usage: loadsock [OPTION]...
Example: loadsock --ip db.host.com --port 1287 --mysql-user paul --mysql-pwd topsecretword
loadsock with no parameters will listen on all IP addresses on port 6666
--ip IP Address on which to listen
(defaults to all available addresses)
Can be numerical IP or hostname
--port Port on which to listen (defaults to 6666)
--mysql-user MySQL username if you want to include the mysql process
list in the output.
--mysql-pwd MySQL password if necessary.
Below is some example client PHP code that connects and echoes the output:
<?php
$remote_ip = "your.db_server.com";
$remote_port = "6666"; // or whatever port you daemon is on
$fp = fsockopen($remote_ip, $remote_port, $errno, $errstr, 30);
if ($fp) {
while (!feof($fp)) {
echo $line; // change this to process the output and do what you need
echo $line;
}
fclose($fp);
}
?>