Last active
December 27, 2022 13:45
-
-
Save twentythousandphantoms/b6d493225b44ad4bcfc8b660d4682bd0 to your computer and use it in GitHub Desktop.
A bash script for open files or running tasks monitoring. Can be used with Zabbix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while getopts ":tfp:" optname; do | |
case "$optname" in | |
"f") | |
# Количество открытых файлов | |
MONITORING_TYPE=0 | |
;; | |
"t") | |
# Количество запущенных подзадач | |
MONITORING_TYPE=1 | |
;; | |
"p") | |
# PID-процесса | |
PID="$OPTARG" | |
;; | |
*) | |
echo "ERROR: Unknown options" | |
;; | |
esac | |
done | |
case "$MONITORING_TYPE" in | |
"0") | |
ls -1 /proc/${PID}/fd | wc -l | |
;; | |
"1") | |
ls -1 /proc/${PID}/task | wc -l | |
;; | |
*) | |
echo "ERROR: Unkown MONITORING_TYPE" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment