scenario: We have about 5k of CPE and our provisioning disables periodic inform. (the way I see it, if we need to configure a CPE right now, then we force a connection request using the appropriate API).
objective: I want, at least once a week, having all available CPE to contact the ACS just to say “hello! I’m here!”.-
skills and tools required:
- python with json.tool module installed
- grep / egrep
(default install of Linux Slackware comes with all of them)
#!/bin/bash lista=$(curl -s 'http://ACS.com:7557/devices/?projection=_id' -X GET ) nada="[ ]" [[ "$lista" == "$nada" ]] && exit 0 logger INICIO CONNREQ lista2=$(echo $lista| python -m json.tool |egrep "_id" |egrep -o '(":\s)(.*)' |egrep -o '\s(.*)' | egrep -o '[^" ]*') while IFS= read -r devid do curl -s 'http://ACS.com:7557/devices/'$devid'/tasks?connection_request' -X POST sleep 2 done < <(echo "$lista2") logger FIN CONNREQ
sleep 2 is important here. Not using it or using a low value can create a bottleneck and eventually leave a large trail of faults on the ACS (also, you might want to use it to test the ACS load but in that case you can also use genieacs-sim, provided you have a large amount of RAM). I think value of 2 is a safe zone. In my case, with 5k of customers, it takes about 3 hours to complete. If we ever reach 500k of customers we will have several ACSs runnings.
once it runs as it should, a crontab could look something like this:
0 5 * * 1 /root/bin/acs/connreq.sh >/dev/null 2>&1
edit: sry about the Spanish mix