IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42923


Ignore:
Timestamp:
Sep 11, 2025, 12:59:29 PM (8 months ago)
Author:
cclin33
Message:

update czartool

Location:
trunk/ippMonitor
Files:
6 edited

Legend:

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

    r42921 r42923  
    260260        $pantasks->getServerStatus($server,'gpc1', \$alive, \$running, \$pan_host);
    261261        $czarDb->updateServerStatusLive($server,'gpc1', $alive, $running, $pan_host);
    262         print "Server: $server | Telescope: gpc1 | Alive: $alive | Running: $running | Host: " . (defined $pan_host ? $pan_host : "undef") . "\n";
     262        #print "Server: $server | Telescope: gpc1 | Alive: $alive | Running: $running | Host: " . (defined $pan_host ? $pan_host : "undef") . "\n";
    263263        # For gpc2
    264264        $pantasks->getServerStatus($server,'gpc2', \$alive, \$running, \$pan_host);
    265265        $czarDb->updateServerStatusLive($server,'gpc2', $alive, $running, $pan_host);
    266         print "Server: $server | Telescope: gpc2 | Alive: $alive | Running: $running | Host: " . (defined $pan_host ? $pan_host : "undef") . "\n";
     266        #print "Server: $server | Telescope: gpc2 | Alive: $alive | Running: $running | Host: " . (defined $pan_host ? $pan_host : "undef") . "\n";
    267267   }
    268268}
     
    318318        if($timediff > 120.) {
    319319            print "There is no recent Czarpoll iteration\n";
    320             print "* Updating database entries*\n";
     320            print "== Updating database entries ==\n";
    321321            $dbupdate = 1;
    322322        } else {
    323323            print "There is a recent Czarpoll iteration already made ($timediff sec ago)\n";
    324             print "* Skipping database queries and entries\n";
     324            print "== Skipping database queries and entries ==\n";
    325325            $dbupdate = 0;
    326326        }
     
    390390        # check ippdb host IPP-2338
    391391        print "* Checking ippdb hosts\n";
    392         my @hosts = qw(ipphome0 ipphome1 ippdb01 ippdb05 ippdb06 ippdb09 ippdb11 ippdb12 ippdb13 ippdb14);
     392        my @hosts = qw(ipphome2 ipphome3 ippdb01 ippdb05 ippdb06 ippdb09 ippdb11 ippdb12 ippdb13 ippdb14);
    393393        if($dbupdate == 1) {check_disk_usage_and_update($czarDb, @hosts);}
    394394
     
    626626
    627627    foreach my $host (@hosts) {
    628         print "Checking $host...\n";
     628        print " - Checking $host...\n";
    629629
    630630        for my $suffix (0, 1) {
     
    654654            my $readable = 1;
    655655            my $writable = 1;
    656             my $xattr = 0;
     656            my $xattr = 9;
    657657
    658658            #print "Mount $mount_point: total=${total_tb}TB, used=${used_tb}TB (${used_percent}%), available=${available_tb}TB (${available_percent}%)\n";
    659659
    660             # Example: ippdb01.0(3.5T)
    661             #my $host_label = "$host.$suffix(${total_tb}T)";
    662660            my $host_label = "$host.$suffix";
     661
     662            # --- Skip update if total TB < 1 ---
     663            if ($total_tb < 1) {
     664                warn " ! Skipping $host_label because total TB ($total_tb) < 1\n";
     665                next;
     666            }
     667
     668            # Update host in DB
    663669            $czarDb->updateHost($host_label, $total_tb, $available_tb, $used_tb, $readable, $writable, $xattr);
    664670        }
  • trunk/ippMonitor/czartool/czartool/CzarDb.pm

    r42921 r42923  
    175175###########################################################################
    176176sub updateServerStatusLive {
     177
    177178    my ($self, $server,$telescope, $alive, $running, $pan_host) = @_;
    178179
    179     my $query = $self->{_db}->prepare(<<SQL);
    180     DELETE FROM live_servers where timestamp < CURRENT_TIMESTAMP - INTERVAL 12 hour;
    181 SQL
    182        $query->execute;
    183 
    184     $query = $self->{_db}->prepare(<<SQL);
    185     INSERT INTO live_servers
    186         (server,telescope, alive, running, host)
    187         VALUES
    188         ('$server','$telescope', $alive, $running, '$pan_host');
    189 SQL
    190        $query->execute;
     180    # --- Provide defaults if undefined ---
     181    $server    = defined $server    ? $server    : '';  # empty string if undef
     182    $telescope = defined $telescope ? $telescope : '';  # empty string if undef
     183    $alive     = defined $alive     ? $alive     : 0;   # default 0 if undef
     184    $running   = defined $running   ? $running   : 0;   # default 0 if undef
     185    $pan_host  = defined $pan_host  ? $pan_host  : '';  # empty string if undef
     186
     187    ## Debug print so you can see the values
     188    #warn sprintf(
     189    #    "server=%s telescope=%s alive=%s running=%s pan_host=%s\n",
     190    #    $server, $telescope, $alive, $running, $pan_host
     191    #);
     192
     193    # --- Delete old records ---
     194    my $query = $self->{_db}->prepare(
     195        'DELETE FROM live_servers WHERE timestamp < CURRENT_TIMESTAMP - INTERVAL 12 HOUR'
     196    );
     197    $query->execute or die $query->errstr;
     198
     199    $query = $self->{_db}->prepare(
     200        'INSERT INTO live_servers (server, telescope, alive, running, host)
     201         VALUES (?, ?, ?, ?, ?)'
     202    );
     203    $query->execute($server, $telescope, $alive, $running, $pan_host);
     204
    191205}
    192206
  • trunk/ippMonitor/czartool/czartool/Nebulous.pm

    r42921 r42923  
    122122
    123123            $self->getReadableWritableStatus($1, \$readable, \$writable, \$xattr);
    124             print "Host: $1, Readable: $readable, Writable: $writable, Xattr: $xattr\n";
     124            #print "Host: $1, Readable: $readable, Writable: $writable, Xattr: $xattr\n";
    125125
    126126
  • trunk/ippMonitor/czartool/czartool/Pantasks.pm

    r42858 r42923  
    109109    my $today = sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day);
    110110
    111     print "stdscience : $ipphome/stdscience/ptolemy.rc\n";
     111    #print "stdscience : $ipphome/stdscience/ptolemy.rc\n";
    112112    my @cmdOut = `echo "ns.show.dates;quit" | pantasks_client -c $ipphome/stdscience/ptolemy.rc 2>&1`;
    113113    my $line;
  • trunk/ippMonitor/raw/czartool_labels.php

    r42922 r42923  
    18271827    $start = microtime(true);
    18281828
    1829     echo "<script type=\"text/javascript\" src=\"loader.js\"></script>";
    1830     echo "<br><div class=\"chartWithOverlay\" style=\"position: relative; width: 100%\">";
    1831     echo "  <div id=\"disk_div\" style=\"width:100%; height:5000px\"></div>";
    1832     echo "  <div class=\"overlay\" style=\"position: absolute; width: 100px; top: 50px; right: 20px;\">";
    1833     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: lightgreen\"><center>Free</div>";
    1834     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: yellow\"><center>Used</div>";
    1835     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: pink\"><center>> 97% limit</div>";
    1836     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: lightgrey\"><center>Down | Repair</div>";
    1837     echo "    <div style=\"font-size: 12px; height: 14px; border: 1px solid; background-color: white\"><center>Offline</div>";
    1838     echo "  </div>";
    1839     echo "</div>";
    18401829
    18411830    // Set environment variables
     
    19431932                    legend: { position: 'none', alignment: 'end', maxLines: 3 },
    19441933                    hAxis: { title: 'Space (TB)', gridlines: {count: 20} },
    1945                     vAxis: { textStyle: {fontSize: 14}, format: 'string',  textPosition: 'in', direction: 1},
     1934                    vAxis: { textStyle: {fontSize: 15}, format: 'string',  textPosition: 'in', direction: 1},
    19461935                    bar: { groupWidth: '95%' },
    19471936                    chartArea: {left:40, top:50, right:20, bottom:40},
     
    19551944            }
    19561945          </script>";
     1946
     1947echo "<script type='text/javascript' src='loader.js'></script>
     1948<br>
     1949<div class='chartWithOverlay' style='position: relative; width: 100%'>
     1950
     1951    <div id='disk_div' style='width:100%; height:5000px'></div>
     1952
     1953    <div class='overlay' style='position: absolute; width:160px; top:50px; right:30px; font-family:Arial, sans-serif;'>
     1954
     1955      <div style='font-size:15px; border:1px solid #888; background-color:lightgreen; color:black; text-align:center; margin-bottom:1px;'>Free</div>
     1956      <div style='font-size:15px; border:1px solid #888; background-color:yellow    ; color:black; text-align:center; margin-bottom:1px;'>Used</div>
     1957      <div style='font-size:15px; border:1px solid #888; background-color:pink      ; color:black; text-align:center; margin-bottom:1px;'>97% Usage</div>
     1958      <div style='font-size:15px; border:1px solid #888; background-color:lightgrey ; color:black; text-align:center; margin-bottom:1px;'>Down/Repair</div>
     1959      <div style='font-size:15px; border:1px solid #888; background-color:white     ; color:black; text-align:center; margin-bottom:1px;'>Offline</div>
     1960      <div style='font-size:15px; border:1px solid #888; background-color:#42a5f5   ; color:white; text-align:center; margin-bottom:1px;'>
     1961        <a href='https://atrcganglia.ifa.hawaii.edu/' target='_blank' style='text-decoration:none; color:white; font-weight:bold;'>ATRC ganglia</a>
     1962      </div>
     1963
     1964    </div>
     1965
     1966</div>";
    19571967
    19581968    $total_time = round(microtime(true) - $start, 3);
  • trunk/ippMonitor/raw/storage.php

    r42922 r42923  
    5858    exec("neb-host |cut -b 17-30,86-", $hostnoteall);
    5959
    60     $sql = "SELECT host, format(total, 2), format(available, 2), format(used, 2), writable, readable, format(used/total*100,3) as ratio FROM hosts where xattr <> 3 ORDER BY CASE WHEN ROUND(used/total*100,3) = 100 THEN 0 ELSE 1 END, CASE WHEN host LIKE '%\_bck.0' THEN 1 ELSE 0 END, host;";
     60    $sql = "SELECT host, format(total, 2), format(available, 2), format(used, 2), writable, readable, format(used/total*100,3) as ratio FROM hosts where xattr <> 3 ORDER BY CASE WHEN ROUND(used/total*100,3) = 100 THEN 0 ELSE 1 END, xattr, host;";
    6161    $qry = $db->query($sql);
    6262
Note: See TracChangeset for help on using the changeset viewer.