Changeset 42858 for trunk/ippMonitor/raw/czartool_labels.php
- Timestamp:
- May 13, 2025, 1:13:09 PM (14 months ago)
- File:
-
- 1 edited
-
trunk/ippMonitor/raw/czartool_labels.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippMonitor/raw/czartool_labels.php
r42794 r42858 266 266 $start = microtime(true); 267 267 echo "<tr>"; 268 createTableTitle("Database status (update fix log <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Replication_Issues\"><font color=\"blue\">here</a>)", 2);268 createTableTitle("Database status (update fix log <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Replication_Issues\"><font color=\"blue\">here</a>)", 3); 269 269 270 270 echo "<tr>"; 271 271 createTableColumnHeader("Database"); 272 createTableColumnHeader("Status (sec behind master)"); 272 createTableColumnHeader("disk (TB)"); 273 createTableColumnHeader("Status"); 273 274 // gpc dbs 274 275 showDatabaseStatus($HOST_GPC1, $USER_GPC1, $PASSWORD_GPC1, $LABEL_GPC1); … … 287 288 288 289 // end time 289 echo "<tr><th colspan= 2>";290 echo "<tr><th colspan=3>"; 290 291 $total_time = round((microtime(true) - $start), 3); 291 292 echo "loading in $total_time seconds."; … … 375 376 echo getSpaces($czardb); 376 377 # storage plot 377 echo getHosts($czardb);378 echo getHosts($czardb); 378 379 379 380 # timer for main page end … … 1252 1253 echo $table; 1253 1254 echo "<tr>"; 1254 createTableTitle("Pantasks server status", 3);1255 createTableTitle("Pantasks server status", 4); 1255 1256 echo "<tr>"; 1256 1257 1257 1258 // Define column headers in an array for flexibility 1258 $columnHeaders = array("Server", " Alive?", "Running?");1259 $columnHeaders = array("Server", "Host", "Alive?", "Running?"); 1259 1260 foreach ($columnHeaders as $header) { 1260 1261 createTableColumnHeader($header); … … 1263 1264 1264 1265 foreach ($servers as &$server) { 1265 getServerStatus($db,$proj, $server, $alive, $running );1266 getServerStatus($db,$proj, $server, $alive, $running, $host); 1266 1267 1267 1268 echo "<tr>\n"; … … 1275 1276 ."&stage=".$selectedStage 1276 1277 ."&plottype=".$plotType; 1278 // ganglia 1279 $link2 = "http://ganglia.pan-starrs.ifa.hawaii.edu/?m=load_one&r=hour&s=descending&c=IPP+Production&h=".$host.".ifa.hawaii.edu&sh=1&hc=7&z=small"; 1277 1280 1278 1281 // Display server row cells 1279 1282 createFormattedTableCell(1, $link, $server, 0, 0); 1283 createFormattedTableCell(1, $link2, $host, 0 , 0); 1280 1284 createFormattedTableCell(0, "", $alive ? "yes" : "NO", !$alive, 0); 1281 1285 createFormattedTableCell(0, "", $running ? "yes" : "NO", !$running, 0); 1286 1282 1287 1283 1288 echo "</tr>\n"; … … 1328 1333 # 1329 1334 ########################################################################### 1330 function getServerStatus($db,$proj, $server, &$alive, &$running ) {1335 function getServerStatus($db,$proj, $server, &$alive, &$running, &$host) { 1331 1336 1332 1337 # $sql = "SELECT alive, running FROM science_servers WHERE server LIKE '$server' AND telescope LIKE '$proj' ORDER BY timestamp DESC LIMIT 1"; 1333 $sql = "SELECT alive, running FROM live_servers WHERE server LIKE '$server' AND telescope LIKE '$proj' ORDER BY timestamp DESC LIMIT 1";1338 $sql = "SELECT alive, running, host FROM live_servers WHERE server LIKE '$server' AND telescope LIKE '$proj' ORDER BY timestamp DESC LIMIT 1"; 1334 1339 if($debug){echo "$sql<br>";} 1335 1340 … … 1340 1345 $alive = $row[0]; 1341 1346 $running = $row[1]; 1347 $host = $row[2]; 1342 1348 } 1343 1349 … … 1385 1391 ########################################################################### 1386 1392 function showReplicationsStatus($replHost, $replUser, $replPassword, $replDatabaseName) { 1387 #print "<br>$replHost, $replUser, $replPassword, $replDatabaseName<br/>"; 1393 //print "<br>$replHost, $replUser, $replPassword, $replDatabaseName<br/>"; 1394 global $czardb; 1395 1396 // Prepare storage info early, https://panstarrs.atlassian.net/browse/IPP-2338 1397 $storageInfo = ''; 1398 $hostPrefixParts = explode(' ', $replDatabaseName); 1399 $hostPrefix = addslashes($hostPrefixParts[0]); 1400 1401 $sql = sprintf( 1402 "SELECT host, FORMAT(total,1), FORMAT(available,2), FORMAT(used,2), writable, readable, FORMAT(used/total*100,1) 1403 FROM hosts 1404 WHERE host LIKE '%s%%' order by available desc 1405 LIMIT 1", 1406 $hostPrefix 1407 ); 1408 1409 $qry = $czardb->query($sql); 1410 if (PEAR::isError($qry)) { 1411 $storageInfo = "<td style=\"background-color: red; color: white;\">Storage query error</td>"; 1412 } else { 1413 if ($qry->fetchInto($row)) { 1414 list($host, $total, $available, $used, $writable, $readable, $ratio) = $row; 1415 $storageInfo = "<td>$ratio% of $total</td>"; 1416 } else { 1417 $storageInfo = "<td>No host storage data</td>"; 1418 } 1419 } 1420 1388 1421 $dbRepl = DB::connect("mysql://$replUser:$replPassword@$replHost"); 1389 1422 if (PEAR::isError($dbRepl)) { 1390 echo "<tr><td>$replDatabaseName</td><td bgcolor=\"red\">MySQL DB connection error - check configuration</td></tr>"; 1391 //die("MySQL DB connection error: Check the configuration for $replDatabaseName"); 1392 //die(""); 1423 echo "<tr><td>$replDatabaseName</td>$storageInfo<td style=\"background-color: red; color: white;\">MySQL DB connection error - check configuration</td></tr>"; 1424 return -1; // Don't stop the rest of the script 1425 } 1426 1427 // Query replication status 1428 $res = $dbRepl->query('SHOW SLAVE STATUS'); 1429 if (PEAR::isError($res)) { 1430 echo "<tr><td>$replDatabaseName</td>$storageInfo<td style=\"background-color: red; color: white;\">MySQL query error - invalid user or privileges</td></tr>"; 1431 $dbRepl->disconnect(); 1393 1432 return -1; 1394 1395 } 1396 1397 # note: mysql user must have either SUPER or REPLICATION CLIENT privileges on the database 1398 $res = $dbRepl->query('SHOW SLAVE STATUS'); 1399 if (dberror($res)) { 1400 echo "<tr><td>$replDatabaseName</td><td bgcolor=\"red\">MySQL query error - invalid user? check configuration</td></tr>"; 1401 //die("MySQL DB connection error: Check the configuration for $replDatabaseName"); 1402 //die(""); 1403 return -1; 1404 } 1405 1406 while ($res->fetchInto($row)) { 1407 # Have a look for Last_Errno in http://dev.mysql.com/doc/refman/5.0/en/show-slave-status.html 1408 $errorStatusInMySql = $row[18]; 1409 $sec_behind = $row[32]; 1410 if ($sec_behind===NULL) { 1411 $sec_behind = 99999999; 1412 $errorStatusInMySql = 999999999; 1413 } 1414 $replStatus = ($errorStatusInMySql==0?"OK ($sec_behind)":"<font style=\"BACKGROUND-COLOR: yellow\" color=\"red\">PROBLEM</font>"); 1415 echo "<tr><td>$replDatabaseName</td><td>$replStatus</td></tr>"; 1416 if ($errorStatusInMySql!=0) { 1417 echo "<tr><td colspan=\"2\">Connect to $replDatabaseName replication host, execute 'SHOW SLAVE STATUS', and fix the problem.<br/>"; 1418 echo "Information <a href=\"http://dev.mysql.com/doc/refman/5.0/en/show-slave-status.html\">here</a></td></tr>"; 1433 } 1434 1435 if (!$res->fetchInto($row)) { 1436 echo "<tr><td>$replDatabaseName</td>$storageInfo<td>No replication data available</td></tr>"; 1437 $dbRepl->disconnect(); 1438 return 0; 1439 } 1440 1441 $errorStatusInMySql = $row[18]; 1442 $sec_behind = $row[32]; 1443 1444 if ($sec_behind === NULL) { 1445 $sec_behind = 99999999; 1446 $errorStatusInMySql = 999999999; 1447 } 1448 1449 $replStatus = ($errorStatusInMySql == 0) 1450 ? "OK ($sec_behind sec behind)" 1451 : "<span style=\"background-color: yellow; color: red;\">PROBLEM</span>"; 1452 1453 echo "<tr><td>$replDatabaseName</td>$storageInfo"; 1454 1455 if ($errorStatusInMySql != 0) { 1456 echo "<tr><td colspan=\"5\">Connect to <strong>$replDatabaseName</strong>, run <code>SHOW SLAVE STATUS</code>, and resolve the issue. "; 1457 echo "See <a href=\"https://dev.mysql.com/doc/refman/5.0/en/show-slave-status.html\" target=\"_blank\">MySQL Docs</a>.</td></tr>"; 1458 } 1459 1460 echo "<td>$replStatus</td>"; 1461 1462 $dbRepl->disconnect(); 1463 1464 } 1465 1466 ########################################################################### 1467 # 1468 # Shows the status of the various replication mysql servers 1469 # 1470 ########################################################################### 1471 function showDatabaseStatus($Host, $User, $Password, $DatabaseName) { 1472 //print "<br>$Host, $User, $Password, $DatabaseName<br/>"; 1473 global $czardb; 1474 // Prepare storage info early, https://panstarrs.atlassian.net/browse/IPP-2338 1475 $storageInfo = ''; 1476 $hostPrefixParts = explode(' ', $DatabaseName); 1477 $hostPrefix = addslashes($hostPrefixParts[0]); 1478 1479 $sql = sprintf( 1480 "SELECT host, FORMAT(total,1), FORMAT(available,2), FORMAT(used,2), writable, readable, FORMAT(used/total*100,1) 1481 FROM hosts 1482 WHERE host LIKE '%s%%' order by available desc 1483 LIMIT 1", 1484 $hostPrefix 1485 ); 1486 1487 $qry = $czardb->query($sql); 1488 if (PEAR::isError($qry)) { 1489 $storageInfo = "<td style=\"background-color: red; color: white;\">Storage query error</td>"; 1490 } else { 1491 if ($qry->fetchInto($row)) { 1492 list($host, $total, $available, $used, $writable, $readable, $ratio) = $row; 1493 $storageInfo = "<td>$ratio% of $total </td>"; 1494 } else { 1495 $storageInfo = "<td>No host storage data</td>"; 1419 1496 } 1420 1497 } 1421 $dbRepl->disconnect(); 1422 } 1423 1424 ########################################################################### 1425 # 1426 # Shows the status of the various replication mysql servers 1427 # 1428 ########################################################################### 1429 function showDatabaseStatus($Host, $User, $Password, $DatabaseName) { 1430 #print "<br>$replHost, $replUser, $replPassword, $replDatabaseName<br/>"; 1498 1431 1499 $db = DB::connect("mysql://$User:$Password@$Host"); 1432 1500 if (PEAR::isError($db)) { 1433 echo "<tr><td>$DatabaseName</td><td bgcolor=\"red\">MySQL DB connection error</td></tr>"; 1434 //die("MySQL DB connection error: Check the configuration for $DatabaseName"); 1435 //die(""); 1501 echo "<tr><td>$DatabaseName</td>$storageInfo<td>$Status</td>"; 1436 1502 return -1; 1437 1438 1503 } 1439 1504 $Status = ($errorStatusInMySql==0?"OK":"<font style=\"BACKGROUND-COLOR: yellow\" color=\"red\">PROBLEM</font>"); 1440 echo "<tr><td>$DatabaseName</td> <td>$Status</td></tr>";1505 echo "<tr><td>$DatabaseName</td>$storageInfo<td>$Status</td>"; 1441 1506 1442 1507 $db->disconnect(); 1443 1508 } 1509 1444 1510 1445 1511 ########################################################################### … … 1664 1730 echo " 'free', {type: 'string', role: 'style'}, {type: 'string', role: 'tooltip', 'p': {'html': true}}],"; 1665 1731 1666 $sql = "SELECT host, format(total,1), format(available,2), format(used,2), writable, readable, format(used/total*100,2) FROM hosts order by host";1732 $sql = "SELECT host, format(total,1), format(available,2), format(used,2), writable, readable, format(used/total*100,2) FROM hosts where host like 'ipp1%' or host like 'ippb%' order by host"; 1667 1733 if ($debug) {echo "$sql<br>";} 1668 1734 $qry = $db->query($sql);
Note:
See TracChangeset
for help on using the changeset viewer.
