Rodolfo Alonso Hernandez | d1c2bf5 | 2022-11-02 16:43:41 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | set -o errexit |
| 16 | |
| 17 | # time to sleep between checks |
| 18 | SLEEP_TIME=20 |
| 19 | |
| 20 | function tracker { |
| 21 | echo "Number of open files | Number of open files not in use | Maximum number of files allowed to be opened" |
| 22 | while true; do |
| 23 | cat /proc/sys/fs/file-nr |
| 24 | sleep $SLEEP_TIME |
| 25 | done |
| 26 | } |
| 27 | |
| 28 | function usage { |
| 29 | echo "Usage: $0 [-x] [-s N]" 1>&2 |
| 30 | exit 1 |
| 31 | } |
| 32 | |
| 33 | while getopts ":s:x" opt; do |
| 34 | case $opt in |
| 35 | s) |
| 36 | SLEEP_TIME=$OPTARG |
| 37 | ;; |
| 38 | x) |
| 39 | set -o xtrace |
| 40 | ;; |
| 41 | *) |
| 42 | usage |
| 43 | ;; |
| 44 | esac |
| 45 | done |
| 46 | |
| 47 | tracker |