--- /dev/null
+
+# First, create the RRD file
+rrdtool create vlc.rrd --step 1 "DS:in:GAUGE:10:0:30000" "DS:demux:GAUGE:10:0:30000" "DS:out:GAUGE:10:0:30000" "RRA:AVERAGE:0,5:1:86400"
+
+# Start "listening" the RRD file
+tail -f rrd |while read in;do;echo $in;rrdtool update vlc.rrd `echo $in`;done
+
+# Start vlc
+vlc normal_vlc_stuff --extraintf logger --rrd-file rrd
+
+# Graph the last 5 minutes (300 seconds)
+rrdtool graph vlc.png --start -300 "DEF:inp=vlc.rrd:in:AVERAGE" "DEF:dem=vlc.rrd:demux:AVERAGE" "DEF:out=vlc.rrd:out:AVERAGE" "LINE2:dem#00FF00:Demux bitrate" "LINE2:inp#0000FF:Input bitrate" "LINE2:out#FF0000:Output bitrate"
struct intf_sys_t
{
int i_mode;
+ FILE *p_rrd;
+ mtime_t last_update;
FILE * p_file; /* The log file */
msg_subscription_t *p_sub;
static void SyslogPrint ( const msg_item_t *);
#endif
+static void DoRRD( intf_thread_t *p_intf );
+
/*****************************************************************************
* Module descriptor
*****************************************************************************/
VLC_FALSE );
change_string_list( mode_list, mode_list_text, 0 );
+ add_string( "rrd-file", NULL, NULL, N_("RRD output file") ,
+ N_("Output data for RRDTool in this file" ), VLC_TRUE );
+
set_capability( "interface", 0 );
set_callbacks( Open, Close );
vlc_module_end();
static int Open( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
- char *psz_mode, *psz_file;
+ char *psz_mode, *psz_file, *psz_rrd_file;
CONSOLE_INTRO_MSG;
msg_Info( p_intf, "Using logger..." );
#endif
}
+ p_intf->p_sys->last_update = 0;
+ p_intf->p_sys->p_rrd = NULL;
+
+ psz_rrd_file = config_GetPsz( p_intf, "rrd-file" );
+ if( psz_rrd_file && *psz_rrd_file )
+ {
+ p_intf->p_sys->p_rrd = fopen( psz_rrd_file, "w" );
+ }
+
p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL );
p_intf->pf_run = Run;
FlushQueue( p_intf->p_sys->p_sub, p_intf->p_sys->p_file,
p_intf->p_sys->i_mode );
+ if( p_intf->p_sys->p_rrd )
+ DoRRD( p_intf );
+
msleep( INTF_IDLE_SLEEP );
}
}
LOG_STRING( "</font>\n", p_file );
}
+static void DoRRD( intf_thread_t *p_intf )
+{
+ playlist_t *p_playlist;
+ float f_input_bitrate;
+ if( mdate() - p_intf->p_sys->last_update < 1000000 )
+ return;
+ p_intf->p_sys->last_update = mdate();
+
+ p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist && p_playlist->p_stats )
+ {
+ fprintf( p_intf->p_sys->p_rrd, I64Fi":%f:%f:%f\n",
+ p_intf->p_sys->last_update/1000000,
+ (float)(p_playlist->p_stats->f_input_bitrate)*1000,
+ (float)(p_playlist->p_stats->f_demux_bitrate)*1000,
+ (float)(p_playlist->p_stats->f_output_bitrate)*1000 );
+ fflush( p_intf->p_sys->p_rrd );
+ vlc_object_release( p_playlist );
+ }
+}