Check HP Server Memory status script
Script 1 (send an email notification if any problem occurs ):
# Vi disk. Sh
Press a or I to enter the editing mode.
#! /Bin/bash
Name = 'hostname'
Date = 'date + % m % d % y'
Num = 'dmidecode | grep-I 'serial number' | head-N 1'
Mem = '/sbin/hpasmcli-s "show dimm" | grep status | awk-f [: ""] +' {print $2 }''
Mem = '/sbin/hpasmcli-s "show dimm" | grep size | awk-f [: ""] +' {print $2} '| head-N 1'
I = 1;
For OK in $ mem
Do
If [$ OK = "OK"]
Then
I = $ ($ I + 1 ))
Else
Touch/log/$ date. Log
Echo "$ name $ I memory ($ MEM2) is bad">/log/$ date. Log
Echo "$ num">/log/$ date. Log
/Usr/bin/mail-s "$ name memory bad" [email protected] </log/$ date. Log
I = $ ($ I + 1 ))
Fi
Done
Press ESC to exit the editing mode
: WQ (save and Exit)
Script 2 (send an email every day ):
# Vi disk. Sh
Press a or I to enter the editing mode.
#! /Bin/bash
Name = 'hostname'
Date = 'date + % m % d % y'
Num = 'dmidecode | grep-I 'serial number' | head-N 1'
Mem = '/sbin/hpasmcli-s "show dimm" | grep status | awk-f [: ""] +' {print $2 }''
Mem = '/sbin/hpasmcli-s "show dimm" | grep size | awk-f [: ""] +' {print $2} '| head-N 1'
Touch/log/$ date. Log
I = 1;
For OK in $ mem
Do
If [$ OK = "OK"]
Then
Echo "$ name $ I memory ($ MEM2) is OK">/log/$ date. Log
I = $ ($ I + 1 ))
Else
Echo "$ name $ I memory ($ MEM2) is bad">/log/$ date. Log
Echo "$ num">/log/$ date. Log
/Usr/bin/mail-s "$ name memory bad" [email protected] </log/$ date. Log
I = $ ($ I + 1 ))
Fi
Done
Press ESC to exit the editing mode
: WQ (save and Exit)
This article is from the "Linux" blog and will not be reproduced!