<commit_before><?php

#throw new Kohana_exception(print_r($WARN,TRUE));

# Use another color for each graph. After eight graphs colors wrap around.
$area_colors = array( "90CAF9", "B39DDB", "E3F2FD", "cc5fff", "ff5fe2", "ff5f6c", "ff975f", "ffec5f");
$line_colors = array( "2196F3", "673AB7", "2f5580", "662f80", "802f71", "802f36", "804b2f", "80762f");


if( $servicedesc == "Status_CPU_Stats" ) {

  $nodesCount = count( $RRDFILE ) / 5;
  $rrdBaseDir = dirname( $RRDFILE[1] );

  #----------------------------------------------------------------------------------------------
  # Idle Times
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_idle_n%s.rrd";
  $optCount   = 1;
  $defCount   = 1;
  $i          = 1;

  $ds_name[$optCount]     = "idle_nX";
  $opt[$optCount]  = "--title 'Idle Times' --upper-limit 105 --lower-limit -105 --rigid --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $nameIdx = array_search("idle_n$nodeId", $NAME);
    #throw new Kohana_exception(print_r($WARN[$nameIdx],TRUE));
    
    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:neg_node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:neg_node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.0lf %%');
    } else {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.0lf %%');
    }

  }

  #----------------------------------------------------------------------------------------------
  # System Tasks
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_sys_n%s.rrd";
  $optCount   = 2;
  $defCount   = 2;
  $i          = 1;

  $ds_name[$optCount]     = "sys_nX";
  $opt[$optCount]  = "--title 'System Times' --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:neg_node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:neg_node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    } else {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    }

  }

  #----------------------------------------------------------------------------------------------
  # User Tasks
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_user_n%s.rrd";
  $optCount   = 3;
  $defCount   = 3;
  $i          = 1;

  $ds_name[$optCount]     = "user_nX";
  $opt[$optCount]  = "--title 'System Times' --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:neg_node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:neg_node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    } else {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    }

  }

  #----------------------------------------------------------------------------------------------
  # Intr
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_intr_n%s.rrd";
  $optCount   = 4;
  $defCount   = 4;
  $i          = 1;

  $ds_name[$optCount]     = "intr_nX";
  $opt[$optCount]  = "--title 'System Times' --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:neg_node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:neg_node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    } else {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    }

  }


  #----------------------------------------------------------------------------------------------
  # Ctxt
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_ctxt_n%s.rrd";
  $optCount   = 4;
  $defCount   = 4;
  $i          = 1;

  $ds_name[$optCount]     = "ctxt_nX";
  $opt[$optCount]  = "--title 'System Times' --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";<commit_msg>rrd mods<commit_after><?php

#throw new Kohana_exception(print_r($WARN,TRUE));

# Use another color for each graph. After eight graphs colors wrap around.
$area_colors = array( "90CAF9", "B39DDB", "E3F2FD", "cc5fff", "ff5fe2", "ff5f6c", "ff975f", "ffec5f");
$line_colors = array( "2196F3", "673AB7", "2f5580", "662f80", "802f71", "802f36", "804b2f", "80762f");


if( $servicedesc == "Status_CPU_Stats" ) {

  $nodesCount = count( $RRDFILE ) / 5;
  $rrdBaseDir = dirname( $RRDFILE[1] );

  #----------------------------------------------------------------------------------------------
  # Idle Times
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_idle_n%s.rrd";
  $optCount   = 1;
  $defCount   = 1;
  $i          = 1;

  $ds_name[$optCount]     = "idle_nX";
  $opt[$optCount]  = "--title 'Idle Times' --upper-limit 105 --lower-limit -105 --rigid --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $nameIdx = array_search("idle_n$nodeId", $NAME);
    #throw new Kohana_exception(print_r($WARN[$nameIdx],TRUE));
    
    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:neg_node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:neg_node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.0lf %%');
    } else {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.0lf %%');
    }

  }

  #----------------------------------------------------------------------------------------------
  # System Tasks
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_sys_n%s.rrd";
  $optCount   = 2;
  $defCount   = 2;
  $i          = 1;

  $ds_name[$optCount]     = "sys_nX";
  $opt[$optCount]  = "--title 'System Times' --upper-limit 105 --lower-limit -105 --rigid --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:neg_node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:neg_node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    } else {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    }

  }

  #----------------------------------------------------------------------------------------------
  # User Tasks
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_user_n%s.rrd";
  $optCount   = 3;
  $defCount   = 3;
  $i          = 1;

  $ds_name[$optCount]     = "user_nX";
  $opt[$optCount]  = "--title 'User Times' --upper-limit 105 --lower-limit -105 --rigid --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:neg_node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:neg_node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    } else {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    }

  }

  #----------------------------------------------------------------------------------------------
  # Intr
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_intr_n%s.rrd";
  $optCount   = 4;
  $defCount   = 4;
  $i          = 1;

  $ds_name[$optCount]     = "intr_nX";
  $opt[$optCount]  = "--title 'Interrupts' --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:neg_node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:neg_node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    } else {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,node$nodeId,PREDICT ";
      $def[$defCount] .= "AREA:node$nodeId#$area_colors[$ii]:\"node$nodeId\" ";
      $def[$defCount] .= "LINE1:pred_node$nodeId#$line_colors[$ii]55: ";
      $def[$defCount] .= "LINE2:node$nodeId#$line_colors[$ii]: ";
      $def[$defCount] .= rrd::gprint( "node$nodeId", array( 'MIN', 'MAX', 'AVERAGE' ), '%6.2lf');
    }

  }


  #----------------------------------------------------------------------------------------------
  # Ctxt
  #----------------------------------------------------------------------------------------------
  
  $rrdFileFmt = $rrdBaseDir . "/Status_CPU_Stats_ctxt_n%s.rrd";
  $optCount   = 5;
  $defCount   = 5;
  $i          = 1;

  $ds_name[$optCount]     = "ctxt_nX";
  $opt[$optCount]  = "--title 'Context Switches' --height 180 --end=+10minutes";
  $def[$defCount]  = "";
  $def[$defCount] .= "HRULE:0#555 ";
  for( $nodeId = 0; $nodeId < $nodesCount; $nodeId++ ) {
    $i++;
    $ii = $i-1;

    $currentRrdFile = sprintf( $rrdFileFmt, $nodeId );

    if( $i % 2 == 1 ) {
      $def[$defCount] .= "DEF:node$nodeId=$currentRrdFile:$DS[1]:MAX ";
      $def[$defCount] .= "CDEF:neg_node$nodeId=node$nodeId,-1,* ";
      $def[$defCount] .= "CDEF:pred_node$nodeId=86400,-7,600,neg_node$nodeId,PREDICT ";
{'fraction_non_alphanumeric': 0.3185476763997415, 'fraction_numerical': 0.0341930556371541, 'mean_word_length': 2.374033696729435, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6985366', 'n_tokens_mistral': 6766, 'n_tokens_neox': 6395, 'n_words': 844}