diff options
author | Donghoon Shin <dhs.shin@samsung.com> | 2016-09-19 17:36:01 +0900 |
---|---|---|
committer | Donghoon Shin <dhs.shin@samsung.com> | 2016-09-19 17:36:01 +0900 |
commit | e8acd13cc87ea038ecd6103e4088ce3cf5d501d7 (patch) | |
tree | 4c7c8cc683a297463996aa286f2f7758e8691b8f /examples | |
parent | b95c2492274542bc4718a863f5d88f37a0a788ab (diff) | |
download | clewarecontrol-e8acd13cc87ea038ecd6103e4088ce3cf5d501d7.tar.gz clewarecontrol-e8acd13cc87ea038ecd6103e4088ce3cf5d501d7.tar.bz2 clewarecontrol-e8acd13cc87ea038ecd6103e4088ce3cf5d501d7.zip |
Update initial source codesHEADupstream/4.3submit/trunk/20201029.132130submit/trunk/20201029.114030submit/trunk/20200409.202020submit/trunk/20200409.200220submit/trunk/20200409.194520submit/trunk/20191101.102136submit/trunk/20191030.112603submit/trunk/20191017.233826submit/trunk/20191017.111201submit/trunk/20190927.012842submit/devel/20190730.075528submit/devel/20190730.074447accepted/tools/devbase/tools/legacy/20240424.050722accepted/tools/devbase/tools/legacy/20240423.040742accepted/tools/devbase/tools/legacy/20240422.110908accepted/tizen/devbase/tools/20190927.045004release-20160930masterdevelaccepted/tools_devbase_tools_legacyaccepted/tizen_devbase_tools
Change-Id: I59bac2188ffbfe5a2ad2d9dcb33847aabfaffe44
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Munin/cleware-munin.sh | 30 | ||||
-rwxr-xr-x | examples/Nagios/RCS/cleware_nagios_script,v | 40 | ||||
-rwxr-xr-x | examples/Nagios/cleware_nagios_script | 34 | ||||
-rw-r--r-- | examples/Nagios/nagios.txt | 42 | ||||
-rw-r--r-- | examples/Nagios/seealso.txt | 4 | ||||
-rwxr-xr-x | examples/RRD/add_measurement_to_rrd | 5 | ||||
-rwxr-xr-x | examples/RRD/draw_graph_from_rrd | 5 | ||||
-rwxr-xr-x | examples/RRD/make_rrd | 3 | ||||
-rw-r--r-- | examples/RRD/rrd.txt | 34 | ||||
-rwxr-xr-x | examples/Watchdog/clewarewatchdog | 34 | ||||
-rw-r--r-- | examples/Watchdog/watchdog.txt | 19 | ||||
-rw-r--r-- | examples/ampel/ampel.txt | 18 | ||||
-rwxr-xr-x | examples/ampel/script.sh | 6 |
13 files changed, 274 insertions, 0 deletions
diff --git a/examples/Munin/cleware-munin.sh b/examples/Munin/cleware-munin.sh new file mode 100644 index 0000000..13caae2 --- /dev/null +++ b/examples/Munin/cleware-munin.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# written by lars falk-petersen, dev@falk-petersen.no + +#clewarecontrol device id (this should be moved to separate config file) +ID=7778 + +case $1 in + config) + cat <<'EOM' +graph_title Temperature And Humidity +graph_vlabel C / % +graph_category sensors +temp.label Temperature +hum.label Humidity +graph_order temp hum +graph_args --base 1000 + +EOM + exit 0;; +esac + +clewarecontrol -ag > /dev/null 2>&1 + +echo -n "temp.value " +clewarecontrol -d $ID -b -rt + +echo -n "hum.value " +clewarecontrol -d $ID -b -rh + diff --git a/examples/Nagios/RCS/cleware_nagios_script,v b/examples/Nagios/RCS/cleware_nagios_script,v new file mode 100755 index 0000000..6f3ebee --- /dev/null +++ b/examples/Nagios/RCS/cleware_nagios_script,v @@ -0,0 +1,40 @@ +head 1.1; +access; +symbols; +locks + folkert:1.1; strict; +comment @# @; + + +1.1 +date 2010.06.10.19.16.47; author folkert; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@Initial revision +@ +text +@#!/bin/sh + +MEASURED_TEMPERATURE=`/usr/bin/clewarecontrol -rt 2> /dev/null | grep 'Temperature' | awk '{ print $2; }' | sed -e "s/^\([0-9]*\).*$/\1/g"` + +if [ $MEASURED_TEMPERATURE -gt $2 ] ; then + echo CRITICAL - temperature above $2 - $MEASURED_TEMPERATURE + exit 2 +fi + +if [ $MEASURED_TEMPERATURE -gt $1 ] ; then + echo WARNING - temperature above $1 - $MEASURED_TEMPERATURE + exit 1 +fi + +echo OK - temperature is $MEASURED_TEMPERATURE +exit 0 +@ diff --git a/examples/Nagios/cleware_nagios_script b/examples/Nagios/cleware_nagios_script new file mode 100755 index 0000000..812cce7 --- /dev/null +++ b/examples/Nagios/cleware_nagios_script @@ -0,0 +1,34 @@ +#!/bin/sh + +if [ -z "$1" -o -z "$2" ] ; then + echo "CRITICAL - Parameter(s) missing (Warning Critical)." + exit 2 +fi + +PARAM1=`echo $1 | tr -c -d [:digit:]` +PARAM2=`echo $2 | tr -c -d [:digit:]` + +if [ "$1" != "$PARAM1" -o "$2" != "$PARAM2" ] ; then + echo "CRITICAL - invalid parameter(s), only integers allowed." + exit 2 +fi + +MEASURED_TEMPERATURE=`/usr/bin/clewarecontrol -rt 2> /dev/null | grep 'Temperature' | awk '{ print $2; }'` + +NAGIOS_TEMPERATURE=`echo $MEASURED_TEMPERATURE | sed -e "s/^\([0-9]*\).*$/\1/g"` +if [ -z "$NAGIOS_TEMPERATURE" ] ; then + echo CRITICAL - invalid temperature $MEASURED_TEMPERATURE + exit 2 +fi +if [ $NAGIOS_TEMPERATURE -gt $2 ] ; then + echo CRITICAL - temperature above $2 - $MEASURED_TEMPERATURE + exit 2 +fi + +if [ $NAGIOS_TEMPERATURE -gt $1 ] ; then + echo WARNING - temperature above $1 - $MEASURED_TEMPERATURE + exit 1 +fi + +echo OK - temperature is $MEASURED_TEMPERATURE +exit 0 diff --git a/examples/Nagios/nagios.txt b/examples/Nagios/nagios.txt new file mode 100644 index 0000000..8f8dfe5 --- /dev/null +++ b/examples/Nagios/nagios.txt @@ -0,0 +1,42 @@ +Monitoring temperature with Nagios +---------------------------------- + +Files: + - nagios.txt + - cleware_nagios_script + +1. copy cleware_nagios_script to the libexec directory of nagios + +2. add the following to the nagios configuration file + (checkcommands.cfg): + + define command{ + command_name check_cleware_temperature + command_line $USER1$/cleware_nagios_script $ARG1$ $ARG2$ + } + +3. now define a check: + + define service { + use generic-service + is_volatile 0 + check_period 24x7 + max_check_attempts 3 + normal_check_interval 5 + retry_check_interval 1 + contact_groups CONTACTGROUP + notification_interval 240 + notification_period 24x7 + notification_options c,r + host_name HOSTNAME + service_description check temperature using Cleware sensor + check_command check_cleware_temperature!WARN!CRIT + } + +4. of course you need to replace 'CONTACTGROUP' and 'HOSTNAME' with + the appropriate settings. also 'WARN' and 'CRIT' must be + replaced with the warning and critical temperatures + + +For any question related to Cleware devices under Linux, feel free to +contact me at the following e-mail address: folkert@vanheusden.com diff --git a/examples/Nagios/seealso.txt b/examples/Nagios/seealso.txt new file mode 100644 index 0000000..ad67ec7 --- /dev/null +++ b/examples/Nagios/seealso.txt @@ -0,0 +1,4 @@ +Please also check: +http://www.vanheusden.com/nagamp/ + +That tool shows the current Nagios status using the Cleware 'ample' (trafficlight) device. diff --git a/examples/RRD/add_measurement_to_rrd b/examples/RRD/add_measurement_to_rrd new file mode 100755 index 0000000..c261043 --- /dev/null +++ b/examples/RRD/add_measurement_to_rrd @@ -0,0 +1,5 @@ +#!/bin/sh + +MEASURED_TEMPERATURE=`clewarecontrol -rt 2> /dev/null | grep 'Temperature' | awk '{ print $2; }'` + +rrdtool update cleware_data.rrd N:$MEASURED_TEMPERATURE diff --git a/examples/RRD/draw_graph_from_rrd b/examples/RRD/draw_graph_from_rrd new file mode 100755 index 0000000..64cba57 --- /dev/null +++ b/examples/RRD/draw_graph_from_rrd @@ -0,0 +1,5 @@ +#!/bin/sh + +rrdtool graph graph.png -a PNG \ + DEF:temp=cleware_data.rrd:temperature:AVERAGE \ + LINE1:temp#FF0000:"temperatures" diff --git a/examples/RRD/make_rrd b/examples/RRD/make_rrd new file mode 100755 index 0000000..ef244c3 --- /dev/null +++ b/examples/RRD/make_rrd @@ -0,0 +1,3 @@ +#!/bin/sh + +rrdtool create cleware_data.rrd DS:temperature:GAUGE:300:U:U RRA:AVERAGE:0:1:105192 diff --git a/examples/RRD/rrd.txt b/examples/RRD/rrd.txt new file mode 100644 index 0000000..5e30e31 --- /dev/null +++ b/examples/RRD/rrd.txt @@ -0,0 +1,34 @@ +Creating temperature graphs +--------------------------- + +Files: + - rrd.txt + - make_rrdr + - add_measurement_to_rrd + - draw_graph_from_rrd + +1. First one executes the 'make_rrd' script (ONCE!) to initialize the + database in which measurements are stored. + +2. Then, from cron for example one executes every 5 minutes the + 'add_measurement_to_rrd' script. Make sure 'clewarecontrol' is in + the path. + +3. Every time you would like to have the graphs updated (e.g. you want + to see what was measured), invoke the draw_graph_from_rrd script. + +4. After invoking the draw-script, you'll find a 'graph.png'-file in + the current directory which can be viewed with your favorite + picture viewer. + + +These scripts can be easily adapted to measure humidity as well. This +is left to an excercise for the reader. +One hint for the humidity sensor: when the power went off of the +humidity sensor one needs to start it first before the sensor will +start measuring. Use 'clewarecontrol -ag' for that. + + + +For any question related to Cleware devices under Linux, feel free to +contact me at the following e-mail address: folkert@vanheusden.com diff --git a/examples/Watchdog/clewarewatchdog b/examples/Watchdog/clewarewatchdog new file mode 100755 index 0000000..c7bc3b4 --- /dev/null +++ b/examples/Watchdog/clewarewatchdog @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Startup script for program +# +# chkconfig: 12345 1 1 - This statement tells the chkconfig command how to add or delete this process to the boot process +# description: Starts the process which pads the Cleware watchdog. +# processname: clewarecontrol + +# Source function library. This creates the operating environment for the process to be started +. /etc/rc.d/init.d/functions + +case "$1" in + start) + echo -n "Starting Cleware watchdog " + /usr/bin/clewarecontrol -w + echo + touch /var/lock/subsys/clewarecontrol + ;; + stop) + echo -n "Shutting down Cleware watchdog: " + killproc clewarecontrol + echo + rm -f /var/lock/subsys/clewarecontrol + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit 0 diff --git a/examples/Watchdog/watchdog.txt b/examples/Watchdog/watchdog.txt new file mode 100644 index 0000000..f33d560 --- /dev/null +++ b/examples/Watchdog/watchdog.txt @@ -0,0 +1,19 @@ +Watchdog +-------- + +files: + - watchdog.txt + - clewarewatchdog + +1. copy clewarewatchdog to /etc/init.d + +2. enable the watchdog: + RedHat/SuSE: chkconfig --level 12345 clewarewatchdog on + Debian/Ubuntu: update-rc.d clewarewatchdog start 1 1 2 3 4 5 . stop 99 1 2 3 4 5 . + +3. physically install the watchdog, of course one needs + to reboot the computer to accomplish this + + +For any question related to Cleware devices under Linux, feel free to +contact me at the following e-mail address: folkert@vanheusden.com diff --git a/examples/ampel/ampel.txt b/examples/ampel/ampel.txt new file mode 100644 index 0000000..ea89f33 --- /dev/null +++ b/examples/ampel/ampel.txt @@ -0,0 +1,18 @@ +Blinkin' lights +--------------- + +Files: + - ampel.txt + - script.sh + +1. Run 'script.sh': + either: + ./script.sh + or: + sh script.sh + +4. Enjoy the lights! + + +For any question related to Cleware devices under Linux, feel free to +contact me at the following e-mail address: folkert@vanheusden.com diff --git a/examples/ampel/script.sh b/examples/ampel/script.sh new file mode 100755 index 0000000..ffa12e6 --- /dev/null +++ b/examples/ampel/script.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +while [ 1 ] +do + clewarecontrol -as `perl -e 'print rand(3); '` `perl -e 'print rand(2); '` +done |