Pular para conteúdo
Logo CEPTRO.br

Medições NIC.br

Exemplos em código fonte#

Ajuste de relógio via HTP#

Bash
#!/bin/sh
## Never use https, system date state is unknown, could fail certificate validation
## TZ= works around some bugs, leave it alone
## accepts BusyBox and GNU coreutils "date". BSD untested
## needs cURL, runs only once.  Call it every time link goes up, e.g. from dhcp hook

sysfixtime_http_settime() {
       local httptime
       local maxtime
       local curtime
       local URL

       URL="http://timesync.simet.nic.br/"

       [ -r /var/run/http-timesync-done ] && return 0
       httptime=$(curl --max-time 5 -s -I -i "$URL" 2>/dev/null | sed -n -e '/^Date:/ { s/^Date:[[:blank:]].*,[[:blank:]]\+// ; p; q; }')
       [ -z "$httptime" ] && return 0
       maxtime=$(TZ='' LC_ALL=C date +%s -D "%d %b %Y %T GMT" -u --date "$httptime" 2>/dev/null) \
         || maxtime=$(TZ='' date +%s -u --date="$httptime" 2>/dev/null) \
         || return 0
       curtime=$(TZ='' date +%s) || return 0
       [ "$curtime" -lt "$maxtime" ] && TZ='' date -s @$maxtime && {
               touch /var/run/http-timesync-done
               logger -t "hotplug" -p daemon.info "updated system time from $URL" || true
       }
}

SIMET2_DEVICE_MODEL a partir de /proc/cpuinfo#

Bash
#!/bin/sh
# Save this at /opt/simet/bin/simet_get_device_model.sh
#
# Model from /proc/cpuinfo, useful on many ARM and other
# Device-tree-based platforms.
#
sed -n -e '/^Model[[:blank:]]\+:/ { s/^.*:[[:blank:]]\+// ; p; }' -e 's/^[[:blank:]]\+//' -e 's/[[:blank:]]\+$//' < /proc/cpuinfo | sed -n -e '1 { p; q; }' || exit 1
: