Sunday, 11 January 2015

Linux LVM IOPs Calculation and Zabbix Template for RHEL/CentOS



Step 1# Create a Script to take IOPs for Linux LVM's and Pass it into Zabbix

vim /root/scripts/iostat.sh
#!/bin/bash
/usr/sbin/lvdisplay  | grep "LV Name" | awk '{print $3}' | awk -F/ '{print $3"-"$4}' > /tmp/lvm.txt
iostat -mN > /tmp/iostat.txt
for lvm in `cat /tmp/lvm.txt`
do
val=`grep "$lvm" /tmp/iostat.txt | awk '{print $4}'`
echo `hostname` "$lvm $val" |  /usr/local/bin/zabbix_sender -z zabbix_server_fqdn -c /usr/local/etc/zabbix_agentd.conf -i -
done


:wq!

Example Result for above Script without passing into zabbix:

server_hostname VolGroup00-LogVol01 0.00server_hostname VolGroup00-LogVol00 0.03server_hostname ARCHIVE-dataarchive 0.00server_hostname MysqlDB-mysqldb 4.44server_hostname BACKUP-BACKUPDATA 0.04 
Note: Here: iostat -mN == will provide the Writes Per Sec in MB

Step 2# Create a Host Group as "IOPS"

Step 3# Create a Template in Zabbix based on the LVM's Name get from iostat.sh script

##Note : Append the item Name & key based on the iostat.sh script output in below xml file






##Copy the below lines as Template.xml and import into Zabbix Under Configuration-->Templates-->Import



<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>2.0</version>
    <date>2015-01-11T13:40:37Z</date>
    <groups>
        <group>
            <name>IPOS</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Templates_IOPS_ServerName</template>
            <name>Templates_IOPS_ServerName</name>
            <groups>
                <group>
                    <name>IPOS</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>IOPS</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>ARCHIVE-dataarchive_Writes_Per_Second_in_MB</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>ARCHIVE-dataarchive</key>
                    <delay>0</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>IOPS</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>BACKUP-BACKUPDATA_Writes_Per_Second_in_MB</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>BACKUP-BACKUPDATA</key>
                    <delay>0</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>IOPS</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>MysqlDB-mysqldb_Writes_Per_Second_in_MB</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>MysqlDB-mysqldb</key>
                    <delay>0</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>IOPS</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>VolGroup00-LogVol00_Writes_Per_Second_in_MB</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>VolGroup00-LogVol00</key>
                    <delay>0</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>IOPS</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>VolGroup00-LogVol01_Writes_Per_Second_in_MB</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>VolGroup00-LogVol01</key>
                    <delay>0</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>IOPS</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
            </items>
            <discovery_rules/>
            <macros/>
            <templates/>
            <screens/>
        </template>
    </templates>
    <triggers>
        <trigger>
            <expression>{Templates_IOPS_ServerName:VolGroup00-LogVol00.last(0)}=0</expression>
            <name>{HOSTNAME} IOPS Increased for LVM NRTDATA-nrtdata</name>
            <url/>
            <status>1</status>
            <priority>5</priority>
            <description>IOPS Increased for LVM NRTDATA-nrtdata</description>
            <type>1</type>
            <dependencies/>
        </trigger>
    </triggers>
</zabbix_export>
 


Step 4# Schedule the script to crontab like below

*/1 * * * * /bin/bash /root/scripts/iostat.sh 1>/dev/null 2>&1

Step 5# Add the Above created Template into corresponding Server

Step 6# Check at Latestdata there IOPS  will present.

No comments:

Post a Comment