Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

fix(): print all error messages on STDERR #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions deb/scripts/nvidia_smi_stats
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use IPC::Open3;
my $fnret = smi_stats();
if(!ok($fnret) )
{
print "Error with nvidia smi stats \n";
print STDERR "Error with nvidia smi stats \n";
}
else
{
Expand All @@ -19,7 +19,7 @@ sub smi_stats
my $fnret = execute("/usr/bin/nvidia-smi", "--query-gpu=gpu_name,gpu_uuid,index,memory.total,memory.used,utilization.memory,utilization.gpu,encoder.stats.sessionCount,temperature.gpu,power.draw", "--format=csv,noheader,nounits");
if ( $fnret->{status} != 100 )
{
print "$fnret->{msg} \n";
print STDERR "$fnret->{msg} \n";
return { status => 500, msg => "nvidia-smi error: $fnret->{msg}" };
}
else
Expand Down Expand Up @@ -61,7 +61,7 @@ sub ok
}
elsif (ref $arg eq 'HASH' and $arg->{status} eq 500 and defined($arg->{msg}))
{
print $arg->{msg};
print STDERR $arg->{msg};
}
return 0;
}
Expand Down
48 changes: 24 additions & 24 deletions deb/scripts/rtmHardware.pl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sub rtmHardware
}
else
{
print "Error with CPUInfo \n";
print STDERR "Error with CPUInfo \n";
}
$fnret = getSgPaths();
if( ok($fnret) )
Expand All @@ -58,7 +58,7 @@ sub rtmHardware
}
else
{
print "Error with kernel_oops \n";
print STDERR "Error with kernel_oops \n";
}
$fnret = os();
if (ok($fnret))
Expand All @@ -67,7 +67,7 @@ sub rtmHardware
}
else
{
print "Error with os \n";
print STDERR "Error with os \n";
}
$fnret = motherboard();
if (ok($fnret))
Expand All @@ -76,7 +76,7 @@ sub rtmHardware
}
else
{
print "Error with motherboard \n";
print STDERR "Error with motherboard \n";
}
$fnret = disk();
if (ok($fnret))
Expand All @@ -85,7 +85,7 @@ sub rtmHardware
}
else
{
print "Error with disk \n";
print STDERR "Error with disk \n";
}
$fnret = lspci();
if (ok($fnret))
Expand All @@ -94,7 +94,7 @@ sub rtmHardware
}
else
{
print "Error with lspci \n";
print STDERR "Error with lspci \n";
}
}

Expand Down Expand Up @@ -129,7 +129,7 @@ sub CPUInfo
}
else
{
print "Cannot open /proc/cpuinfo";
print STDERR "Cannot open /proc/cpuinfo";
return {status => 500, msg => "Cannot open /proc/loadavg" };
}
}
Expand All @@ -140,7 +140,7 @@ sub kernel
my $fnret = execute('uname -r');
if ( $fnret->{status} != 100 or !defined($fnret->{value}[0]))
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "uname error: ".$fnret->{msg}};
}
else
Expand All @@ -151,7 +151,7 @@ sub kernel
$fnret = execute('uname -v');
if ( $fnret->{status} != 100 or !defined($fnret->{value}[0]))
{
print $fnret->{msg}. "\n";
print STDERR $fnret->{msg}. "\n";
return { status => 500, msg => "uname error: ".$fnret->{msg} };
}
else
Expand All @@ -166,7 +166,7 @@ sub os
my $fnret =execute("lsb_release","-a");
if ( $fnret->{status} != 100 )
{
print "Error ".$fnret->{msg}." \n";
print STDERR "Error ".$fnret->{msg}." \n";
# maybe red hat:
if (open(my $fh, '<', "/etc/redhat-release"))
{
Expand All @@ -179,7 +179,7 @@ sub os
}
else
{
print "Cannot open /etc/redhat-release";
print STDERR "Cannot open /etc/redhat-release";
return {status => 500, msg => "Cannot open /etc/redhat-release" };
}
}
Expand Down Expand Up @@ -210,7 +210,7 @@ sub motherboard
my $fnret = execute('dmidecode');
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "dmidecode error: ".$fnret->{msg}};
}
else
Expand Down Expand Up @@ -280,7 +280,7 @@ sub disk
my $fnret = execute('lsblk -r --nodeps -o name 2>/dev/null');
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "lsblk error: ".$fnret->{msg}};
}
else
Expand Down Expand Up @@ -309,7 +309,7 @@ sub disk
my $fnret = execute("smartctl -a $diskSmart 2>/dev/null");
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
next;
}
else
Expand Down Expand Up @@ -438,7 +438,7 @@ sub disk
my $fnret= execute("hddtemp $diskSmart 2>/dev/null");
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
next;
}
elsif (defined $fnret->{value}[0])
Expand Down Expand Up @@ -504,7 +504,7 @@ sub lspci
my $fnret = execute("lspci -n 2>/dev/null");
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "lspci error: ".$fnret->{msg}};
}
else
Expand Down Expand Up @@ -537,7 +537,7 @@ sub getSectorSize {
my $fnret = execute("blockdev --getss $disk");
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "Error: unable to get sector size for device $disk"};
}
elsif (defined($fnret->{value}[0]))
Expand Down Expand Up @@ -1202,7 +1202,7 @@ sub getSgPaths
my $fnret = execute("lsscsi -tg 2>/dev/null");
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "Unable to gather sg paths ".$fnret->{msg}};
}
else
Expand Down Expand Up @@ -1239,7 +1239,7 @@ sub getSupportedLogPages
my $fnret = execute("sg_logs -x $devPath 2>/dev/null");
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "Unable to get sg logs pages ".$fnret->{msg}};
}
else
Expand Down Expand Up @@ -1279,7 +1279,7 @@ sub getGenericLogPage
my $fnret = execute("sg_logs -x --page $page $devPath");
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "Unable to get sg logs requested page ".$fnret->{msg}};
}
else
Expand Down Expand Up @@ -1347,7 +1347,7 @@ sub getBackgroundScanResultsLogPage
my $fnret = execute("sg_logs -x --page 0x15 $devPath 2>/dev/null");
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "Unable to get background scan page: ".$fnret->{msg}."\n"};
}
else
Expand Down Expand Up @@ -1419,7 +1419,7 @@ sub getDmesg
my $fnret = execute('/bin/dmesg -T | tail -n 15000');
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "dmesg error: ".$fnret->{msg}};
}
else
Expand Down Expand Up @@ -1479,7 +1479,7 @@ sub iostatCounters
my $fnret = execute("/usr/bin/iostat -d -x $devPath");
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "iostat error: ".$fnret->{msg}};
}
else
Expand Down Expand Up @@ -1960,7 +1960,7 @@ sub ok
}
elsif (ref $arg eq 'HASH' and $arg->{status} eq 500 and defined($arg->{msg}))
{
print $arg->{msg};
print STDERR $arg->{msg};
}
return 0;
}
Expand Down
26 changes: 13 additions & 13 deletions deb/scripts/rtmHourly.pl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sub systemInfo
}
else
{
print "Error with processes \n";
print STDERR "Error with processes \n";
}
$fnret = _getTopProcess();
if (ok($fnret))
Expand All @@ -32,7 +32,7 @@ sub systemInfo
}
else
{
print "Error with getTopProcess \n";
print STDERR "Error with getTopProcess \n";
}
$fnret = _getPortsAndInfos();
if (ok($fnret))
Expand All @@ -41,7 +41,7 @@ sub systemInfo
}
else
{
print "Error with getPortsAndInfos \n";
print STDERR "Error with getPortsAndInfos \n";
}
$fnret = uptime();
if (ok($fnret))
Expand All @@ -50,7 +50,7 @@ sub systemInfo
}
else
{
print "Error with uptime \n";
print STDERR "Error with uptime \n";
}

# hostname
Expand All @@ -71,7 +71,7 @@ sub processes
my $fnret = execute('/bin/ps --no-headers -C noderig,beamium -o sess | sort -n | uniq');
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}." \n";
print STDERR $fnret->{msg}." \n";
return { status => 500, msg => "ps error: ".$fnret->{msg}." \n" };
}
else
Expand All @@ -80,7 +80,7 @@ sub processes
$fnret = execute('/bin/ps --no-headers -A -o sess,state,command');
if( $fnret->{status} != 100 )
{
print "ps error: ".$fnret->{msg}."\n";
print STDERR "ps error: ".$fnret->{msg}."\n";
return { status => 500, msg => "ps error: ".$fnret->{msg}." \n" };
}
else
Expand Down Expand Up @@ -112,7 +112,7 @@ sub _getTopProcess
my $fnret = execute('/bin/ps -A -o vsz,cmd --sort=-vsz --no-headers | head -n 7 | grep -vE "[0123456789]+[ ]/usr/bin/(noderig|beamium)"');
if ( $fnret->{status} != 100 )
{
print "ps error: ".$fnret->{msg}." \n";
print STDERR "ps error: ".$fnret->{msg}." \n";
return { status => 500, msg => "ps error: ".$fnret->{msg}."\n" };
}
else
Expand Down Expand Up @@ -143,7 +143,7 @@ sub _getPortsAndInfos
my $fnret = execute('/bin/netstat -tlenp | grep LISTEN | grep -v \'tcp6\' | awk \'{print $4"|"$9}\'');
if ( $fnret->{status} != 100 )
{
print $fnret->{msg}."\n";
print STDERR $fnret->{msg}."\n";
return { status => 500, msg => "netstat error: ".$fnret->{msg}."\n" };
}
else
Expand Down Expand Up @@ -212,21 +212,21 @@ sub _getPortsAndInfos
}
else
{
print "Could not open /proc/$pid/status";
print STDERR "Could not open /proc/$pid/status";
return {status=>500};
}
}
else
{
print "Could not open /proc/$pid/cmdline";
print STDERR "Could not open /proc/$pid/cmdline";
return {status=>500};
}
}
return {status=>100};
}
else
{
print "Could not open /etc/passwd";
print STDERR "Could not open /etc/passwd";
return {status=>500};
}
}
Expand All @@ -245,7 +245,7 @@ sub uptime
}
else
{
print "Cannot open /proc/uptime";
print STDERR "Cannot open /proc/uptime";
return {status => 500, msg => "Cannot open /proc/loadavg" };
}
}
Expand Down Expand Up @@ -299,7 +299,7 @@ sub ok
}
elsif (ref $arg eq 'HASH' and $arg->{status} eq 500 and defined($arg->{msg}))
{
print $arg->{msg};
print STDERR $arg->{msg};
}
return 0;
}
Expand Down
Loading