no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | monitors:rasusagepl [2010/06/09 07:51] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== ras-usage ====== | ||
+ | |||
+ | ^ Author | [[ nelis@nlr.nl | Wim Nelis ]] | | ||
+ | ^ Compatibility | Xymon 4.2 | | ||
+ | ^ Requirements | Perl, unix | | ||
+ | ^ Download | None | | ||
+ | ^ Last Update | 2010-06-09 | | ||
+ | |||
+ | ===== Description ===== | ||
+ | Script ras-usage.pl monitors the number of web users of a Juniper RAS cluster, as well as the state of each node in the cluster: active or passive. It is a server-side script, which uses SNMP to retrieve the information. It reports results in two tests, " | ||
+ | |||
+ | Test " | ||
+ | |||
+ | Test " | ||
+ | |||
+ | ===== Installation ===== | ||
+ | As the script is a server-side script, all istallation steps below are performed at the Xymon server. | ||
+ | |||
+ | Copy script ras-usage.pl into an appropriate directory, typically ~xymon/ | ||
+ | |||
+ | Edit file ~xymon/ | ||
+ | < | ||
+ | TEST2RRD=" | ||
+ | GRAPHS=" | ||
+ | NCV_usage=" | ||
+ | </ | ||
+ | |||
+ | Edit file ~xymon/ | ||
+ | < | ||
+ | [usage] | ||
+ | ENVFILE / | ||
+ | CMD / | ||
+ | LOGFILE $BBSERVERLOGS/ | ||
+ | INTERVAL 5m | ||
+ | </ | ||
+ | You might need to adapt the pathnames to match your environment. | ||
+ | |||
+ | Edit file ~xymon/ | ||
+ | < | ||
+ | [usage] | ||
+ | TITLE , Concurrent usage | ||
+ | YAXIS VPN clients [] | ||
+ | -l 0 | ||
+ | DEF: | ||
+ | # | ||
+ | # | ||
+ | AREA: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | </ | ||
+ | If you have defined the consolidation function (CF) MAX in the RRD created by Xymon, the comment lines can be un-commented to show the maximum use as well. | ||
+ | |||
+ | |||
+ | |||
+ | ===== Source ===== | ||
+ | ==== ras-usage.pl ==== | ||
+ | |||
+ | <hidden onHidden=" | ||
+ | < | ||
+ | # | ||
+ | # | ||
+ | # RAS-usage: determine the number of users (VPN clients) of the Juniper | ||
+ | # SA-2500 remote access cluster. All members of the cluster know how many | ||
+ | # users there are. The result is reported to Xymon using the clustername | ||
+ | # as hostname. | ||
+ | # | ||
+ | # - Added test cluster, which is reported for each multi-node cluster | ||
+ | # | ||
+ | # on ideas of Tom Schmitt. | ||
+ | # | ||
+ | use strict ; | ||
+ | use POSIX qw/ strftime / ; # Format time | ||
+ | |||
+ | # | ||
+ | # Installation constants. | ||
+ | # | ||
+ | my $XyDisp= $ENV{BBSERVERHOSTNAME} ; # Name of monitor server | ||
+ | my $XySend= $ENV{BB} ; # Monitor interface program | ||
+ | my $FmtDate= ' | ||
+ | | ||
+ | my $TestName= ' | ||
+ | |||
+ | # | ||
+ | # Define the Juniper RAS clusters. | ||
+ | # Each entry describes one cluster. The key of an entry is name of the cluster. | ||
+ | # The value of an entry is a reference to a list of names of the physical nodes | ||
+ | # in the cluster. It is assumed that the DNS name is equal to the Xymon name in | ||
+ | # all these cases. | ||
+ | # | ||
+ | my %Ras= ( | ||
+ | < | ||
+ | ) ; | ||
+ | # | ||
+ | # Define the number of available licenses per cluster. | ||
+ | # | ||
+ | my %MaxUsers= ( # Number of available licenses | ||
+ | < | ||
+ | ) ; | ||
+ | |||
+ | # | ||
+ | # Define the SNMP query command to determine the number of users. The OIDs | ||
+ | # of interest in subtree .1.3.6.1.4.1.12532. are: | ||
+ | # 2.0 - Number of Signed-In Web Users | ||
+ | # 3.0 - Number of Signed-In Mail Users | ||
+ | # 9.0 - the number of concurrent meeting users | ||
+ | # 12.0 - The Total number of Users Logged In for the IVE Node | ||
+ | # 13.0 - The Total number of Users Logged In for the Cluster | ||
+ | # | ||
+ | my $SnmpUser | ||
+ | |||
+ | # | ||
+ | # Define the SNMP query to determine which physical server holds the Virtual | ||
+ | # IP address of the cluster. | ||
+ | # | ||
+ | my $SnmpCluster= ' | ||
+ | |||
+ | # | ||
+ | # Variable allocation. | ||
+ | # | ||
+ | my $Now= strftime( $FmtDate, localtime ) ; # Timestamp of tests | ||
+ | my $HostName ; # Xymon host name | ||
+ | my $Server ; # RAS node name | ||
+ | my $Cmd ; # Full blown snmpget command | ||
+ | my $Color ; # Test status | ||
+ | my $Users ; # Number of users | ||
+ | my %Cluster ; # Status of cluster nodes | ||
+ | my @Lines ; # Command output | ||
+ | my $Result ; # Test result | ||
+ | |||
+ | # | ||
+ | # Function UnpackIp transforms a binary formatted IPv4 address into a | ||
+ | # dotted decimal encoded string. | ||
+ | # | ||
+ | sub UnpackIp($) { return join(' | ||
+ | |||
+ | # | ||
+ | # Main program. | ||
+ | # ------------- | ||
+ | # | ||
+ | foreach $HostName ( keys %Ras ) { | ||
+ | $Color = ' | ||
+ | $Users = undef ; | ||
+ | $Result= '' | ||
+ | |||
+ | # | ||
+ | # -A- Determine for each cluster the number of web users. | ||
+ | # | ||
+ | # The number of users is retrieved from the nodes. It was found that an | ||
+ | # `snmpget` often fails if it is directed to the cluster service. | ||
+ | # | ||
+ | foreach $Server ( @{$Ras{$HostName}} ) { | ||
+ | $Cmd= sprintf( $SnmpUser, $Server ) ; | ||
+ | @Lines= `$Cmd` ; | ||
+ | next unless defined $Lines[0] ; | ||
+ | next unless $Lines[0]=~ m/ = Gauge32: (\d+)\s*$/ ; | ||
+ | $Users= $1 ; # Concurrent web users | ||
+ | last ; | ||
+ | } # of foreach | ||
+ | |||
+ | # | ||
+ | # Determine the test status and build the tail of the message. | ||
+ | # | ||
+ | unless ( defined $Users ) { | ||
+ | $Color= ' | ||
+ | $Result= "& | ||
+ | } else { | ||
+ | if ( $Users > 0.9 * $MaxUsers{$HostName} ) { | ||
+ | $Color = ' | ||
+ | $Result= "& | ||
+ | } # of if | ||
+ | $Result.= "< | ||
+ | } # of else | ||
+ | | ||
+ | # | ||
+ | # Build the header of the message, and send it to Xymon. | ||
+ | # | ||
+ | $Result= " | ||
+ | " | ||
+ | | ||
+ | `$XySend $XyDisp $Result` ; # Inform Xymon | ||
+ | |||
+ | # | ||
+ | # -B- Determine the cluster status of each multi-node cluster. | ||
+ | # | ||
+ | # | ||
+ | next unless @{$Ras{$HostName}} > 1 ; | ||
+ | |||
+ | $Color | ||
+ | $Result = '' | ||
+ | %Cluster= () ; | ||
+ | my $VirtualIp= UnpackIp( gethostbyname($HostName) ) ; | ||
+ | |||
+ | foreach $Server ( @{$Ras{$HostName}} ) { | ||
+ | $Cmd= sprintf( $SnmpCluster, | ||
+ | @Lines= `$Cmd` ; | ||
+ | if ( defined $Lines[0] ) { | ||
+ | if ( $Lines[0]=~ m/ | ||
+ | $Cluster{$Server}= [ ' | ||
+ | $Result.= "& | ||
+ | } elsif ( $Lines[0]=~ m/No Such Instance currently exists at this OID$/ ) { | ||
+ | $Cluster{$Server}= [ ' | ||
+ | $Result.= "& | ||
+ | } else { | ||
+ | $Color | ||
+ | $Cluster{$Server}= [ ' | ||
+ | " | ||
+ | $Result.= "& | ||
+ | } # of else | ||
+ | } else { | ||
+ | $Color | ||
+ | $Cluster{$Server}= [ $Color, " | ||
+ | $Result.= "& | ||
+ | } # of else | ||
+ | } # of foreach | ||
+ | |||
+ | # | ||
+ | # Report the status of all nodes together for the cluster service. | ||
+ | # | ||
+ | $Result= " | ||
+ | " | ||
+ | | ||
+ | `$XySend $XyDisp $Result` ; # Inform Xymon | ||
+ | |||
+ | # | ||
+ | # Report the individual node status to each node individually. | ||
+ | # | ||
+ | foreach $Server ( keys %Cluster ) { | ||
+ | $Color = $Cluster{$Server}[0] ; | ||
+ | $Result= " | ||
+ | | ||
+ | `$XySend $XyDisp $Result` ; # Inform Xymon | ||
+ | } # of foreach | ||
+ | } # of foreach | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | This script is used to monitor a two-node Juniper SA-2500 cluster. I assume it will work as well on the other Juniper RAS clusters. | ||
+ | |||
+ | ===== Credits ===== | ||
+ | Test " | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * **2010-06-09** | ||
+ | * Initial release | ||