IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42798 for trunk/ippMonitor


Ignore:
Timestamp:
May 1, 2025, 11:40:03 AM (15 months ago)
Author:
cclin33
Message:

add new function to monitor ippdb disk

File:
1 edited

Legend:

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

    r41302 r42798  
    380380        }
    381381
     382        # check ippdb host IPP-2338
     383        print "* Checking ippdb hosts\n";
     384        my @hosts = qw(ipphome0 ipphome1 ippdb01 ippdb05 ippdb06 ippdb09 ippdb11 ippdb12 ippdb13 ippdb14);
     385        if($dbupdate == 1) {check_disk_usage_and_update($czarDb, @hosts);}
     386
    382387        # check pantasks status
    383388        if($dbupdate == 1) {updateServerStatus();}
     
    604609}
    605610
     611###########################################################################
     612#
     613# Loops through given host and update to the host list
     614#
     615###########################################################################
     616sub check_disk_usage_and_update {
     617    my ($czarDb, @hosts) = @_;
     618
     619    foreach my $host (@hosts) {
     620        print "Checking $host...\n";
     621
     622        for my $suffix (0, 1) {
     623            my $mount_point = "/export/$host.$suffix";
     624
     625            # Use SSH to get disk stats
     626            my $df_output = `ssh $host df -k $mount_point 2>/dev/null`;
     627
     628            #if (!$df_output || $df_output !~ /\d/) {
     629            #    warn "Failed to get disk usage for $host on $mount_point\n";
     630            #    next;
     631            #}
     632
     633            my @lines = split /\n/, $df_output;
     634            my $line = $lines[1] || next;
     635
     636            my ($filesystem, $blocks, $used, $available, $percent, $mount) = split /\s+/, $line;
     637
     638            # Convert KB to TB
     639            my $total_tb     = sprintf("%.1f", $blocks    / 1024 / 1024 / 1024);
     640            my $used_tb      = sprintf("%.1f", $used      / 1024 / 1024 / 1024);
     641            my $available_tb = sprintf("%.1f", $available / 1024 / 1024 / 1024);
     642
     643            my $used_percent      = sprintf("%.3f", $used / $blocks * 100);
     644            my $available_percent = sprintf("%.3f", $available / $blocks * 100);
     645
     646            my $readable = 1;
     647            my $writable = 1;
     648
     649            #print "Mount $mount_point: total=${total_tb}TB, used=${used_tb}TB (${used_percent}%), available=${available_tb}TB (${available_percent}%)\n";
     650
     651            # Example: ippdb01.0(3.5T)
     652            my $host_label = "$host.$suffix(${total_tb}T)";
     653            $czarDb->updateHost($host_label, 100, $available_percent, $used_percent, $readable, $writable);
     654        }
     655    }
     656}
Note: See TracChangeset for help on using the changeset viewer.