CPU idle rate plug-ins developed using the shell

Source: Internet
Author: User
Tags exit
#!/bin/bash #=============================================== # AUTHOR:JC # Email : jiechao2013@gmail.com # changelog:2013.5.4 # Description:check the Cpu-utili Zation rate #=============================================== state_ok=0 state_warning=1 STATE_CRIT ical=2 state_unknown=3 cpu_idle= ' top-b-N 1 | grep Cpu | awk ' {print $} ' | Cut-f 1-d "."
    
     
    
' progname=$ (basename $) release= "Revision 1.2.0" author= "(c) 2013 JC (jiechao2013@gmail.com)" 
    
        Print_release () {echo "$RELEASE $AUTHOR"} print_usage () { 
    
        echo "echo" $PROGNAME $RELEASE-cpu Utilization rate Check script for Nagios "echo"
    
        echo "Usage:check_cpurate.sh" echo "" echo "-V Check the" version " echo "echo" Usage: $PROGNAME "echo" "Exit 0} print_help () {Print_
    
        Usage echo "echo" This plugin'll check CPU utilization rate "echo" Exit 0} While [$#-GT 0]; Do case "$" in-v | 
    
                --version) print_release exit $STATE _OK Shift 
    
;; 
    
            *) echo "Unknown argument: $ print_usage exit $STATE _unknown 
    
        ;; ESAC shift do case ' uname ' in Linux percent=$ (bc<<&lt ;" scale=2;621/977 "|tr ' ^." ') cpu_idle= ' Top-b-N 1 | grep Cpu | awk ' {print $} ' | Cut-f 1-d "." ' If (("$cpu _idle" <)) then echo "Ok-utilization rate $cpu _idle (free: $PERCENT%) Free CPU "Exit $STATe_ok else echo "CRITICAL-CPU utilization rate $cpu _idle ($PERCENT%) 
    
  Free CPU "Exit $STATE _critical fi;; *) echo "UNKNOWN: ' uname ' not yet supported by this plugin.
    
Coming soon! " 
    
Exit $STATE _unknown;; Esac
Related Article

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.