Módosítások

FederationStats

2 066 bájt hozzáadva, 2010. november 30., 16:20
Creating IdPs
Federation visualization project
* source (ruby on rails) https://repo.niif.hu/gitweb/gitweb.cgi?p=federation-stats.git;a=summary * live demo httpshttp://papigw.aai.niifeduid.hu/fedstatsstats
== Running the sample project ==
* Install ruby, rails Ruby* Install Rails (<code>gem install rails</code>)* Setup a <code>development.sqlite3</code> database with the <code>rake db:setup</code> command
* Fire up <code>script/server</code>, it will run the project on localhost:3000
 
== Statistic types ==
ENTITYID #ENTITYID#
APIKEY #API_KEY#
DATE yyyy-mm-dd
ENTITYID https://idp.niif.hu/idp/shibboleth
APIKEY 0123.......
DATE 2009-03-18
2 | https://idp.sch.bme.hu:443/opensso/sp/test
== Running the log statistics collector ==
This following script can be used the collect statistics from the idp audit logs of Shibboleth 2 IdP generated on the day before running. It is based on Peter Schober's audit_r7.py, and good for run from daily cronjob:
 
<source lang="bash">
#!/bin/bash
 
#Config section
PARSER_COMMAND="/opt/shibboleth-idp/bin/audit_r7.py"
SOURCEDIR="/opt/shibboleth-idp/logs"
TARGETDIR="/tmp"
 
ENTITYID="idp-entity-id"
APIKEY="aaa..."
LOCATION2PUT="https://fedstats.example.org/import_stats"
 
DATE=`date -d "yesterday" +"%Y-%m-%d"`
SOURCEFILE="$SOURCEDIR/idp-audit-$DATE.log"
 
#Should not edit below this
 
if [ -f $SOURCEFILE ]
then
LOGINS=`$PARSER_COMMAND -l $SOURCEFILE`
UNIQUE_LOGINS=`$PARSER_COMMAND -u $SOURCEFILE`
SERVICES=`$PARSER_COMMAND -p $SOURCEFILE | sed '/^[0-9]/p' -n`
 
TARGETFILE="stat-$DATE.log"
 
echo "ENTITYID $ENTITYID
APIKEY $APIKEY
DATE $DATE
 
STAT AUTH
$LOGINS
 
STAT USER_COUNT
$UNIQUE_LOGINS
 
STAT SSO_TO_SERVICE
$SERVICES
" > $TARGETDIR/$TARGETFILE
 
wget -q --no-check-certificate --post-file=$TARGETDIR/$TARGETFILE $LOCATION2PUT -O /dev/null
rm $TARGETDIR/$TARGETFILE
fi
</source>
== Running the log statistics collector ==This following The script below can be used the collect statistics from all the idp audit logs of Shibboleth 2 IdP. It is based on Peter Scober's audit_r7placed in a folder.py:
<source lang="bash">
#!/bin/bash
FILES#Config sectionPARSER_COMMAND="log/opt/shibboleth-directoryidp/bin/audit_r7.py"SOURCEDIR="/opt/shibboleth-idp-audit-*.log/logs"TARGETDIR="/tmp/stats
ENTITYID="idp-entity-id"
AUDITAPIKEY="aaa..."LOCATION2PUT="https:/path/tofedstats.example.org/audit_r7import_stats" FILES="idp-audit-*.pylog"
#Should not edit below this
cd $SOURCEDIR
for f in $FILES
do
if [ -f $f ] then echo "Processing $f file..." DATE=${f:10:10} LOGINS=`$AUDIT PARSER_COMMAND -l $f` USERS UNIQUE_LOGINS=`$AUDIT PARSER_COMMAND -u $f` SERVICES=`$AUDIT PARSER_COMMAND -p $f | sed '/^[0-9]/p' -n` FILENAME TARGETFILE="stat-$fDATE.log"
echo "ENTITYID $ENTITYIDAPIKEY $APIKEY
DATE $DATE
STAT USER_COUNT
$USERSUNIQUE_LOGINS
STAT SSO_TO_SERVICE
$SERVICES
" > $TARGETDIR/$FILENAMETARGETFILE
wget -q --no-check-certificate --post-file=$TARGETDIR/$TARGETFILE $LOCATION2PUT -O /dev/null rm $TARGETDIR/$TARGETFILE fidone #for files
</source>
The federation statistics rails project contains the <code>script/stat_parser/file.rb</code> command which can process the statistics format and load the data to the database. Note that this script currently contains an absolute path for the <code>script/runner</code> script, so you must fix this before use.
== Using HTTP-Post to feed the database ==
When deployed, the rails project provides a <code>/import_stats</code> URL to which one could POST the generated statistics file.
 
== Creating IdPs ==
Use the rails console to create new idps:
 
$ RAILS_ENV=production script/console
>> Entity.create :name => 'foo', :entity_type => 'idp'
=> #<Entity id: 1, name: "foo", entity_type: "idp", created_at: "2010-11-29 14:55:40", updated_at: "2010-11-29 14:55:40", api_key: "da9l233a45698fa5c4a252e301e3da2sf5ece24e">
[[Category:Csonkok]]
565
szerkesztés

Navigációs menü