krom / zabbix_template_md

MD Soft RAID minitoring template for zabbix
GNU General Public License v3.0
57 stars 30 forks source link

I made some new items / triggers & graphs #11

Open notlebowski opened 4 years ago

notlebowski commented 4 years ago

I've been using your softraid.conf template for a while. Recently I had high read/write speeds on one of my servers and after investigating this I noticed that my RAID had been broken and it was syncing.

I noticed that none of the triggers were showing anything, so I decided to extend on your template. The things I wanted it to show was working.

image

Luckily I was able to finish writing it before the RAID was fully synced. This way I was able to test it in a real-world environment.

Although I have a Github-account, I'm totally not into collaborative projects. I was a programmer for years, but always worked alone although I did publish sources. This was long before Github and alike. Even before html.

Do you want to incorporate it for me? I will start by giving you the config in softraid.conf. The rest I will post after you tell me you want it.

UserParameter=md.completed[*], sudo cat /sys/block/$1/md/sync_completed | awk '/none/{print "100"; next} {print $$1 / $$3}'
UserParameter=md.syncspeed[*], sudo cat /sys/block/$1/md/sync_speed | sed 's/none/0/g'
notlebowski commented 4 years ago

Of course I needed to multiply by 100 and decided to do this in softraid.conf

UserParameter=md.completed[*], sudo cat /sys/block/$1/md/sync_completed | awk '/none/{print "100"; next} {print 100 * $$1 / $$3}'
UserParameter=md.syncspeed[*], sudo cat /sys/block/$1/md/sync_speed | sed 's/none/0/g'

image

notlebowski commented 4 years ago

Better even round it to 1 digit behind the decimal. I am unable to provide a screenshot, but I was able to test it using this command:

echo '5585476740 / 43754374546 ' | awk '/none/{print "100"; next} {printf ("%.1f\n", 100 * $1 / $3)}'
12.8

In softraid.conf this is:

UserParameter=md.completed[*], sudo cat /sys/block/$1/md/sync_completed | awk '/none/{print "100"; next} {printf ("%.1f\n", 100 * $$1 / $$3)}'
UserParameter=md.syncspeed[*], sudo cat /sys/block/$1/md/sync_speed | sed 's/none/0/g'
krom commented 4 years ago

Hi. I plan to add Busybox friendly version of userparameter_md.conf file so this will modify userparameter_md.conf and Readme.md.

About your collaboration.

In an ideal world, you can create a fork, modify, and create PR of your changes to my repo.

In a real word, I use Makefile for converting templates to another version and zip archives with distributives. But, you may change template_md_4.0.xml and userparameter_md.conf And after your PR I will update all files and create a new release.

Another thing: as I see, you use sudo, this is not safe by default because there is needed additional configuration os OS.

Your product should work everywhere because if you use sudo or something else many users will create issues with the title: "this configuration does not work for me"

notlebowski commented 4 years ago

Sorry for the late reaction. I read your post at a moment I had no time and forgot about it later on. If you need more data, please let me know.

Don't forget to return discovery time to 1h (I set it to 2m while testing)

@krom

I have attached MD.softraid.xml which I renamed to MD.softraid.xml.zip so it could be uploaded to Github MD.softraid.xml.zip

It should work with your softraid.conf with these added lines.

UserParameter=md.completed[*], sudo cat /sys/block/$1/md/sync_completed | awk '/none/{print "100"; next} {printf ("%.1f\n", 100 * $$1 / $$3)}'
UserParameter=md.syncspeed[*], sudo cat /sys/block/$1/md/sync_speed | sed 's/none/0/g'
notlebowski commented 4 years ago

A while ago 2 Linux servers warned me that my RAID was resyncing. After troubleshooting I found out that it was merely doing a monthly check. I changed my RAID-template to see the difference between a real RAID-resync and merely a check.

I forgot that I posted my template here. So if you want to implement this as well in your template, you're welcome!!

zbx_export_templates.xml.txt

cat softraid.conf

UserParameter=md.discover,ls /sys/class/block | sudo awk 'BEGIN{printf "{\"data\":["}; /md/ {printf c"{\"{#MDNAME}\":\""$1"\"}";c=","}; END{print "]}"}'
UserParameter=md.degraded[*], sudo cat /sys/block/$1/md/degraded
UserParameter=md.completed[*], sudo cat /sys/block/$1/md/sync_completed | awk '/none/{print "100"; next} {printf ("%.1f\n", 100 * $$1 / $$3)}'
UserParameter=md.syncspeed[*], sudo cat /sys/block/$1/md/sync_speed | sed 's/none/0/g'
UserParameter=md.sync_action[*], sudo cat /sys/block/$1/md/sync_action
UserParameter=md.raid_disks[*], sudo cat /sys/block/$1/md/raid_disks