axis cam scripting
here's some bits and pieces I used to get an axis network camera to show the currently connected users.
listconnected.script
#!/bin/sh
# save to /tmp so we don't wear the flash memory out
netstat -t -n |grep ":80.*ESTABLISHED" |tr -s " " "\t" |cut -f 5 |cut -d ":" -f 1 |xargs -n 1 nslookup |grep "Name:" |tr -s " " "\t" |cut -f 2 > /tmp/connectedtmp.txt
mv /tmp/connectedtmp.txt /tmp/connected.txt
user.list.task
# immune is required to let the task finish before utask tries to kill it
{tooty} time(h(0-23)m(0-59)s(0,20,40)) once immune % /etc/scripts/listconnected.script;
# make things accessible to the webserver
ln -s /tmp/connected.txt /etc/httpd/html/viewer/connected.txt
in the html source, make sure you work around an i.e. bug that will prevent the cache from being updated
function sndReq() {
http.open('get', '/local/viewer/connected.txt', true);
// workaround for win/ie
http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
http.onreadystatechange = handleResponse;
http.send(null);
}
from here just do the usual to paste the result into your dom.
listconnected.script
#!/bin/sh
# save to /tmp so we don't wear the flash memory out
netstat -t -n |grep ":80.*ESTABLISHED" |tr -s " " "\t" |cut -f 5 |cut -d ":" -f 1 |xargs -n 1 nslookup |grep "Name:" |tr -s " " "\t" |cut -f 2 > /tmp/connectedtmp.txt
mv /tmp/connectedtmp.txt /tmp/connected.txt
user.list.task
# immune is required to let the task finish before utask tries to kill it
{tooty} time(h(0-23)m(0-59)s(0,20,40)) once immune % /etc/scripts/listconnected.script;
# make things accessible to the webserver
ln -s /tmp/connected.txt /etc/httpd/html/viewer/connected.txt
in the html source, make sure you work around an i.e. bug that will prevent the cache from being updated
function sndReq() {
http.open('get', '/local/viewer/connected.txt', true);
// workaround for win/ie
http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
http.onreadystatechange = handleResponse;
http.send(null);
}
from here just do the usual to paste the result into your dom.
0 Comments:
Post a Comment
<< Home