quarta-feira, 25 de setembro de 2019

Check your servers are UP - Linux BASH

Recently I was trying to check if one of my servers had a glitch, so after some research and coding I came up with this solution for Linux (ie. in my case for Raspbian Jessie):

1) Get the following code and save it to your target server.

# Test connectivity with ping

# filename: test_alive.sh
# braselectron.com - September 25, 2019
# get IP from command line argument
# check IP address format code
# Mitch Frazier - Linux Journal - June 26, 2008
valid_ip () {
    local  ip=$1
    local  stat=1
    if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
        [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
    return $stat
# check syntax
if [ $# -eq 0 ]
   then echo "syntax: test_live.sh <ip address>"
   exit 1
if ! valid_ip $ip
   then echo "IP is invalid"
   exit 1
# ping but don't wait
# log if ping fails
while true
   do ping -w 1 -c 1 $ip |\
      grep received |\
      cut -d" " -f 4 |\
      if [ "$(cat -)" != "1" ]
         then echo "Ping failed $(date)"

 2) Choose another host on your network to ping that is up (for sure) and is trusted by you.  For example: (usually the router on your network - default factory value).

3) Now using "nohup" to setup your test on the target host, at the command terminal, do this:

nohup  /bin/bash test_alive.sh &
# remember to rename the with your host IP (step 2)

4) Now you can logoff and from time to time check the nohup.out file to see if the ping failed.

5) When you are satisfied with your tests just kill the process on the target host, doing this:

5.1) first find your process with:  ps -ef | grep test_alive

This will give you a output similar to this:

pi        1257  4688  1 17:59 pts/1    00:00:00 grep --color=auto test_alive
pi       22213     1  9 15:08 ?        00:16:24 /bin/bash test_alive.sh

5.2) get the process id and kill it with:  kill 22213  # caution! use your id number

5.3) and remove the  nohup.out file with: rm nohup.out

NOTE:  if the nohup.out file is empty, means no erros, your server is working and connectivity is working.  But if the target host is freezing or other problems that make the script stop, this may mislead your conclusion.


quarta-feira, 11 de setembro de 2019

Transformar 2014 - Palestra Mitchel Resnick

Mitchel Resnick, diretor do grupo Lifelong Kindergarten, do MIT Media Lab (Massachussets, EUA), apresentou a palestra "Aprender a programar, programar para aprender", durante o Transformar 2014.

O projeto Lifelong Kindergarten desenvolve novas tecnologias que, no espírito dos blocos e tintas de dedo do jardim de infância, expandam o alcance do que as pessoas podem projetar, criar e aprender.

O Transformar foi realizado no dia 28 de julho de 2014, em São Paulo, pelo Inspirare/Porvir, Fundação Lemann e Instituto Península, com apoio de Google, Globo e Canal Futura.

Para mais informação acesse:

Para saber mais sobre o scratch:

Isto é uma continuação do "post" sobre Raspberry Pi aqui:

domingo, 1 de setembro de 2019

Telegram - My phone got stolen (or lost), now what ?

My phone was stolen, what do I do?

First of all, sorry about your phone. Unfortunately, the phone number is the only way for us to identify a Telegram user at the moment. Telegram doesn‘t collect additional information about you, so whoever has the number, has the account. This means we can’t help you unless you have access either to the phone number or to Telegram itself on any of your devices.
If you have access to Telegram on another device:
  1. Go to Telegram Settings — Privacy and Security and turn on Two-Step Verification. This way the phone number alone will not be enough to log in to your account.
  2. Go to Settings — Privacy and Security — Active Sessions and terminate your Telegram session on the old device. Whoever has your phone will not be able to log in again, since they don't know your password.
  3. Contact your phone provider, so that they block your old SIM and issue a new one with your number.
  4. If you decide to switch to a new phone number, don't forget to go to Settings, tap on your phone number and change your Telegram number to the new one.
I don't have access to Telegram on any other devices:
  1. First and foremost, you need to contact your phone provider, so that they block your old SIM and issue a new one with your number.
  2. Wait till you receive your new SIM with the old number, log in to Telegram, then go to Settings — Privacy and Security — Active Sessions and terminate your Telegram session on the old device.
Removing sensitive data
Common thieves usually throw out the SIM card immediately (the phone is harder to locate this way), then wipe the devices and sell them, so there isn't much risk for the data in case of regular petty theft. But if you have reasons to worry about the data on the device and are unable to log out the other device, it is best that you wipe it remotely. You can read more about it here: Apple iOS, Android. Unfortunately, this requires you to have prepared in advance for this scenario.

You can delete your Telegram account if you are logged in on at least one of your other devices (mobile or desktop). Note that inactive Telegram accounts self-destruct automatically after a period of time — 6 months being the default setting.

Last but not least

My final advice is to always install Telegram at least on two devices (ie. your phone and your laptop/desktop/tablet) and activate the Two-Step Verification, just to be safe.

REF:  https://telegram.org/faq#deleting-contacts-on-android