資源描述:
《Linux Shell 編程一》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、LinuxShell編程一一.變量,數(shù)組二.if,while,until,for,case,三.function四.test,[],(()),[[]],``,$()五.
2、,<><<>>,stdinstdoutstderr六.正則腳本示例#!/bin/bash#========================================================================================#RAIDhealthpluginforNagios##Writtenby:Roland#Release:1.0.0#Creationdate:2010-06
3、-10#Revisiondate:2010-06-10#Description:Nagiosplugin(script)tocheckRAIDhealth.#ThisscripthasbeendesignedandwrittenonLinuxSystem.##USAGE:./check_raid_health.sh[-d(raidnum)]##Exemple:./check_raid_stats.sh#./check_raid_stats.sh-draid1###HISTORY:#Release
4、Date
5、Authors
6、Description#--------------+------
7、----------+----------------------+----------------------------------#1.0.0
8、2010-06-10
9、Roland
10、Createthescript#-----------------------------------------------------------------------------------------#NOTICE:#-----------------------------------------------------------------------------------------#
11、YoushouldhavetherootPermissions,Youcanusesudotorealize.#-----------------------------------------------------------------------------------------#Nagiosreturncodes#定義nagios返回的狀態(tài)變量STATE_OK=0STATE_WARNING=1STATE_CRITICAL=2STATE_UNKNOWN=3#Pathstocommandsusedinthisscript.Thesemayhavetobemodifiedtomat
12、chyoursystemsetup.#定義關(guān)鍵的核心命令MegaCli路徑。#MEAGCLI=/root/MegaCli-AdpAllInfo-aALL
13、egrep"Degrade
14、FailedDisks
15、Offline"
16、egrep-v"No
17、Yes"#Pluginparametersvalueifnotdefine#定義默認(rèn)的檢測RAIDCHECK_RAID="raid1"#Pluginvariabledescription#插件定義此插件腳本的描述信息PROGNAME=$(basename$0)RELEASE="Revision1.0.0"AUTHOR="(c)2010Roland
18、(Rolandqu@gmail.com)"#Functionspluginusage#插件的使用方法函數(shù)print_release(){echo"$RELEASE$AUTHOR"}print_usage(){echo""echo"$PROGNAME$RELEASE-RAIDhealthcheckscriptforNagios"echo""echo"Usage:check_raid_health.sh-draid1"echo""echo"-dtheRAID(raidnum)"echo"-vchecktheversion"echo"-hShowthispage"echo""echo"Usag
19、e:$PROGNAME"echo"Usage:$PROGNAME--help"echo""exit0}print_help(){print_usageecho""echo"Thispluginwillcheckdiskhealth"echo""exit0}#Parseparameters#傳遞參數(shù)while[$#-gt0]docase"$1"in-h
20、--help)print_helpexit$STATE_OK;;-v
21、--vers