This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

SAM 6.0: Apache HTTP (Linux script execution error.)

Good day,

I've been attempting to monitor an Apache HTTP server version 2.2.15 running on a CentOS 6.5 (running on Oracle VM VirtualBox) in SAM 6.0 (running on Windows Server 2008 R2); before proceeding any further, would like to note that I'm still a newbie in using Orion and would appreciate some feedback from the community.


Prior to adding the Apache HTTP server to SAM, I've performed the following steps on the CentOS server:

1. Edited the snmpd.conf file to add the following entries:


rocommunity public <ip_address>

rwcommunity priviate <ip_address>

2. Successfully executed a snmpwalk (both v1 and v2c) locally.

# snmpwalk -v 1  -c public -O e <server_ip_address>

# snmpwalk -v 2c  -c public -O e <server_ip_address>

3. Added the following rules in IPTables to allow HTTP and SNMP to be accessed externally.


# iptables -I input 2 -m state --state NEW -m tcp -p tcp --dport 161 -j ACCEPT

# iptables -I input 2 -m state --state NEW -m udp -p udp --dport 161 -j ACCEPT

# iptables -I input 2 -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

4. Started the HTTPd daemon/service successfully.


# service httpd start

5. Accessed the Apache server and performed a SNMP walk (using snmpwalk utility for both v1 and v2c) from the Windows Server 2008 R2 server successfully.

6. To add Apache in SAM, clicked Settings -> SAM Settings -> Manually Assigned Application.

7. Selected Apache followed by selecting the node (or Apache server) from the list and then providing the proper credentials in accessing the Apache server.

8. Clicked Test button; after a while, all Component Test Results returned an "Linux script execution error."

Detailed description of the error message is as follows:

Testing node on <ip_address>: failed with 'Unknown' status.

Scripting Error: Script does not contain the expected parameters or is improperly formatted. 'Statistic' missing.

Output:  ================================================================

Can't locate URI.pm in @INC  (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/local/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5.) at (eval 6) line 3.

Compilation failed in require at /usr/local/share/perl5/HTTP/Request.pm line 3.

Compilation failed in require at /usr/local/share/perl5/LWP/UserAgent.pm line 10.

BEGIN failed--compilation aborted at /usr/local/share/perl5/LWP/UserAgent.pm line 10.

Compilation failed in require at /tmp/APM_355417347.pl line 7.

BEGIN failed--compilation aborted at /tmp/APM_35517347.pl line 7.

After seeing the part of the error message referring to the Perl modules specifically the LWP, I went back to the CentOS server and checked the installed modules on the server.

# instmodsh

Available commands are:

l                - List all installed modules

m <module >      - Select a module

q                - Quit the program

cmd? l

Installed modules are:

Perl

Admittedly limited knowledge on Perl modules but based on the error message's detail, is it possible that the root cause of the error message is due to the LWP module not being installed? Based on the assumption that LWP is not built-in to Perl.

Thank for your time in reading this post and looking forward for some feedback.

  • It looks like you're mixing apples with Volkswagens.

    Your SNMP settings appear to be all well and good

    BUT

    linux script execution has nothing to do with SNMP.

    Orion logs onto the system via ssh using the supplied credentials and executes the script that was set in the script body of the SAM component.

    Based on the error message you're getting, I'd say your perl installation doesn't have the URI.pm that the script requires.

    infact your use of instmodsh is correct. Now you need to get the URI.pm installed.

    A quck scan of one of my linux boxes show many more perl modules installed than what you show.

    Since you're running centos 6.5 ( Oracle stole it from RedHat), you should be able to do the following as root on the box:

    yum install perl-URI

    and that should get the URI.pm on the system and all the dependancies.

    Also it would be useful to post the script you are trying to run. It assists people in helping.

    Chris

  • Hi cgregors,

    Thanks for the feedback; appreciate it. emoticons_happy.png

    I'll get the perl-URI (and dependencies) as advised; as for the script, I'm using the built-in Apache template of SAM.

    Benjie

  • Hi Chris,

    As advised, ran yum install perl-URI as root on my CentOS box and returned the following message:

    Package perl-URI-1.40-2.e16.noarch already installed and latest version

    Executed instmodsh to list all installed modules but it only returned Perl just like in my initial post, for some reason the URI.pm can't be listed.

    Double checked by running yum list perl-URI and returned:

    perl-URI.noarch 1.40-2.e16 @anaconda-CentOS-201311272148.x86_64/6.5

    As well as (although uncertain if it is helpful) find / -name "URI.pm" -print :


    /usr/share/perl5/URI.pm

    /usr/lib64/perl5/Apache2/URI.pm

    /usr/lib64/perl5/APR/URI.pm

    Any idea why the URI.pm is not being listed in instmodsh?

    Will check CentOS' forums to see if anyone encountered a similar incident with their Perl modules; just thought of updating you.

    Benjie

  • I think I figured it out.

    you said you were running the stock apache SAM template. I tried it and got similar results.

    The template I tried has the following description:

    This template assesses the overall performance of an Apache web server.

    Prerequisites: Configure the Apache web server to allow itself access to the /server-status page.

    Credentials: SSH account on the web server.

    I applied it to a server with apache running on it and got similar errors when I tested it.

    Solution for me:

    • sudo yum install lwp
    • sudo yum install perl-LWP

    I briefly had it working, and then it stopped.

    I also had to edit the /etc/httpd/conf/httpd.conf file and change the following:

    uncommment

    • ExtendedStatus On

    enable and change the section

    <Location /server-status>

        SetHandler server-status

        Order deny,allow

        Deny from all

    #    Allow from .example.com

        Allow from all

    </Location>

    I know the Allow from all is crude

    Most components now seem to work

  • From the SAM Administrators Guide -> http://www.solarwinds.com/documentation/en/flarehelp/SAM/default.htm#SAM Template Reference/OrionAPMAGTemplateApache.htm

    Configuring Apache to allow access to the server-status page:

    1. Log on to your Apache server using an SSH or telnet client.
    2. Grant yourself root permissions (su root).
    3. Locate the Apache configuration file, typically in /etc/httpd/conf/httpd.conf
      (For more information, see: http://wiki.apache.org/httpd/DistrosDefaultLayout)
    4. Append the following lines to your httpd.conf Apache configuration file, substituting the IP address or host name of your Apache server for localhost. Use localhost only if the Apache server services the loopback interface.

      <Location /server-status>
      SetHandler server-status
      Order Deny,Allow
      Deny from all
      Allow from localhost
      </Location>
      ExtendedStatus On

    1. Restart the Apache server (apachectl graceful).

    If the event a counter returns the following error, you will need to install libwww-perl.

    “Can't locate LWP/UserAgent.pm in @INC ...” error:

    To install libwww-perl., enter the following command:

    cpan LWP::UserAgent
  • To install libwww-perl., enter the following command:

    cpan LWP::UserAgent

    if you use cpan on RedHat variants of Linux, you miss the updates.

    it is better to use "yum install perl-LWP-UserAgent-Determined" to stay up to date.

    I'm sure there is an apt-get equiv package for Debian variants of Linux

  • Hi Chris,

    Thank you for the update; really appreciate your help and taking the time to test/replicate the encountered error message (in the stock Apache SAM template) on your Linux box.

    As advised, will implement the recommended changes on the httpd.conf file and run another test in SAM.

  • Hi aLTeReGo,

    Thank you for your feedback.

    Will implement the suggested changes on the Apache server's httpd.conf file.

    Appreciate the link you've provided for the Apache HTTPd server's default installation layout; it is quite informative. Thanks.

  • Hi Chris & aLTeReGo,

    Just would like to update you that the Apache server on my CentOS is now managed / monitored by SAM.

    Thank you. emoticons_happy.png

  • Hi Chris and aLTeReGo,

    When documenting the changes made on my test server's httpd.conf file prior to the implementing it on our customer's CentOS (for production use), noticed that I forgot to remove the comment '#' from the Deny from all line of the <Location /server-status>.

    Removing the comment (and restarting httpd) resulted to the stock Apache SAM template's component names (namely ServerUptime,etc.) displaying the following message:

    "The return code is different than expected. Testing on node '<CentOS server's IP Address> ' failed with 'Down' status ('Down' might be different if script exits with a different exit code). unable access to localhost".

    However, putting the comment back on (and restarting the httpd) resulted to the component names displaying data and SAM working fine.

    Admittedly not familiar with Apache's configuration directives and was wondering if keeping the comment on the Deny from all (in order to keep SAM running) is advisable? Or in doing so will be a security risk especially that Apache server will be deployed for public Internet use?