#!/bin/bashecho"param num:$#"echo"sh name is :$0"echo"The first param is :$1"echo"The second param is :$2"echo"The all param list is :$@"echo"The all param str is :$*"echo"The PID is:$$"echo"The precomm stat is:$?"
第三节 功能函数的实现
# process.cfg[GROUP_LIST]
WEB
DB
HADOOP
YARN
[WEB]
nginx
httpd
[DB]
mysql
postgresql
oracle
[HADOOP]
datanode
namenode
journalnode
[YARN]
resourcemanager
nodemanager
[nginx]description="Web Server 1"program_name=tail
parameter=-f /root/lesson/9.1/tmp/web-nginx.conf
[httpd]description="Web Server 2"program_name=tail
parameter=-f /root/lesson/9.1/tmp/web-httpd.conf
[mysql]description="High Performance DataBase"program_name=tail
parameter=-f /root/lesson/9.1/tmp/mysql.conf
[postgresql]description="PG Server"program_name=tail
parameter=-f /root/lesson/9.1/tmp/postgresql.conf
[oracle]description="The Best DB Server In The World"program_name=tail
parameter=-f /root/lesson/9.1/tmp/oracle.conf
[datanode]description="NODE: Storage Data For HDFS"program_name=tail
parameter=-f /root/lesson/9.1/tmp/hdfs-datanode.xml
[namenode]description="NODE: Storage MetaData For HDFS"program_name=tail
parameter=-f /root/lesson/9.1/tmp/hdfs-namenode.xml
[journalnode]description="Data synchronization For NameNode"program_name=tail
parameter=-f /root/lesson/9.1/tmp/hdfs-journalnode.xml
[resourcemanager]description="Resource allocation, task scheduling"program_name=tail
parameter=-f /root/lesson/9.1/tmp/yarn-resourcemanager.xml
[nodemanager]description="Compute nodes to perform tasks assigned by RM"program_name=tail
parameter=-f /root/lesson/9.1/tmp/yarn-nodemanager.xml
function get_all_group说明:该函数无需输入任何参数;返回配置文件 process.cfg中所有的组信息,例如WEB、DB等。
functionget_all_group{if[! -e $HOME_DIR/$CONFIG_FILE];thenecho"CONFIG_FILE is not exist .. PLease CHeck.."
EXIT 1elseG_LIST=$(sed -n '/\[GROUP_LIST\]/,/\[.*\]/p' process.cfg |egrep -v "(^$|\[.*\])")echo"$G_LIST"fi}# 测试一下# groups=`get_all_group`# echo $groups# for g in `get_all_group`# do # echo $g# done
function get_all_process: 说明:该函数无需输入任何参数;返回配置文件 process.cfg中所有的进程信息。