Don't know if it could interest someone. I wrote this 2 little shell scripts cause I couldn't find anything to monitor sabnzbd from the desktop. I'm not a script expert and i'm not aware of conky's advanced functionality , so it's very basic. hope someone could improve this base.
script require xmlstarlet for xml parsing.
-sabnzbd monitor :
Code: Select all
#!/bin/bash
#sabnzbd host
hostname=
port=
# user/password authentication here
user=
password=
# api_key here
api=
prntvalue () {
echo $XML | xmlstarlet sel -t -v "$1"
}
XML=$(wget -q -O - "http://$hostname:$port/sabnzbd/api?mode=queue&start=START&limit=LIMIT&output=xml&addid&ma_username=$user&ma_password=$password&apikey=$api")
state=$(prntvalue "/queue/status")
state=`echo $state | tr [A-Z] [a-z]`
jobs=$(prntvalue "count(/queue/slots/slot)")
if [ "$jobs" != 0 ]; then
timeleft=$(prntvalue "/queue/timeleft")
totmbleft=$(prntvalue "/queue/mbleft")
totmb=$(prntvalue "/queue/mb")
kbpersec=$(prntvalue "/queue/kbpersec")
current=$(prntvalue "/queue/slots/slot[index=0]/filename" | cut -c1-20)
current_percent=$(prntvalue "/queue/slots/slot[index=0]/percentage")
queue_item=$(prntvalue "/queue/slots/slot[index>0]/filename" | cut -c1-20)
if [ "$state" = "paused" ]; then
echo "SABnzbd+ $state. $jobs items queued."
else
echo "SABnzbd+ $state @$kbpersec k/s"
echo "Current: $current - $current_percent %"
echo "Queue: $queue_item"
echo "ETA:$timeleft - Still "$totmbleft"MB to download"
fi
else
echo "SABnzbd+ is $state"
fi
exit 0
Code: Select all
#!/bin/bash
#sabnzbd host
hostname=
port=
# user/password authentication here
user=
password=
# api_key here
api=
XML_History=$(wget -q -O - "http://$hostname:$port/sabnzbd/api?mode=history&start=START&limit=LIMIT&output=xml&addid&ma_username=$user&ma_password=$password&apikey=$api")
history_item=$(echo $XML_History | xmlstarlet sel -t -v 'math:max(/history/slots/slot/id)')
for i in $(seq 1 $history_item)
do
history_name=$( echo $XML_History | xmlstarlet sel -t -v "/history/slots/slot[id=${i}]/name" | cut -c1-20)
history_status=$( echo $XML_History | xmlstarlet sel -t -v "/history/slots/slot[id=${i}]/status")
if [ -z "$history_name" ];then
continue
else
if [ "$history_status" != "Completed" ]; then
echo "$history_name - Failed"
else
echo "$history_name - Completed"
fi
fi
done
exit 0
Code: Select all
${color1} ${font Ubuntu:style=Bold:size=11}Sabnzb Monitor${hr 2}${font}${color}
${color1} ${font Ubuntu:style=Bold:size=9}${execi 10 sh ~/.sabcli/sabconky.sh}${font}${color}
${color1} ${font Ubuntu:style=Bold:size=11}Sabnzb Monitor${hr 2}${font}${color}
${color1} ${font Ubuntu:style=Bold:size=9}${execi 10 sh ~/.sabcli/sabhistory.sh}${font}${color}