Page 6 of 10 FirstFirst ... 45678 ... LastLast
Results 51 to 60 of 96

Thread: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

  1. #51
    Join Date
    Jun 2009
    Location
    PA - 215
    Beans
    18
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by bvz View Post
    Ok, well at least line 11 is short enough that we can see it all.

    Do you see where your script differs from mine in the line above? Line 10? The awk statement has a different mix of characters than the degree symbol.

    Try running the following on the command line directly:

    Code:
    /usr/sbin/hddtemp /dev/sda | sed 's/\(.*\)://g' | awk -F '�' '{ print $1}')
    This is just line 10 set up to run directly from the command line for disk sda. Other than substituting in the actual hddtemp command for the variable, and substituting in the sda drive for the variable, it is identical to what you posted. I suspect that the results of this command will not come back with an integer number. I suspect that that is because the original script was supposed to split the returned text on the degree symbol and throw away anything other than the first part (the part before the degree symbol). That is what awk does. If your script is looking for something other than the degree symbol, it won't split the line properly and you will get some extra cruft in there that should have been cut away.

    A second question I have is about your line 2

    You concatenate all your drives by saying /dev/sd[a-d]

    That's pretty fancy. I've never done that before. Does that actually give you the correct array? Just wondering.
    Line 10 was changed because of a previous comment somewhere in this thread that fixed another error I was getting.

    Code:
    frank@Server:~$ /usr/sbin/hddtemp /dev/sda | sed 's/\(.*\)://g' | awk -F '�' '{ print )1}'
    -bash: syntax error near unexpected token `)'
    About line 2 I saw it somewhere when I was googling my errors.

  2. #52
    Join Date
    Sep 2007
    Beans
    97

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by Philliesfan251 View Post
    Line 10 was changed because of a previous comment somewhere in this thread that fixed another error I was getting.

    Code:
    frank@Server:~$ /usr/sbin/hddtemp /dev/sda | sed 's/\(.*\)://g' | awk -F '�' '{ print )1}'
    -bash: syntax error near unexpected token `)'
    About line 2 I saw it somewhere when I was googling my errors.
    re: Line 2
    Cool trick


    Did you try running the command by itself?

    Code:
    /usr/sbin/hddtemp /dev/sda | sed 's/\(.*\)://g' | awk -F '�' '{ print $1}')
    That will spit back exactly what line 10 in the script is doing. I suspect it will return something that is your hd temp plus some extra text.

  3. #53
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by Philliesfan251 View Post
    How do I go about doing that?
    The only time I have run into that particular problem is if I am connecting to the box via Putty on Windows. It defaults to Latin-1, but you can change it from Windows > Translation
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  4. #54
    Join Date
    Jun 2009
    Location
    PA - 215
    Beans
    18
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by bvz View Post
    re: Line 2
    Cool trick


    Did you try running the command by itself?

    Code:
    /usr/sbin/hddtemp /dev/sda | sed 's/\(.*\)://g' | awk -F '�' '{ print $1}')
    That will spit back exactly what line 10 in the script is doing. I suspect it will return something that is your hd temp plus some extra text.
    Check the code you quoted

  5. #55
    Join Date
    Sep 2007
    Beans
    97

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by Philliesfan251 View Post
    Check the code you quoted
    Whoops. Total reading comprehension fail on my part.


    Try running the following command (I had an extra parenthesis at the end):

    Code:
    /usr/sbin/hddtemp /dev/sda | sed 's/\(.*\)://g' | awk -F '�' '{ print $1}'

    I went ahead and ran a similar command here. Note that I am traveling for work and don't have access to my server, but I am in front of a linux machine. I literally ran the following command (I don't have hddtemp installed on this machine so I had to fake the output of hddtemp. That's why I have that echo command in there. But this should be mostly identical to what your hddtemp is putting out.):

    Code:
    echo '/dev/sda: WDC WD2500YS-01SHB1:  25°C' | sed 's/\(.*\)://g' | awk -F '�' '{ print $1}'
    and got back this:

    Code:
     25°C

    Note the degree symbol plus the letter 'C'. That is what is messing up the next line which expects just an integer.

    If I modify your command just the tiniest bit (replace the funky characters with a degree symbol) it gets closer:

    Code:
    echo '/dev/sda: WDC WD2500YS-01SHB1:  25°C' | sed 's/\(.*\)://g' | awk -F '°' '{ print $1}'
    this gets me:

    Code:
     25
    This is just the temperature, but note that it still leaves me with some leading spaces. I don't know if that is going to be an issue or not, but my original line in my script does not have any leading spaces.


    I modified the line to remove any leading spaces (this might be the overkill way to do it, but it was the fastest way I could think of):

    Code:
    echo '/dev/sda: WDC WD2500YS-01SHB1:  25°C' | sed 's/\(.*\)://g' | sed 's/^[ \t]*//' | awk -F '°' '{ print $1}'
    This returns just an integer.



    So... after all of that, try putting the following line into your script:

    Code:
    HDTEMP=$($HDT $disk | sed 's/\(.*\)://g' | sed 's/^[ \t]*//' | awk -F '°' '{ print $1}')


    Double check that line yourself to make sure it makes sense. We have already established that my reading comprehension is a bit off


    That should get your script functioning correctly.

    I hope.
    Last edited by bvz; December 17th, 2012 at 08:22 PM.

  6. #56
    Join Date
    Jun 2009
    Location
    PA - 215
    Beans
    18
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Replaced that line
    Code:
    #!/bin/bash
    HDDS="/dev/sd[a-d]"
    HDT=/usr/sbin/hddtemp
    LOG=/usr/bin/logger
    DOWN=/sbin/shutdown
    ALERT_LEVEL=1
    for disk in $HDDS
    do
      if [ -b $disk ]; then
            HDTEMP=$($HDT $disk | sed 's/\(.*\)://g' | sed 's/^[ \t]*//' | awk -F '�' '{ print $1}')
            if [ $HDTEMP -ge $ALERT_LEVEL ]; then
               echo "Your server is shutting down due to excessive hard drive temp. Drive: $disk has reached a temperature of $HDTEMP�C and has crossed its limit of $ALERT_LEVEL�C" | mail -s "ALERT! The Your server is shutting down due to e$       $LOG "System going down as hard disk : $disk temperature $HDTEMP�C crossed its limit"
               sync;sync
               $DOWN -h 0
            fi
      fi
    done
    Got this
    Code:
    frank@Server:~$ sudo ~/hddtemp_monitor.sh
    /home/frank/hddtemp_monitor.sh: line 11: [: 28Â: integer expression expected
    /home/frank/hddtemp_monitor.sh: line 11: [: 26Â: integer expression expected
    /home/frank/hddtemp_monitor.sh: line 11: [: 26Â: integer expression expected
    /home/frank/hddtemp_monitor.sh: line 11: [: 27Â: integer expression expected
    I'm running 12.04 if that makes any difference.
    Last edited by Philliesfan251; December 18th, 2012 at 03:23 PM.

  7. #57
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    It looks like the problem is because of the way the script checks to see if the temp is higher than alert level.

    I just checked the script you posted and it bombed out on me:

    Code:
    ./test.sh: line 11: [: 32°C: integer expression expected
    It looks like bvz fixed it by replacing the delimiter in awk with the degree symbol (which your code doesn't have). Your code also does not have the degree symbol at all and I can only think that is due to not using UFT-8 encoding, as I have run into similar problems in the past.

    I went back to the original script and compared it with the current one and got this:

    Code:
    #!/bin/bash
    HDDS="/dev/sd[a-d]"
    HDT=/usr/sbin/hddtemp
    LOG=/usr/bin/logger
    DOWN=/sbin/shutdown
    ALERT_LEVEL=40
    for disk in $HDDS
    do
      if [ -b $disk ]; then
            HDTEMP=$($HDT $disk | sed 's/\(.*\)://g' | sed 's/^[ \t]*//' | awk -F '°' '{ print $1}')
            if [ $HDTEMP -ge $ALERT_LEVEL ]; then
    echo $HDTEMP
               echo "The server ubuntu is shutting down due to excessive hard drive temp. Drive: $disk has reached a temperature of $HDTEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server ubuntu is shutting down due to excessive hard drive temperature" email@domain.com
              $LOG "System going down as hard disk : $disk temperature $HDTEMP°C crossed its limit"
               sync;sync
               $DOWN -P 0
            fi
      fi
    done
    Note: This script will bomb out if you have a drive that doesn't report a SMART temp:
    Code:
    ./test.sh: line 12: [: too many arguments
    @bvz: Outstanding job on that script.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  8. #58
    Join Date
    Jun 2009
    Location
    PA - 215
    Beans
    18
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    This is what it does UTF-8
    Code:
    frank@Server:~$ sudo ~/hddtemp_monitor.sh
    [sudo] password for frank:
    /home/frank/hddtemp_monitor.sh: line 11: [: 32▒: integer expression expected
    /home/frank/hddtemp_monitor.sh: line 11: [: 29▒: integer expression expected
    /home/frank/hddtemp_monitor.sh: line 11: [: 30▒: integer expression expected
    /home/frank/hddtemp_monitor.sh: line 11: [: 30▒: integer expression expected
    EDIT: Wow, just changed to UTF-8 and put the original script in and it worked! Should have listened to you from the beginning Charles. Thanks for the troubleshooting as well bvz, you have an awesome guide here.
    Last edited by Philliesfan251; December 18th, 2012 at 06:35 PM.

  9. #59
    Join Date
    Jun 2009
    Location
    PA - 215
    Beans
    18
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by bvz View Post
    Try modifying your command to add the following flag:

    --no-sharing


    So the command becomes:
    sudo mdadm --monitor --scan --no-sharing
    Now for this problem I tried that and it kind of just hung, no emails or anything, had to Ctrl+C after like 5 minutes.

  10. #60
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by Philliesfan251 View Post
    EDIT: Wow, just changed to UTF-8 and put the original script in and it worked! Should have listened to you from the beginning Charles. Thanks for the troubleshooting as well bvz, you have an awesome guide here.
    It has happened to everyone. I just know about it because I was trying to figure out why I was getting an odd character from cputemp and found out it was cuz of my encoding.

    Glad you got it sorted.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

Page 6 of 10 FirstFirst ... 45678 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •