It is currently 19. Sep 2017, 22:38

Tools: Calendar Calendar   Games Games   Gallery Gallery   Downloads Downloads   

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 11 posts ] Go to page  1, 2  Next
AuthorMessage
 Post subject: Script to check your crunchers to make sure they are up.
PostPosted: 2. May 2009, 08:57 
User avatar

Joined: 03.2009
Posts: 66
Location: Republic of Texas, Central
Gender: Male
I used to fire up the BOINC GUI Manager each morning and each evening and connected to every cruncher on my LAN just to make sure it was up and running. This got old pretty quick. While I still try to do that once in a while I needed a quick and dirty check that would run while I was getting my first cup of coffee and logging onto work each morning. Now mind you this was back in my 'Windoze' days (not that long ago). Well to solve this I wrote a .bat file that had some kind of loop control to call a subroutine... don't recall if it was for-next or a do while or what but anyway all it did was use the index for the loop control as the last node of the IP address and pinged that IP. If it respond and was an IP that I knew a cruncher should be at, the .bat went on. If it got a response from an IP that I don't have anything on it gave a warning that IP.something.whatever was in use. If an IP didn't respond that should it gave a different message about crunchxx not responding. This got to be a pretty messy batch file with all the ERRORLEVEL checking. I still have it on the WinXP boot but don't use it anymore because I'm rarely in Windoze on this box. Anyway... after "The Conversion" to Ubuntu this was a tool I was missing. I wanted to start learning bash scripts but really wanted to start with something I at least understood the function of. So I arm-twisted my youngest son into taking a rough shot at converting my 'pinger.bat' to a bash script. This was a perfect 1st script task for me because I, better than anyone, knew what machines sat at what IP and if they should be up or not. I took the draft he sent me and corrected some of the logic and got it working. I use it at least once a day now just to make sure the boxes are up and also to see if there's anything sitting on an IP that shouldn't be. Ya never know when that 80 year old lady across the road might hack my network ;-)

For you REAL Linux folks this will be absolute kindergarten scripting. Anyway I thought some other recent convert to "The Way" might have some use for it. You can download it HERE.

Move it to /usr/local/bin/ or to /usr/bin/ so it is in your default executable path.
Code:
sudo mv -v /whereitsat/pinger.sh /usr/bin/


After moving it make sure it's set to be executable
Code:
sudo chmod a+x pinger.sh


If you ol' pros have some positive feedback on how to do something better... and I can understand it, your comments would be greatly appreciated.

_________________
- da shu @ the BOINC farm, SkipsJunk, Guru Mountain
- BoincDV is on-line! Click HERE
Phillip Warren Anderson works on my RAM & CPU problems


Offline
 Profile  
 
 Post subject: Re: Script to check your crunchers to make sure they are up.
PostPosted: 3. May 2009, 21:24 

Joined: 04.2009
Posts: 5
Gender: None specified
I used a little different approach to the same thing. Differences being that I have my computers running on a remote network. I put a little script in the cron.daily to upload the client_state.xml into an ftp directory based on the hostname. Now, I can just look at the ftp server and see that all the hosts uploaded their file in the last 24 hours. Sometime in the near future i'll have time to put together a little php script to live on the server and check this for me, possibly pull some stats from the client_state.xml and send me an email or something.

The script I've got to do the ftping requires lftp

Code:
#!/bin/bash
DIRR="$(hostname)"
### FTP SERVER Login info ###
FTPU="your_acct"
FTPP="your_pass"
FTPS="your_host"
NOW=$(date +"%d-%m-%Y")
lftp -u $FTPU,$FTPP -e "mkdir /$DIRR; cd /$DIRR; put /home/boinc/BOINC/client_state.xml; quit" $FTPS


Just another idea someone might find usefull.


Offline
 Profile  
 
 Post subject: Re: Script to check your crunchers to make sure they are up.
PostPosted: 3. May 2009, 22:23 
User avatar

Joined: 03.2009
Posts: 66
Location: Republic of Texas, Central
Gender: Male
Fantastic! This would've been over my noob head but I think it's a great approach.

Also very happy to see some sharing of ideas on how to handle what I guess I would call 'maint and monitoring' tasks here.

Thanx.

_________________
- da shu @ the BOINC farm, SkipsJunk, Guru Mountain
- BoincDV is on-line! Click HERE
Phillip Warren Anderson works on my RAM & CPU problems


Offline
 Profile  
 
 Post subject: Re: Script to check your crunchers to make sure they are up.
PostPosted: 4. May 2009, 03:50 

Joined: 04.2009
Posts: 5
Gender: None specified
Still very new to linux myself!


Offline
 Profile  
 
 Post subject: Re: Script to check your crunchers to make sure they are up.
PostPosted: 5. May 2009, 07:39 

Joined: 11.2008
Posts: 138
Gender: None specified
Skip, it's a very good idea !

From the programmng it looks good.
From the side of the logic, I think a script which do everything automaticly, without a user invention or change of the script would be nice.

A short example for a script, wich reads in the configuration variables from the Dotsch/UX config, and makes a ping probe and tries to connect to the BOINC GUI RPC port and logs errors also to the syslog :
Code:
#!/bin/sh

clear

echo "                          Host uptime check"
echo ""
echo "Hostname             Ping           BOINC"
echo "--------------------------------------------------"

. /etc/opt/dotsch_ux/dotsch_ux.conf
. /$DOTSCHUX_ETC/diskless.conf

cd $DISKLESS_ROOT


for HOST in `ls  | grep -v master.x86 |grep -v master.x64 | grep -v tftpboot `; do
   #ping test
   printf "$HOST " | awk '{ printf "%-20s %s\n", $1, $2 }' | tr -d "\n"
   ping -c 2 $HOST > /dev/null 2>&1
   if [ "$?" = "0" ]; then
      printf "OK     "
    else
      printf "DOWN   "
      logger "$0 : ping test $HOST DOWN !"
   fi

   #check BOINC GUI PRC port
   echo "\n" | nc  -v -t -q 1 $HOST 31416 > /dev/null 2>&1
   if [ "$?" = "0" ]; then
      printf "OK     "
    else
      printf "DOWN   "
      logger "$0 : BOINC test $HOST DOWN !"
   fi

   echo ""

done


The sample output :
Code:
                          Host uptime check

Hostname               Ping   BOINC
--------------------------------------------------
192.168.181.1          DOWN   DOWN   
192.168.181.151      OK     OK     
192.168.181.250      OK     OK     
dl1                            OK     DOWN   
dl10                          OK     DOWN   
dl11                          OK     DOWN 


I think bennettsweb's idea to probe the ftp, or eventualy better the ssh port is a very good idea..


Offline
 Profile  
 
 Post subject: Re: Script to check your crunchers to make sure they are up.
PostPosted: 6. May 2009, 02:25 
User avatar

Joined: 03.2009
Posts: 66
Location: Republic of Texas, Central
Gender: Male
Dotsch wrote:
Skip, it's a very good idea !

From the programmng it looks good.
From the side of the logic, I think a script which do everything automaticly, without a user invention or change of the script would be nice.

I agree. I just didn't know how to do that. This is a great example.

This sample also got me to finally understand what this does / how it works:
Code:
. /etc/opt/dotsch_ux/dotsch_ux.conf
. /$DOTSCHUX_ETC/diskless.conf

cd $DISKLESS_ROOT
This is good as I have immediate use for it in the propgt.sh script.

Can someone explain how the below line works? It seems to be feeding the output of the 'ls' command to grep whose output goes to another grep whose output goes to another grep. I am not following how this gets me the hosts.
Code:
for HOST in `ls  | grep -v master.x86 |grep -v master.x64 | grep -v tftpboot `;

I'd like to take this and see if I can test it out and repost it. I think the test of the GUI port might need to be embedded in the 'if' before the 'else' so it only happens if the ping is good. I'm thinking if ping fails the GUI isn't going to respond.

What would be the best way to have it include machines that are NOT Dotsch/UX clients (my main desktop, my work laptop, the SAMBA server/apt-cacher, the wife's computer, etc.) ?

Thanx for bash 101 class and looking forward to the next lesson, Skip

_________________
- da shu @ the BOINC farm, SkipsJunk, Guru Mountain
- BoincDV is on-line! Click HERE
Phillip Warren Anderson works on my RAM & CPU problems


Offline
 Profile  
 
 Post subject: bash 101
PostPosted: 6. May 2009, 03:49 
User avatar

Joined: 03.2009
Posts: 66
Location: Republic of Texas, Central
Gender: Male
This:
Code:
DISKLESS_MSTR=$DOTSCHUX/masters
is giving me:
Code:
/opt/dotsch_ux//masters
but this:
Code:
DISKLESS_MSTR=$DOTSCHmasters
gives me a null string. What I want is for $DISKLESS_MSTR to be "/opt/dotsch_ux/masters". I realize I can just set it with the complete path but I was trying to work within the existing framework.

Code:
boinc@crunch34:/opt/dotsch_ux/bin$ . /etc/opt/dotsch_ux/dotsch_ux.conf
boinc@crunch34:/opt/dotsch_ux/bin$ echo $DOTSCHUX
/opt/dotsch_ux/

_________________
- da shu @ the BOINC farm, SkipsJunk, Guru Mountain
- BoincDV is on-line! Click HERE
Phillip Warren Anderson works on my RAM & CPU problems


Offline
 Profile  
 
 Post subject: Re: bash 101
PostPosted: 7. May 2009, 07:25 

Joined: 11.2008
Posts: 138
Gender: None specified
Skip Da Shu wrote:
This:
Code:
DISKLESS_MSTR=$DOTSCHUX/masters
is giving me:
Code:
/opt/dotsch_ux//masters
but this:
Code:
DISKLESS_MSTR=$DOTSCHmasters
gives me a null string. What I want is for $DISKLESS_MSTR to be "/opt/dotsch_ux/masters". I realize I can just set it with the complete path but I was trying to work within the existing framework.

"DISKLESS_MSTR=$DOTSCHmasters" would be interpreted as variable. You need to set DISKLESS_MSTR=$DOTSCH_UX/masters.


Offline
 Profile  
 
 Post subject: Re: bash 101
PostPosted: 7. May 2009, 21:02 
User avatar

Joined: 03.2009
Posts: 66
Location: Republic of Texas, Central
Gender: Male
Dotsch wrote:
Skip Da Shu wrote:
This:
Code:
DISKLESS_MSTR=$DOTSCHUX/masters
is giving me:
Code:
/opt/dotsch_ux//masters
but this:
Code:
DISKLESS_MSTR=$DOTSCHmasters
gives me a null string. What I want is for $DISKLESS_MSTR to be "/opt/dotsch_ux/masters". I realize I can just set it with the complete path but I was trying to work within the existing framework.

"DISKLESS_MSTR=$DOTSCHmasters" would be interpreted as variable. You need to set DISKLESS_MSTR=$DOTSCH_UX/masters.


OK, but look what you quoted. The variable is "DOTSCHUX" as defined in /etc/opt/dotsch_ux/dotsch_ux.conf as:
Code:
#The location of the binaries, scripts, packages
DOTSCHUX=/opt/dotsch_ux/

But this one (and only this one) is defined with a trailing "/". So I end up with the double "//" in the new variable when I do
Code:
DISKLESS_MSTR=$DOTSCHUX/masters
as shown in the original note.

UPDATE: #3 son (alias scriptX) just showed up and the following resolves the problem:
Code:
DISKLESS_MSTR=${DOTSCHUX}masters

_________________
- da shu @ the BOINC farm, SkipsJunk, Guru Mountain
- BoincDV is on-line! Click HERE
Phillip Warren Anderson works on my RAM & CPU problems


Offline
 Profile  
 
 Post subject: Re: Script to check your crunchers to make sure they are up.
PostPosted: 7. May 2009, 22:34 
User avatar

Joined: 05.2009
Posts: 5
Gender: None specified
You could also run a crontab script every couple of minutes that checks whether the process is still running or not (and restart it if it's not running) - and even output that status to your /etc/motd file so as soon as you ssh into the box, you'll see if it's working or not.

Code:
#/bin/bash
#BOINC status script
rm -f /etc/motd
killall -0 boinc
if [ $? = '0' ] ;
   then echo 'BOINC running' >> /etc/motd
else echo 'BOINC *NOT* running - restarting' >> /etc/motd
/user/home/BOINC/run_client --daemon --allow_remote_gui_rpc
fi

Something like that...

_________________
SELECT * FROM USERS WHERE CLUE > 0
0 rows returned


Offline
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] Go to page  1, 2  Next

All times are UTC + 1 hour [ DST ]


 Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
 
cron