Recently, in the current media server, use RealNetworks's Helix Server 9.0.3.916 for Linux version. Because there are multiple servers to provide services, you need to do real-time monitoring of load balancing and server, you need to achieve real-time acquisition server information. I haven't found a good solution for a long time in the streaming media forum, not, there are many big cattle to develop a management plug-in and other stuff, but I don't want to spend money! Through the exploration (even English is very poor, only a little bit), finally discovered that the Custom logging in Server Monitor in the Helix console, HELIX can send the server information through HTTP's POST Out, it is it. Not talk nonsense. Start ~~~~ 系统 系统 系统: Flow Media: Helix Server 9.03 (9.0.3.916) Web: Apache 2.0.50 PHP 5.0.2 Mysql 4.0.21 System: Redhat Enterprise Linux Advanced Server 3 Update 3 1. Build a library ServerStat 2. Create Table ServerList Create Table `ServerList` (` ServerID` Tinyint (2) unsigned not null default '0', `Servername` VARCHAR (32) Not null default ',` Serverip` Varchar (16) NOT NULL Default ', `CPUUSAGE` INT (8) Unsigned Not Null Default' 0 ',` serveruptime` int (11) Not null default' 0 ', `adminport` VARCHAR (5) Not null default' , `Clientnum` int (4) unsigned not null default '0',` Bandwidth` VARCHAR (20) Not null default ', `Infotime` DateTime Not Null Default' 0000-00-00 00:00:00 ', Primary Key (`ServerID`), UNIQUE Key` Serverip` (`Serverip`) Type = Myisam; add your server information in the table, IP address must have, other do not do
3. The PHP program The following is a small program that gains streaming server information. MySql.inc.php used in the program is a class I found on the Internet. It is too long. If you can't find it. MySQL.inc.php can write to me: crazyMouse @ 163.com, in addition to the database of IP, users, passwords outside of the database, huh, huh incrude_once ("../ incrude / config. Inc.php "); include_once (" ../ incrude / mysql.inc.php "); $ db = new sql (); $ db-> host = $ dbhostname; $ db-> database = $ dbdatabase; $ db -> User = $ dbuser; $ db-> password = $ dbpassword; $ db-> connect (); $ debug = 0; // Debug, output query_string to server.log file
$ DateTime = Date ("YMD H: I: S"); $ clientnum = $ _ post ['client_count']; $ serverip = $ _ server ['remote_addr']; $ cpuusage = $ _ post ['cpu_usage']; $ Bandwidth = $ _ Post ['bandwidth_output']; $ filenum = intVal ($ _ post ['filenum']); $ serverUptime = $ _POST ['Server_uptime'];
$ Query_string = "update ServerList set ServerUptime =". $ Serveruptime. ", ClientNum =". $ Clientnum. ", InfoTime = '". $ Datetime. "', BandWidth = '". $ Bandwidth. "' Where ServerIP = ' "$ serverip."; ";
IF ($ debug) {// debug $ fError = fopen ("Server.log", "A "); if (! fwrite ($ FERROR, $ query_string. "/ n")) {exit;}} $ db -> Query ($ query_string); $ db-> free_result (); exit ();> A test program for displaying server status information, judges the difference between the current time and the server report time, if more than 60 seconds, basically The server hangs. As for the issue of ensuring streaming media server and web server time synchronization, you can solve it through NTP. You don't say it. Inc.php "); include_once (" ../ incrude / mysql.inc.php ");
$ db = new SQL (); $ db-> host = $ dbhostname; $ db-> database = $ db-> user = $ dbuser; $ db-> password = $ dbpassword; $ db-> connect $ NOWTIME = DATE ("YMD H: I: S"); $ query_string = "SELECT *, UNIX_TIMESTAMP ('". $ nowtime. "') - Unix_TimeStamp (Infotime) as Overtime from ServerList"; $ db-> Query ($ query_string);
Echo ""; echo "
"; echo ''; Echo ' server name div> | | server IP address div> td> | number online number div> td> < Td width = "186"> Status report time div> td> | Run State div> TD> tr> '; for (;;) {IF ($ db-> next_record ()) {echo' | '. $ dB- > f ("ServerName"). ' div> td>'; Echo ' | f (" adminport "). '/ Admin / index.html">'. $ Db-> f ("Serverip"). ' div> td> '; echo' | |