forked from fatyogi/epever-upower-tracer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathget_tracer.sh
executable file
·51 lines (44 loc) · 1.2 KB
/
get_tracer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Get Epever Tracer data from filesnap
######################################################
GREP=/usr/bin/grep
CAT=/usr/bin/cat
CUT=/usr/bin/cut
WC="/usr/bin/wc -l"
####
DUMP="/tmp/ep_tracer_$1.log"
######################################################
function show_usage {
echo "#######################################################"
echo "# Get Epever Tracer data from filesnap #"
echo "#######################################################"
echo ""
echo "Usage: ./get_tracer.sh <id> <check>"
echo ""
}
function show_error {
echo "#######################################################"
echo "# Get Epever Tracer data from filesnap #"
echo "#######################################################"
echo ""
echo $1
echo ""
}
if test "${1+set}" != set ; then
show_usage
exit -1
fi
if test "${2+set}" != set ; then
show_usage
exit -1
fi
if [ ! -f $DUMP ]; then
show_error "ERROR: $DUMP not found. Check the ID or logtracer.py (filesnap) never executed"
exit -1
fi
if [ `$CAT $DUMP | $GREP $2 | $CUT -d':' -f2 | $WC` == "0" ]; then
show_error "ERROR: Data not found. Verify the seeking check"
exit -1
fi
$CAT $DUMP | $GREP $2 | $CUT -d':' -f2
exit 0