24.10.2003

MRTG a SNMPD

Filed under: Uncategorized — nax @ 15:54

Dnes jsem se konecne dostal k tomu, abych rozebehl nejakeho demona ktery mi bude generovat statistiky zatizenosti serveru. Velice rychle jsem nasel projekt Multi Router Traffic Grapher, ktery pouziva snmp k zisteni udaju od routeru. Presne to co potrebuju. Dobry bude ze ten demon muze bezet na serveru a tim padem nebudu zatezovat 233MHz routrik tak aby se mohl soustredit jen a jen na routovani.

Problem ale byl rozbehnout ten snmpd. Pokud vam vypise na dotaz
# snmpget 10.27.72.1 public interfaces.ifNumber.0
Timeout: No Response from 10.27.72.1.
tak to znamena ze bud vam nejede demon nebo mate spatne nastavene tzv community (coz je vlastne jakasy obdoba hesla).

Po chvilce hrabani se v konfiguraku jsem se dostal do faze
# snmpget -v 1 10.27.72.1 public interfaces.ifNumber.0
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: interfaces.ifNumber.0

MIB jsou soubory s definicema jak ziskat urcitou hodnotu. Uz jsem se videl jak se budu hrabat v nejakych drsnych souborech (konkretne v /usr/share/snmp/mibs/). Nastesti guru guli mi poslal na mejl jednoduchoucky prikladek. Tady je:

naxrouter:/etc/snmp# cat snmpd.conf
ECTION: System Information Setup
#
# This section defines some of the information reported in
# the “system” mib group in the mibII tree.

# syslocation: The [typically physical] location of the system.
# arguments: location_string

syslocation nax_Modrany

# sysservices: The proper value for the sysServices object.
# arguments: sysservices_number

sysservices 78

# syscontact: The contact information for the administrator
# arguments: contact_string

syscontact root@10.27.0.8

##########################################################################
# SECTION: Access Control Setup
#
# This section defines who is allowed to talk to your running
# snmp agent.

# rouser: a SNMPv3 read-only user
# arguments: user [noauth|auth|priv] [restriction_oid]

rouser public

# rocommunity: a SNMPv1/SNMPv2c read-only access community name
# arguments: community [default|hostname|network/bits] [oid]

rocommunity public 127.0.0.1
rocommunity public 10.27.72.1
rocommunity public 10.27.72.2

###########################################################################
# SECTION: Monitor Various Aspects of the Running Host
#
# The following check up on various aspects of a host.

# proc: Check for processes that should be running.
# proc NAME [MAX=0] [MIN=0]
#
# NAME: the name of the process to check for. It must match
# exactly (ie, http will not find httpd processes).
# MAX: the maximum number allowed to be running. Defaults to 0.
# MIN: the minimum number to be running. Defaults to 0.
#
# The results are reported in the prTable section of the UCD-SNMP-MIB tree
# Special Case: When the min and max numbers are both 0, it assumes
# you want a max of infinity and a min of 1.

proc ssh 10 1
#pass .1.3.6.1.4.1.2021.255 /usr/local/libexec/ipfwsnmp .1.3.6.1.4.1.2021.255

No a ted uz stacilo jen spravne pustit
[naxsite:/var/www/mrtg 15:46:36 Fri Oct 24]
# cfgmaker –global ‘WorkDir: /var/www/mrtg’ –global ‘Options[_]: bits,growright’ –output=/var/www/mrtg/mrtg.cfg public@10.27.72.7

Coz mi vygenerovalo config, ktery jsem jeste kapanek poeditoval a ted uz se muzeme kochat statistikama. Jeste tam musim pridat statistiky ze serveru a zkusim tam pridat treba jeste CPU vytizenost a podobny veci. Velice rychle jsem nasel projekt Multi Router Traffic Grapher, ktery pouziva snmp k zisteni udaju od routeru. Presne to co potrebuju. Dobry bude ze ten demon muze bezet na serveru a tim padem nebudu zatezovat 233MHz routrik tak aby se mohl soustredit jen a jen na routovani.

Problem ale byl rozbehnout ten snmpd. Pokud vam vypise na dotaz
# snmpget 10.27.72.1 public interfaces.ifNumber.0
Timeout: No Response from 10.27.72.1.
tak to znamena ze bud vam nejede demon nebo mate spatne nastavene tzv community (coz je vlastne jakasy obdoba hesla).

Po chvilce hrabani se v konfiguraku jsem se dostal do faze
# snmpget -v 1 10.27.72.1 public interfaces.ifNumber.0
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: interfaces.ifNumber.0

MIB jsou soubory s definicema jak ziskat urcitou hodnotu. Uz jsem se videl jak se budu hrabat v nejakych drsnych souborech (konkretne v /usr/share/snmp/mibs/). Nastesti guru guli mi poslal na mejl jednoduchoucky prikladek. Tady je:

naxrouter:/etc/snmp# cat snmpd.conf
ECTION: System Information Setup
#
# This section defines some of the information reported in
# the “system” mib group in the mibII tree.

# syslocation: The [typically physical] location of the system.
# arguments: location_string

syslocation nax_Modrany

# sysservices: The proper value for the sysServices object.
# arguments: sysservices_number

sysservices 78

# syscontact: The contact information for the administrator
# arguments: contact_string

syscontact root@10.27.0.8

##########################################################################
# SECTION: Access Control Setup
#
# This section defines who is allowed to talk to your running
# snmp agent.

# rouser: a SNMPv3 read-only user
# arguments: user [noauth|auth|priv] [restriction_oid]

rouser public

# rocommunity: a SNMPv1/SNMPv2c read-only access community name
# arguments: community [default|hostname|network/bits] [oid]

rocommunity public 127.0.0.1
rocommunity public 10.27.72.1
rocommunity public 10.27.72.2

###########################################################################
# SECTION: Monitor Various Aspects of the Running Host
#
# The following check up on various aspects of a host.

# proc: Check for processes that should be running.
# proc NAME [MAX=0] [MIN=0]
#
# NAME: the name of the process to check for. It must match
# exactly (ie, http will not find httpd processes).
# MAX: the maximum number allowed to be running. Defaults to 0.
# MIN: the minimum number to be running. Defaults to 0.
#
# The results are reported in the prTable section of the UCD-SNMP-MIB tree
# Special Case: When the min and max numbers are both 0, it assumes
# you want a max of infinity and a min of 1.

proc ssh 10 1
#pass .1.3.6.1.4.1.2021.255 /usr/local/libexec/ipfwsnmp .1.3.6.1.4.1.2021.255

No a ted uz stacilo jen spravne pustit
[naxsite:/var/www/mrtg 15:46:36 Fri Oct 24]
# cfgmaker –global ‘WorkDir: /var/www/mrtg’ –global ‘Options[_]: bits,growright’ –output=/var/www/mrtg/mrtg.cfg public@10.27.72.7

Coz mi vygenerovalo config, ktery jsem jeste kapanek poeditoval a ted uz se muzeme kochat statistikama tady. Jeste tam musim pridat statistiky ze serveru a zkusim tam pridat treba jeste CPU vytizenost a podobny veci. Zacnu treba tady.

Jeste jsem do /var/www/mrtg/mrtg.cfg pridal radek
RunAsDaemon: Yes
aby se to startovalo rovnou jako demon a upravil /etc/init.d/skeleton. Trochu problem byl s zabijenim ale vyresil to prikaz
kill -9 `ps -ef | awk ‘{print $1″ “$2}’ | grep $NAME | awk ‘{print $2}’`
respektive
kill -9 `cat /var/www/mrtg/$NAME.pid`

Comments are closed.

Powered by WordPress