Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
SNMP & MRTG made in easy (Power Under Control ;)
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4, 5, 6  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
decker in flux
n00b
n00b


Joined: 08 Dec 2002
Posts: 60
Location: in flux

PostPosted: Tue Nov 25, 2003 12:49 am    Post subject: Reply with quote

Loooking at the CPU output, i am curious if it is possible to set it up ( or rather how would i go about setting mrtg up ) for monitoring multiple CPUs?

So having out put for
cpu0
cpu1
cpu2
cpu3
...
...

thanks
-d
_________________
>;/
sloppy focus owns you
>;/design.inspire.create.progress
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Tue Nov 25, 2003 9:46 am    Post subject: Reply with quote

Sorry, but I've just one cpu and I can't try it...anyway, put this in your cpu1.cfg and match the results (cpu0 vs cpu1):

Code:

Target[localhost.cpu1]:ssCpuRawUser.1&ssCpuRawUser.1:public@localhost + ssCpuRawSystem.1&ssCpuRawSystem.1:public@localhost + ssCpuRawNice.1&ssCpuRawNice.1:public@localhost


and go on...

Code:

Target[localhost.cpuN]:ssCpuRawUser.N&ssCpuRawUser.N:public@localhost + ssCpuRawSystem.N&ssCpuRawSystem.N:public@localhost + ssCpuRawNice.N&ssCpuRawNice.N:public@localhost


Let me know (or give me the link)....I'm curious.
Remember:
https://forums.gentoo.org/viewtopic.php?p=657204#657204

khazad-dum
Back to top
View user's profile Send private message
maomao
n00b
n00b


Joined: 25 Apr 2003
Posts: 3
Location: china

PostPosted: Tue Nov 25, 2003 12:56 pm    Post subject: Reply with quote

I had emerged net-snmp,but when I started snmpd,the system told me as follow:
Code:

root:/etc/init.d# ./snmpd start
* Starting net-snmpd...
/usr/sbin/snmpd: relocation error: /usr/sbin/snmpd: undefined symbol: smux_listen_sd                           [!!]
                                                                                                                               

who can tell me why?how to solve?
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Tue Nov 25, 2003 9:22 pm    Post subject: Reply with quote

It's strange...try to:
Code:

emerge sync
emerge -u system


And re-emerge snmpd

khazad-dum
Back to top
View user's profile Send private message
maomao
n00b
n00b


Joined: 25 Apr 2003
Posts: 3
Location: china

PostPosted: Wed Nov 26, 2003 2:44 am    Post subject: Reply with quote

I've solve it.

re-emerge perl,version is 5.8.0-r12

download net-snmp source

unzip package and complie source ourself
[/code]
Back to top
View user's profile Send private message
servermonk
Apprentice
Apprentice


Joined: 07 Nov 2003
Posts: 182
Location: MI

PostPosted: Wed Nov 26, 2003 4:24 am    Post subject: multiple hosts... Reply with quote

totally awesome walk through btw ;) Maybe someone can tackle this one:

I've had snmp/mrtg setup before on this same machine and never had any problems getting it setup to query multiple machines until I installed gentoo.
For some reason I can not make snmpget or snmpwalk requests to other machines OR from other machines to this one, even when snmp/mrtg works localy on all the machines in question.

I've even tried disabling iptables entirely just to make sure it wasn't a botched iptables config... still no response to snmp requests. So far I've run into two other people having this same problem: exact same snmp config works on a machine with redhat, and doesn't in gentoo. Any idea's?
_________________
Gentoo makes me wanna shoop.
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Wed Nov 26, 2003 8:32 am    Post subject: Reply with quote

You must specify IP class or ip address.

For example:
HostA have 216.239.59.99 ip address (and Netmask 255.255.255.0). It gets statistics from: HostB,HostC and HostD.

In every HOST polled (B,C and D) the

Code:

/etc/snmp/snmpd.conf


must have this line:

Code:

com2sec local     localhost              public
com2sec public   216.239.59.99/24    public


Restart snmpd.

khazad-dum
Back to top
View user's profile Send private message
servermonk
Apprentice
Apprentice


Joined: 07 Nov 2003
Posts: 182
Location: MI

PostPosted: Wed Nov 26, 2003 4:56 pm    Post subject: Reply with quote

Here is an example of my snmpd.conf file:

Code:

com2sec local       local.ip.add.ress/32    mygroup
com2sec mynetwork   my.ip.add.ress/32      mygroup
com2sec mynetwork   my.other.ip.address/32      mygroup

group MyROGroup v1         local
group MyROGroup v2c        local
group MyROGroup usm        local
group MyROGroup v1         mynetwork
group MyROGroup v2c        mynetwork
group MyROGroup usm        mynetwork

view all    included  .1                               80

access MyROGroup ""      any       noauth    exact  all    none   none

syslocation mylocation
syscontact myemailaddress
disk1   /       100000
disk2   /home   100000
disk3   /backup 100000



the problem is that even simple snmpget and snmpwalk queries can't exit or enter the machine even with no firewall rules present. Is there anything at teh kernel level I need to be looking for?
_________________
Gentoo makes me wanna shoop.
Back to top
View user's profile Send private message
Jeff Poulin
n00b
n00b


Joined: 31 Dec 2002
Posts: 10

PostPosted: Thu Nov 27, 2003 6:41 am    Post subject: Reply with quote

Hmmm, I tried this on one Gentoo system (Dell PE300, Pentium III/800, Linux 2.4.22 vanilla, Intel Pro 100) and it worked perfectly. I tried it on another system (Dell PE1600SC, Pentium IV/2.8GHz, Linux 2.4.22 vanilla, Intel Pro 1000) and it failed with the following message:

Code:

--base: Get Device Info on public@localhost:
SNMP Error:
no response received
SNMPv1_Session (remote host: "localhost" [127.0.0.1].161)
                  community: "public"
                 request ID: 1024590663
                PDU bufsize: 8000 bytes
                    timeout: 2s
                    retries: 5
                    backoff: 1)
 at /usr/bin/../lib/mrtg2/SNMP_util.pm line 570
SNMPWALK Problem for 1.3.6.1.2.1.1 on public@localhost:
 at /usr/bin/cfgmaker line 709

What's interesting is that these two systems are nearly identical in setup (I created the gentoo system on the 2.8GHz machine and compiled everything for i686, then did a "cp -a" from a rescue CD to image an identical drive for the 2nd system. I only changed a few config files (hostname, IP address info, etc...), so the two should be the same.

Does snmp not work on the kernel's e1000 driver? That's the only material difference I can think of. Anybody know what I can do here?
Back to top
View user's profile Send private message
Jeff Poulin
n00b
n00b


Joined: 31 Dec 2002
Posts: 10

PostPosted: Thu Nov 27, 2003 6:51 am    Post subject: Reply with quote

Just a little more info on the above post, I did an "emerge sync" then an "emerge net-snmp libgd mrtg" on both machines before starting and followed the intructions on the first post to the letter. Googling pointed to articles about the community string, but since the first one (P3/800) worked fine with the same setup, I'm not sure that's the problem.
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Thu Nov 27, 2003 2:33 pm    Post subject: Reply with quote

I'm currently use this version:

Code:

net-analyzer/net-snmp-5.0.9-r1  +ssl -ipv6 +tcpd
net-analyzer/mrtg-2.9.29
media-libs/libgd-2.0.15-r1  -X -gif
dev-lang/perl-5.8.0-r12  +berkdb -doc +gdbm -threads


and I've no problems.
Please, try to upgrade/downgrade (only for test) your programs in all machines monitored, and give me a feedback.

khazad-dum


Last edited by khazad-dum on Sat Nov 29, 2003 5:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
servermonk
Apprentice
Apprentice


Joined: 07 Nov 2003
Posts: 182
Location: MI

PostPosted: Thu Nov 27, 2003 4:41 pm    Post subject: still no luck Reply with quote

I recompiled perl, net-snmp, libgd and mrtg with the same USE flags listed above and tried again using this line from the net-snmp.org site under the v5 tutorial:

Code:

snmpget -v 2c -c demopublic test.net-snmp.org sysUpTime.0


Using this line returns a value on all of my machines except for my gentoo box, even with iptables and portsentry turned off.
_________________
Gentoo makes me wanna shoop.
Back to top
View user's profile Send private message
Jeff Poulin
n00b
n00b


Joined: 31 Dec 2002
Posts: 10

PostPosted: Thu Nov 27, 2003 6:31 pm    Post subject: Reply with quote

khazad-dum wrote:
I'm currently use this version:

Code:

net-analyzer/net-snmp-5.0.9-r1  +ssl -ipv6 +tcpd
net-analyzer/mrtg-2.9.29
media-libs/libgd-2.0.15-r1  -X -gif
dev-lang/perl-5.8.0-r12  +berkdb -doc +gdbm -threads


and I've no problems.

I'm running exactly the same versions, but still can't get snmp to work with my Intel Pro/1000. BTW, what command line did you use to show the USE variables compiled for your packages?
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Thu Nov 27, 2003 9:56 pm    Post subject: Reply with quote

Quote:

I'm running exactly the same versions, but still can't get snmp to work with my Intel Pro/1000. BTW, what command line did you use to show the USE variables compiled for your packages?


emerge -vp
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Thu Nov 27, 2003 10:13 pm    Post subject: Reply with quote

servermonk enable snmp's logging:

Code:

/etc/conf.d/snmpd


and restart the daemon.
The problem can be solved if we have more log.

khazad-dum
Back to top
View user's profile Send private message
servermonk
Apprentice
Apprentice


Joined: 07 Nov 2003
Posts: 182
Location: MI

PostPosted: Fri Nov 28, 2003 12:55 am    Post subject: Reply with quote

snmpd is logging to /var/log/net-snmpd.log but the only thing listed there is "Connection from (my local ip address)" over and over again.

Is there a way to enable more verbose logging?
_________________
Gentoo makes me wanna shoop.
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Sat Nov 29, 2003 4:44 pm    Post subject: Reply with quote

Try to increase the level on your logger:

From man klogd
Code:

-c n   Sets the default log level of console messages to n.


and edit the
/etc/conf.d/syslogd
Code:

KLOGD="-c 9 -2"


or try to set a faciity level for snmpd:

Code:

-S d|0-7 Specifies  the  syslog facility to use when logging to syslog.  'd' means LOG_DAEMON and 0 through 7 mean LOG_LOCAL0 through LOG_LOCAL7.  LOG_DAEMON is the default.


and increase the debug option in your syslog file. If you use (for example) local7 try to put

Code:

local7.=debug (or local7=* too)


into /etc/syslog.conf and restart it.

Another way is the debugging:

from man snmpd
Code:

-D[TOKEN[,...]] Turn on debugging output for  the  given TOKEN(s).   Without  any  tokens  specified,  it defaults to printing all the tokens (which is equivalent to the keyword "ALL").  You might want to try ALL for extremely verbose output.  Note: You can not put a space  between  the -D flag and the listed TOKENs.


and man sysklogd
Code:

-d     Turns on debug mode.  Using this the daemon will not proceed a fork(2) to set itself in  the  background,but opposite to that stay in the foreground and write much debug information on the current tty.  See the DEBUGGING section for more information.


khazad-dum
Back to top
View user's profile Send private message
Jeff Poulin
n00b
n00b


Joined: 31 Dec 2002
Posts: 10

PostPosted: Tue Dec 02, 2003 7:37 am    Post subject: Reply with quote

I found a solution to my problem (above)
Code:

--base: Get Device Info on public@localhost:
 SNMP Error:

If I replace @localhost with @[my hostname] in my /etc/mrtg/*.cfg files, everything works.
Back to top
View user's profile Send private message
crypt0shite
n00b
n00b


Joined: 21 Nov 2003
Posts: 21
Location: slc, utah

PostPosted: Fri Dec 05, 2003 11:02 pm    Post subject: thank you Reply with quote

Thanks to your great guide and the follow-up replies I have MRTG up and running. Gentoo has the best community!
Back to top
View user's profile Send private message
hertog
Tux's lil' helper
Tux's lil' helper


Joined: 28 Jun 2002
Posts: 138
Location: Enschede/The Netherlands/Europe

PostPosted: Wed Dec 17, 2003 2:39 pm    Post subject: Reply with quote

Hmmm... the memory part and the swap part don't seem to work, no matter what I put in the Target line.

Anyone who can confirm that this has to do with the 2.6.0 kernel?

No value of what I see passingby rings a bell, and those that do have a value of '0' in it :(
Back to top
View user's profile Send private message
chrisyu
Apprentice
Apprentice


Joined: 10 Apr 2003
Posts: 206
Location: China

PostPosted: Tue Dec 23, 2003 5:38 am    Post subject: Reply with quote

I use kernel 2.6, mem and swap didn't work either. :?
no error, but just no data output in picture.
Back to top
View user's profile Send private message
hertog
Tux's lil' helper
Tux's lil' helper


Joined: 28 Jun 2002
Posts: 138
Location: Enschede/The Netherlands/Europe

PostPosted: Tue Dec 23, 2003 6:46 am    Post subject: Reply with quote

chrisyu wrote:
I use kernel 2.6, mem and swap didn't work either. :?
no error, but just no data output in picture.


Exactly what I am seeing, so let's keep it at a kernel version related problem.

Now for a solution :)...

Gr.

Hertog
Back to top
View user's profile Send private message
chrisyu
Apprentice
Apprentice


Joined: 10 Apr 2003
Posts: 206
Location: China

PostPosted: Tue Dec 23, 2003 9:42 am    Post subject: Reply with quote

found something in /var/log/net-snmpd.log

No swap line in /proc/stat
No page line in /proc/stat

maybe this problem??

and my /proc/stat file
Code:

cpu  155998 0 61383 3568895 29288 0 0
cpu0 155998 0 61383 3568895 29288 0 0
intr 44145554 38155664 8 0 0 0 0 2 0 2 0 5866193 0 92 0 123574 19
ctxt 7036989
btime 1072134446
processes 32760
procs_running 1
procs_blocked 0

Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Tue Dec 23, 2003 6:25 pm    Post subject: Reply with quote

I think we'll have to wait for the new OID (Object IDentifier) from net-snmp.sf.net for 2.6.x branch.

Work around
cat and cut are your friends :) !!

Code:

root@guardian proc # cat /proc/meminfo  | grep SwapFree | cut -d ' ' -f 8
224884


Look into /proc/meminfo (and /proc/stat or /proc/* too) and cat&cut your $VARIABLES

Code:

Target[localhost.mem]: `cat /proc/meminfo  | grep  |MemTotal cut -d ' ' -f 8`



Enjoy
:-D :-D
Back to top
View user's profile Send private message
apokalyptik
n00b
n00b


Joined: 18 Jun 2002
Posts: 62

PostPosted: Tue Dec 23, 2003 8:05 pm    Post subject: for everyone who likes to cut and paste :) Reply with quote

Code:
WORKDIR=/home/blah/public_html/svc/`hostname`
PAGETITLE=`hostname`": Statistics"
DELOLDINFO=1
MAKECRON=1

if [ $DELOLDINFO -eq 1 ]
 then
  if [ -d $WORKDIR ]
   then
    rm -rf $WORKDIR
  fi
fi

/usr/bin/mkdir /etc/mrtg
/usr/bin/mkdir /etc/cron.mrtg
/usr/bin/mkdir $WORKDIR

echo 'com2sec local     127.0.0.1/32    public
com2sec local     10.0.0.0/24     public
group MyROGroup v1         local
group MyROGroup v2c        local
group MyROGroup usm        local
view all    included  .1                               80
access MyROGroup ""      any       noauth    exact  all    none   none
syslocation MyLocation
syscontact Me <service@eaglenetworks.net> ' > /etc/snmp/snmpd.conf

echo 'SNMPD_FLAGS="$SNMPD_FLAGS -c /etc/snmp/snmpd.conf"' >> /etc/conf.d/snmpd
/sbin/rc-update add snmpd default
/etc/init.d/snmpd start
mkdir $WORKDIR
/usr/bin/cfgmaker  \
--output=/etc/mrtg/traffic.cfg \
--ifdesc=ip \
--ifref=descr \
--global "WorkDir: $WORKDIR" \
--global "Options[_]: bits,growright" \
public@localhost

echo 'WorkDir: '$WORKDIR'
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost
RouterUptime[localhost.cpu]: public@localhost
MaxBytes[localhost.cpu]: 100
Title[localhost.cpu]: CPU Load
PageTop[localhost.cpu]: <H1>Active CPU Load %</H1>
Unscaled[localhost.cpu]: ymwd
ShortLegend[localhost.cpu]: %
YLegend[localhost.cpu]: CPU Utilization
Legend1[localhost.cpu]: Active CPU in % (Load)
Legend2[localhost.cpu]:
Legend3[localhost.cpu]:
Legend4[localhost.cpu]:
LegendI[localhost.cpu]:  Active
LegendO[localhost.cpu]:
Options[localhost.cpu]: growright,nopercent ' > /etc/mrtg/cpu.cfg

echo 'LoadMIBs: /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
Target[localhost.mem]: .1.3.6.1.4.1.2021.4.11.0&.1.3.6.1.4.1.2021.4.11.0:public@localhost
PageTop[localhost.mem]: <H1>Free Memory </H1>
WorkDir: '$WORKDIR'
Options[localhost.mem]: nopercent,growright,gauge,noinfo
Title[localhost.mem]: Free Memory
MaxBytes[localhost.mem]: 1000000
kMG[localhost.mem]: k,M,G,T,P,X
YLegend[localhost.mem]: bytes
ShortLegend[localhost.mem]: bytes
LegendI[localhost.mem]:  Free Memory:
LegendO[localhost.mem]:
Legend1[localhost.mem]: Free memory, not including swap, in bytes ' > /etc/mrtg/mem.cfg

echo 'LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.swap]: memAvailSwap.0&memAvailSwap.0:public@localhost
PageTop[localhost.swap]: <H1>Swap Memory</H1>
WorkDir: '$WORKDIR'
Options[localhost.swap]: nopercent,growright,gauge,noinfo
Title[localhost.swap]: Free Memory
MaxBytes[localhost.swap]: 1000000
kMG[localhost.swap]: k,M,G,T,P,X
YLegend[localhost.swap]: bytes
ShortLegend[localhost.swap]: bytes
LegendI[localhost.swap]:  Free Memory:
LegendO[localhost.swap]:
Legend1[localhost.swap]: Swap memory avail, in bytes ' > /etc/mrtg/swap.cfg

echo 'WorkDir: '$WORKDIR'
Title[localhost.ping]: Round Trip Time
PageTop[localhost.ping]: <H1>Round Trip Time</H1>
Target[localhost.ping]: `/etc/mrtg/ping.sh`
MaxBytes[localhost.ping]: 2000
Options[localhost.ping]: growright,unknaszero,nopercent,gauge
LegendI[localhost.ping]: Pkt loss %
LegendO[localhost.ping]: Avg RTT
Legend1[localhost.ping]: Maximum Round Trip Time in ms
Legend2[localhost.ping]: Minimum Round Trip Time in ms
Legend3[localhost.ping]: Maximal 5 Minute Maximum Round Trip Time in ms
Legend4[localhost.ping]: Maximal 5 Minute Minimum Round Trip Time in ms
YLegend[localhost.ping]: RTT (ms) ' > /etc/mrtg/ping.cfg

echo '#!/bin/sh
/usr/bin/mrtg /etc/mrtg/traffic.cfg ' > /etc/cron.mrtg/traffic.sh
chmod 751 /etc/cron.mrtg/traffic.sh

echo '#!/bin/sh
/usr/bin/mrtg /etc/mrtg/mem.cfg ' > /etc/cron.mrtg/mem.sh
chmod 751 /etc/cron.mrtg/mem.sh

echo '#!/bin/sh
/usr/bin/mrtg /etc/mrtg/swap.cfg ' > /etc/cron.mrtg/swap.sh
chmod 751 /etc/cron.mrtg/swap.sh

echo '#!/bin/sh
/usr/bin/mrtg /etc/mrtg/ping.cfg ' > /etc/cron.mrtg/ping.sh
chmod 751 /etc/cron.mrtg/ping.sh

echo '#!/bin/sh
/usr/bin/mrtg /etc/mrtg/cpu.cfg ' > /etc/cron.mrtg/cpu.sh
chmod 751 /etc/cron.mrtg/cpu.sh

echo '#!/bin/sh
PING="/bin/ping"
# Google, for example
ADDR="google.com"
DATA=`$PING -c10 -s500 $ADDR -q `
LOSS=`echo $DATA | awk "{print $18 }" | tr -d %`
echo $LOSS
if [ $LOSS = 100 ];
then
               echo 0
else
        echo $DATA | awk -F/ "{print $5 }"
fi
' > /etc/mrtg/ping.sh

chmod 751 /etc/mrtg/ping.sh
/bin/chmod +x /etc/cron.mrtg/*.sh
/bin/chmod +x /etc/mrtg/ping.sh

/etc/cron.mrtg/traffic.sh
/etc/cron.mrtg/cpu.sh
/etc/cron.mrtg/mem.sh
/etc/cron.mrtg/swap.sh
/etc/cron.mrtg/ping.sh
/etc/cron.mrtg/traffic.sh
/etc/cron.mrtg/cpu.sh
/etc/cron.mrtg/mem.sh
/etc/cron.mrtg/swap.sh
/etc/cron.mrtg/ping.sh
/etc/cron.mrtg/traffic.sh
/etc/cron.mrtg/cpu.sh
/etc/cron.mrtg/mem.sh
/etc/cron.mrtg/swap.sh
/etc/cron.mrtg/ping.sh

/usr/bin/indexmaker --output=$WORKDIR/index.html \
--title="$PAGETITLE" \
--sort=name \
--enumerate \
/etc/mrtg/traffic.cfg \
/etc/mrtg/cpu.cfg \
/etc/mrtg/mem.cfg \
/etc/mrtg/swap.cfg \
/etc/mrtg/ping.cfg

if [ $MAKECRON -eq 1 ]
 then
  echo '*/5 * * * * /bin/run-parts /etc/cron.mrtg 1> /dev/null' >> /var/spool/cron/crontabs/root
fi

_________________
http://www.apokalyptik.com/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 2 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum