| View previous topic :: View next topic |
| Author |
Message |
Anonymous Guest
|
Posted: Mon Aug 20, 2007 10:39 am Post subject: Icecast stats |
|
|
Hi!
I'm looking for a script/program/whatever, to parse stats.xsl and if possible, save it in a *sql (preferibly mysql) database.
I've found a "class_icecast2.php", but maybe someone knows something better.
Thanks in advance!
PS.- Sorry for my english! |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Wed Aug 29, 2007 1:44 pm Post subject: |
|
|
Well, if the solution is not found, then, create it!
This script saves icecast admin page to a rudimentary (not boyce-codd, 5FN, any shit of that ) mysql database:
| Code: |
<?php
/********************************************************************************/
/* Script en php que se encarga de guardar todos los datos de un mountpoint. */
/* Para usarlo: php -f mountpoint_to_sql.php puntomontaje */
/********************************************************************************/
include('icecounter.php');
/* Datos de la bbdd */
$dbhost='yourhost';
$dbuser='youruser';
$dbpass='yourpass';
$db='yourdb';
/* Comprobar si se le ha pasado el parametro puntomontaje */
if(is_null($argv[1])){
exit;
}
$conexion=mysql_connect($dbhost,$dbuser,$dbpass);
$i=mysql_select_db($db,$conexion) or die;
$m1=$argv[1];
/* Array para almacenar los datos que quieren ser parseados */
$tags=array(
array($m1,'LISTENERS'),
array($m1,'BITRATE'),
array($m1,'LISTENER_PEAK'),
array($m1,'MAX_LISTENERS'),
array($m1,'TITLE')
);
$data=retrieve($tags,true);
/* El ancho de banda lo calculamos con bitrate X listeners */
$bw=$data[0]*$data[1];
$fecha=date("Y/m/d H:i:s");
/* Almacenamos todos los datos */
$query="INSERT INTO stats (id,mountpoint,listeners,bitrate,peak,max,bw,descripcion,hora) VALUES (NULL,'$m1','$data[0]','$data[1]','$data[2]','$data[3]','$bw','$data[4]','$fecha')";
$result=mysql_query($query,$conexion);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
mysql_close($conexion);
?>
|
It depends of icecounter.php (www.netzond.com), where it's located host data for the icecast server.
I hope it works for someone  |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group subRebel style by ktauber
|