IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42931


Ignore:
Timestamp:
Oct 1, 2025, 4:09:43 PM (10 months ago)
Author:
cclin33
Message:

updates for working on ubuntu

Location:
trunk/ippMonitor/czartool
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/czartool/czarpoll.pl

    r42930 r42931  
    1313use List::MoreUtils qw(uniq);
    1414use DateTime;
     15# This tells Perl: “also look in the same directory where this script lives”.
     16use FindBin;
     17use lib "$FindBin::Bin";
    1518
    1619# local classes
     
    390393        # check ippdb host IPP-2338
    391394        print "* Checking ippdb hosts\n";
    392         my @hosts = qw(ipphome2 ipphome3 ippdb01 ippdb05 ippdb06 ippdb09 ippdb11 ippdb12 ippdb13 ippdb14);
    393         if($dbupdate == 1) {check_disk_usage_and_update($czarDb, @hosts);}
     395        my @ippdb_hosts = qw(ipphome2 ipphome3 ippdb01 ippdb05 ippdb06 ippdb09 ippdb11 ippdb12 ippdb13 ippdb14);
     396        if($dbupdate == 1) {check_disk_usage_and_update($czarDb, @ippdb_hosts);}
    394397
    395398        print "* Checking ippdvo hosts\n";
    396         my @hosts = qw(ippdvo00 ippdvo01 ippdvo02 ippdvo03 ippdvo04 ippdvo05 ippdvo06 ippdvo07 ippdvo08 ippdvo09 ippdvo10 ippdvo11 ippdvo12 ippdvo13 ippdvo14 ippdvo15);
    397         if($dbupdate == 1) {check_disk_usage_and_update($czarDb, @hosts);}
     399        my @ippdvo_hosts = qw(ippdvo00 ippdvo01 ippdvo02 ippdvo03 ippdvo04 ippdvo05 ippdvo06 ippdvo07 ippdvo08 ippdvo09 ippdvo10 ippdvo11 ippdvo12 ippdvo13 ippdvo14 ippdvo15);
     400        if($dbupdate == 1) {check_disk_usage_and_update($czarDb, @ippdvo_hosts);}
    398401
    399402        # check pantasks status
     
    632635        print " - Checking $host...\n";
    633636
    634         for my $suffix (0, 1) {
     637        # Determine which suffixes to check
     638        my @suffixes;
     639        if ($host eq 'ippdb06') {
     640            @suffixes = (1);   # only .1
     641        } else {
     642            @suffixes = (0);   # all others only .0
     643        }
     644
     645        foreach my $suffix (@suffixes) {
    635646            my $mount_point = "/export/$host.$suffix";
    636647
    637             # Use SSH to get disk stats
     648            # --- Default values ---
     649            my $total_tb     = 0;
     650            my $used_tb      = 0;
     651            my $available_tb = 0;
     652            my $readable     = 0;
     653            my $writable     = 0;
     654            my $xattr        = 9;
     655
     656            # SSH/df
    638657            my $df_output = `ssh $host df -k $mount_point 2>/dev/null`;
    639658
    640             #if (!$df_output || $df_output !~ /\d/) {
    641             #    warn "Failed to get disk usage for $host on $mount_point\n";
    642             #    next;
    643             #}
    644 
    645             my @lines = split /\n/, $df_output;
    646             my $line = $lines[1] || next;
    647 
    648             my ($filesystem, $blocks, $used, $available, $percent, $mount) = split /\s+/, $line;
    649 
    650             # Convert KB to TB
    651             my $total_tb     = sprintf("%.3f", $blocks    / 1024 / 1024 / 1024 );
    652             my $used_tb      = sprintf("%.3f", $used      / 1024 / 1024 / 1024 );
    653             my $available_tb = sprintf("%.3f", $available / 1024 / 1024 / 1024 );
    654 
    655             my $used_percent      = sprintf("%.3f", $used / $blocks * 100);
    656             my $available_percent = sprintf("%.3f", $available / $blocks * 100);
    657 
    658             my $readable = 1;
    659             my $writable = 1;
    660             my $xattr = 9;
    661 
    662             #print "Mount $mount_point: total=${total_tb}TB, used=${used_tb}TB (${used_percent}%), available=${available_tb}TB (${available_percent}%)\n";
     659            if ($df_output && $df_output =~ /\d/) {
     660                my @lines = split /\n/, $df_output;
     661                my $line = $lines[1];
     662
     663                if ($line) {
     664                    my ($filesystem, $blocks, $used, $available, $percent, $mount) = split /\s+/, $line;
     665
     666                    if ($blocks && $blocks > 0) {
     667                        $total_tb     = sprintf("%.3f", $blocks    / 1024 / 1024 / 1024 );
     668                        $used_tb      = sprintf("%.3f", $used      / 1024 / 1024 / 1024 );
     669                        $available_tb = sprintf("%.3f", $available / 1024 / 1024 / 1024 );
     670
     671                        $readable = 1;
     672                        $writable = 1;
     673                    }
     674                }
     675            } else {
     676                warn " ! Failed to SSH/df $host:$mount_point, defaulting to zeros\n";
     677            }
    663678
    664679            my $host_label = "$host.$suffix";
    665680
    666             if ($host_label =~ /ippdvo/i) {        # case-insensitive match
    667                 $xattr = 8;                        # override for ippdvo hosts
     681            if ($host_label =~ /ippdvo/i) {
     682                $xattr = 8;
    668683            }
    669684
    670             # --- Skip update if total TB < 1 ---
    671             if ($total_tb < 1) {
    672                 warn " ! Skipping $host_label because total TB ($total_tb) < 1\n";
    673                 next;
    674             }
    675 
    676             # Update host in DB
     685            # Update DB
    677686            $czarDb->updateHost($host_label, $total_tb, $available_tb, $used_tb, $readable, $writable, $xattr);
    678687        }
  • trunk/ippMonitor/czartool/czartool/Config.pm

    r41302 r42931  
    66use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    77use POSIX qw/strftime/;
    8 use CGI::Pretty qw[:standard];
     8# use CGI::Pretty qw[:standard];
     9use CGI qw(:standard -utf8);
    910use XML::LibXML;
    1011
  • trunk/ippMonitor/czartool/czartool/DayMetrics.pm

    r38258 r42931  
    66use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    77use POSIX qw/strftime/;
    8 use CGI::Pretty qw[:standard];
     8#use CGI::Pretty qw[:standard];
     9use CGI qw(:standard -utf8);
    910
    1011use czartool::CzarDb;
  • trunk/ippMonitor/czartool/czartool/Metrics.pm

    r38258 r42931  
    66use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    77use POSIX qw/strftime/;
    8 use CGI::Pretty qw[:standard];
     8#use CGI::Pretty qw[:standard];
     9use CGI qw(:standard -utf8);
    910
    1011use czartool::CzarDb;
  • trunk/ippMonitor/czartool/czartool/MetricsIndex.pm

    r38258 r42931  
    66use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    77use POSIX qw/strftime/;
    8 use CGI::Pretty qw[:standard];
     8# use CGI::Pretty qw[:standard];
     9use CGI qw(:standard -utf8);
    910
    1011use czartool::CzarDb;
  • trunk/ippMonitor/czartool/czartool/MultiDayMetrics.pm

    r32093 r42931  
    66use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    77use POSIX qw/strftime/;
    8 use CGI::Pretty qw[:standard];
     8#use CGI::Pretty qw[:standard];
     9use CGI qw(:standard -utf8);
    910
    1011use czartool::CzarDb;
Note: See TracChangeset for help on using the changeset viewer.