This file is indexed.

/usr/share/collectl/tiny.ph is in collectl-utils 4.8.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# debug
#  1 - allow running from cli

# defaults:
my $debug=0;
my $height=.1;
my $width=.04;
my $yrange='';    # leave as is
# - turn off x-axis (bmargin)
# - turn off y-axis (lmargin)
# - turn off legend (rmargin)
# - minimal room for title (tmargin)
my ($bmargin,$lmargin,$rmargin,$tmargin,$links)=(0,0,0,1,0);

my $subtitle='';

sub tinyValid
{
  my $pparams=shift;
  my $params= shift;

  $debug=$1    if defined($params) && $params=~/d=(\d+)/;

  my $reason='';
  $reason="cannot use 'tiny' from the cli interface"    if $pparams->{uitype}!=1 && !($debug & 1);

  return($reason);
}

sub tinyInitParams
{
  my $mycfg=  shift;
  my $pparams=shift;
  my $context=shift;
  my $params= shift;

  if (defined($params))
  {
    foreach my $param (split(/,/,$params))
    {
      my ($name, $value)=(split(/=/, $param));
      liberror($mycfg, "'tiny' does not support parameter: $param")    if $name!~/[bdhlrstwyL]/;

      $debug=$value      if $name=~/d/;
      $bmargin=$value    if $name=~/b/;
      $lmargin=$value    if $name=~/l/;
      $rmargin=$value    if $name=~/r/;
      $tmargin=$value    if $name=~/t/;
      $height=$value     if $name=~/h/;
      $width=$value      if $name=~/w/;
      $subtitle=$value   if $name=~/s/;
      $yrange=$value     if $name=~/y/;
      $links=$value      if $name=~/L/;
    }
  }

  # height width too messy so do up front so let colplot do the calculations
  # for both 'set size' and 'set png'
  $pparams->{height}=$height;
  $pparams->{width}= $width;
  $pparams->{links}=$links;

  $commands='';
  return($commands);
}

sub tinySubtitle
{
  return($subtitle);
}

sub tinyCommands
{
  my $mycfg=  shift;
  my $pparams=shift;
  my $context=shift;
  my $filename=shift;

  # just use rightmost 3-digit node numbers from the filename, noting some are only 3 digits!
  $filename=~/\d*(\d{3})-\d{8}/;
  #print "FILE: $filename\n";
  #$filename="FOO";
  my $nodeNum=$1;

  my $commands='';
  $commands.="set bmargin $bmargin\n";
  $commands.="set lmargin $lmargin\n";
  $commands.="set rmargin $rmargin\n";
  $commands.="set tmargin $tmargin\n";
  $commands.="set nokey\n"             if $rmargin==0;
  $commands.="set yrange $yrange\n"    if $yrange ne '';
  $commands.=sprintf("set title \"$nodeNum\" %s 0,-1\n", $mycfg->{GnuVersion}>=4.2 ? 'offset ' : '');
  return($commands);
}

sub tinyLinks
{
  my $mycfg=shift;
  my $href= shift;

  my $debug=$mycfg->{debug};

  $href=~s/<img src=//;
  $href=~s/genplot/genpage/;
  $href=~s/">$//;

  if ($debug & 128)
  {
    displayText($mycfg, ">>>Before<<<");
    foreach my $var (split(/&/, $href))
    { print "<br>VAR: $var\n"; }  
  }

  $href=~s/subject.*\&//;
  $href=~s/plots=.*?\&/plots=sumall&/;
  $href=~s/filename=(.*?)\&//;
  my $file=$1;
  my $dir=dirname($file);

  # remove date and everything to the right of it so we select ALL files
  # in case they span mulitple dates
  $file=basename($file);
  $file=~s/-\d{8}.*//;

  $href.="&contains=$file";
  $href.="&directory=$dir";
  $href.="&tabcol=sp";
  $href.="&timeframe=fixed";
  $href.='"';

  $href=~s/legend=off/legend=on/;
  $href=~s/thick=1/thick=3/;

  if ($debug & 128)
  {
    displayText($mycfg, ">>>After<<<");
    foreach my $var (split(/&/, $href))
    { print "<br>VAR: $var\n"; }  
  }

  return($href); 
}

1;