FAQ
Hi
I have a database with my servers details in .. I would like to write
a scripts to get the servers log on info ssh to the box and get basic
info using the following

hostname
cat /etc/issue
cat /proc/cpuinfo | grep "model name"
cat /proc/meminfo | grep "MemTotal"
uname -s -r
squid -v
/usr/sbin/sendmail -v -d0.1

Then save the info to the database.

Any tips on doing this ?

Search Discussions

  • Jeff Pang at Sep 9, 2008 at 8:07 am

    2008/9/9 Gregory Machin <gdm@linuxpro.co.za>:
    Hi
    I have a database with my servers details in .. I would like to write
    a scripts to get the servers log on info ssh to the box and get basic
    info using the following

    hostname
    cat /etc/issue
    cat /proc/cpuinfo | grep "model name"
    cat /proc/meminfo | grep "MemTotal"
    uname -s -r
    squid -v
    /usr/sbin/sendmail -v -d0.1

    Then save the info to the database.
    From my thought, you can write a script on that host, which should
    update the database for the info you needed, and run it by crontab.

    If you really need to do a ssh operation in Perl, see "perldoc Net::SSH".
    For database oepration, see "perldoc DBI".
  • Gregory Machin at Sep 9, 2008 at 12:56 pm
    Thanks will look into those .
    On Tue, Sep 9, 2008 at 10:07 AM, Jeff Pang wrote:
    2008/9/9 Gregory Machin <gdm@linuxpro.co.za>:
    Hi
    I have a database with my servers details in .. I would like to write
    a scripts to get the servers log on info ssh to the box and get basic
    info using the following

    hostname
    cat /etc/issue
    cat /proc/cpuinfo | grep "model name"
    cat /proc/meminfo | grep "MemTotal"
    uname -s -r
    squid -v
    /usr/sbin/sendmail -v -d0.1

    Then save the info to the database.
    From my thought, you can write a script on that host, which should
    update the database for the info you needed, and run it by crontab.

    If you really need to do a ssh operation in Perl, see "perldoc Net::SSH".
    For database oepration, see "perldoc DBI".
  • Juan Pablo Feria Gomez at Sep 10, 2008 at 3:37 pm

    If you really need to do a ssh operation in Perl, see "perldoc Net::SSH".
    For database oepration, see "perldoc DBI".
    Expect-perl can be another useful tool to record each program response...
  • Ignacio at Sep 12, 2008 at 2:29 am

    On Sep 9, 3:36 am, g...@linuxpro.co.za (Gregory Machin) wrote:
    Hi
    I have a database with my servers details in .. I would like to write
    a scripts to get the servers log on info ssh to the box and get basic
    info using the following

    hostname
    cat /etc/issue
    cat /proc/cpuinfo | grep "model name"
    cat /proc/meminfo | grep "MemTotal"
    uname -s -r
    squid -v
    /usr/sbin/sendmail -v -d0.1

    Then save the info to the database.

    Any tips on doing this ?
    Instead of using ssh yo could create a perl script on a webserver that
    runs those commands and show them as a webpage, thttpd should work.
  • Zentara at Sep 12, 2008 at 1:27 pm

    On Thu, 11 Sep 2008 19:28:35 -0700 (PDT), rastapoulous@gmail.com (Ignacio) wrote:
    On Sep 9, 3:36 am, g...@linuxpro.co.za (Gregory Machin) wrote:
    Hi
    I have a database with my servers details in .. I would like to write
    a scripts to get the servers log on info ssh to the box and get basic
    info using the following

    hostname
    cat /etc/issue
    cat /proc/cpuinfo | grep "model name"
    cat /proc/meminfo | grep "MemTotal"
    uname -s -r
    squid -v
    /usr/sbin/sendmail -v -d0.1

    Then save the info to the database.

    Any tips on doing this ?
    Instead of using ssh yo could create a perl script on a webserver that
    runs those commands and show them as a webpage, thttpd should work.
    You should switch to Net::SSH2 if possible and use it's shell()

    #!/usr/bin/perl
    use warnings;
    use strict;
    use Net::SSH2;

    # assuming a user named 'z' for demonstration
    # connecting to localhost, so you need your sshd running

    # see maillist archives at
    # http://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users
    # for deeper discussions

    my $ssh2 = Net::SSH2->new();
    $ssh2->connect('localhost') or die "Unable to connect Host $@ \n";
    $ssh2->auth_password('z','zpass') or die "Unable to login $@ \n";

    #shell use
    my $chan = $ssh2->channel();
    $chan->blocking(0);
    $chan->shell();
    print $chan "ls -la\n";
    print "LINE : $_" while <$chan>;

    print $chan "who\n";
    print "LINE : $_" while <$chan>;

    print $chan "date\n";
    print "LINE : $_" while <$chan>;


    $chan->close;
    __END__






    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/Remember_How_Lucky_You_Are.html

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedSep 9, '08 at 7:37a
activeSep 12, '08 at 1:27p
posts6
users5
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase