I need help to do some calculation in script.
I have a monitor program (munin) that I would like to log uptime information from a server.
The script looks like this (not complete):
#!/bin/sh
# server_uptime
### Config Start
# Reads the server parameters using the HTTP port with correct username and password
user="root"
pass="password"
port="80"
server="192.168.1.20"
### Config End
url="http://$user:$pass@$server:$port"
case $1 in
config)
cat <<'EOM'
graph_title Server uptime
graph_vlabel days
graph_category System
uptime.label Server1
EOM
exit 0;;
esac
echo -n "uptime.value "
echo `wget -q -O - "$url" | grep Uptime`
Output from this is a long line. Start of it is omitted. End looks always the same.
*** <BR><BR>Current time 10:27:14<BR>NodeID: d3432<BR>Uptime: 22d 18:10:37
I can get 22 (days) and 18(hours) out from this but I like to see the output like this
uptime.value 22.75
So I need to calculate 22+18/24 Days+Hour/24
I have tried different solution with printf, but can not get it to calculate.