Difference between revisions of "Main Page"

From HeadBackup
Jump to navigationJump to search
Line 101: Line 101:
 
</pre>
 
</pre>
 
The resulting web page shown by browsing to index.html will look something like this:<br>
 
The resulting web page shown by browsing to index.html will look something like this:<br>
[[File:wowzastats.png]]
+
[[File:wowzastats.jpg]]
  
 
== Amazon EC2 instance start, status and stop batch files ==
 
== Amazon EC2 instance start, status and stop batch files ==

Revision as of 14:27, 23 November 2009

Welcome! This site is a place to document technical information and other stuff that I was not able to find easily.

Graph Wowza Connection Statistics

Problem: I wanted a way to trend connections to an Amazon EC2 Wowza streaming server instance even though we stop the server following each broadcast.

Solution: Create a script to retrieve and record the current connection count using http://ec2servername.com:1935 which is enabled by default on Wowza and use csv2png to graph the recorded data.

Get Statistics

This script creates a log file with the date/time and the number of connections to the Wowza server. It then generates a graph from the log file.

/bin/date +%F\ %T | tr -d '\n' >> [fullpath]/stats/`/bin/date +%F`_connections.log
wget -t 1 -T 9 -O - http://ec2servername.com:1935 | sed 's/server=/,/' >> [fullpath]/stats/`/bin/date +%F`_connections.log
echo >> [fullpath]/stats/`/bin/date +%F`_connections.log
[fullpath]/stats/csv2png [fullpath]/stats/`/bin/date +%F`_connections.log [fullpath]/stats/`/bin/date +%F`_connections.png 250 250 YmdHMS

Generate HTML

This script will generate HTML snippets for each month, then combine them into an overview page. Uncomment and specify the date at the top and comment the next line if running this for something other than the current month.

#date="2009-03"
date=`/bin/date +%Y-%m`

cd [fullpath]/stats/
list=`ls $date*.png`

echo "<br><br><table><tr>" > $date-month.html

for file in $list
do
echo "<td>$file</td>" | sed 's/_connections.png/:/' >> $date-month.html
done

echo "</tr><tr>" >> $date-month.html

for file in $list
do
echo "<td><img src=$file alt=$file></td>" >> $date-month.html
done

echo "</tr></table>" >> $date-month.html


list2=`ls -r 2*month.html`
echo "<html><title>Webcast Stats</title><h2>Webcast Stats</h2>" > index.html
echo "Summary of max connections from each week:<br>" >> index.html
echo "<img src=summary.png alt=summary.png>" >> index.html
for file in $list2
do
cat $file >> index.html
done
echo "</html>" >> index.html

Generate Summary

This script will generate HTML snippets for each month, then combine them into an overview page. Uncomment and specify the date at the top and comment the next line if running this for something other than the current month

cd [fullpath]/stats/
list=`ls *connections.log`

#echo "2009/02/28 12:52:00,0" > summary.log
echo > summary.log

for file in $list
do
sort -n -k 2 -t , $file | tail -1 >> summary.log
done

[fullpath]/stats/csv2png [fullpath]/stats/summary.log [fullpath]/stats/summary.png 800 250 YmdHMS

Configure cronjobs

On linux use the following command to edit your cronjobs:

crontab -e
  • In this example we gather statistics every minute on Saturdays between 10:00am and 12:59pm.
  • At the start of the window we generate the HTML to include the current day.
  • At the end of the window we update the summary graph to include the highest connection count from today.
* 10-12 * * 6 [fullpath]/stats/getstats.sh
5 10 * * 6 [fullpath]/stats/genhtml.sh
5 13 * * 6 [fullpath]/stats/gensummary.sh

Results

With the above configuration files will be created like this:

2009-10-month.html
2009-10-31_connections.png
2009-10-31_connections.log
2009-11-07_connections.png
2009-11-07_connections.log
2009-11-14_connections.png
2009-11-14_connections.log
index.html
2009-11-month.html
2009-11-21_connections.png
2009-11-21_connections.log
summary.png
summary.log

The resulting web page shown by browsing to index.html will look something like this:
Wowzastats.jpg

Amazon EC2 instance start, status and stop batch files

I currently use these batch files to start a Wowza server EC2 instance on Vista 32 bit edition. I have created shortcuts to the batch files using the following syntax so that the command prompts stay open after a user double clicks the shortcut.

C:\Windows\System32\cmd.exe /k c:\ec2\start.bat

Start

The following batch file will start an Amazon instance and automatically assign your elastic (static) IP address to it after the instance ID is assigned by Amazon. Just replace any environment or instance preferences and change to your own elastic IP. The most tricky part of this is the for command which first launches the instance and then extracts the instance id from line 2 (line 1 is skipped), field (token) 2 and assigns the elastic IP address to it.

@echo off
set JAVA_HOME="c:\Program Files (x86)\Java\jre6"
set EC2_HOME=c:\ec2
set PATH=%PATH%;%EC2_HOME%\bin
set EC2_PRIVATE_KEY=c:\ec2\keys\private.pem
set EC2_CERT=c:\ec2\keys\509.pem

echo to check status run status.bat (startup usually take a couple of minutes)

for /f "skip=1 tokens=2" %%i in ('c:\ec2\bin\ec2-run-instances ami-413fd828 -k wowza-keypair -t m1.small -f c:\ec2\includes\live.zip') do c:\ec2\bin\ec2-associate-address -i %%i 123.123.123.123

Status

This batch file simply checks the current instance status.

@echo off
set JAVA_HOME="c:\Program Files (x86)\Java\jre6"
set EC2_HOME=c:\ec2
set PATH=%PATH%;%EC2_HOME%\bin
set EC2_PRIVATE_KEY=c:\ec2\keys\private.pem
set EC2_CERT=c:\ec2\keys\509.pem

echo The instance id is i-something

c:\ec2\bin\ec2-describe-instances

Stop

This one finds the instance ID and then stops that instance. If you have multiple instances running it will stop each of them one by one (it will also generate some errors, but worked when I tested it).

@echo off
set JAVA_HOME="c:\Program Files (x86)\Java\jre6"
set EC2_HOME=c:\ec2
set PATH=%PATH%;%EC2_HOME%\bin
set EC2_PRIVATE_KEY=c:\ec2\keys\private.pem
set EC2_CERT=c:\ec2\keys\509.pem

echo After you stop the server verify that the status shows terminated with the status.bat command

for /f "skip=1 tokens=2" %%i in ('c:\ec2\bin\ec2-describe-instances') do c:\ec2\bin\ec2-terminate-instances %%i

MediaWiki Tips & Tricks

Enable word wrap for pre tags on MediaWiki

Add these lines to skins/monobook/main.css in the section which defines the formatting for the pre tags (search for pre):

        white-space: pre-wrap;       /* css-3 */
        white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
        white-space: -pre-wrap;      /* Opera 4-6 */
        white-space: -o-pre-wrap;    /* Opera 7 */
        word-wrap: break-word;       /* Internet Explorer 5.5+ */

Disable anonymous editing and new user registrations in MediaWiki

# Disable anonymous editing
$wgGroupPermissions['*']['edit'] = false;

# Prevent new user registrations except by sysops
$wgGroupPermissions['*']['createaccount'] = false;

How to Create Livesets in VT5

The most helpful explanation I came across on this topic was [this forum post]. I opted to install the Aura plugin and the included tutorial is extremely helpful for getting started.

Create a simple picture in picture using Aura

Here are the quick steps for creating an angled picture in picture view with blurred edges (from memory, may not be exactly right):

  1. Open a new project in Aura
  2. Name the first layer Input
  3. Open the liveset brush creator (Filters>LiveSet>LiveSet Brush Creator)
  4. Click on the Full Screen Layer button
  5. Create a new layer and name it FX
  6. In the brush generator set the size to what you want for your picture in picture window and then click Create Brush
  7. Optionally if you want to crop the brush follow this steps first
    1. Change the view to only show 1 layer (= sign)
    2. Stamp the brush onto the blank layer
    3. Press the b key to enable the rectangle select tool
    4. Select the new cropped brush space you want to use
    5. Type shift-k to clear the layer
  8. Open Filters>Motion>KeyFramer
  9. Check the Preview box
  10. Adjust parameters as needed (in this case the H A is changed to 45 degrees)
  11. Click Apply Filter
  12. Open the blur filter (Blut>Blur)
  13. Configure the blur amount (2 in this case)
  14. Click Apply Filter
  15. Open the LiveSet Generator (Filters>LiveSet>LiveSet Generator
  16. Set the Effects Warp Type to Complex (this is required to render the angled video I believe)
  17. Name the scene and the shot
  18. Click on Create LiveSet
  19. Open VT5 and you will now be able to select the LiveSet and shot (the effects bus will display within the pip window