Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8046391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:46:17+00:00 2026-06-05T05:46:17+00:00

I was mind altered, and was trying to configure munin plugin on ubuntu server.

  • 0

I was mind altered, and was trying to configure munin plugin on ubuntu server. I pasted Perl code in terminal as bash – and each line of code ran as a command.

Is perl syntax different enough to not have caused any damage or unintended changes to server?

Here is the code (btw, it did create two folders in my home directory that’s why Im worried):

I wonder if I unintentionally messed up something :S

#!/usr/bin/perl
#
# Plugin to monitor the number of accesses to Apache servers. It handles
# a list of ports passed in from a plugin configuration file.
#
# Requirements:
#   - Needs access to http://localhost/server-status?auto (or modify the
#     address for another host). See your apache documentation on how to
#     set up this url in your httpd.conf. Apache needs ExtendedStatus
#     enabled for this plugin to work
#
# Tip: To see if it's already set up correctly, just run this plugin
# with the parameter "autoconf". If you get a "yes", everything should
# work like a charm already.
#
# Parameters supported:
#
#   config
#   autoconf
#
# Configurable variables
#
#   url      - Override default status-url
#   port     - HTTP port numbers
#
#   ssl      - activate SSL (add env.ssl yes in munin plugin configuration)
#   urls     - Override default status-url (SSL)
#   ports    - HTTPS port numbers (SSL)
#
# $Log$
# Revision 1.13  2006/03/07 20:30:00 fra519
# adapt script for Apache-SSL Server.
#
# Revision 1.12  2004/12/10 18:51:43  jimmyo
# linux/apt* has been forced to LANG=C, to get predictable output.
#
# Revision 1.11  2004/12/10 10:47:47  jimmyo
# Change name from ${scale} to ${graph_period}, to be more consistent.
#
# Revision 1.10  2004/12/09 22:12:54  jimmyo
# Added "graph_period" option, to make "graph_sums" usable.
#
# Revision 1.9  2004/09/26 22:14:39  jimmyo
# Changd COUNTER -> DERIVE for some plugins. Set min/max values.
#
# Revision 1.8  2004/05/20 13:57:11  jimmyo
# Set categories to some of the plugins.
#
# Revision 1.7  2004/05/14 21:16:46  jimmyo
# "Upped" som plugins from contrib/manual to auto.
#
# Revision 1.6  2004/04/27 21:32:06  jimmyo
# Clarified the vlabels in the apache-plugins (Deb#238594).
#
# Revision 1.5  2004/04/27 08:46:57  jimmyo
# Fixed broken autoconf in apache-* plugins (Deb#236144).
#
# Revision 1.4  2004/02/18 15:47:35  jimmyo
# The generic/apache_* plugins now have defined max values.
#
# Revision 1.3  2004/02/03 17:17:25  jimmyo
# Generic/apache-plugins have been modified to properly to report the correct autoconf value. Also, bugfixes in _processes and _volume.
#
# Revision 1.2  2004/01/29 18:47:30  jimmyo
# Made plugins apache_* compatible with older versions of LWP::UserAgent (SF#881411).
#
# Revision 1.1  2004/01/02 18:50:00  jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.4  2003/12/18 16:35:33  jimmyo
# fail more gracefully when using uninstalled perl modules.
#
# Revision 1.3  2003/11/07 17:43:16  jimmyo
# Cleanups and log entries
#
#
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf

my $ret = undef;
my $ssl = undef;

if (! eval "require LWP::UserAgent;")
{
    $ret = "LWP::UserAgent not found";
}
if (! eval "require Crypt::SSLeay;" and exists $ENV{'ssl'})
{
    $ssl = "Crypt::SSLeay not found";
}

my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto";
my @PORT = exists $ENV{'port'} ? split(' ', $ENV{'port'}) : (80);

my $URLS = exists $ENV{'urls'} ? $ENV{'urls'} : "https://127.0.0.1:%d/server-status?auto";
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (443);

if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
{
    if ($ret)
    {
        print "no ($ret)\n";
        exit 1;
    }

    if ($ssl) {
        print "no ($ssl)\n";
        exit 1;
    }

    my $ua = LWP::UserAgent->new(timeout => 30);

    my @badports;
    foreach my $port (@PORT) {
        my $url = sprintf $URL, $port;
        my $response = $ua->request(HTTP::Request->new('GET',$url));
        push @badports, $port unless $response->is_success and $response->content =~ /^Total Accesses:/im;
    }
    if (exists $ENV{'ssl'}) {
        foreach my $port (@PORTS) {
            my $url = sprintf $URLS, $port;
            my $response = $ua->request(HTTP::Request->new('GET',$url));
            push @badports, $port unless $response->is_success and $response->content =~ /^Total Accesses:/im;
        }
    }
    if (@badports) {
        print "no (no apache server-status or ExtendedStatus missing on ports @badports)\n";
        exit 1;
    } else {
        print "yes\n";
        exit 0;
    }
}

if ( exists $ARGV[0] and $ARGV[0] eq "config" )
{
    print "graph_title Apache accesses\n";
    print "graph_args --base 1000\n";
    print "graph_vlabel accesses / \${graph_period}\n";
    print "graph_category apache\n";
    foreach my $port (@PORT) {
        print "accesses$port.label port $port\n";
        print "accesses$port.type DERIVE\n";
        print "accesses$port.max 1000000\n";
        print "accesses$port.min 0\n";
    }
    if (exists $ENV{'ssl'}) {
        foreach my $port (@PORTS) {
            print "accesses$port.label port $port\n";
            print "accesses$port.type DERIVE\n";
            print "accesses$port.max 1000000\n";
            print "accesses$port.min 0\n";
        }
    }
    exit 0;
}

my $ua = LWP::UserAgent->new(timeout => 30);

foreach my $port (@PORT) {
    my $url = sprintf $URL, $port;
    my $response = $ua->request(HTTP::Request->new('GET',$url));
    if ($response->content =~ /^Total Accesses:\s+(.+)$/im) {
        print "accesses$port.value $1\n";
    } else {
        print "accesses$port.value U\n";
    }
}

if (exists $ENV{'ssl'}) {
    foreach my $port (@PORTS) {
        my $url = sprintf $URLS, $port;
        my $response = $ua->request(HTTP::Request->new('GET',$url));
        if ($response->content =~ /^Total Accesses:\s+(.+)$/im) {
            print "accesses$port.value $1\n";
        } else {
            print "accesses$port.value U\n";
        }
    }
}
# vim:syntax=perl
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:46:19+00:00Added an answer on June 5, 2026 at 5:46 am

    The comments will be ignored. I originally meant the Perl comments. Looks like I will have to ignore downvotes as I help you out here 🙂

    I have pasted the command into a bash shell of a vanilla Ubuntu desktop install. Downvoters will (not unreasonably) think this a bad idea for a whole host of reasons.

    My attitude is I have a spare Ubuntu Virtual Machine available to test this so I am happy to destroy it if anything bad happens to it. A cursory visual inspection of the code reveals the following.

    Do you have a command call my? If not then the following code is clear of mines.

    my $ret = undef;
    my $ssl = undef;
    
    if (! eval "require LWP::UserAgent;")
    
    
    if (! eval "require Crypt::SSLeay;" and exists $ENV{'ssl'})
    {
        $ssl = "Crypt::SSLeay not found";
    }
    
    my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto";
    my @PORT = exists $ENV{'port'} ? split(' ', $ENV{'port'}) : (80);
    
    my $URLS = exists $ENV{'urls'} ? $ENV{'urls'} : "https://127.0.0.1:%d/server-status?auto";
    my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (443);
    

    Following on we have

    if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
    {
      if ($ret)
      {
          print "no ($ret)\n";
          exit 1;
      }
    
    if ($ssl) {
        print "no ($ssl)\n";
        exit 1;
    

    The exit 1 would have taken you out of the current shell.

    Assuming that you were in a sub shell more analysis to follow …

    So here is the interesting code.

    rkielty@ubuntu:~$ foreach my $port (@PORT) {
    bash: syntax error near unexpected token `('
    

    Clear of mines

    rkielty@ubuntu:~$     push @badports, $port unless $response->is_success and $response->content =~ /^Total Accesses:/im;
    The program 'push' is currently not installed.  You can install it by typing:
    sudo apt-get install heimdal-clients
    

    Now here you will have to check to see if you have a push program and see what it does.

    run which push then man or info push

    rkielty@ubuntu:~$         print "no (no apache server-status or ExtendedStatus missing on ports @badports)\n";
    Warning: unknown mime-type for "no (no apache server-status or ExtendedStatus missing on ports @badports)\n" -- using "application/octet-stream"
    Error: no such file "no (no apache server-status or ExtendedStatus missing on ports @badports)\n"
    

    So here we are protected by the error.

    Following on from there there are two invocations of exit.

    So it’s looks like you probably should be fine.

    The caveats are that you need to ensure that there are no programs called my or push on your system

    I’m not sure how the directories would have been created and you should probably investigate that further. Remember they may not have been caused by this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get my mind around google protobuf. I found some implementation of protobuf
Would anyone mind having a look at these bits of code and see if
I freaking loosing my mind on this: I have this code: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name =
I am loosing my mind trying to build my NDK project from eclipse using
I'm trying to replace a Keyword Analyser based Lucene.NET index with an SQL Server
I'm losing my mind over trying to get Facebook SDK for iPhone to upload
I'm having a mind blowing problem using WCF 4.0 RESTful service. I am trying
I need some mind reading here, since I am trying to do what I
I have in mind a design problem that does not look like complex, but
Having in mind that there are thousands of news in a table called sn_news

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.