Oh look, a GUI

Discussion and Technical Support for general software applications and utilities including OS related issues.
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Oh look, a GUI

Post by Ian »

Here you go. Give this script a go. Obviously I've not been able to test it since the output from my "sensors" command differs greatly to yours.
I've removed the lines which shut your server down and send you the email. You can re-enable them (by removing the # from the start of the line) once you're happy.

The msg.txt file referred to in the script contains the following:

Code: Select all

To: youremail@gmail.com
From: youremail@gmail.com
Subject: CPU/Drive Temperature Exceeded



The server has shut down!
From what I've read "temp2" is the CPU and temp3 is the northbridge. Temp1 is "the system" whatever that might be. If you don't want all 3 of them monitored then change the line in the script which reads "for i in 1 2 3" to whatever numbers you want to check. So, "for i in 2 3" for example.

Let me know how you get on.

Ian.
Attachments
stuart.txt
(1.75 KiB) Downloaded 139 times
Sergeus
Member
Member
Posts: 24
Joined: September 30th, 2011, 12:46 pm

Re: Oh look, a GUI

Post by Sergeus »

Awesome! Thanks that works really well, I haven't been getting any more errors via email, and it's reporting properly because there's a warning log file in my home folder now lol. Its warning temperature is 35 and the CPU appears to be sitting at 36. There's a single quote missing from the second last line, at first it was saying expecting ' and found EOF. Vim's color coding makes it easier to spot. Am I correct in thinking I should remove the # from in front of the shutdown and email lines once I've filled in my details?

Thanks, Ian! :D I'm learning a bit more about how this code works reading yours. It's all in 'bash', right? I'm not sure if that's the formal name of the language, or if it's even technically a language at all.

Any idea why my emails are going to the wrong addresses though? And the HDD monitoring scripts are also giving similar errors to the CPU one, they say:

Code: Select all

/home/stuart/Scripts/HDDTempShutdown.sh: line 69: [: -ge: unary operator expected
/home/stuart/Scripts/HDDTempShutdown.sh: line 80: [: -ge: unary operator expected
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Oh look, a GUI

Post by Ian »

Sorry about the missing quote, I couldn't test it because it doesn't work on my setup.

I tend to set the "warning" temp to be slightly above normal otherwise you get a huge log! Not sure if you've read but my server lives in a cupboard so if the cupboard vents get blocked I'd have problems! With this script it'd just warn me a few times (I have it set to run every minute) and then would shut down before it gets too hot in there. Only happened once before.

Yup, it's all in "bash". You can google for bash and learn loads (don't read up too much otherwise you'll soon suss I'm a mere novice at it!! :lolno: )

Re the emails, are you seeing this issue in your "sent" items? Presumably you are cos they'd not reach your inbox but someone else's, right?

The HDD monitoring scripts are probably throwing errors for the exact same reason as your CPU scripts. The output in my setup differs to yours.
The script is simple string manipulation and presumably the output from mine and yours is not the same.

Issue the following command and send me the output:

Code: Select all

sudo /usr/sbin/smartctl -n standby -a /dev/sdX
where sdX is the mount name of your drive (eg. /dev/sda, /dev/sdb, /dev/sdc and so on)

Ian.
Sergeus
Member
Member
Posts: 24
Joined: September 30th, 2011, 12:46 pm

Re: Oh look, a GUI

Post by Sergeus »

No worries, I'm glad I was able to fix it here. It's difficult enough to program stuff when you can test it, let alone when it's for another machine. My server's out in the open for now, I haven't decided where to put it yet long term. It seems to be running a bit hot if it's at 34 when it's not really doing anything. =/

I'm seeing the emails in my sentbox, and gmail is bouncing them back at me since the address stuart@gmail.com doesn't exist, apparently. It's probably a reserved address or something.

My output from that command is rather massive, though I do see the temperature buried in there:

Code: Select all

smartctl 5.40 2010-07-12 r3124 [x86_64-unknown-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Device Model:     SAMSUNG HD204UI
Serial Number:    S2H7J90B820484
Firmware Version: 1AQ10001
User Capacity:    2,000,398,934,016 bytes
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   8
ATA Standard is:  ATA-8-ACS revision 6
Local Time is:    Wed Oct 26 00:31:34 2011 BST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Power mode is:    ACTIVE or IDLE

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                                        was never started.
                                        Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                 (20340) seconds.
Offline data collection
capabilities:                    (0x5b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        No Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   2) minutes.
Extended self-test routine
recommended polling time:        ( 255) minutes.
SCT capabilities:              (0x003f) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   100   100   051    Pre-fail  Always       -       22
  2 Throughput_Performance  0x0026   252   252   000    Old_age   Always       -       0
  3 Spin_Up_Time            0x0023   066   065   025    Pre-fail  Always       -       10576
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       25
  5 Reallocated_Sector_Ct   0x0033   252   252   010    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   252   252   051    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0024   252   252   015    Old_age   Offline      -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       73
 10 Spin_Retry_Count        0x0032   252   252   051    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   252   252   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       25
181 Program_Fail_Cnt_Total  0x0022   100   100   000    Old_age   Always       -       2754117
191 G-Sense_Error_Rate      0x0022   100   100   000    Old_age   Always       -       2
192 Power-Off_Retract_Count 0x0022   252   252   000    Old_age   Always       -       0
194 Temperature_Celsius     0x0002   064   063   000    Old_age   Always       -       34 (Lifetime Min/Max 18/37)
195 Hardware_ECC_Recovered  0x003a   100   100   000    Old_age   Always       -       0
196 Reallocated_Event_Count 0x0032   252   252   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   252   252   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   252   252   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0036   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x002a   100   100   000    Old_age   Always       -       0
223 Load_Retry_Count        0x0032   252   252   000    Old_age   Always       -       0
225 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       -       25

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]


Note: selective self-test log revision number (0) not 1 implies that no selective self-test has ever been run
SMART Selective self-test log data structure revision number 0
Note: revision number not 1 implies that no selective self-test has ever been run
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Completed [00% left] (0-65535)
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
I see in there as well that SMART seems to be enabled. I read somewhere on the forums here, I think, that the SMART system on HDDs tends to wake them after they've spun down? I thought I had that option disabled from my motherboard BIOS though.
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Oh look, a GUI

Post by Ian »

Thanks for the dump.

OK, I'll let you tweak this script yourself since it's a bit easier.

On line 67 insert a new line and paste the following contents onto it.

Code: Select all

str2=${str2:1:2}
Then save the script and run it again. Does it work better now?

Ian.
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Oh look, a GUI

Post by Ian »

Re your cron job emails.

In the script you posted earlier where you had the XXXXXs, are you using a legit email address in the actual script itself or a made-up one?

Try deleting the entry in the revaliases file and see whether that helps.

I'm wondering whether it's something to do with 11.04 verses 10.04 cos I really can't see what's wrong. I won't give up until I've sussed it tho :thumbup:

Ian.
Sergeus
Member
Member
Posts: 24
Joined: September 30th, 2011, 12:46 pm

Re: Oh look, a GUI

Post by Sergeus »

Thanks for the help, Ian! I hadn't had a chance to try this stuff out until just now. The edit to the HDD temperature script works like a charm. :D So all of my temperature monitoring stuff is up and running.

I tried deleting the revaliases file, but the email still goes the wrong address. The XXXXXs in my ssmtp.conf are all the same legit email. I notice that there's an entry in the ssmtp.conf file that defines an address for root, and I think when webmin tries to email root it works. But I added another line that defined an address for my username and it didn't seem to affect anything. At does say in the ssmtp.conf comments that the address defined where I've got root=XXXXX@gmail.com receives all emails for users whose id is < 1000. My user id is 1001, so there must be some other way to define individual accounts.
Post Reply