summaryrefslogtreecommitdiffstats
path: root/contrib/check_joy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/check_joy.sh')
-rwxr-xr-xcontrib/check_joy.sh69
1 files changed, 69 insertions, 0 deletions
diff --git a/contrib/check_joy.sh b/contrib/check_joy.sh
new file mode 100755
index 0000000..cd076db
--- /dev/null
+++ b/contrib/check_joy.sh
@@ -0,0 +1,69 @@
1#! /bin/sh
2
3PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
4
5PROGNAME=`basename $0`
6PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
7REVISION=`echo '$Revision$' | sed -e 's/[^0-9.]//g'`
8STATUS=""
9
10. $PROGPATH/utils.sh
11
12
13print_usage() {
14 echo "Usage: $PROGNAME /dev/js<#> <button #>"
15}
16
17print_help() {
18 print_revision $PROGNAME $REVISION
19 echo ""
20 print_usage
21 echo ""
22 echo "This plugin checks a joystick button status using the "
23 echo "joyreadbutton utility from the joyd package."
24 echo ""
25 support
26 exit 0
27}
28
29if [ $# -ne 2 ]; then
30 print_usage
31 exit 0
32fi
33
34case "$1" in
35 --help)
36 print_help
37 exit 0
38 ;;
39 -h)
40 print_help
41 exit 0
42 ;;
43 --version)
44 print_revision $PROGNAME $REVISION
45 exit 0
46 ;;
47 -V)
48 print_revision $PROGNAME $REVISION
49 exit 0
50 ;;
51 /dev/js*)
52 joyreadbutton $1 $2 1>&1 1>/dev/null
53 STATUS=$?
54 if [ "$STATUS" -eq 0 ]; then
55 echo OK
56 exit 0
57 elif [ "$STATUS" -eq 1 ];then
58 echo CRITICAL
59 exit 2
60 else
61 echo UNKNOWN
62 exit -1
63 fi
64 ;;
65 *)
66 print_usage
67 exit 0
68 ;;
69esac