I came up with a quick DroboApp that runs a simple service to display the CPU: and Mem: lines from top in the DroboApps section of Drobo Dashboard. This came in handy recently as I was migrating a lot of data and I wanted to watch the load on the Drobo. I thought it would be nice to have this in the Drobo Dashboard.
How it works:
The DroboApps 2.0 framework moves the simple app management functions into the dashboard. Properly written DroboApps can be started, stopped and monitored from the dashboard interface. DroboApps can also display a 50 character status message (the default is “Application is running”) while an app is running. You do this by writing to a file in /tmp/DroboApps/ named status.txt The dashboard checks and updates every 15 seconds so while not real-time is is frequent enough to be useful. This simple status service takes advantage of this by writing status messages to display to the status file. The Drobo dashboard does the rest.
The drobo app is nothing more than a short shell script named status.sh that rotates the top two lines of the top command to the status.txt file every 15 seconds. There is also the usual service.sh script to control starting and stopping the service. service.sh goes in the root of the app directory (must be named status) and status.sh goes in the bin subdirectory, like this:
DroboApps
status
service.sh
bin
status.sh
service.sh
#!/bin/sh
#
# status service
. /etc/service.subr
prog_dir=`dirname \`realpath $0\``
name="status"
description="Update status display on dashboard"
version="0.1"
framework_version="2.0"
pidfile=/tmp/DroboApps/$name/pid.txt
statfile=/tmp/DroboApps/$name/status.txt
logfile=${prog_dir}/$name.log
conffile=${prog_dir}/etc/$name.conf
start()
{
# if [ ! -f $conffile ]; then
# cp ${conffile}.default ${conffile} > /dev/null 2>&1
# fi
nohup ${prog_dir}/bin/$name.sh ${conffile} ${statfile} >> ${logfile} 2>&1 &
echo `/bin/pidof -s $name.sh` > ${pidfile}
}
case "$1" in
start)
start_service
;;
stop)
stop_service
;;
restart)
stop_service
sleep 3
start_service
;;
status)
status
;;
*)
echo "Usage: $0 [start|stop|restart|status]"
exit 1
;;
esac
~
status.sh
#!/bin/sh
#
# trivial status daemon
. /etc/service.subr
prog_dir=`dirname \`realpath $0\``
conffile=$1
statfile=$2
# Banner
date
echo Starting up...
# main loop
# Replace the two top commands with your own status info. 50 chars max.
while [ 1 ]; do
top -b -n1 | grep ^Mem > $statfile
# Drobo checks status every 15 seconds
sleep 15
top -b -n1 | grep ^CPU > $statfile
# Drobo checks status every 15 seconds
sleep 15
done
If anyone wants this as an installable status.tgz please let me know where to submit it and I’d be happy to. Hope this is useful or at least leads to some even more interesting services.
I wrapped the two scripts up in an installable tgz file. To install it from the command line (provided you’ve previously configured your Drobo for ssh access) follow the series of commands shown below or download the file from http://dl.dropboxusercontent.com/u/2403501/DroboApps/status.tgz , copy it to your DroboApps share and restart your Drobo.
If you open the “Drobo Apps” page on the DroboDashboard you should now see an entry for the status Drobo app. Under Status and Actions you should have controls for starting/stopping the apps as well as uninstalling it. When running the status line should switch between CPU: and Mem: status of the Drobo processor.
While this app probably works on a Drobo FS the Drobo Dashboard display does not show the Drobo Apps option for a Drobo FS so there is no way to view the status text from within the Dashboard making the app sadly pointless for FS Owners. Maybe this can be remedied by a future update to Drobo Dashboard (please?)
Great. There are probably some more interesting statistics that could be displayed than just “top”. The status.sh script is very easy to change. I’d love to hear ideas.