How to detect feed status using api

So. what is correct way to detect if feed is updated and synced after greenbone-feed sync.

Currently using this and not sure if it’s is correct or not.

#!/bin/bash

source ./config

greenbone-feed-sync --type all

while true; do
FEED_STATUS=$(gvm-cli --gmp-username $USERNAME --gmp-password $PASSWORD socket --xml “<get_feeds/>”)
if echo “$FEED_STATUS” | grep -q “status_text="OK"”; then
echo “Feed is synced!”
break
else
echo “Feed is not synced yet. Waiting…”
sleep 60
fi
done

Eero

I’m not sure what you mean by right way. You could use the @status or @status_text attributes from the XML response according to the docs. There are many code that can accomplish this using bash or python-gvm.

There is also a prepared Python script in gvm-tools for this type of task.

Well. in working way, since while feed is syncing, I cannot create targets with tasks. maybe this works.

#!/bin/bash

source ./config

greenbone-feed-sync --type all

while true; do
    FEED_STATUS=$(gvm-cli --gmp-username $USERNAME --gmp-password $PASSWORD socket --xml "<get_feeds/>")
    if echo "$FEED_STATUS" | grep -q -i 'currently_syncing'; then
        echo "Feed is not synced yet. Waiting..."
        sleep 60
    else
        echo "Feed is synced!"
        break
    fi
done