Hello all,
i have a simple shell-script, when i run the script as user cacti direct from the command line it works, but not when the poller runs the script.
Script:
FILE="/tmp/proxy"
proxy21=$(cat ${FILE} | /usr/bin/grep "10.x.x.x" | /usr/bin/grep "Masq" | /usr/bin/awk 'BEGIN {FS=" "} {print $5}'|tr -d '\012')
proxy22=$(cat ${FILE} | /usr/bin/grep "10.x.x.x" | /usr/bin/grep "Masq" | /usr/bin/awk 'BEGIN {FS=" "} {print $5}'|tr -d '\012')
proxy23=$(cat ${FILE} | /usr/bin/grep "10.x.x.x" | /usr/bin/grep "Masq" | /usr/bin/awk 'BEGIN {FS=" "} {print $5}'|tr -d '\012')
/usr/bin/printf "proxy21:%s proxy22:%s proxy23:%s" ${proxy21} ${proxy22} ${proxy23}
Output (Commandline) as user cacti:
proxy21:207 proxy22:217 proxy23:215
Output cacti log:
output: proxy21: proxy22: proxy23:
I can't find my mistake, can someone assist?
Thanks in advance
regards,
Porkenza
Simple shell-script doesnt work
Moderators: Developers, Moderators
Re: Simple shell-script doesnt work
Try to specify "cat" and "tr" with absolute pathname.
Re: Simple shell-script doesnt work
Same result, no data in cacti.
Re: Simple shell-script doesnt work
Then, try to investigate the results when your script was performed from cron, as like this.
Re: Simple shell-script doesnt work
ok, i had to add the following line to the script, then it works under cron:
#!/bin/bash
. /home/cacti/.profile
proxy21=$(/bin/cat /tmp/proxy | /usr/bin/grep "10.3.81.21" | /usr/bin/grep "Masq" | /usr/bin/awk 'BEGIN {FS=" "} {print $5}'|/usr/bin/tr -d '\012')
proxy22=$(/bin/cat /tmp/proxy | /usr/bin/grep "10.3.81.22" | /usr/bin/grep "Masq" | /usr/bin/awk 'BEGIN {FS=" "} {print $5}'|/usr/bin/tr -d '\012')
proxy23=$(/bin/cat /tmp/proxy | /usr/bin/grep "10.3.81.23" | /usr/bin/grep "Masq" | /usr/bin/awk 'BEGIN {FS=" "} {print $5}'|/usr/bin/tr -d '\012')
/usr/bin/printf "proxy21:%s proxy22:%s proxy23:%s" ${proxy21} ${proxy22} ${proxy23}
But the same result in the cacti log, no data.
#!/bin/bash
. /home/cacti/.profile
proxy21=$(/bin/cat /tmp/proxy | /usr/bin/grep "10.3.81.21" | /usr/bin/grep "Masq" | /usr/bin/awk 'BEGIN {FS=" "} {print $5}'|/usr/bin/tr -d '\012')
proxy22=$(/bin/cat /tmp/proxy | /usr/bin/grep "10.3.81.22" | /usr/bin/grep "Masq" | /usr/bin/awk 'BEGIN {FS=" "} {print $5}'|/usr/bin/tr -d '\012')
proxy23=$(/bin/cat /tmp/proxy | /usr/bin/grep "10.3.81.23" | /usr/bin/grep "Masq" | /usr/bin/awk 'BEGIN {FS=" "} {print $5}'|/usr/bin/tr -d '\012')
/usr/bin/printf "proxy21:%s proxy22:%s proxy23:%s" ${proxy21} ${proxy22} ${proxy23}
But the same result in the cacti log, no data.
Re: Simple shell-script doesnt work
Then, try:
1) System Utilities -> Rebuild Poller Cache
2) Delete the RRD file or/and Re-create the datasource (and graph)
1) System Utilities -> Rebuild Poller Cache
2) Delete the RRD file or/and Re-create the datasource (and graph)
Who is online
Users browsing this forum: No registered users and 2 guests