Monitor HP Server CPU status script

Source: Internet
Author: User
Tags hp server


Monitor HP Server CPU status script


Script 1 (send an email notification if any problem occurs ):

# Vi CPU. Sh

Press a or I to enter the editing mode.

#! /Bin/bash

Name = 'hostname'


IP = '/sbin/ifconfig eth0 | grep "Inet ADDR" | awk-f [: ""] +' {print $4 }''


Date = 'date + % m % d % y'

Num = '/usr/sbin/dmidecode | grep-I 'serial number' | head-N 1'

CPU = '/sbin/hpasmcli-s "show server" | grep status | awk-f [: ""] +' {print $2 }''
Cpu2 = '/sbin/hpasmcli-s "show server" | grep speed | awk-f [: ""] +' {print $2} '| head-N 1' MHz

I = 1;

For OK in $ CPU
Do
If [$ OK = "OK"]
Then
I = $ ($ I + 1 ))
Else
Touch/log/$ date. Log
Echo "$ name ($ IP) $ I CPU ($ cpu2) is bad">/log/$ date. Log
Echo "$ num">/log/$ date. Log
/Usr/bin/mail-s "$ name ($ IP) CPU ($ cpu2) 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 CPU. Sh

Press a or I to enter the editing mode.

#! /Bin/bash

Name = 'hostname'


IP = '/sbin/ifconfig eth0 | grep "Inet ADDR" | awk-f [: ""] +' {print $4 }''


Date = 'date + % m % d % y'

Num = '/usr/sbin/dmidecode | grep-I 'serial number' | head-N 1'

CPU = '/sbin/hpasmcli-s "show server" | grep status | awk-f [: ""] +' {print $2 }''

Cpu2 = '/sbin/hpasmcli-s "show server" | grep speed | awk-f [: ""] +' {print $2} '| head-N 1'

Touch/log/$ date. Log


I = 1;

For OK in $ mem
Do
If [$ OK = "OK"]
Then

Echo "$ name ($ IP) $ I cpu ($ cpu2) is OK">/log/$ date. Log

I = $ ($ I + 1 ))
Else
Echo "$ name ($ IP) $ I CPU ($ cpu2) is bad">/log/$ date. Log
Echo "$ num">/log/$ date. Log
/Usr/bin/mail-s "$ name ($ IP) CPU ($ cpu2) 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!

Monitor HP Server CPU status script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.