Shunze ¾Ç¶é >¹q¸£¸ê°T¾Ç¨t >OpenNMS > ¡m¤Q¤@¡nLinux Resource Threshold «¢Åo¡AÁÙ¨S¦³µù¥U©ÎªÌµn¤J¡C½Ð§A[µù¥U|µn¤J]
« ¤W¤@½g¥DÃD ¤U¤@½g¥DÃD » Åã¥Ü¦¨¦C¦L¼Ò¦¡ | ¼W¥[¨ì§Úªº³Ì·R
µoªí·s¥DÃD µoªí¦^ÂÐ
§@ªÌ
¥DÃD
shunze
¤u¤Í§B§B


µù¥U¤é´Á: 2002 04
¨Ó¦Û: ¼é¦Á²×¤î¤§¦a
¤å³¹: 2380

shunze Â÷½u
¡m¤À¨É¡nLinux Resource Threshold¤Þ¥Î¦^ÂÐ ½s¿è/§R°£¤å³¹ ·j´M¥Ñ  µoªíªº¨ä¥L¤å³¹ ¦^³øµ¹ª©¥D IP ¦ì¸m ¦^¦¹­¶³Ì¤W¤è

Linux¦b±Ò¥ÎSNMP«á¡AResource Graphs¤w¥i±o¨ìCPU/Memory/Diskµ¥¬y¶q¹Ï¡C

CPU


Memory


Disk


Disk-inodes



¦Ó¨ä°Ñ·Óªº³]©w«h©w¸q¦bnetsnmp.xml¤¤¡A¸ô®|¦p¤U¡C

/usr/share/opennms/etc/datacollection/netsnmp.xml

##### CPU #####
<group name="ucd-loadavg" ifType="ignore">
    <mibObj oid=".1.3.6.1.4.1.2021.10.1.5" instance="1" alias="loadavg1" type="integer" />
    <mibObj oid=".1.3.6.1.4.1.2021.10.1.5" instance="2" alias="loadavg5" type="integer" />
    <mibObj oid=".1.3.6.1.4.1.2021.10.1.5" instance="3" alias="loadavg15" type="integer" />
</group>
##### Memory #####
<group name="ucd-memory" ifType="ignore">
    <!-- Total Swap Size configured for the host. -->
    <mibObj oid=".1.3.6.1.4.1.2021.4.3" instance="0" alias="memTotalSwap" type="integer" />
    <mibObj oid=".1.3.6.1.4.1.2021.4.4" instance="0" alias="memAvailSwap" type="integer" />
    <mibObj oid=".1.3.6.1.4.1.2021.4.5" instance="0" alias="memTotalReal" type="integer" />
    <mibObj oid=".1.3.6.1.4.1.2021.4.6" instance="0" alias="memAvailReal" type="integer" />
    <mibObj oid=".1.3.6.1.4.1.2021.4.11" instance="0" alias="memTotalFree" type="integer" />
    <mibObj oid=".1.3.6.1.4.1.2021.4.13" instance="0" alias="memShared" type="integer" />
    <mibObj oid=".1.3.6.1.4.1.2021.4.14" instance="0" alias="memBuffer" type="integer" />
    <mibObj oid=".1.3.6.1.4.1.2021.4.15" instance="0" alias="memCached" type="integer" />
    <!-- Error flag. 1 indicates very little swap space left -->
    <mibObj oid=".1.3.6.1.4.1.2021.4.100" instance="0" alias="memSwapError" type="integer" />
</group>
##### Disk #####
<group name="net-snmp-disk" ifType="all">
    <mibObj oid=".1.3.6.1.4.1.2021.9.1.2" instance="dskIndex" alias="ns-dskPath" type="string" />
    <mibObj oid=".1.3.6.1.4.1.2021.9.1.6" instance="dskIndex" alias="ns-dskTotal" type="gauge" />
    <mibObj oid=".1.3.6.1.4.1.2021.9.1.7" instance="dskIndex" alias="ns-dskAvail" type="gauge" />
    <mibObj oid=".1.3.6.1.4.1.2021.9.1.8" instance="dskIndex" alias="ns-dskUsed" type="gauge" />
    <mibObj oid=".1.3.6.1.4.1.2021.9.1.9" instance="dskIndex" alias="ns-dskPercent" type="gauge" />
</group>
<group name="net-snmp-disk-more" ifType="all">
    <mibObj oid=".1.3.6.1.4.1.2021.9.1.3" instance="dskIndex" alias="ns-dskDevice" type="string" />
    <mibObj oid=".1.3.6.1.4.1.2021.9.1.10" instance="dskIndex" alias="ns-dskPercentNode" type="gauge" />
</group>

¦³¤F³o¨Çoid©w¸q¡A¤S¯à¥H³o¨Ç¼Æ¾Úø»s¬y¶q¹Ï¡A
§Ú­Ì·íµM¤]¥i¥H¨Ï¥Î³o¨Ç¼Æ¾Ú¨Ó³]©w¬ÛÃöthresholdªº§iĵ¾÷¨î¡C

  • CPU
    CPUªº³¡¤À¦b¹w³]ªºthreshold group - netsnmp¤¤¡A¤w©w¸q¤F¤@²ÕCPU loading¹L°ªªºthreshold¡A¥iª½±µ®M¥Î©Î®³¨Ó°µ¬°½d¥»°Ñ¦Ò¡C



    ³o²Õthresholdªº¤º®e¬O¡A·í¨C5ÄÁªºCPU¨Ï¥Î²v¥­§¡­È(loadavg5)¡A³sÄò¨â¦¸³£¶W¹L10®É(high)¡A·|IJµo¨Æ¥ó¡F
    ·í­°¦^7.5®É¡A«h·|¨ú®ø¸Ó¨Æ¥ó¡C



    ±q³o¼Ëªº©w¸q§Ú­Ì¥i¥Hª¾¹D¦b³]©wCPU loadingªºthreshold®É¡A
    §Ú­Ì¥i¥H¨Ì»Ý¨D¿ï¥Î loadavg1 / loadavg5 / loadavg15 ¤T­Ó¼Æ­È¤§¤@¨Ó°µ¬°CPU loadingªº°Ñ¦Ò¼Æ­È¡C
    (³o¤T­Ó¼Æ¦r¤À§O¬O1¡A5¡A15¤ÀÄÁªºCPU loading¥­§¡­È¡C)

    ¦ÓDatasource Type«h­n¿ï¥Î node ³o­Ó«¬§O¡A³o¼Ë´N¥i¥H¨ÌCPUªºloading¨Ó³]©wthreshold¡C

  • Memory
    Memoryªº³¡¤À¸òCPU¤@¼Ë¡A¦b¹w³]ªºthreshold group - netsnmp¤¤¡A¤w©w¸q¤F¤@²ÕSWAP¥i¥Î²v¹L§Cªºthreshold¡C



    ³o²Õthresholdªº¤º®e¬O¡A·íSWAPªº¥i¥Î²v³sÄò¨â¦¸³£§C©ó10%®É¡A·|IJµo¨Æ¥ó¡F
    ·í¥i¥Î²v¦^¤É¨ì15%®É¡A«h·|¨ú®ø¸Ó¨Æ¥ó¡C



    ¨ä­pºâ¤½¦¡¦p¤U¡C
    memAvailSwap / memTotalSwap * 100.0

    ¦bDatasource Typeªº³¡¤À¸òCPU¤@¼Ë±Ä¥Î node ³o­Ó«¬§O¡C

    ¬Û¦P¹D²z¡A§Ú­Ì¥i¥H§â°»´ú¹ï¶H¥ÑSWAP§ï¬°¹êÅé°O¾ÐÅé(memTotalReal/memAvailReal)¡AµM«á¥h³]©w¹êÅé°O¾ÐÅé¨Ï¥Î²vªºthreshold¡C
    ¤£¹LLinuxªº°O¾ÐÅé°t¸m¸òWindows¤£¦P¡A¹w³]¬O¦³¦h¤Ö¡A´N±¾¸ü¦h¤Ö¡A¦A¤Àµ¹process¨Ï¥Î¡C
    ©Ò¥HºÊ´úLinuxªº¹êÅé°O¾ÐÅé¨Ï¥Î²v·N¸q¤£¤j¡C

  • Disk
    Diskªº³¡¤À¸òCPU/Memory¤@¼Ë¡A¦b¹w³]ªºthreshold group - netsnmp¤¤¡A¤w©w¸q¤F¨â²ÕµwºÐ¨Ï¥Î²v¹L°ªªºthreshold¡C



    ³o¨â²Õ¦³¤°»ò¤£¦P©O¡H
    ¤@­Ó¬O­pºâºÏºÐªÅ¶¡ªº ns-dskPercent¡A¥t¤@­Ó«h¬O­pºâ¨t²Îªºinode¼Æªº ns-dskPercentNode¡C
    ¤§©Ò¥H·|¦³³o¨âºØ»Ý¨D¡A¨º¬O¦]¬°¦bLinux¤W°£¤F­n¦Ò¶qºÏºÐªÅ¶¡block¥~¡AÁÙ­n¦Ò¶qinode¼Æ¡C


    ¡ô½Ð°Ñ¦Ò ³¾­ô¡ÐLinux ªº EXT2 Àɮרt²Î(inode)

    ³o¨â²Õthresholdªº³]©w´X¥G¤@¼Ò¤@¼Ë¡A¤@¼Ë³£¬O³sÄò¨â¦¸¨Ï¥Î²v¶W¹L90%¥Üĵ¡A§C©ó75%¸Ñ°£Äµ³ø¡F
    °ß¤@ªº®t§O¦b©ó Datasource Äæ¦ì¡C



    ·í§Ú­Ì­n°»´úµwºÐªÅ¶¡®É¡A¿ï¥Î ns-dskPercent¡F­Y­n°»´úinode¨Ï¥Î²v«h¿ï¥Î ns-dskPercentNode¡C

    ¦Ü©óDatasource type«h¨Ï¥Î Disk Table Index (UCD-SNMP MIB) ³o­Ó«¬§O¡A
    µM«á·f°tDatasource label¬° ns-dskPath ¨ÓÅã¥ÜºÏºÐ¤À³Î°Ï¦WºÙ¡ã

    ¬JµM¥i¥H³z¹L ns-dskPath ¨ÓÅã¥ÜºÏºÐ¤À³Î°Ï¡A
    ¨º·íµM¤]¥i¥H¥H¥¦°µ¬°¹LÂo±ø¥ó¡A¨Ó«ü©w­n°»´úªººÏºÐ¤À³Î°Ï¡C

    ¨Ò¦p§Ú­Ì¥u­n°»´ú/boot¤À³Î°Ïªº¨Ï¥Î²v¡A
    ¨º»ò¥i¥H¦bField Name¤¤¿é¤J ns-dskPath¡A¦bRegular Expression¤¤¿é¤J ^/boot$ °µ¬°¹LÂo±ø¥ó¡A
    «ö¤UAdd«ö¶s¡A¨ÃÀx¦s«á¡A´N¥i¥H¥u°w¹ï/boot¤À³Î°Ï¨Ó¶i¦æ°»´ú¤F¡ã




¥H¤W³]©w¡A³£¬O®³¨t²Î¹w³]ªºthreshold¨Ó°µ¥Ü½d¡A
§Ú­Ì¥i¥Hª½±µ­×§ï®M¥Î¡A©Î¥H¥¦¬°½d¥»¨Ó·s¼W¦Û¤v»Ý­nªºthreshold¡C
¦Ó³o¨Çthresholdªº¤º®e´N¦s©ñ¦b¥H¤U¸ô®|ªº thresholds.xml Àɮפ¤¡C
/usr/share/opennms/etc/thresholds.xml


¦bthresholds.xmlªº³]©w¤¤¡A§Ú­Ì¥u¯à®³¦PÄݤ@­Ógroupªºoid¨Ó°µ¹LÂo±ø¥ó¡A
¦p¤W¨Òdisk threshold¤¤¡A§Ú­Ì¥Hns-dskPath°µ¬°¹LÂo±ø¥ó¡C

­Y§Ú­Ì»Ý­n¥HIP¨Ó°µ¬°±ø¥ó¡A©Î¬O­×§ï¨C5¤ÀÄÁªº°»´ú¶¡¹j¡A
¥²»Ý³z¹L­×§ï¥t¤@­Ó³]©wÀÉ threshd-configuration.xml ¨Ó§¹¦¨¡C
/usr/share/opennms/etc/threshd-configuration.xml


threshd-configuration.xml »P thresholds.xml ³o¨â­Ó³]©wÀɬO¬Û¤¬©IÀ³ªº¡A¥H¸É©¼¦¹¤£¨¬¡C
Â^¨úthreshd-configuration.xml¤¤ netsnmp ªº³]©w¬°¨Ò
<package name="netsnmp">
    <filter>IPADDR != '0.0.0.0' & (nodeSysOID LIKE '.1.3.6.1.4.1.2021.%' | nodeSysOID LIKE '.1.3.6.1.4.1.8072.%')</filter>
    <include-range begin="1.1.1.1" end="254.254.254.254"/>
    <include-range begin="::1" end="ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" />

    <service name="SNMP" interval="300000" user-defined="false" status="on">
        <parameter key="thresholding-group" value="netsnmp"/>
    </service>
</package>

§Ú­Ì¥i¥H¬Ý¨ì¦bnetsnmp³o­ÓpackageùØ¡A©w¸q¤F°»´ú®É¶¡¶¡¹j»PIP½d³òµ¥¦h¶µ°Ñ¼Æ¡C
¦Ó¨ä¤¤³othresholding-group³o­Ókey­È¡A«h²M·¡©w¸q³o­Ópackage¬O»Pnetsnmp³o­Ógroup¤¬¬Û©IÀ³ªº¡C

¦bthreshd-configuration.xml¤¤¡A¹w³]ªº°»´ú®É¶¡¶¡¹j¬°300000²@¬í¡A¤]´N¬O5¤ÀÄÁ¡A
­Y·QÁYµu®É¶¡¶¡¹j¬°1¤ÀÄÁ¡A¥iª½±µ­×§ï interval °Ñ¼Æ¨Ó¹F¦¨¡C
­Y·Q¥HIP°µ¬°±ø¥ó¹LÂo¡A¤]¥i©ó¦¹³]©wÀɤ¤¡A³z¹L­×§ï IPADDR ªºÅÞ¿è§PÂ_¡A©Î¹ï include-range ªº begin & end¨Ó½Õ¾ã¹ïÀ³ªºIP½d³ò¡C

*½Ðª`·N¡A
­×§ï threshd-configuration.xml¡A»Ý­«±ÒªA°È³]©w¤~·|¥Í®Ä¡I


Linuxªºthreshold³]©w¨ì¦¹§i¤@¬q¸¨¡ã


°Ñ¦Ò¸ê®Æ
Âø¶Ãªº¾Ç²ßµ§°O¥»



♥¶¶¤l¦Ñ±Cªººô©ç¡A½Ð¦hÃö·Ó¡ã

If you don't like something, change it.
If you can't change it, change your attitude.
Don't complain!




2015-11-13, 18:39 shunze ªº­Ó¤H¸ê®Æ §â shunze ¥[¤J¦n¤Í¦Cªí µo°eEmailµ¹ shunze ÂsÄý shunze ªººô¯¸ MSN : shunze@gmail.com
  « ¤W¤@½g¥DÃD ¤U¤@½g¥DÃD »
µoªí·s¥DÃD µoªí¦^ÂÐ
¸õ¨ì:

Powered by: Burning Board 1.1.1 2001 WoltLab GbR