There is a mention here of a bug that linux always reports online.
https://developer.mozilla.org/en-US/doc ... tor.onLine
Maybe you could considering using a different language to do this.
I had a lot of stability issues with my pi so i set up a script that ran as a crontab and updated my db as to whether the pi could ping my router.
this way i was able to see when and if there was a pattern to my pi going offfline
Here is the python script i use.
Code: Select all
command_line = "ping -c 1 192.168.0.1"
args = shlex.split(command_line)
db = MySQLdb.connect (host = "localhost", user = "xxxx", passwd = "xxxxx", db = "xxxxxxx")
# print "connected"
print "Error "
now = datetime.datetime.now()
now1 = now.strftime("%Y-%m-%d %H:%M")
cur = db.cursor()
cur.execute("INSERT INTO tablename(row1, row2) VALUES(%s, 'ping alive')", now1)
cur.execute("INSERT INTO tablename(row1, row2) VALUES(%s, 'ping dead')", now1)