Apr 10 2009

Monitoring AS400 Resources with SNMP

Published by under AS400,Monitoring

AS400 CPU and memory resources monitoring can be handled with the SNMP protocol if SNMP service has been enabled. Values are not directly exploitable and need to be worked on before being displayed. All of these commands were executed on a Linux server. Check your Linux distribution to install snmpwalk, there’s a package for it most likely.


CPU Monitoring with SNMP

It is recommended to monitor IBM i CPU load with SNMP OID .1.3.6.1.4.1.2.6.4.5.1.0 that returns a value based on 10,000 units. It needs then to be divided by 100 to get a percentage.
The 2nd disadvantage is that the result is slightly wrong, the integer part only is being returned.
However, OID HOST-RESOURCES-MIB::hrProcessorLoad.2 from an IBM i gives the correct value in percentage.

For instance:

monitoring@server:~> snmpwalk -c $COMMUNITY -v1 $AS400_IP .1.3.6.1.4.1.2.6.4.5.1.0;
SNMPv2-SMI::enterprises.2.6.4.5.1.0 = Gauge32: 2380
monitoring@server:~> snmpwalk -c $COMMUNITY -v1 $AS400_IP .1.3.6.1.2.1.25.3.3.1.2.2
HOST-RESOURCES-MIB::hrProcessorLoad.2 = INTEGER: 24


Memory Monitoring with SNMP

First, MaxBytes and max amount of memory can be retrieved with snmpwalk (in KB) with a bit of processing:
expr `snmpwalk -v1 -c $COMMUNITY $AS400_IP hrMemorySize.0 | awk ‘{ print $(NF-1) }’` \* 1024
 

AS400 memory usage monitoring


Here is a shell script that computes memory usage from SNMP values (from Cacti forum). It is not a straightforward value as you can see.

#!/bin/sh
IP=$1
COMMUNITY=$2
SNMP_VERSION=$3
# RAM used
NB_ELEMENTS=`snmpwalk -v $SNMP_VERSION -c $COMMUNITY $IP hrStorageIndex \
| awk '{ print $NF }' | tail -n 1`

RAM_USED=0

for i in `seq 1 $NB_ELEMENTS`; do
  TYPE_ELEMENT=`snmpget -v $SNMP_VERSION -c $COMMUNITY $IP hrStorageDescr.$i \
  | awk '{ print $NF }'`
  if [ "$TYPE_ELEMENT" != "RAM" ]; then
    continue
  fi

  BLOCK_SIZE=`snmpget -v $SNMP_VERSION -c $COMMUNITY $IP hrStorageAllocationUnits.$i \
  | awk '{ print $(NF-1) }'`
  NB_BLOCKS_USED=`snmpget -v $SNMP_VERSION -c $COMMUNITY $IP hrStorageUsed.$i \
  | awk '{ print $NF }'`
  RAM_USED=`expr $NB_BLOCKS_USED \* $BLOCK_SIZE`
  TOTAL_RAM_USED=`expr $TOTAL_RAM_USED + $RAM_USED`
done

TOTAL_RAM_USED=`expr $TOTAL_RAM_USED`

echo $TOTAL_RAM_USED
echo $TOTAL_RAM_USED


MRTG Configuration

The resulting MRTG configuration looks like the following. It will generate usage graphs like above. These AS400 values can of course be handled by any other monitoring tool that support the SNMP protocol such as Zabbix or Cacti for example.

# Standard method displays twice the same value
# Target[AS400.cpu]:.1.3.6.1.2.1.25.3.3.1.2.2&.1.3.6.1.2.1.25.3.3.1.2.2:COMMUNITY@IP
# Or via a script as described here
Target[AS400.cpu]:`/home/mrtg/get-as400-cpu.sh IP COMMUNITY 1`
RouterUptime[AS400.cpu]: COMMUNITY@IP
MaxBytes[AS400.cpu]: 100
Title[AS400.cpu]: AS400 CPU Load
PageTop[AS400.cpu]: <H1>AS400 CPU Load</H1>
Unscaled[AS400.cpu]: ymwd
ShortLegend[AS400.cpu]: %
YLegend[AS400.cpu]: CPU Utilization
Legend1[AS400.cpu]: Active CPU Load
LegendI[AS400.cpu]: CPU
Options[AS400.cpu]: growright,nopercent,gauge
Colours[AS400.cpu]: RED#e13c13,RED#e13c13,RED#e13c13,RED#e13c13

# Same for memory usage
Target[AS400.mem]:`/home/mrtg/get-as400-memory.sh IP COMMUNITY 1`
RouterUptime[AS400.mem]: COMMUNITY@IP
MaxBytes[AS400.mem]: 12129927168
Title[AS400.mem]: AS400 Memory Usage
PageTop[AS400.mem]: <H1>AS400 Memory Usage</H1>
Unscaled[AS400.mem]: ymwd
YLegend[AS400.mem]: Memory Usage
Legend1[AS400.mem]: Memory Usage
LegendI[AS400.mem]: Memory
Options[AS400.mem]: growright,nopercent,gauge
Colours[AS400.mem]: ORANGE#F88017,ORANGE#F88017,ORANGE#F88017,ORANGE#F88017
 

3 responses so far

Mar 19 2009

Graph Only One Value in MRTG

Published by under Monitoring




MRTG needs at least 2 values to generate graphs. Thus, Most configurations contain the same OID twice in the target line.
This leads to 2 problems:
– The same data is collected twice which requires more bandwidth, especially when a large number of hosts is monitored

– The value may vary during this very short lap, producing 2 different lines in the graph. This is the case with AS400 cpus for instance.
To graph only one value such as CPU or memory usage, you can write a short script that collects the SNMP field once:

mrtg@snmp-server:~> cat /home/mrtg/get-cpu.sh
#!/bin/sh
IP=$1
COMMUNITY=$2
SNMP_VERSION=$3
CPU_LOAD=`snmpget -c $COMMUNITY -v $SNMP_VERSION $IP .1.3.6.1.2.1.25.3.3.1.2.2 | awk '{print $(NF) }'`
echo $CPU_LOAD
echo $CPU_LOAD

 
MRTG CPU Usage
 
Replace with your own OID, and call the script in your MRTG config file:

Target[cpu]:`/home/mrtg/get-cpu.sh my_ip my_community 1`

Quick and easy!

 

One response so far

Feb 27 2009

Linux Graphic Mode Installation Crash

Published by under Linux,Misc




Packard Bell Easynote E6100

Graphic cards aren’t always detected by Linux. This can be a problem as many distributions only support graphic mode installation type, like Ubuntu, Fedora or Debian.
This is the case of my Packard Bell Easynote E6100 and its onboard Via Unichrome card freezing on graphic mode startup.

One solution is to run the installation in text mode. Xubuntu 8.10 alternate has this feature and offers Xfce, a very light desktop environment, ideal for older laptops.

Generic Driver Configuration

We still get an X session crash at first boot.
The last option is to boot in recovery mode, and select “Drop to root shell prompt”. Replace /etc/X11/xorg.conf with this file, which makes reference to the generic Vesa driver:
 

Section "Files"
EndSection

Section "InputDevice"
	Identifier	"Generic Keyboard"
	Driver		"kbd"
	Option		"CoreKeyboard"
	Option		"XkbRules"	"xorg"
	Option		"XkbModel"	"pc105"
	Option		"XkbLayout"	"gb"
EndSection

Section "InputDevice"
	Identifier	"Configured Mouse"
	Driver		"mouse"
	Option		"CorePointer"
	Option		"Device"		"/dev/input/mice"
	Option		"Protocol"		"ImPS/2"
	Option		"ZAxisMapping"		"4 5"
	Option		"Emulate3Buttons"	"true"
EndSection

Section "Device"
	Identifier	"Generic Video Card"
	Driver		"vesa"
	BusID		"PCI:1:0:0"
EndSection

Section "Monitor"
	Identifier	"Generic Monitor"
	Option		"DPMS"
	HorizSync	30-70
	VertRefresh	50-160
EndSection

Section "Screen"
	Identifier	"Default Screen"
	Device		"Generic Video Card"
	Monitor		"Generic Monitor"
	DefaultDepth	24
EndSection

Section "ServerLayout"
	Identifier	"Default Layout"
	Screen		"Default Screen"
	InputDevice	"Generic Keyboard"
	InputDevice	"Configured Mouse"

EndSection

 
This driver being generic, it is of course better to use the appropriate driver to get the most of your graphic card. In the meantime, this will sort you out and let you run Linux in your favourite desktop environment.

 

One response so far

Jan 22 2009

How to Add a Permanent Static Route in AIX 4.3

Published by under Aix

To add a permanent static route in AIX, add the route command in the startup file /etc/rc.net:

AIX Server.root / $ route add -net 192.168.2.0 -netmask 255.255.255.0 192.168.0.1


or use Smitty, AIX text interface to perform global system management (preferred):
 
AIX Server.root / # smitty
-> Communications applications and Services
-> TCIP/IP
-> Further Configuration
-> Static Routes
-> Add a Static Route
Then type in the new static route settings.

 

3 responses so far

Jan 21 2009

Find Duplicate Files with a Shell Script

Published by under Linux

This shell script finds duplicate files in a given directory comparing their (md5) checksum. This means the content is checked and is strictly identical, rather than the filename or date of creation.
This is usually useful to delete large files. ‘Find’ command option -size can help speeding up and finding the largest duplicate files.
 

admin@fileserver$
find /usr/bin -type f -print0 |
xargs -0 -n1 md5sum |
sort -k 1,32 |
uniq -w 32 -d --all-repeated=separate |
sed -e 's/^[0-9a-f]*\ *//;'

/usr/bin/c2ph
/usr/bin/pstruct

/usr/bin/pgrep
/usr/bin/pkill

/usr/bin/perl
/usr/bin/perl5.8.8
/usr/bin/suidperl
...

This could be run on Windows file systems mounted via Samba.

 

No responses yet

« Prev - Next »