It is clear that my script to count earthquakes are not working with cron. So I need new scripts to do the job, I am sadly not a programmer (or really bad one at best).
The problem is that mrtg is showing zero value when I run the script in cron. The script, when run manual shows current number, here is the script in question.
When I run the script manually, I get this data from it.
When I run it with cron, I get the result shown in the image attachment. Here is also the config file for mrtg.
I was thinking it would be a good idea to get the data into a simple text file, rather then to have mrtg read it from the shell, as that might be the actual problem. I am however not sure on that detail.
Thanks for the help.
The problem is that mrtg is showing zero value when I run the script in cron. The script, when run manual shows current number, here is the script in question.
Code:
#!/bin/sh
#earthquake count shell V0.0.3
URL="http://hraun.vedur.is/ja/englishweb/eqlist.html"
TODAYSDATE=`date +%Y-%m-%d`
#TODAYSDATE=`date +%Y/%m/%d`
#TODAYSDATE=`date +%Y-%m-%d`
COUNT=`lynx -dump ${URL} | grep ${TODAYSDATE} | grep -vi updated | wc -l`
#COUNT=`wget -O ${URL} | grep ${TODAYSDATE} | grep -vi updated | wc -l`
echo ${COUNT}
echo ${COUNT}
#echo ${COUNT}
#echo "uptime"
#echo "hostname"
exit 0
When I run the script manually, I get this data from it.
Code:
./eq.imo.sh
320
320
When I run it with cron, I get the result shown in the image attachment. Here is also the config file for mrtg.
Code:
#---------Apache hits-----------------------
WorkDir: /usr/local/www/apache24/data/mrtg/
Target[localhost_eq]: `/usr/local/etc/mrtg/eq.imo.sh`
Options[localhost_eq]: gauge, integer ,perminute, nopercent, growright, noinfo
MaxBytes[localhost_eq]: 100000
YLegend[localhost_eq]: count
#Colours[localhost_eq]: GREEN#458B00
ShortLegend[localhost_eq]: quakes
LegendO[localhost_eq]: Earthquakes:
LegendI[localhost_eq]: Earthquakes:
Legend2[localhost_eq]: Earthquakes pr hour
Legend4[localhost_eq]: Max number of earthquakes
Title[localhost_eq]: Number of earthquakes Iceland
WithPeak[localhost_eq]: wmy
PageTop[localhost_eq]: <h1>Earthquakes Iceland Automatic </h1>
#------------End Apache Hits------------------
I was thinking it would be a good idea to get the data into a simple text file, rather then to have mrtg read it from the shell, as that might be the actual problem. I am however not sure on that detail.
Thanks for the help.