Bitcoin Forum
April 19, 2024, 08:27:21 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: Sound alarm script to monitor internet and BAMT miner connectivity status  (Read 2852 times)
01BTC10 (OP)
VIP
Hero Member
*
Offline Offline

Activity: 756
Merit: 503



View Profile
April 21, 2012, 04:25:04 PM
Last edit: April 22, 2012, 09:37:37 PM by 01BTC10
 #1

EDIT: Windows section added.


This is a script that will show/sound an alert if internet access or BAMT miner are unreachable.


Linux:

alarm.sh
Code:
#! /bin/bash

printf '\033]2;%s\007' "Network Monitor"

if curl --connect-timeout 30 --silent --head http://www.google.com/  |egrep "20[0-9] Found|30[0-9] Found" >/dev/null
then
echo Internet status: OK

else
printf '\033]2;%s\007' "**** ALERT ****"
echo Internet status: ERROR
mpg321 alarm.mp3 &> /dev/null
fi

if curl --connect-timeout 30 --silent --head http://BAMTworkerIP/  |egrep "20[0-9] OK|30[0-9] OK" >/dev/null  # *** Don't forget to edit http address ***
then
echo Miner status: OK

else
printf '\033]2;%s\007' "**** ALERT ****"
echo Miner status: ERROR
mpg321 alarm.mp3 &> /dev/null
fi

## You can add a worker by uncommenting this section
#
# if curl --connect-timeout 30 --silent --head http://BAMTworkerIP 2/  |egrep "20[0-9] OK|30[0-9] OK" >/dev/null
# then
# echo Miner 2 status: OK
#
# else
# printf '\033]2;%s\007' "**** ALERT ****"
# echo Miner 2 status: ERROR
# mpg321 alarm.mp3 &> /dev/null
# fi
##

sleep 60
clear
./alarm.sh

You need curl and mpg321:
Code:
sudo apt-get install curl mpg321

Optional: Put a sound file renamed to alarm.mp3 in the same folder to activate the audible alarm.









Windows:

alarm.bat
Code:
@echo off
cls
TITLE Network Monitor

ping -n 1 -w 30000 google.com >NULL  
if %errorlevel% == 0 echo Internet status: OK
if %errorlevel% == 1 echo Internet status: ERROR
if %errorlevel% == 1 TITLE *** ALERT ***
if %errorlevel% == 1 mpg123.exe alarm.mp3 2>NULL


REM *** IMPORTANT EDIT BAMTminerIP ***

ping -n 1 -w 30000 BAMTminerIP >NULL  
if %errorlevel% == 0 echo Miner status: OK
if %errorlevel% == 1 echo Miner status: ERROR
if %errorlevel% == 1 TITLE *** ALERT ***
if %errorlevel% == 1 mpg123.exe alarm.mp3 2>NULL

REM *** Remove "REM" from next section to add a worker ***

REM ping -n 1 -w 30000 BAMTminerIP2 >NULL  
REM if %errorlevel% == 0 echo Miner 2 status: OK
REM if %errorlevel% == 1 echo Miner 2 status: ERROR
REM if %errorlevel% == 1 TITLE *** ALERT ***
REM if %errorlevel% == 1 mpg123.exe alarm.mp3 2>NULL

ping 1.0.0.0 -n 1 -w 60000 >NULL
alarm.bat    

Optional: You need mpg123 if you want audible alarm.

Win32: http://www.mpg123.de/download/win32/
Win64: http://www.mpg123.de/download/win64/

I tested version 1.13.4-x86 on XP X86.

Extract mpg123 then add alarm.bat in the same folder as mpg123.exe. Rename a .mp3 sound file to alarm.mp3 and put it in the same folder.
1713515241
Hero Member
*
Offline Offline

Posts: 1713515241

View Profile Personal Message (Offline)

Ignore
1713515241
Reply with quote  #2

1713515241
Report to moderator
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, which will follow the rules of the network no matter what miners do. Even if every miner decided to create 1000 bitcoins per block, full nodes would stick to the rules and reject those blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
Cablez
Legendary
*
Offline Offline

Activity: 1400
Merit: 1000


I owe my soul to the Bitcoin code...


View Profile
April 22, 2012, 03:25:59 PM
 #2

That looks really neat,  too bad it's not on windoze.  I know I know, mitigating circumstances though.  Cheesy

Tired of substandard power distribution in your ASIC setup???   Chris' Custom Cablez will get you sorted out right!  No job too hard so PM me for a quote
Check my products or ask a question here: https://bitcointalk.org/index.php?topic=74397.0
01BTC10 (OP)
VIP
Hero Member
*
Offline Offline

Activity: 756
Merit: 503



View Profile
April 22, 2012, 03:58:29 PM
 #3

I may do one for Windows someday. It's very easy to write.
01BTC10 (OP)
VIP
Hero Member
*
Offline Offline

Activity: 756
Merit: 503



View Profile
April 22, 2012, 04:31:44 PM
 #4

Ok it will be done today  Cheesy
01BTC10 (OP)
VIP
Hero Member
*
Offline Offline

Activity: 756
Merit: 503



View Profile
April 22, 2012, 07:43:07 PM
 #5

Subscribed then.  Wink
Added Windows script to first post. It could be more pretty but it should work like that.
Cablez
Legendary
*
Offline Offline

Activity: 1400
Merit: 1000


I owe my soul to the Bitcoin code...


View Profile
April 22, 2012, 10:21:19 PM
 #6

Cool, I will give this a go and let you know how I get on.  Smiley

Tired of substandard power distribution in your ASIC setup???   Chris' Custom Cablez will get you sorted out right!  No job too hard so PM me for a quote
Check my products or ask a question here: https://bitcointalk.org/index.php?topic=74397.0
Bitcoiner_cph
Full Member
***
Offline Offline

Activity: 160
Merit: 100


View Profile
February 11, 2014, 08:41:54 AM
 #7

How to make the alarm work, with normal CGminer installation on xubuntu?? SSH???


01BTC10 (OP)
VIP
Hero Member
*
Offline Offline

Activity: 756
Merit: 503



View Profile
February 12, 2014, 12:08:52 AM
 #8

How to make the alarm work, with normal CGminer installation on xubuntu?? SSH???

This topic is very old and I'm almost ashamed by my bash skills back then. Anyway to make the alarm work you need mpg321 on the computer running the script and a sound file named alarm.mp3 in the same folder.

Code:
sudo apt-get install mpg321
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!