lesovsky / zabbix-extensions

Zabbix additional monitoring modules
BSD 3-Clause "New" or "Revised" License
316 stars 230 forks source link

Update crontab #63

Closed vikingUnet closed 5 years ago

vikingUnet commented 5 years ago

No need to type "root" in crontab in modern linux systems. Cront task period is 1 minute, so if collect script will refresh in the same time, it can be strange behavior for next call (which value will be read by zabbix agent - older or newer?). I recommend to set 55 secods period for collect script to avoid collisions. Name of output file is iostat-cron.out - for follow logic in iostat.conf (parameter iostat.collect is output in iostat-non-cron.out file). Optionality result of running cron task may be redirected in dev/null for avoid root user reciving mails every minute (this option may use only after make sure, that scron task is correct and executing every minute).

stephankn commented 5 years ago

I am not using the iostat templates. The existing implementation seems overly expensive. Do you think it could be rewritten into sending back JSON and parsing that on Zabbix? Removes the need to do multiple calls and probably then also the need for the cronjob and the processing/collecting scripts. See my comments on #56

vikingUnet commented 5 years ago

Thanks for answer! I think it is not good idea for sending back JSON in deal with iostat. iostat utility need time to calculate difference between two last calls and if you call "iostat 60 2" you will pause for 60 seconds and only then recive statisitc, but zabbix maximum timeout is only 30 seconds. So cron task will pause by hisself for N seconds and write out calculated statistic in file. Another reason to use iostat in that way, as it exists in this template (not JSON), is ability to control many hard disk metrics. Example, i whant to control my /dev/sda disk partition for three metrics at one time - util, await and queue request size. For that i must add three zabbix items from this template: iostat.metric[sda,util], iostat.metric[sda,await], iostat.metric[sda,avgqu-sz]. If i will recive JSON value, i must process this JSON value at three times at each item post processing, whatever.

stephankn commented 5 years ago

How is this iostat typically used? Is it supposed to calculate averages? You can as well call it for a snapshot every minute and let zabbix do the average calculation. That would be only a quite small delay in runtime.

Reading metrics for more than a few seconds at most is quite a bad idea. I agree.

Has not mucht to do with returning the data as JSON. You would call it one time, then zabbix internally reads the value you want to plot, check out "internal items".

vikingUnet commented 5 years ago

iostat without arguments will print average statistic since os reboot, that is not useful. For get average statistic over 1 minute, we must call "iostat 60 2" that prints start state and average over last 60 seconds. Zabbix can't ask iostat to wait 60 seconds, because his maximum timeout limit is 30 seconds. Using cron task - is not my own idea, this ability was introuduced by lesovsy in repository file zabbix-extensions/files/iostat/crontab, i just edit this file to be litle more nisely and clearly. Thanks for point to JSON "internal items", i will try it and think about how to edit this template for support the opportunity.