PDA

View Full Version : UserParameters scripts with sar


saulosilva
06-06-2005, 16:25
Hi ,

I tried to use zabbix in a feels server to collect sysstat parameters using UserParameter object but after 1 hour the server stop collect the data .
The graph shows th no data found for this period . In any time tha I change the status in items page the data started collect again .

Some times in a 4 processor machine the continuos collect one of them and stop to collect others . And all scripts are likes .

So that the scripts :

ALL processors :
script name : cpu.idle_1min
#!/bin/sh
sar -u -h | grep idle | tail -n1 | cut -f 6

processor 0 :

#!/bin/sh
sar -P 0 -u -h | grep idle | tail -n1 | cut -f 6

For processor 1 :

#!/bin/sh
sar -P 1 -u -h | grep idle | tail -n1 | cut -f 6

the UserParameter section :

UserParameter=cpu[idle_1min],echo `/opt/zabbix/scripts/cpu.idle_1min`
UserParameter=cpu0[idle_1min],echo `/opt/zabbix/scripts/cpu0.idle_1min`
UserParameter=cpu1[idle_1min],echo `/opt/zabbix/scripts/cpu1.idle_1min`
UserParameter=cpu2[idle_1min],echo `/opt/zabbix/scripts/cpu2.idle_1min`
UserParameter=cpu3[idle_1min],echo `/opt/zabbix/scripts/cpu3.idle_1min`

Any help ???

cadbury
07-06-2005, 15:09
you can make directly in your Userparameter :

UserParameter=cpu[idle_1min],sar -u -h | grep idle | tail -n1 | cut -f 6

and for a specific cpu
UserParameter=cpu_idle ,/opt/zabbix/scripts/cpu.idle_1min
and in the script cpu.idle_1min :

#!/bin/sh
sar -P $1 -u -h | grep idle | tail -n1 | cut -f 6

and in your zabbix item, define it as cpu_idle[0], cpu_idle[1] ...
zabbix will give the number between "[ ]" as an argument to the script

but that will not fix your problem

when you run manually the command, does it fail sometimes? (after many tries for example)
and isn't the delay between two checks too short?

saulosilva
07-06-2005, 15:59
I don't thing that is problem with interval cause the zabbix is a server 2 processor with 3GHZ Intel .
But I change the collect time to 120 seconds in one client machine and 60 seconds in another . The both machine stops but in diferrents periods .
One of this problems is that the collect stop during the night . Are there some log that I can look at .

I will try to change the scripts , maybe help .

thanks for the help ,


Saulo Augusto Silva
RHCE
LPI-C

cadbury
10-06-2005, 11:49
perhaps try to write the result of the command in a log file in your script
something like this :

script name : cpu.idle_1min
#!/bin/sh
RET=`sar -u -h | grep idle | tail -n1 | cut -f 6`
echo `date` : RET >> /path/logfile
echo RET

if the script return no value (if RET is empty), zabbix_agentd return ZBX_NOTSUPPORTED, and then the item is disabled, so the values are no more retrieved
this can be a clue, but then why is RET empty sometimes?

saulosilva
10-06-2005, 14:08
It could be that , but some strange happens .
I make the scripts like you wrote before and start both than zabbix agents .
The old cpu.idle_1min and another cpu0.idle_1min .... and the new cpu_idle[0] , cpu_idle[1] scripts .

After to days started the new scripts stops to collect and the old one still collect after this period . I really can not understand whats happend .

Now I will stop the new items and look at whats happend with the old one . But now I will put the log file and see whats happend .


Thanks

Saulo Augusto Silva