Cheshire Cat Computing

Software support and information
It is currently Wed May 24, 2017 7:05 pm

All times are UTC + 12 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Host template for Linux
PostPosted: Wed Aug 20, 2008 1:51 pm 
Offline
Site Admin

Joined: Tue Jul 29, 2003 11:42 am
Posts: 3035
Location: Auckland, New Zealand
This host template can be used with Linux servers, if you have enabled the SNMP daemon and the options in /etc/snmp/snmpd.conf correctly.

Note that you will need to use cfgstoragemaker to monitor the disks.

Code:
if( $sysdescr =~ /linux/i ) {
$head_lines .= "#---------------------------------------------------------------------\n";
$target_lines .= <<ECHO;
routers.cgi*Icon: linux-sm.gif
routers.cgi*Description: $sysname
routers.cgi*ShortDesc: $router_name
#-------------------------------------------------
# CPU load
Target[$router_name-snmp-cpu]: 100 - enterprises.2021.11.11.0&enterprises.2021.11.11.0:$router_connect
PageTop[$router_name-snmp-cpu]: $router_name CPU usage
Title[$router_name-snmp-cpu]: CPU on $router_name
Maxbytes[$router_name-snmp-cpu]: 100
Options[$router_name-snmp-cpu]: gauge
YLegend[$router_name-snmp-cpu]: percent
ShortLegend[$router_name-snmp-cpu]: %
LegendI[$router_name-snmp-cpu]: cpu:
Legend1[$router_name-snmp-cpu]: CPU usage
Legend3[$router_name-snmp-cpu]: Peak CPU usage
routers.cgi*Options[$router_name-snmp-cpu]: noo, nopercent, nototal
routers.cgi*InOut[$router_name-snmp-cpu]: no
routers.cgi*ShortDesc[$router_name-snmp-cpu]:CPU


# Memory used
Target[$router_name-snmp-memory]: enterprises.2021.4.6.0&enterprises.2021.4.4.0:$router_connect
PageTop[$router_name-snmp-memory]: $router_name Memory Available
Title[$router_name-snmp-memory]: Available Memory on $router_name
SetEnv[$router_name-snmp-memory]: MRTG_INT_DESCR="Memory"
Factor[$router_name-snmp-memory]: 1024
# This should be set to your real memory size, in K
MaxBytes1[$router_name-snmp-memory]: 10000000
# This should be set to your swap size, in K
MaxBytes2[$router_name-snmp-memory]: 10000000
Options[$router_name-snmp-memory]: gauge
YLegend[$router_name-snmp-memory]: Bytes
ShortLegend[$router_name-snmp-memory]: b
LegendI[$router_name-snmp-memory]: real:
LegendO[$router_name-snmp-memory]: swap:
Legend1[$router_name-snmp-memory]: Available real memory
Legend2[$router_name-snmp-memory]: Available swap space
Legend3[$router_name-snmp-memory]: Peak available real
Legend4[$router_name-snmp-memory]: Peak available swap
routers.cgi*Options[$router_name-snmp-memory]: nototal
routers.cgi*Mode[$router_name-snmp-memory]: memory
routers.cgi*ShortDesc[$router_name-snmp-memory]: Memory
routers.cgi*Description[$router_name-snmp-memory]: Memory available: $router_name
routers.cgi*InOut[$router_name-snmp-memory]: no
routers.cgi*InSummary[$router_name-snmp-memory]: yes
routers.cgi*InCompact[$router_name-snmp-memory]: yes
routers.cgi*Icon[$router_name-snmp-memory]: chip-sm.gif
routers.cgi*MBLegend[$router_name-snmp-memory]: 100% usage

# Load average
Target[$router_name-snmp-lavg]: enterprises.2021.10.1.5.2&enterprises.2021.10.1.5.3:$router_connect / 100
PageTop[$router_name-snmp-lavg]: $router_name Load Average
Title[$router_name-snmp-lavg]: Load Average on $router_name
SetEnv[$router_name-snmp-lavg]: MRTG_INT_DESCR="Load Average"
MaxBytes[$router_name-snmp-lavg]: 1000
Options[$router_name-snmp-lavg]: nopercent, gauge
YLegend[$router_name-snmp-lavg]: Processes
ShortLegend[$router_name-snmp-lavg]: &nbsp;
LegendI[$router_name-snmp-lavg]: 5min avg:
LegendO[$router_name-snmp-lavg]: 15min avg:
Legend1[$router_name-snmp-lavg]: 5-min load average
Legend2[$router_name-snmp-lavg]: 15-min load average
Legend3[$router_name-snmp-lavg]: Peak 5-min load average
Legend4[$router_name-snmp-lavg]: Peak 15-min load average
routers.cgi*Options[$router_name-snmp-lavg]: nomax, nototal, fixunit, noo
routers.cgi*Mode[$router_name-snmp-lavg]: general
routers.cgi*ShortDesc[$router_name-snmp-lavg]: Load Avg
routers.cgi*Description[$router_name-snmp-lavg]: Load average: $router_name
routers.cgi*UnScaled[$router_name-snmp-lavg]: none
routers.cgi*WithPeak[$router_name-snmp-lavg]: none
routers.cgi*InOut[$router_name-snmp-lavg]: no
routers.cgi*InSummary[$router_name-snmp-lavg]: yes
routers.cgi*InCompact[$router_name-snmp-lavg]: no
routers.cgi*Icon[$router_name-snmp-lavg]: load-sm.gif

# User count
Target[$router_name-snmp-users]: internet.2.1.25.1.5.0&internet.2.1.25.1.5.0:$router_connect
PageTop[$router_name-snmp-users]: $router_name Active users
Title[$router_name-snmp-users]: Active Users on $router_name
MaxBytes[$router_name-snmp-users]: 1000
SetEnv[$router_name-snmp-users]: MRTG_INT_DESCR="Users"
Options[$router_name-snmp-users]: nopercent, gauge
YLegend[$router_name-snmp-users]: Users
ShortLegend[$router_name-snmp-users]: &nbsp;
LegendI[$router_name-snmp-users]: Users
Legend1[$router_name-snmp-users]: Active Users
Legend3[$router_name-snmp-users]: Peak Active Users
routers.cgi*Options[$router_name-snmp-users]: nomax, nototal, fixunit, noo
routers.cgi*Mode[$router_name-snmp-users]: general
routers.cgi*ShortDesc[$router_name-snmp-users]: Users
routers.cgi*Description[$router_name-snmp-users]: Users on $router_name
routers.cgi*UnScaled[$router_name-snmp-users]: none
routers.cgi*InOut[$router_name-snmp-users]: no
routers.cgi*InSummary[$router_name-snmp-users]: yes
routers.cgi*InCompact[$router_name-snmp-users]: no
routers.cgi*Icon[$router_name-snmp-users]: user-sm.gif

# Process count
Target[$router_name-snmp-procs]: internet.2.1.25.1.6.0&internet.2.1.25.1.6.0:$router_connect
PageTop[$router_name-snmp-procs]: $router_name Processes
Title[$router_name-snmp-procs]: Processes on $router_name
MaxBytes[$router_name-snmp-procs]: 1000000
SetEnv[$router_name-snmp-procs]: MRTG_INT_DESCR="Procs"
Options[$router_name-snmp-procs]: nopercent, gauge
YLegend[$router_name-snmp-procs]: Processes
ShortLegend[$router_name-snmp-procs]: &nbsp;
LegendI[$router_name-snmp-procs]: Procs
Legend1[$router_name-snmp-procs]: Processes
Legend3[$router_name-snmp-procs]: Peak Processes
routers.cgi*Options[$router_name-snmp-procs]: nomax, nototal, fixunit, noo
routers.cgi*Mode[$router_name-snmp-procs]: general
routers.cgi*ShortDesc[$router_name-snmp-procs]: Processes
routers.cgi*Description[$router_name-snmp-procs]: Processes on $router_name
routers.cgi*UnScaled[$router_name-snmp-procs]: none
routers.cgi*InOut[$router_name-snmp-procs]: no
routers.cgi*InSummary[$router_name-snmp-procs]: yes
routers.cgi*InCompact[$router_name-snmp-procs]: no
routers.cgi*Icon[$router_name-snmp-procs]: list-sm.gif

ECHO
}

_________________
Steve Shipway
UNIX Systems, ITSS, University of Auckland, NZ
Woe unto them that rise up early in the morning... -- Isaiah 5:11


Top
 Profile Send private message  
 
PostPosted: Mon Jan 09, 2012 4:29 am 
Offline
User

Joined: Mon Jan 09, 2012 4:19 am
Posts: 1
Thanks! This is great infor and works!


Top
 Profile Send private message  
 
PostPosted: Thu Apr 26, 2012 10:02 pm 
Offline
User

Joined: Thu Apr 26, 2012 9:21 pm
Posts: 1
Hello,
I am having trouble getting this template to work properly. I am new to MRTG and SNMP and have NULL Perl skills. I am running debian linux with net-SNMP snmpd version 5.4.3 and mrtg version 2.17.3-2.
I am not running IPv6. If anyone is able to give a hint or point me in a direction I will be very grateful.

After copying the file to host.template.cfg I have run:
cfgmaker --global 'Workdir: /var/www/mrtg/localhost' --output /home/mrtg/cfg/mrtgHost.cfg --host-template=host.htp public@localhost
which gives output:
#------------------------------ Begin Output ---------------------------------------------
Use of uninitialized value $t in substitution (s///) at /usr/bin/cfgmaker line 1381.
Use of uninitialized value $t in substitution (s///) at /usr/bin/cfgmaker line 1382.
Use of uninitialized value $t in substitution (s///) at /usr/bin/cfgmaker line 1383.
Use of uninitialized value $fs in pattern match (m//) at /usr/bin/cfgmaker line 1388.
Use of uninitialized value $t in hash element at /usr/bin/cfgmaker line 1389.
Use of uninitialized value $t in substitution (s///) at /usr/bin/cfgmaker line 1381.
Use of uninitialized value $t in substitution (s///) at /usr/bin/cfgmaker line 1382.
Use of uninitialized value $t in substitution (s///) at /usr/bin/cfgmaker line 1383.
Use of uninitialized value $fs in pattern match (m//) at /usr/bin/cfgmaker line 1388.
Use of uninitialized value $t in hash element at /usr/bin/cfgmaker line 1389.
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMP_Session::unpack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMP_Session::sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608
Subroutine SNMPv1_Session::unpack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608
Subroutine SNMPv1_Session::sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608
--base: Get Device Info on public@localhost:
--base: Vendor Id: Unknown Vendor - 1.3.6.1.4.1.8072.3.2.10
--base: Populating confcache
--base: Get Interface Info
--base: Walking ifIndex
--snpd: public@localhost: -> 1 -> ifIndex = 1
--snpd: public@localhost: -> 2 -> ifIndex = 2
--snpd: public@localhost: -> 3 -> ifIndex = 3
--base: Walking ifType
--snpd: public@localhost: -> 1 -> ifType = 24
--snpd: public@localhost: -> 2 -> ifType = 6
--snpd: public@localhost: -> 3 -> ifType = 6
--base: Walking ifAdminStatus
--snpd: public@localhost: -> 1 -> ifAdminStatus = 1
--snpd: public@localhost: -> 2 -> ifAdminStatus = 1
--snpd: public@localhost: -> 3 -> ifAdminStatus = 1
--base: Walking ifOperStatus
--snpd: public@localhost: -> 1 -> ifOperStatus = 1
--snpd: public@localhost: -> 2 -> ifOperStatus = 2
--snpd: public@localhost: -> 3 -> ifOperStatus = 1
--base: Walking ifMtu
--snpd: public@localhost: -> 1 -> ifMtu = 16436
--snpd: public@localhost: -> 2 -> ifMtu = 1500
--snpd: public@localhost: -> 3 -> ifMtu = 1500
--base: Walking ifSpeed
--snpd: public@localhost: -> 1 -> ifSpeed = 10000000
--snpd: public@localhost: -> 2 -> ifSpeed = 0
--snpd: public@localhost: -> 3 -> ifSpeed = 0
--base: Writing /home/mrtg/cfg/mrtgHost.cfg
#--------------------------------- end output ----------------------------------

I then run:
sudo env LANG=C mrtg /home/mrtg/cfg/mrtgHost.cfg
#----------------------- Begin Output -----------------------------------
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMP_Session::unpack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMP_Session::sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608
Subroutine SNMPv1_Session::unpack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608
Subroutine SNMPv1_Session::sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608
#------------------------ End Output -----------------------------------------

I again run:
sudo env LANG=C mrtg /home/mrtg/cfg/mrtgHost.cfg

------------------------ Begin Output -----------------------------------------
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMP_Session::unpack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMP_Session::sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 149
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608
Subroutine SNMPv1_Session::unpack_sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608
Subroutine SNMPv1_Session::sockaddr_in6 redefined at /usr/share/perl/5.14/Exporter.pm line 67.
at /usr/share/perl5/SNMP_Session.pm line 608
------------------------ End Output -----------------------------------------
I am not running IPv6.
And then I set up the cron for root user to run MRTG every 5 minutes.

Then when I check the html files: localhost-snmp-cpu.html, localhost-snmp-lavg.html, localhost-snmp-memory.html, localhost-snmp-procs.html they always read 0.
localhost-snmp-users.html seems to work fine.
I assume this is because MRTG is not getting a response from snmpd. However running:
snmpget -v 2c -c public localhost .1.3.6.1.4.1.2021.10.1.3.2
returns: UCD-SNMP-MIB::laLoad.2 = STRING: 0.12
which I think is the CPU load averaged over 5 minutes.

Running: snmpget -v 1 -c public localhost .1.3.6.1.4.1.2021.10.1.3.2 (NOTE: SNMP v1)
also returns an integer.
UCD-SNMP-MIB::laLoad.2 = STRING: 0.08

Again if anyone has any idea as to where my problems may lay I would be very grateful for the information.

Regards,
Adam.

Actually since going through the setup process again to get this post correct all functions are now working except for the load average.


Top
 Profile Send private message  
 
PostPosted: Mon May 07, 2012 5:04 pm 
Offline
Site Admin

Joined: Tue Jul 29, 2003 11:42 am
Posts: 3035
Location: Auckland, New Zealand
If you are using laLoad as the OID to monitor, it seems this returns a string, not a number. You would need to use postprocessing to convert this to a number which requires... Perl skills...

I think there is a separate OID with a numerical load avg?

_________________
Steve Shipway
UNIX Systems, ITSS, University of Auckland, NZ
Woe unto them that rise up early in the morning... -- Isaiah 5:11


Top
 Profile Send private message  
 
 Post subject: Host template for Linux
PostPosted: Sun May 14, 2017 4:12 am 
Offline
User
User avatar

Joined: Thu May 11, 2017 1:49 am
Posts: 2
Location: Ukraine
So this is the default sentence template for this fact type and you customize it for each instance by filling in the #s?

.

_________________
dieta-blanda.com/


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 12 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group