I need some technical help, for the reason that I am not a programmer and I never have. I guess that I never am going to be one, since I lack the talent of doing numerical math (I possibly have dyscalculia).
I problem is this, I run a internal counter on my local server. This counter helps me by telling me the total number of earthquakes during the day, week, month and a year in Iceland, it is really useful when large earthquake swarm takes place.
I used Gentoo Linux on my server, but I have now moved over to FreeBSD for technical and practical reasons. The move to FreeBSD did work as I expected, with the exception of this counter, it does not work in FreeBSD, I do not get any reading to mrtg (the counter software). The script I have been testing work when run from command line, but when I run the cron job on them. Nothing more happens and no data is handed over to mrtg.
Here are the scripts,
#!/usr/local/bin/bash
#earthquake count shell V0.0.6
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
This script does not give me any error, but no data is handed over to mrtg as it did in Gentoo Linux. I do not know why that it and I have been unable to resolve this issue.
The second script I was testing is this one here, more details and discussions can be found here on FreeBSD forum.
#!/usr/local/bin/bash
#earthquake count shell V0.0.7
URL=”http://hraun.vedur.is/ja/englishweb/eqlist.html”
TODAY=`date +%Y-%m-%d`
HOURS=`date +%H`
MINUTES=`date +%M`
OUT=”$TODAY.txt”NOW=`echo “($HOURS * 60) + $MINUTES” | bc`
EARTHNUM=`wget –quiet -O – $URL | grep $TODAY | grep -vci updated`if [ $OUT ]; then
touch $OUT
fiecho “$NOW $EARTHNUM” >> $OUT
exit 0
When run in mrtg, I get this error here. The script runs without a issue when run it from command line.
2013-05-20 22:46:09: WARNING: Could not get any data from external command ‘/usr/local/etc/mrtg/eq.imo.sh’
Maybe the external command did not even start. (Illegal seek)2013-05-20 22:46:09: WARNING: Problem with External get ‘/usr/local/etc/mrtg/eq.imo.sh’:
Expected a Number for ‘in’ but nothing’2013-05-20 22:46:09: WARNING: Problem with External get ‘/usr/local/etc/mrtg/eq.imo.sh’:
Expected a Number for ‘out’ but nothing’2013-05-20 22:46:09: ERROR: Target[localhost_eq][_IN_] ‘ $target->[0]{$mode} ‘ did not eval into defined data
2013-05-20 22:46:09: ERROR: Target[localhost_eq][_OUT_] ‘ $target->[0]{$mode} ‘ did not eval into defined data
I am bit lost what is the issue here, since the script works from command line. If anyone out there has any idea what this might be. A help is most welcomed in this matter, since I am no programmer at all and I have little understanding on how to deal with this problem.