#!/usr/bin/perl -w use integer; @vos=("cms", "ops", "balticgrid"); $SETotal=0; $SEFree=0; $SETaken=0; $data=`hadoop dfsadmin -report 2> /dev/null | head -n 4 | tail -n 3`; @d = split(/[\r\n]+/, $data); # get the total present capacity of the HDFS if ($d[0] =~ /Present Capacity: (\d+)/) { $SETotal=$1 / 1024; } # get the available capacity if ($d[1] =~ /DFS Remaining: (\d+)/) { $SEFree=$1 / 1024; } # and the amount of used space if ($d[2] =~ /DFS Used: (\d+)/) { $SETaken=$1 / 1024; } print "dn: GlueSEUniqueID=ganymede.hep.kbfi.ee,mds-vo-name=resource,o=grid\n"; $totalgb = $SETotal / 1024 / 1024; $freegb = $SEFree / 1024 / 1024; print "GlueSESizeTotal: $totalgb\n"; print "GlueSESizeFree: $freegb\n\n"; foreach $vo (@vos) { print "dn: GlueSALocalID=$vo,GlueSEUniqueID=ganymede.hep.kbfi.ee,mds-vo-name=resource,o=grid\n"; print "GlueSAStateAvailableSpace: $SEFree\n"; print "GlueSAStateUsedSpace: $SETaken\n\n"; }