--- scripts/agent-local/opkg 1970-01-01 00:00:00.000000000 +0000 +++ scripts/agent-local/opkg 2023-04-25 17:20:23.954706342 +0100 @@ -0,0 +1,18 @@ +#!/bin/sh +# Originally dpkg from Observium +# Cache the file for 30 minutes +# If you want to override this, put the command in cron. +# We cache because it is a 10sec delay, which is painful for the poller + +opkgFILE=/tmp/observium-agent-opkg + +if opkg list-installed >/dev/null 2>&1; then + echo "<<>>" + if [ ! -e $opkgFILE ] || [ $(($(date +%s)-$(stat -c %Y $opkgFILE))) -gt 1800 ]; then + true > $opkgFILE + opkg list-installed | cut -f1 -d' ' | while IFS= read -r line; do + opkg info "$line" | awk '/^Package/ { p=$2 } /^Version/ { v=$2 } /^Architecture/ { a=$2 } /^Size/ { s=$2 } END { print p, v, a, s }' | head -1 >> $opkgFILE + done + fi + cat $opkgFILE +fi