Hi Zabbix Expert,
I'm currently develop some script to get some value with "bash scripting"
My script is like below :
#!/bin/bash
##START OF SCRIPT
filenow=$(date --date="now" +"cpu_""%d%m%y-%H""00")
dir=/home/local/zabbixresearch/logreport/cpu
CPU_TEST()
{
echo "TEST_SERVER" >> $dir/$filenow.txt
app1_cpu=`zabbix_get -s 192.168.0.22 -k "system.cpu.util[,system,avg1]" | awk -F '.' '{print $1}'`
if [ $app1_cpu -lt 90 ];
then
echo "OK" >> $dir/$filenow.txt
elif [ $app1_cpu -gt 90 ];
then
echo "NOK" >> $dir/$filenow.txt
else
echo "NOT VALUE" >> $dir/$filenow.txt
fi
}
CPU_TEST
##ENDOFSCRIPT
when I running this from the screen it produce output like below :
[local@local cpu]$ /home/local/zabbixresearch/script/cpu.sh
It produce output like I expected in the .txt file
[local@local cpu]$ cat /home/local/zabbixresearch/logreport/cpu
TEST_SERVER
OK
But when I using crontab it always produce NOT VALUE.
[local@local cpu]$ cat /home/local/zabbixresearch/logreport/cpu
TEST_SERVER
NOT VALUE
I dont know why this is happen, is that because zabbix_get command cannot use by crontab or this is problem with some permission?
my crontab is like below (with user local):
[local@local cpu]$ crontab -l
0 */1 * * * /home/local/zabbixresearch/script/cpu.sh
Any ideas with it?
Regards,
Arif
I'm currently develop some script to get some value with "bash scripting"
My script is like below :
#!/bin/bash
##START OF SCRIPT
filenow=$(date --date="now" +"cpu_""%d%m%y-%H""00")
dir=/home/local/zabbixresearch/logreport/cpu
CPU_TEST()
{
echo "TEST_SERVER" >> $dir/$filenow.txt
app1_cpu=`zabbix_get -s 192.168.0.22 -k "system.cpu.util[,system,avg1]" | awk -F '.' '{print $1}'`
if [ $app1_cpu -lt 90 ];
then
echo "OK" >> $dir/$filenow.txt
elif [ $app1_cpu -gt 90 ];
then
echo "NOK" >> $dir/$filenow.txt
else
echo "NOT VALUE" >> $dir/$filenow.txt
fi
}
CPU_TEST
##ENDOFSCRIPT
when I running this from the screen it produce output like below :
[local@local cpu]$ /home/local/zabbixresearch/script/cpu.sh
It produce output like I expected in the .txt file
[local@local cpu]$ cat /home/local/zabbixresearch/logreport/cpu
TEST_SERVER
OK
But when I using crontab it always produce NOT VALUE.
[local@local cpu]$ cat /home/local/zabbixresearch/logreport/cpu
TEST_SERVER
NOT VALUE
I dont know why this is happen, is that because zabbix_get command cannot use by crontab or this is problem with some permission?
my crontab is like below (with user local):
[local@local cpu]$ crontab -l
0 */1 * * * /home/local/zabbixresearch/script/cpu.sh
Any ideas with it?
Regards,
Arif

Comment