Created
June 11, 2014 02:03
-
-
Save fujiwara/68dd604a362243c57d08 to your computer and use it in GitHub Desktop.
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
$ zabbix_get_eval.sh system.uname agent.version '[[ $1 =~ "foo" || $2 =~ ^1\.8 ]]' |
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 | |
VALUES=() | |
# 最後の引数を除いた引数をループして zabbix_get した値を配列に入れる | |
for KEY in "${@:0:($#)}" | |
do | |
V=`zabbix_get -k "${KEY}"` | |
VALUES=("${VALUES[@]}" "${V}") | |
done | |
# 最後の引数は評価式 | |
EXPR="${!#}" | |
# 評価式に値を渡して評価 | |
bash -c "${EXPR}" -- "${VALUES[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment