diff options
| author | Qiuwen Lu <[email protected]> | 2015-12-23 16:06:54 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2015-12-23 16:06:54 +0800 |
| commit | 4e748874dc47d25868a5ae732a466598ec8d09d4 (patch) | |
| tree | b82c3613b8ef6908f1f85d62c01c8780b069d92d /tools | |
| parent | 01383b63d12f3c20a1c45e9d44dd507a840ba8c7 (diff) | |
提交tools
Diffstat (limited to 'tools')
| -rw-r--r--[-rwxr-xr-x] | tools/dpdk_intel | 518 | ||||
| -rw-r--r--[-rwxr-xr-x] | tools/dpdk_mlx4 | 392 | ||||
| -rw-r--r--[-rwxr-xr-x] | tools/drv_monitor.sh | 70 | ||||
| -rw-r--r--[-rwxr-xr-x] | tools/drv_start.sh | 56 | ||||
| -rw-r--r--[-rwxr-xr-x] | tools/r2_driver.sh | 2 |
5 files changed, 519 insertions, 519 deletions
diff --git a/tools/dpdk_intel b/tools/dpdk_intel index 0dcb79f..523b74f 100755..100644 --- a/tools/dpdk_intel +++ b/tools/dpdk_intel @@ -1,259 +1,259 @@ -#! /bin/bash - -prog=dpdk_intel -config=/etc/ixgbe.conf - -quit() -{ - QUIT=$1 -} - -# -# Creates hugepage filesystem. -# -create_mnt_huge() -{ - echo "Creating /mnt/huge and mounting as hugetlbfs" - mkdir -p /mnt/huge - - grep -s '/mnt/huge' /proc/mounts > /dev/null - if [ $? -ne 0 ] ; then - mount -t hugetlbfs nodev /mnt/huge - fi -} - -# -# Removes hugepage filesystem. -# -remove_mnt_huge() -{ - echo "Unmounting /mnt/huge and removing directory" - grep -s '/mnt/huge' /proc/mounts > /dev/null - if [ $? -eq 0 ] ; then - umount /mnt/huge - fi - - if [ -d /mnt/huge ] ; then - rm -R /mnt/huge - fi -} - -# -# Unloads igb_uio.ko. -# -remove_igb_uio_module() -{ - echo "Unloading any existing DPDK UIO module" - /sbin/lsmod | grep -s igb_uio > /dev/null - if [ $? -eq 0 ] ; then - /sbin/rmmod igb_uio - fi -} - -# -# Loads new igb_uio.ko (and uio module if needed). -# -load_igb_uio_module() -{ - if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then - echo "## ERROR: Target does not have the DPDK UIO Kernel Module." - echo " To fix, please try to rebuild target." - return - fi - - remove_igb_uio_module - - /sbin/lsmod | grep -s uio > /dev/null - if [ $? -ne 0 ] ; then - modinfo uio > /dev/null - if [ $? -eq 0 ]; then - echo "Loading uio module" - /sbin/modprobe uio - fi - fi - - # UIO may be compiled into kernel, so it may not be an error if it can't - # be loaded. - - echo "Loading DPDK UIO module" - /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko - if [ $? -ne 0 ] ; then - echo "## ERROR: Could not load kmod/igb_uio.ko." - quit - fi -} - -# -# Unloads the rte_kni.ko module. -# -remove_kni_module() -{ - echo "Unloading any existing DPDK KNI module" - /sbin/lsmod | grep -s rte_kni > /dev/null - if [ $? -eq 0 ] ; then - /sbin/rmmod rte_kni - fi -} - -# -# Loads the rte_kni.ko module. -# -load_kni_module() -{ - # Check that the KNI module is already built. - if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko ];then - echo "## ERROR: Target does not have the DPDK KNI Module." - echo " To fix, please try to rebuild target." - return - fi - - # Unload existing version if present. - remove_kni_module - - # Now try load the KNI module. - echo "Loading DPDK KNI module" - /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko - if [ $? -ne 0 ] ; then - echo "## ERROR: Could not load kmod/rte_kni.ko." - quit - fi -} - -# -# Removes all reserved hugepages. -# -clear_huge_pages() -{ - echo > .echo_tmp - for d in /sys/devices/system/node/node? ; do - echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp - done - echo "Removing currently reserved hugepages" - sh .echo_tmp - rm -f .echo_tmp - - remove_mnt_huge -} - -# -# Creates hugepages. -# -set_non_numa_pages() -{ - clear_huge_pages - - echo "echo $HUGEPAGE_MEM > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp - echo "Reserving hugepages" - - sh .echo_tmp - rm -f .echo_tmp - - create_mnt_huge -} - -# -# Creates hugepages on specific NUMA nodes. -# -set_numa_pages() -{ - clear_huge_pages - - echo "" - echo " Input the number of 2MB pages for each node" - echo " Example: to have 128MB of hugepages available per node," - echo " enter '64' to reserve 64 * 2MB pages on each node" - - echo > .echo_tmp - for d in /sys/devices/system/node/node? ; do - node=$(basename $d) - echo -n "Number of pages for $node: " - read Pages - echo "echo $Pages > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp - done - echo "Reserving hugepages" - sh .echo_tmp - rm -f .echo_tmp - - create_mnt_huge -} - -# -# Uses dpdk_nic_bind.py to move devices to work with igb_uio -# -bind_nics_to_igb_uio() -{ - oldIFS=$IFS - IFS=, - for PCI_PATH in $IXGBE_UIO; do - ${RTE_SDK}/tools/dpdk_nic_bind.py -b igb_uio $PCI_PATH - done - IFS=$oldIFS -} - -# -# Uses dpdk_nic_bind.py to move devices to work with kernel drivers again -# -unbind_nics() -{ - oldIFS=$IFS - IFS=, - - for PCI_PATH in $IXGBE_UIO; do - sudo ${RTE_SDK}/tools/dpdk_nic_bind.py -b ixgbe $PCI_PATH - done - IFS=$oldIFS -} - - -load_config_file() -{ - if [ ! -f $config ] ; then - echo "Loading Configure file $config error" - exit 3 - fi - source $config -} - -start() -{ - echo -n $"Starting $prog: " - - load_config_file - load_igb_uio_module - bind_nics_to_igb_uio - set_non_numa_pages - - return 0 -} - -stop() -{ - echo -n $"Stopping $prog: " - load_config_file - clear_huge_pages - unbind_nics - remove_igb_uio_module - - return 0 -} - -restart() { - stop - start -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - *) - echo $"Usage: $0 {start|stop|restart}" - RETVAL=2 -esac -exit $RETVAL +#! /bin/bash
+
+prog=dpdk_intel
+config=/etc/ixgbe.conf
+
+quit()
+{
+ QUIT=$1
+}
+
+#
+# Creates hugepage filesystem.
+#
+create_mnt_huge()
+{
+ echo "Creating /mnt/huge and mounting as hugetlbfs"
+ mkdir -p /mnt/huge
+
+ grep -s '/mnt/huge' /proc/mounts > /dev/null
+ if [ $? -ne 0 ] ; then
+ mount -t hugetlbfs nodev /mnt/huge
+ fi
+}
+
+#
+# Removes hugepage filesystem.
+#
+remove_mnt_huge()
+{
+ echo "Unmounting /mnt/huge and removing directory"
+ grep -s '/mnt/huge' /proc/mounts > /dev/null
+ if [ $? -eq 0 ] ; then
+ umount /mnt/huge
+ fi
+
+ if [ -d /mnt/huge ] ; then
+ rm -R /mnt/huge
+ fi
+}
+
+#
+# Unloads igb_uio.ko.
+#
+remove_igb_uio_module()
+{
+ echo "Unloading any existing DPDK UIO module"
+ /sbin/lsmod | grep -s igb_uio > /dev/null
+ if [ $? -eq 0 ] ; then
+ /sbin/rmmod igb_uio
+ fi
+}
+
+#
+# Loads new igb_uio.ko (and uio module if needed).
+#
+load_igb_uio_module()
+{
+ if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then
+ echo "## ERROR: Target does not have the DPDK UIO Kernel Module."
+ echo " To fix, please try to rebuild target."
+ return
+ fi
+
+ remove_igb_uio_module
+
+ /sbin/lsmod | grep -s uio > /dev/null
+ if [ $? -ne 0 ] ; then
+ modinfo uio > /dev/null
+ if [ $? -eq 0 ]; then
+ echo "Loading uio module"
+ /sbin/modprobe uio
+ fi
+ fi
+
+ # UIO may be compiled into kernel, so it may not be an error if it can't
+ # be loaded.
+
+ echo "Loading DPDK UIO module"
+ /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko
+ if [ $? -ne 0 ] ; then
+ echo "## ERROR: Could not load kmod/igb_uio.ko."
+ quit
+ fi
+}
+
+#
+# Unloads the rte_kni.ko module.
+#
+remove_kni_module()
+{
+ echo "Unloading any existing DPDK KNI module"
+ /sbin/lsmod | grep -s rte_kni > /dev/null
+ if [ $? -eq 0 ] ; then
+ /sbin/rmmod rte_kni
+ fi
+}
+
+#
+# Loads the rte_kni.ko module.
+#
+load_kni_module()
+{
+ # Check that the KNI module is already built.
+ if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko ];then
+ echo "## ERROR: Target does not have the DPDK KNI Module."
+ echo " To fix, please try to rebuild target."
+ return
+ fi
+
+ # Unload existing version if present.
+ remove_kni_module
+
+ # Now try load the KNI module.
+ echo "Loading DPDK KNI module"
+ /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko
+ if [ $? -ne 0 ] ; then
+ echo "## ERROR: Could not load kmod/rte_kni.ko."
+ quit
+ fi
+}
+
+#
+# Removes all reserved hugepages.
+#
+clear_huge_pages()
+{
+ echo > .echo_tmp
+ for d in /sys/devices/system/node/node? ; do
+ echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
+ done
+ echo "Removing currently reserved hugepages"
+ sh .echo_tmp
+ rm -f .echo_tmp
+
+ remove_mnt_huge
+}
+
+#
+# Creates hugepages.
+#
+set_non_numa_pages()
+{
+ clear_huge_pages
+
+ echo "echo $HUGEPAGE_MEM > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp
+ echo "Reserving hugepages"
+
+ sh .echo_tmp
+ rm -f .echo_tmp
+
+ create_mnt_huge
+}
+
+#
+# Creates hugepages on specific NUMA nodes.
+#
+set_numa_pages()
+{
+ clear_huge_pages
+
+ echo ""
+ echo " Input the number of 2MB pages for each node"
+ echo " Example: to have 128MB of hugepages available per node,"
+ echo " enter '64' to reserve 64 * 2MB pages on each node"
+
+ echo > .echo_tmp
+ for d in /sys/devices/system/node/node? ; do
+ node=$(basename $d)
+ echo -n "Number of pages for $node: "
+ read Pages
+ echo "echo $Pages > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
+ done
+ echo "Reserving hugepages"
+ sh .echo_tmp
+ rm -f .echo_tmp
+
+ create_mnt_huge
+}
+
+#
+# Uses dpdk_nic_bind.py to move devices to work with igb_uio
+#
+bind_nics_to_igb_uio()
+{
+ oldIFS=$IFS
+ IFS=,
+ for PCI_PATH in $IXGBE_UIO; do
+ ${RTE_SDK}/tools/dpdk_nic_bind.py -b igb_uio $PCI_PATH
+ done
+ IFS=$oldIFS
+}
+
+#
+# Uses dpdk_nic_bind.py to move devices to work with kernel drivers again
+#
+unbind_nics()
+{
+ oldIFS=$IFS
+ IFS=,
+
+ for PCI_PATH in $IXGBE_UIO; do
+ sudo ${RTE_SDK}/tools/dpdk_nic_bind.py -b ixgbe $PCI_PATH
+ done
+ IFS=$oldIFS
+}
+
+
+load_config_file()
+{
+ if [ ! -f $config ] ; then
+ echo "Loading Configure file $config error"
+ exit 3
+ fi
+ source $config
+}
+
+start()
+{
+ echo -n $"Starting $prog: "
+
+ load_config_file
+ load_igb_uio_module
+ bind_nics_to_igb_uio
+ set_non_numa_pages
+
+ return 0
+}
+
+stop()
+{
+ echo -n $"Stopping $prog: "
+ load_config_file
+ clear_huge_pages
+ unbind_nics
+ remove_igb_uio_module
+
+ return 0
+}
+
+restart() {
+ stop
+ start
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart}"
+ RETVAL=2
+esac
+exit $RETVAL
diff --git a/tools/dpdk_mlx4 b/tools/dpdk_mlx4 index 62b8289..b9640bf 100755..100644 --- a/tools/dpdk_mlx4 +++ b/tools/dpdk_mlx4 @@ -1,196 +1,196 @@ -#!/bin/bash -# -# dpdk-kernel Start up the DPDK configuration and insert kernel model -# -### END INIT INFO - -prog=dpdk_mlx4 -config=/etc/mlx4.conf - -load_mlx4_core_module() -{ - /sbin/insmod /lib/modules/$(uname -r)/kernel/drivers/net/mlx4/mlx4_core.ko - /sbin/insmod /lib/modules/$(uname -r)/kernel/drivers/net/mlx4/mlx4_en.ko -} - -remove_mlx4_uio_module() -{ - echo "Unloading any existing DPDK UIO module" - /sbin/lsmod | grep -s mlx4_uio > /dev/null - if [ $? -eq 0 ] ; then - sudo /sbin/rmmod mlx4_uio - fi -} - -remove_mlx4_en_module() -{ - echo "Unloading any existing MLX4 EN module" - /sbin/lsmod | grep -s mlx4_en > /dev/null - if [ $? -eq 0 ] ; then - sudo /sbin/rmmod mlx4_en - fi -} - -remove_mlx4_core_module() -{ - echo "Unloading any existing MLX4 CORE module" - /sbin/lsmod | grep -s mlx4_core > /dev/null - if [ $? -eq 0 ] ; then - sudo /sbin/rmmod mlx4_core - fi -} - -load_mlx4_uio_module() -{ - if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/mlx4_uio.ko ];then - echo "## ERROR: Target does not have the DPDK UIO Kernel Module." - echo " To fix, please try to rebuild target." - return - fi - - remove_mlx4_uio_module - - /sbin/lsmod | grep -s uio > /dev/null - if [ $? -ne 0 ] ; then - if [ -f /lib/modules/$(uname -r)/kernel/drivers/uio/uio.ko ] ; then - echo "Loading uio module" - sudo /sbin/modprobe uio - fi - fi - - # UIO may be compiled into kernel, so it may not be an error if it can't - # be loaded. - - echo "Loading DPDK UIO module" - sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/mlx4_uio.ko intr_mode="msix" - if [ $? -ne 0 ] ; then - echo "## ERROR: Could not load kmod/mlx4_uio.ko." - quit - fi -} - -bind_mlx4_uio_module() -{ - oldIFS=$IFS - IFS=, - for PCI_PATH in $MLX4_UIO; do - sudo ${RTE_SDK}/tools/pci_unbind.py -b mlx4_uio $PCI_PATH - done - IFS=$oldIFS -} - -unbind_mlx4_uio_module() -{ - oldIFS=$IFS - IFS=, - - for PCI_PATH in $MLX4_UIO; do - sudo ${RTE_SDK}/tools/pci_unbind.py -b mlx4_core $PCI_PATH - done - IFS=$oldIFS -} - - -remove_mnt_huge() -{ - echo "Unmounting /mnt/huge and removing directory" - grep -s '/mnt/huge' /proc/mounts > /dev/null - if [ $? -eq 0 ] ; then - sudo umount /mnt/huge - fi - - if [ -d /mnt/huge ] ; then - sudo rm -R /mnt/huge - fi -} - -create_mnt_huge() -{ - echo "Creating /mnt/huge and mounting as hugetlbfs" - sudo mkdir -p /mnt/huge - - grep -s '/mnt/huge' /proc/mounts > /dev/null - if [ $? -ne 0 ] ; then - sudo mount -t hugetlbfs nodev /mnt/huge - fi -} - -clear_huge_pages() -{ - echo > .echo_tmp - for d in /sys/devices/system/node/node? ; do - echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp - done - echo "Removing currently reserved hugepages" - sudo sh .echo_tmp - rm -f .echo_tmp - - remove_mnt_huge -} - -# -# Creates hugepages. -# -set_non_numa_pages() -{ - clear_huge_pages - - echo "echo $HUGEPAGE_MEM > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp - echo "Reserving hugepages" - sudo sh .echo_tmp - rm -f .echo_tmp - create_mnt_huge -} - -load_config_file() -{ - if [ ! -f $config ] ; then - echo "Loading Configure file $config error" - exit 3 - fi - source $config -} - -start() -{ - echo -n $"Starting $prog: " - - load_config_file - load_mlx4_uio_module - bind_mlx4_uio_module - set_non_numa_pages - - return 0 -} - -stop() -{ - echo -n $"Stopping $prog: " - load_config_file - clear_huge_pages - unbind_mlx4_uio_module - remove_mlx4_uio_module - - return 0 -} - -restart() { - stop - start -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - *) - echo $"Usage: $0 {start|stop|restart}" - RETVAL=2 -esac -exit $RETVAL +#!/bin/bash
+#
+# dpdk-kernel Start up the DPDK configuration and insert kernel model
+#
+### END INIT INFO
+
+prog=dpdk_mlx4
+config=/etc/mlx4.conf
+
+load_mlx4_core_module()
+{
+ /sbin/insmod /lib/modules/$(uname -r)/kernel/drivers/net/mlx4/mlx4_core.ko
+ /sbin/insmod /lib/modules/$(uname -r)/kernel/drivers/net/mlx4/mlx4_en.ko
+}
+
+remove_mlx4_uio_module()
+{
+ echo "Unloading any existing DPDK UIO module"
+ /sbin/lsmod | grep -s mlx4_uio > /dev/null
+ if [ $? -eq 0 ] ; then
+ sudo /sbin/rmmod mlx4_uio
+ fi
+}
+
+remove_mlx4_en_module()
+{
+ echo "Unloading any existing MLX4 EN module"
+ /sbin/lsmod | grep -s mlx4_en > /dev/null
+ if [ $? -eq 0 ] ; then
+ sudo /sbin/rmmod mlx4_en
+ fi
+}
+
+remove_mlx4_core_module()
+{
+ echo "Unloading any existing MLX4 CORE module"
+ /sbin/lsmod | grep -s mlx4_core > /dev/null
+ if [ $? -eq 0 ] ; then
+ sudo /sbin/rmmod mlx4_core
+ fi
+}
+
+load_mlx4_uio_module()
+{
+ if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/mlx4_uio.ko ];then
+ echo "## ERROR: Target does not have the DPDK UIO Kernel Module."
+ echo " To fix, please try to rebuild target."
+ return
+ fi
+
+ remove_mlx4_uio_module
+
+ /sbin/lsmod | grep -s uio > /dev/null
+ if [ $? -ne 0 ] ; then
+ if [ -f /lib/modules/$(uname -r)/kernel/drivers/uio/uio.ko ] ; then
+ echo "Loading uio module"
+ sudo /sbin/modprobe uio
+ fi
+ fi
+
+ # UIO may be compiled into kernel, so it may not be an error if it can't
+ # be loaded.
+
+ echo "Loading DPDK UIO module"
+ sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/mlx4_uio.ko intr_mode="msix"
+ if [ $? -ne 0 ] ; then
+ echo "## ERROR: Could not load kmod/mlx4_uio.ko."
+ quit
+ fi
+}
+
+bind_mlx4_uio_module()
+{
+ oldIFS=$IFS
+ IFS=,
+ for PCI_PATH in $MLX4_UIO; do
+ sudo ${RTE_SDK}/tools/pci_unbind.py -b mlx4_uio $PCI_PATH
+ done
+ IFS=$oldIFS
+}
+
+unbind_mlx4_uio_module()
+{
+ oldIFS=$IFS
+ IFS=,
+
+ for PCI_PATH in $MLX4_UIO; do
+ sudo ${RTE_SDK}/tools/pci_unbind.py -b mlx4_core $PCI_PATH
+ done
+ IFS=$oldIFS
+}
+
+
+remove_mnt_huge()
+{
+ echo "Unmounting /mnt/huge and removing directory"
+ grep -s '/mnt/huge' /proc/mounts > /dev/null
+ if [ $? -eq 0 ] ; then
+ sudo umount /mnt/huge
+ fi
+
+ if [ -d /mnt/huge ] ; then
+ sudo rm -R /mnt/huge
+ fi
+}
+
+create_mnt_huge()
+{
+ echo "Creating /mnt/huge and mounting as hugetlbfs"
+ sudo mkdir -p /mnt/huge
+
+ grep -s '/mnt/huge' /proc/mounts > /dev/null
+ if [ $? -ne 0 ] ; then
+ sudo mount -t hugetlbfs nodev /mnt/huge
+ fi
+}
+
+clear_huge_pages()
+{
+ echo > .echo_tmp
+ for d in /sys/devices/system/node/node? ; do
+ echo "echo 0 > $d/hugepages/hugepages-2048kB/nr_hugepages" >> .echo_tmp
+ done
+ echo "Removing currently reserved hugepages"
+ sudo sh .echo_tmp
+ rm -f .echo_tmp
+
+ remove_mnt_huge
+}
+
+#
+# Creates hugepages.
+#
+set_non_numa_pages()
+{
+ clear_huge_pages
+
+ echo "echo $HUGEPAGE_MEM > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" > .echo_tmp
+ echo "Reserving hugepages"
+ sudo sh .echo_tmp
+ rm -f .echo_tmp
+ create_mnt_huge
+}
+
+load_config_file()
+{
+ if [ ! -f $config ] ; then
+ echo "Loading Configure file $config error"
+ exit 3
+ fi
+ source $config
+}
+
+start()
+{
+ echo -n $"Starting $prog: "
+
+ load_config_file
+ load_mlx4_uio_module
+ bind_mlx4_uio_module
+ set_non_numa_pages
+
+ return 0
+}
+
+stop()
+{
+ echo -n $"Stopping $prog: "
+ load_config_file
+ clear_huge_pages
+ unbind_mlx4_uio_module
+ remove_mlx4_uio_module
+
+ return 0
+}
+
+restart() {
+ stop
+ start
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart}"
+ RETVAL=2
+esac
+exit $RETVAL
diff --git a/tools/drv_monitor.sh b/tools/drv_monitor.sh index 728c877..e3731d8 100755..100644 --- a/tools/drv_monitor.sh +++ b/tools/drv_monitor.sh @@ -1,35 +1,35 @@ -#!/bin/sh - -sleep_period=1 -worker_proc_name="start" -driver_proc_name="driver" -log_path="./MONITOR.log" - -get_worker_proc_num() -{ - num=`ps -ef | grep $worker_proc_name | grep -v grep | wc -l` - return $num -} - -get_driver_proc_num() -{ - num=`ps -ef | grep $driver_proc_name | grep -v grep | wc -l` - return $num -} - -while true -do - sleep $sleep_period - - get_worker_proc_num - nb_worker=$? - get_driver_proc_num - nb_driver=$? - - if [ $nb_worker -ge 1 ] && [ $nb_driver -eq 0 ] - then - pid=$(ps -ef | grep $worker_proc_name | grep -v grep | awk '{print $2}') - kill $pid - fi -done - +#!/bin/sh
+
+sleep_period=1
+worker_proc_name="start"
+driver_proc_name="driver"
+log_path="./MONITOR.log"
+
+get_worker_proc_num()
+{
+ num=`ps -ef | grep $worker_proc_name | grep -v grep | wc -l`
+ return $num
+}
+
+get_driver_proc_num()
+{
+ num=`ps -ef | grep $driver_proc_name | grep -v grep | wc -l`
+ return $num
+}
+
+while true
+do
+ sleep $sleep_period
+
+ get_worker_proc_num
+ nb_worker=$?
+ get_driver_proc_num
+ nb_driver=$?
+
+ if [ $nb_worker -ge 1 ] && [ $nb_driver -eq 0 ]
+ then
+ pid=$(ps -ef | grep $worker_proc_name | grep -v grep | awk '{print $2}')
+ kill $pid
+ fi
+done
+
diff --git a/tools/drv_start.sh b/tools/drv_start.sh index 723118a..7aed836 100755..100644 --- a/tools/drv_start.sh +++ b/tools/drv_start.sh @@ -1,28 +1,28 @@ -#!/bin/sh - -DRV_PROG=./driver -DRV_MONITOR=./drv_monitor.sh - -sh $DRV_MONITOR & - -while [ 1 ]; do - count=`ls -l core.* |wc -l` - echo $count - if [ $count -lt 6 ] - then - echo "set unlimited" - ulimit -c unlimited - else - ulimit -c 0 - fi - - $DRV_PROG - -# ./start >> start.`date +"%Y-%m-%d_%H-%M"`.log - echo $DRV_PROG crashed, restart at `date +"%w %Y/%m/%d, %H:%M:%S"` >> RESTART.log - sleep 5 -done - -#./start -#echo program crashed, reboot at `date +"%w %Y/%m/%d, %H:%M:%S"` >> REBOOT.log -#reboot +#!/bin/sh
+
+DRV_PROG=./driver
+DRV_MONITOR=./drv_monitor.sh
+
+sh $DRV_MONITOR &
+
+while [ 1 ]; do
+ count=`ls -l core.* |wc -l`
+ echo $count
+ if [ $count -lt 6 ]
+ then
+ echo "set unlimited"
+ ulimit -c unlimited
+ else
+ ulimit -c 0
+ fi
+
+ $DRV_PROG
+
+# ./start >> start.`date +"%Y-%m-%d_%H-%M"`.log
+ echo $DRV_PROG crashed, restart at `date +"%w %Y/%m/%d, %H:%M:%S"` >> RESTART.log
+ sleep 5
+done
+
+#./start
+#echo program crashed, reboot at `date +"%w %Y/%m/%d, %H:%M:%S"` >> REBOOT.log
+#reboot
diff --git a/tools/r2_driver.sh b/tools/r2_driver.sh index 19c8089..9c3df42 100755..100644 --- a/tools/r2_driver.sh +++ b/tools/r2_driver.sh @@ -1 +1 @@ -./drv_start.sh &> /dev/null & +./drv_start.sh &> /dev/null &
|
