Quantcast
Channel: THWACK: All Content - Server & Application Monitor
Viewing all articles
Browse latest Browse all 12281

Linux script monitor

$
0
0

I am trying to write a script (not a script guy) for Linux servers (not a Linux guy either) that will return the system uptime for a server.  I want to use 1.3.6.1.2.1.1.3.0 which is a timetick OID.  I found the following file in the C:\Program Files (x86)\SolarWinds\Orion\APM\SampleScriptMonitors\LinuxScripts directory but cannot get it to work.

 

When I run it I get this:

Message.Statistic:

 

Server Uptime at host "c111bexhdd078": (9023307) 1 day, 1:03:53.07

 

Statistic.Statistic:NaN
It appears that "something" is automatically reformating the timeticks into DateTime format which is prevent Orion from seeing it as an acceptable statistic.  I have hit a wall on this and am looking for some help

 

#!/usr/bin/perl

 

#

#

# Copyright \xbf 1999-2008 SolarWinds, Inc. All Rights Reserved.

#

#

 

if (@ARGV[0] =~ /\bhelp\b/)

{

        print "ServerUptime.pl SNMPver community hostname\n";

        print "SNMPver - version of SNMP protocol\n";

        print "community - community name of SNMP protocol\n";

        print "hostname - Target host\n";

        exit 1;

}

 

# Get hostname and trim newline

 

$localhost = `hostname`;

 

$localhost =~ s/\s*$//g;

 

$hostname  = shift || $localhost;

$community = shift || "public";

$version = shift || "v1";

 

$results =  "";

$MIB= "1.3.6.1.2.1.1.3.0";

$outres = "snmpget -$version -c $community $hostname $MIB |";

open(OUTSTD,$outres) || die "Unable read pipe\n";

while ($line = <OUTSTD>) {

             $indval = index($line,"=");

             $indval = index($line,":",$indval);

             $val = substr($line,$indval+1,length($line) - $indval);

             $val =~ s/[\/\n]//g;

             print "Message: Server Uptime at host \"$hostname\": $val\n";

             print "Statistic: $val\n";

         exit 0;

}

print "Statistic: 0\n";

exit 1;


Viewing all articles
Browse latest Browse all 12281

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>