collectl: init at 4.3.20.1

- Add collectl 4.3.20.1 performance monitoring tool for Linux systems
- Add test suite for configuration functionality
- Include patches for external tool handling and install script fixes
- Document --config option in package metadata
- Add maintainer entry for seven_bear

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

+753
+6
maintainers/maintainer-list.nix
··· 23008 23008 githubId = 2049686; 23009 23009 name = "Sebastián Estrella"; 23010 23010 }; 23011 + seven_bear = { 23012 + name = "Edmond Freeman"; 23013 + email = "edmondfreeman7@gmail.com"; 23014 + github = "yueneiqi"; 23015 + githubId = 26707756; 23016 + }; 23011 23017 seylerius = { 23012 23018 name = "Sable Seyler"; 23013 23019 email = "sable@seyleri.us";
+444
pkgs/by-name/co/collectl/0001-scripts-external-executable-calls.patch
··· 1 + Processing diff for: collectl.conf 2 + --- a/collectl.conf 2025-08-14 08:42:24.434419733 +0000 3 + +++ b/collectl.conf 2025-08-16 07:56:13.806350456 +0000 4 + @@ -43,7 +43,7 @@ 5 + #Ps = /bin/ps 6 + #Rpm = /bin/rpm 7 + #Lspci = /sbin/lspci 8 + -#Lctl = /usr/sbin/lctl 9 + +#Lctl = /usr/sbin/lctl # disabled since collectl 4.0.4 10 + 11 + # I n f i n i b a n d S u p p o r t 12 + 13 + @@ -55,10 +55,11 @@ 14 + # variable below. PQuery for OFED, PCounter for get_pcounter calls and 15 + # VStat for ALL non-ofed access of any kind. 16 + # can disable either by commenting out the reference to VStat/PQuery below. 17 + -PQuery = /usr/sbin/perfquery:/usr/bin/perfquery:/usr/local/ofed/bin/perfquery 18 + -PCounter = /usr/mellanox/bin/get_pcounter 19 + -VStat = /usr/mellanox/bin/vstat:/usr/bin/vstat 20 + -OfedInfo = /usr/bin/ofed_info:/usr/local/ofed/bin/ofed_info 21 + +# Disable the Infiniband support by default 22 + +# PQuery = /usr/sbin/perfquery:/usr/bin/perfquery:/usr/local/ofed/bin/perfquery 23 + +# PCounter = /usr/mellanox/bin/get_pcounter 24 + +# VStat = /usr/mellanox/bin/vstat:/usr/bin/vstat 25 + +# OfedInfo = /usr/bin/ofed_info:/usr/local/ofed/bin/ofed_info 26 + 27 + # D e f a u l t s 28 + 29 + @@ -116,7 +117,7 @@ 30 + # size, comment out the Resize line and uncomment TermHeight, setting it to 31 + # what you want. 32 + #TermHeight = 24 33 + -Resize=/usr/bin/resize:/usr/X11R6/bin/resize 34 + +Resize=@resize@ 35 + 36 + # To turn off Time:HiRes/glibc incompatibility checking, the following 37 + # should be enabled and set to 0 38 + @@ -125,7 +126,7 @@ 39 + # These control environmental monitoring and to use it you MUST have ipmitool 40 + # installed (see http://ipmitool.sourceforge.net/). If not in the path shown 41 + # below, you must change it. 42 + -Ipmitool = /usr/bin/ipmitool:/usr/local/bin/ipmitool:/opt/hptc/sbin/ipmitool 43 + +Ipmitool = @ipmitool@ 44 + IpmiCache = /var/run/collectl-ipmicache 45 + IpmiTypes = fan,temp,current 46 + 47 + Processing diff for: collectl 48 + --- a/collectl 2025-08-14 08:42:24.434419733 +0000 49 + +++ b/collectl 2025-08-16 09:25:20.238548613 +0000 50 + @@ -69,14 +69,14 @@ 51 + use IO::Select; 52 + use Cwd 'abs_path'; 53 + 54 + -$Cat= '/bin/cat'; 55 + -$Grep= '/bin/grep'; 56 + -$Egrep= '/bin/egrep'; 57 + -$Ps= '/bin/ps'; 58 + -$Rpm= '/bin/rpm'; 59 + -$Lspci= '/sbin/lspci'; 60 + -$Lctl= '/usr/sbin/lctl'; 61 + -$Dmidecode= '/usr/sbin/dmidecode'; 62 + +$Cat= '@cat@'; 63 + +$Grep= '@grep@'; 64 + +$Egrep= '@egrep@'; 65 + +$Ps= '@ps@'; 66 + +$Rpm= '@rpm@'; 67 + +$Lspci= '@lspci@'; 68 + +$Lctl= '/usr/sbin/lctl'; # disabled since collectl 4.0.4 69 + +$Dmidecode= '@dmidecode@'; 70 + 71 + %TopProcTypes=qw(vsz '' rss '' syst '' usrt '' time '' accum '' rkb '' wkb '' iokb '' 72 + rkbc '' wkbc '' iokbc '' ioall '' rsys '' wsys '' iosys '' 73 + @@ -108,7 +108,7 @@ 74 + $syslogFlag=(eval {require "Sys/Syslog.pm" or die}) ? 1 : 0; 75 + 76 + # Always nice to know if we're root 77 + -$rootFlag=(!$PcFlag && `whoami`=~/root/) ? 1 : 0; 78 + +$rootFlag=(!$PcFlag && `@whoami@`=~/root/) ? 1 : 0; 79 + $SrcArch= $Config{"archname"}; 80 + 81 + $Version= '4.3.20'; 82 + @@ -126,15 +126,15 @@ 83 + # we're in the background. We also need to know if STDOUT connected to a terminal. 84 + if (!$PcFlag) 85 + { 86 + - $MyDir=`pwd`; 87 + - $Cat= 'cat'; 88 + + $MyDir=`@pwd@`; 89 + + $Cat= '@cat@'; 90 + $Sep= '/'; 91 + $backFlag=(getpgrp()!=tcgetpgrp(0)) ? 1 : 0; 92 + $termFlag= (-t STDOUT) ? 1 : 0; 93 + } 94 + else 95 + { 96 + - $MyDir=`cd`; 97 + + $MyDir=`@cd@`; 98 + $Cat= 'type'; 99 + $Sep= '\\'; 100 + $backFlag=0; 101 + @@ -148,7 +148,7 @@ 102 + # which was recorded with the data file and WILL override in playback mode. 103 + # We also need our host name before calling initRecord() so we can log it at 104 + # startup as well as for naming the logfile. 105 + -$myHost=($PcFlag) ? `hostname` : `/bin/hostname`; 106 + +$myHost=($PcFlag) ? `@hostname@` : `@hostname@`; 107 + $myHost=(split(/\./, $myHost))[0]; 108 + chomp $myHost; 109 + $Host=$myHost; 110 + @@ -509,12 +509,12 @@ 111 + 112 + if ($runasUser!~/^\d+$/) 113 + { 114 + - $runasUid=(split(/:/, `grep ^$runasUser: /etc/passwd`))[2]; 115 + + $runasUid=(split(/:/, `@grep@ ^$runasUser: /etc/passwd`))[2]; 116 + error("can't find '$runasUser' in /etc/passwd. Consider UID.") if !defined($runasUid); 117 + } 118 + if (defined($runasGroup) && $runasGroup!~/^\d+$/) 119 + { 120 + - $runasGid=(split(/:/, `grep ^$runasGroup: /etc/group`))[2]; 121 + + $runasGid=(split(/:/, `@grep@ ^$runasGroup: /etc/group`))[2]; 122 + error("can't find '$runasGroup' in /etc/group. Consider GID.") if !defined($runasGid); 123 + } 124 + $runasUid=$runasUser if $runasUser=~/^\d+/; 125 + @@ -1167,19 +1167,19 @@ 126 + if (!$PcFlag) 127 + { 128 + # This matches THIS host, but in playback mode will be reset to the target 129 + - $Kernel=`uname -r`; 130 + + $Kernel=`@uname@ -r`; 131 + chomp $Kernel; 132 + error("collectl no longer supports 2.4 kernels") if $Kernel=~/^2\.4/; 133 + 134 + - $LocalTimeZone=`date +%z`; 135 + + $LocalTimeZone=`@date@ +%z`; 136 + chomp $LocalTimeZone; 137 + 138 + # Some distros put lspci in /usr/sbin and others in /usr/bin, so take one last look in 139 + # those before complaining, but only if in record mode AND only if looking at interconnects 140 + if (!-e $Lspci && $playback eq '' && $subsys=~/x/i) 141 + { 142 + - $Lspci=(-e '/usr/sbin/lspci') ? '/usr/sbin/lspci' : '/usr/bin/lspci'; 143 + - if (!-e "/usr/sbin/lspci" && !-e "/usr/bin/lspci") 144 + + $Lspci='@lspci@'; 145 + + if (!-e "@lspci@") 146 + { 147 + pushmsg('W', "-sx disabled because 'lspci' not in $Lspci or '/usr/sbin' or '/usr/bin'"); 148 + pushmsg('W', "If somewhere else, move it or define in collectl.conf"); 149 + @@ -1274,7 +1274,7 @@ 150 + # it further on so not to worry, but at least record a warning. 151 + $pid=`$Cat $PidFile`; 152 + chomp $pid; 153 + - @ps=`ps axo pid,command`; 154 + + @ps=`@ps@ axo pid,command`; 155 + foreach my $line (@ps) 156 + { 157 + $line=~s/^\s+//; # trim leading whitespace for short pids 158 + @@ -1551,14 +1551,14 @@ 159 + } 160 + 161 + # if -N, set priority to 20 162 + -`renice 20 $$` if $niceFlag; 163 + +`@renice@ 20 $$` if $niceFlag; 164 + 165 + # Couldn't find anywhere else to put this one... 166 + error("-sT only works with -P for now (too much data)") 167 + if $TFlag && !$plotFlag; 168 + 169 + # get parent pid so we can check later to see it still there 170 + -$stat=`cat /proc/$$/stat`; 171 + +$stat=`@cat@ /proc/$$/stat`; 172 + $myPpid=(split(/\s+/, $stat))[3]; 173 + 174 + ############################### 175 + @@ -2311,7 +2311,7 @@ 176 + printBriefCounters('T'); 177 + } 178 + 179 + - `stty echo` if !$PcFlag && $termFlag && !$backFlag; # in brief mode, we turned it off 180 + + `@stty@ echo` if !$PcFlag && $termFlag && !$backFlag; # in brief mode, we turned it off 181 + my $temp=(!$msgFlag) ? ' Try again with -m.' : ''; 182 + print "No files selected contain the selected data.$temp\n" if !$numProcessed; 183 + exit(0); 184 + @@ -2453,7 +2453,7 @@ 185 + open STDIN, '/dev/null' or logmsg("F", "Can't read /dev/null: $!"); 186 + open STDOUT, '>/dev/null' or logmsg("F", "Can't write to /dev/null: $!"); 187 + open STDERR, '>/dev/null' or logmsg("F", "Can't write to /dev/null: $!"); 188 + - `echo $$ > $PidFile`; 189 + + `@echo@ $$ > $PidFile`; 190 + 191 + # Now that we're set up to start, if '--runas' has been sprecified we need to do a 192 + # few things that require privs before actually changing our UID. Also note the 193 + @@ -2469,8 +2469,8 @@ 194 + $logname=(-d $filename) ? $filename : dirname($filename); 195 + $logname.="/$myHost-collectl-$yymm.log"; 196 + 197 + - `chown $runasUid $logname`; 198 + - `chgrp $runasGid $logname` if defined($runasGid); 199 + + `@chown@ $runasUid $logname`; 200 + + `@chgrp@ $runasGid $logname` if defined($runasGid); 201 + 202 + # now we can change our process's ownership taking care to do the group first 203 + # since we won't be able to change anything once we change our UID. 204 + @@ -3244,7 +3244,7 @@ 205 + # close logs cleanly and turn echo back on because when 'brief' we turned it off. 206 + closeLogs($subsys); 207 + unlink $PidFile if $daemonFlag; 208 + -`stty echo` if !$PcFlag && $termFlag && !$backFlag; 209 + +`@stty@ echo` if !$PcFlag && $termFlag && !$backFlag; 210 + 211 + # clean up when in pure top mode 212 + if ($numTop && !$topVertFlag) 213 + @@ -4350,7 +4350,7 @@ 214 + if (!-e $temp) 215 + { 216 + logmsg('W', "Creating directory '$temp'"); 217 + - `mkdir $temp`; 218 + + `@mkdir@ $temp`; 219 + } 220 + 221 + # track number of times same file processed, primarily for options 'a/c'. in 222 + @@ -5363,7 +5363,7 @@ 223 + 224 + # build up the search list being extra neat and leaving 225 + # off possible duplicate /etc 226 + - $configFile="$BinDir/$ConfigFile;$etcDir/$ConfigFile"; 227 + + $configFile="$BinDir/../etc/$ConfigFile;$etcDir/$ConfigFile"; 228 + $configFile.=";/etc/$ConfigFile" if $etcDir ne '/etc'; 229 + } 230 + print "Config File Search Path: $configFile\n" if $debug & 1; 231 + @@ -5789,7 +5789,7 @@ 232 + # what gets stored in /proc/XXX/stat and to make sure we look at the same 233 + # values dynamically as well as staticly, we better pull cmd from the stat 234 + # file itself. 235 + - @ps=`ps axo pid,ppid,uid,comm,user`; 236 + + @ps=`@ps@ axo pid,ppid,uid,comm,user`; 237 + my $firstFilePass=1; 238 + foreach $process (@ps) 239 + { 240 + @@ -6228,7 +6228,7 @@ 241 + $briefFlag=0; 242 + $verboseFlag=1; 243 + intervalPrint(time); 244 + - `stty echo` if !$PcFlag && $termFlag && !$backFlag; 245 + + `@stty@ echo` if !$PcFlag && $termFlag && !$backFlag; 246 + } 247 + 248 + sub error 249 + @@ -6241,7 +6241,7 @@ 250 + # printText() will try to send error over socket and we want it local. 251 + $sockFlag=0 if $serverFlag; 252 + 253 + - `stty echo` if !$PcFlag && $termFlag && !$backFlag; 254 + + `@stty@ echo` if !$PcFlag && $termFlag && !$backFlag; 255 + logmsg("F", "Error: $text") if $daemonFlag; 256 + 257 + # we can only call printText() when formatit loaded. 258 + Processing diff for: colmux 259 + --- a/colmux 2025-08-14 08:42:24.438419919 +0000 260 + +++ b/colmux 2025-08-15 07:38:22.003168089 +0000 261 + @@ -78,7 +78,7 @@ 262 + my $License="colmux may be copied only under the terms of either the Artistic License\n"; 263 + $License.= "or the GNU General Public License, which may be found in the source kit"; 264 + 265 + -my $Ping='/bin/ping'; 266 + +my $Ping='@ping@'; 267 + my $ResizePath='/usr/bin/resize:/usr/X11R6/bin/resize'; 268 + my $Route='/sbin/route'; 269 + my $Ifconfig='/sbin/ifconfig'; 270 + @@ -235,7 +235,7 @@ 271 + $Collectl="sudo $Collectl" if $sudoFlag; 272 + 273 + # ok if host not in known_hosts and when not debugging be sure to turn off motd 274 + -my $Ssh='/usr/bin/ssh -o StrictHostKeyChecking=no -o BatchMode=yes'; 275 + +my $Ssh='@ssh@ -o StrictHostKeyChecking=no -o BatchMode=yes'; 276 + $Ssh.=" -o ServerAliveInterval=$keepalive" if $keepalive ne ''; 277 + $Ssh.=" -q" unless $debug; 278 + 279 + @@ -357,7 +357,7 @@ 280 + # See if any host specs contain 'username@' & reset 'localhost' and 281 + # adjust maximum hostname length if necessary. 282 + my $hostlen=$hostWidth; 283 + -my $myhost=`hostname`; 284 + +my $myhost=`@hostname@`; 285 + chomp $myhost; 286 + 287 + my (%usernames, %sshswitch, %aliases); 288 + @@ -510,7 +510,7 @@ 289 + $line=~s/^\s+//; # can have leading space 290 + my $pid=(split(/\s+/, $line))[0]; 291 + print "Killing ssh with pid: $pid\n" if $debug & 1; 292 + - `kill $pid`; 293 + + `@kill@ $pid`; 294 + } 295 + sleep 1; # wait a tad for ssh in thread to exit 296 + close PS; 297 + @@ -983,7 +983,7 @@ 298 + $line=~s/^\s+//; 299 + my $pid=(split(/\s+/, $line))[0]; 300 + print "Killing ssh with pid: $pid\n" if $debug & 1; 301 + - `kill $pid`; 302 + + `@kill@ $pid`; 303 + } 304 + } 305 + 306 + @@ -1179,7 +1179,7 @@ 307 + foreach my $host (keys %files) 308 + { 309 + print "Killing pid $files{$host}->{pid} for '$host'\n" if $debug & 1; 310 + - `kill -9 $files{$host}->{pid}`; 311 + + `@kill@ -9 $files{$host}->{pid}`; 312 + #close $files{$host}->{fd} or error("Failed to close playback file for '$host'"); 313 + } 314 + 315 + Processing diff for: formatit.ph 316 + --- a/formatit.ph 2025-08-14 08:42:24.438419919 +0000 317 + +++ b/formatit.ph 2025-08-15 07:18:19.548190580 +0000 318 + @@ -20,19 +20,19 @@ 319 + $rawPFlag=0; # always 0 when no files involved 320 + 321 + # In some case, we need to know if we're root. 322 + - $rootFlag=`whoami`; 323 + + $rootFlag=`@whoami@`; 324 + $rootFlag=($rootFlag=~/root/) ? 1 : 0; 325 + 326 + # be sure to remove domain portion if present. also note we keep the hostname in 327 + # two formats, one in it's unaltered form (at least needed by lustre directory 328 + # parsing) as well as all lc because it displays nicer. 329 + - $Host=`hostname`; 330 + + $Host=`@hostname@`; 331 + chomp $Host; 332 + $Host=(split(/\./, $Host))[0]; 333 + $HostLC=lc($Host); 334 + 335 + # when was system booted? 336 + - $uptime=(split(/\s+/, `cat /proc/uptime`))[0]; 337 + + $uptime=(split(/\s+/, `@cat@ /proc/uptime`))[0]; 338 + $boottime=time-$uptime; 339 + 340 + $Distro=cat('/etc/redhat-release') if -e '/etc/redhat-release'; 341 + @@ -83,11 +83,11 @@ 342 + if ($subsys=~/y/i && $slabinfoFlag || $slubinfoFlag) 343 + { 344 + $message=''; 345 + - $message='/proc/slabinfo' if $slabinfoFlag && !(eval {`cat /proc/slabinfo 2>/dev/null` or die}); 346 + - $message='/sys/slab' if $slubinfoFlag && !(eval {`cat /proc/slubinfo 2>/dev/null` or die}); 347 + + $message='/proc/slabinfo' if $slabinfoFlag && !(eval {`@cat@ /proc/slabinfo 2>/dev/null` or die}); 348 + + $message='/sys/slab' if $slubinfoFlag && !(eval {`@cat@ /proc/slubinfo 2>/dev/null` or die}); 349 + if ($message ne '') 350 + { 351 + - my $whoami=`whoami`; 352 + + my $whoami=`@whoami@`; 353 + chomp $whoami; 354 + disableSubsys('y', "/proc/slabinfo is not readable by $whoami"); 355 + $interval=~s/(^\d*):\d+/$1:/ if $subsys!~/z/i; # remove int2 if not needed or we'll get error 356 + @@ -132,7 +132,7 @@ 357 + 358 + for (my $i=1; $i<$NumCpus; $i++) 359 + { 360 + - my $online=`cat /sys/devices/system/cpu/cpu$i/online`; 361 + + my $online=`@cat@ /sys/devices/system/cpu/cpu$i/online`; 362 + chomp $online; 363 + 364 + $cpuEnabled[$i]=$online; 365 + @@ -266,7 +266,7 @@ 366 + $ibSpeed='??'; 367 + if (-e '/sys/class/infiniband') 368 + { 369 + - $line=`cat /sys/class/infiniband/*/ports/1/rate 2>&1`; 370 + + $line=`@cat@ /sys/class/infiniband/*/ports/1/rate 2>&1`; 371 + if ($line=~/\s*(\d+)\s+(\S)/) 372 + { 373 + $ibSpeed=$1; 374 + @@ -669,7 +669,7 @@ 375 + { 376 + # Get Luster and SFS Versions before looking at any data structures in the 377 + # 'lustreCheck' routines because things change over time 378 + - $temp=`cat /proc/fs/lustre/version | grep lustre 2>/dev/null`; 379 + + $temp=`@cat@ /proc/fs/lustre/version | grep lustre 2>/dev/null`; 380 + $temp=~/lustre: (\d+.*)/; 381 + $cfsVersion=$1; 382 + $sfsVersion=''; 383 + @@ -716,7 +716,7 @@ 384 + # The first step is to build up a hash of the sizes of all the 385 + # existing partitions. Since we're only doing this once, a 'cat's 386 + # overhead should be minimal 387 + - @partitions=`cat /proc/partitions`; 388 + + @partitions=`@cat@ /proc/partitions`; 389 + foreach $part (@partitions) 390 + { 391 + # ignore blank lines and header 392 + @@ -778,7 +778,7 @@ 393 + $temp=`head -n 1 /proc/slabinfo`; 394 + $temp=~/(\d+\.\d+)/; 395 + $SlabVersion=$1; 396 + - $NumSlabs=`cat /proc/slabinfo | wc -l`*1; 397 + + $NumSlabs=`@cat@ /proc/slabinfo | wc -l`*1; 398 + chomp $NumSlabs; 399 + $NumSlabs-=2; 400 + 401 + @@ -4127,7 +4127,7 @@ 402 + $netSpeeds{$netName}='??'; 403 + if ($line ne '') 404 + { 405 + - $speed=`cat $line 2>&1`; 406 + + $speed=`@cat@ $line 2>&1`; 407 + chomp $speed; 408 + $line=~/.*\/(\S+)\/speed/; 409 + my $netName=$1; 410 + Processing diff for: graphite.ph 411 + --- a/graphite.ph 2025-08-14 08:42:24.442420106 +0000 412 + +++ b/graphite.ph 2025-08-14 08:44:07.351625049 +0000 413 + @@ -117,7 +117,7 @@ 414 + # behavior for -f logs matches that of -A 415 + $rawtooFlag=1 if $filename ne '' && !$plotFlag; 416 + 417 + - $graphiteMyHost=(!$graphiteFqdnFlag) ? `hostname` : `hostname -f`; 418 + + $graphiteMyHost=(!$graphiteFqdnFlag) ? `@hostname@` : `@hostname@ -f`; 419 + chomp $graphiteMyHost; 420 + $graphiteMyHost =~ s/\./$graphiteEscape/g if $graphiteEscape ne ''; 421 + 422 + Processing diff for: vmsum.ph 423 + --- a/vmsum.ph 2025-08-14 08:42:24.442420106 +0000 424 + +++ b/vmsum.ph 2025-08-14 08:44:24.184414112 +0000 425 + @@ -20,8 +20,8 @@ 426 + my $oneMB=1024*1024; 427 + my ($debug, $helpFlag, $instMin, $versionFlag, $zeroFlag); 428 + 429 + -my $Ssh= '/usr/bin/ssh'; 430 + -my $Ping='/bin/ping'; 431 + +my $Ssh= '@ssh@'; 432 + +my $Ping='@ping@'; 433 + my $PingTimeout=1; 434 + 435 + # these control writing the vm text file 436 + @@ -32,7 +32,7 @@ 437 + 438 + my $lexprFlag=0; 439 + my $noNetMsg=''; # if not null, problem with n/w stats (very rare) 440 + -my $hostname=`hostname`; 441 + +my $hostname=`@hostname@`; 442 + chomp $hostname; 443 + 444 + sub vmsumInit
+133
pkgs/by-name/co/collectl/0002-fix-install-script.patch
··· 1 + --- a/INSTALL 2025-08-14 08:46:43.845548078 +0000 2 + +++ b/INSTALL 2025-08-14 08:50:33.771706783 +0000 3 + @@ -1,28 +1,29 @@ 4 + #!/bin/sh 5 + 6 + -DESTDIR=${DESTDIR:="/"} 7 + +# Use Nix output directory instead of system paths 8 + +DESTDIR=${out} 9 + 10 + -BINDIR=$DESTDIR/usr/bin 11 + -DOCDIR=$DESTDIR/usr/share/doc/collectl 12 + -SHRDIR=$DESTDIR/usr/share/collectl 13 + -MANDIR=$DESTDIR/usr/share/man/man1 14 + -SYSDDIR=$DESTDIR/usr/lib/systemd/system 15 + -ETCDIR=$DESTDIR/etc 16 + -INITDIR=$ETCDIR/init.d 17 + +BINDIR=$out/bin 18 + +DOCDIR=$out/share/doc/collectl 19 + +SHRDIR=$out/share/collectl 20 + +MANDIR=$out/share/man/man1 21 + +SYSDDIR=$out/lib/systemd/system 22 + +ETCDIR=$out/etc 23 + +INITDIR=$out/etc/init.d 24 + 25 + mkdir -p $BINDIR 26 + mkdir -p $DOCDIR 27 + mkdir -p $SHRDIR 28 + mkdir -p $ETCDIR 29 + mkdir -p $MANDIR 30 + -mkdir -p $INITDIR 31 + +# Skip init.d creation for Nix 32 + mkdir -p $SHRDIR/util 33 + mkdir -p $DESTDIR/var/log/collectl 34 + 35 + cp collectl colmux $BINDIR 36 + cp collectl.conf $ETCDIR 37 + cp man1/* $MANDIR 38 + -cp initd/* $INITDIR 39 + +# Skip init scripts for Nix 40 + 41 + cp docs/* $DOCDIR 42 + cp GPL ARTISTIC COPYING $DOCDIR 43 + @@ -42,87 +43,12 @@ 44 + # Force in case redoing the install and files already zipped 45 + gzip -f $MANDIR/collectl* 46 + 47 + -chmod 755 $INITDIR/collectl* 48 + +# Skip chmod on init scripts for Nix 49 + chmod 444 $ETCDIR/collectl.conf 50 + chmod 755 $BINDIR/collectl 51 + chmod 444 $DOCDIR/ARTISTIC $DOCDIR/COPYING $DOCDIR/GPL 52 + chmod 444 $SHRDIR/*ph 53 + chmod 755 $SHRDIR/util/* 54 + 55 + -# remove any stale versions in case the names/numbers used have changed. 56 + -# on new ROCKS installion 'rm' isn't there yet! [thanks roy] 57 + -if [ -x /bin/rm ] ; then 58 + - /bin/rm -f $INITDIR/rc*.d/*collectl 59 + - /bin/rm -f $ETCDIR/rc.d/rc*.d/*collectl 60 + -fi 61 + - 62 + -# only if systemd is supported 63 + -if [ -d $SYSDDIR ]; then 64 + - cp service/collectl.service $SYSDDIR 65 + -fi 66 + - 67 + -# Try and decide which distro this is based on distro specific files. 68 + -distro=1 69 + -if [ -f /sbin/yast ]; then 70 + - distro=2 71 + - mv -f $INITDIR/collectl-suse $INITDIR/collectl 72 + - rm -f $INITDIR/collectl-debian 73 + - rm -f $INITDIR/collectl-generic 74 + -fi 75 + - 76 + -# debian 77 + -if [ -f /usr/sbin/update-rc.d ]; then 78 + - distro=3 79 + - mv -f $INITDIR/collectl-debian $INITDIR/collectl 80 + - rm -f $INITDIR/collectl-suse 81 + - rm -f $INITDIR/collectl-generic 82 + - 83 + - # only if we're installing under / 84 + - [ "$DESTDIR" = "/" ] && update-rc.d collectl defaults 85 + -fi 86 + - 87 + -# redhat 88 + -if [ -f /etc/redhat-release ]; then 89 + - distro=4 90 + - rm -f $INITDIR/collectl-suse 91 + - rm -f $INITDIR/collectl-debian 92 + - rm -f $INITDIR/collectl-generic 93 + - if [ -f /usr/sbin/chkconfig ]; then 94 + - [ "$DESTDIR" = "/" ] && chkconfig --add collectl 95 + - fi 96 + -# Not needed for RHEL8 and higher 97 + -fi 98 + - 99 + -# gentoo 100 + -if [ -f $ETCDIR/gentoo-release ]; then 101 + - distro=5 102 + - mv -f $INITDIR/collectl-generic $INITDIR/collectl 103 + - rm -f $INITDIR/collectl-suse 104 + - rm -f $INITDIR/collectl-debian 105 + - [ "$DESTDIR" = "/" ] && rc-update -a collectl default 106 + -fi 107 + - 108 + -# Generic Distros 109 + -# If /etc/init.d doesn't exist and/or there's no way to use chkconfig or 110 + -# rc-update you're going to have to add some custom code below... 111 + -if [ ${distro} = 1 ]; then 112 + - 113 + - mv -f $INITDIR/collectl-generic $INITDIR/collectl 114 + - rm -f $INITDIR/collectl-suse 115 + - rm -f $INITDIR/collectl-debian 116 + - 117 + - # If in not installing under / there's nothing extra do 118 + - [ $DESTDIR != "/" ] && exit 0 119 + - 120 + - # figure out how to handle reboots 121 + - if [ -f /sbin/chkconfig ]; then 122 + - chkconfig --add collectl 123 + - elif [ -f /sbin/rc-update ]; then 124 + - rc-update -a collectl default 125 + -# RHEL9 has no chkconfig 126 + - elif [ -f /usr/bin/systemctl ]; then 127 + - systemctl enable collectl 128 + - else 129 + - echo "could not figure out how to enable restarting across reboots" 130 + - fi 131 + -fi 132 + +# Skip all distro-specific service installation for Nix 133 + +# Nix manages services differently through NixOS modules
+126
pkgs/by-name/co/collectl/package.nix
··· 1 + { 2 + callPackage, 3 + lib, 4 + stdenv, 5 + fetchFromGitHub, 6 + replaceVars, 7 + 8 + # Runtime dependencies 9 + coreutils, 10 + dmidecode, 11 + gnugrep, 12 + inetutils, 13 + openssh, 14 + pciutils, 15 + perl, 16 + procps, 17 + rpm, 18 + util-linux, 19 + xterm, 20 + 21 + # Dependencies 22 + ipmitool, 23 + }: 24 + 25 + let 26 + inherit (lib) getExe getExe' genAttrs; 27 + 28 + # Define tool dependencies for script patches 29 + scriptDeps = 30 + let 31 + mkTools = pkg: tools: genAttrs tools (tool: getExe' pkg tool); 32 + in 33 + # Tools from various packages 34 + (mkTools coreutils [ 35 + "cat" 36 + "whoami" 37 + "pwd" 38 + "uname" 39 + "date" 40 + "mkdir" 41 + "chown" 42 + "chgrp" 43 + "echo" 44 + "kill" 45 + "cd" 46 + "stty" 47 + ]) 48 + // (mkTools util-linux [ "renice" ]) 49 + // (mkTools gnugrep [ 50 + "grep" 51 + "egrep" 52 + ]) 53 + // (mkTools inetutils [ 54 + "hostname" 55 + "ping" 56 + ]) 57 + // (mkTools procps [ "ps" ]) 58 + // (mkTools pciutils [ "lspci" ]) 59 + // (mkTools xterm [ "resize" ]) 60 + // (mkTools dmidecode [ "dmidecode" ]) 61 + // (mkTools rpm [ "rpm" ]) 62 + // { 63 + # Single-tool packages 64 + ssh = getExe openssh; 65 + ipmitool = getExe ipmitool; 66 + }; 67 + in 68 + 69 + stdenv.mkDerivation (finalAttrs: { 70 + pname = "collectl"; 71 + version = "4.3.20.1"; 72 + 73 + src = fetchFromGitHub { 74 + owner = "sharkcz"; 75 + repo = "collectl"; 76 + rev = finalAttrs.version; 77 + hash = "sha256-OJGCuxWvoId1cQ5Ugiav5/T/NzddwhM+gG3s0BnYYz0="; 78 + }; 79 + 80 + strictDeps = true; 81 + 82 + patches = [ 83 + (replaceVars ./0001-scripts-external-executable-calls.patch scriptDeps) 84 + ./0002-fix-install-script.patch 85 + ]; 86 + 87 + buildInputs = [ 88 + perl 89 + dmidecode 90 + ipmitool 91 + ]; 92 + 93 + dontBuild = true; 94 + 95 + installPhase = '' 96 + runHook preInstall 97 + 98 + bash ./INSTALL 99 + 100 + runHook postInstall 101 + ''; 102 + 103 + passthru.tests.run = callPackage ./test.nix { }; 104 + 105 + meta = { 106 + description = "Performance monitoring tool for Linux systems"; 107 + longDescription = '' 108 + Collectl is a light-weight performance monitoring tool capable of reporting 109 + interactively as well as logging to disk. It reports statistics on cpu, disk, 110 + infiniband, lustre, memory, network, nfs, process, quadrics, slabs and more 111 + in easy to read format. 112 + 113 + The `--config` option allows specifying a custom configuration file path, 114 + overriding the default configuration file in the package's etc directory. 115 + ''; 116 + homepage = "https://github.com/sharkcz/collectl"; 117 + downloadPage = "https://github.com/sharkcz/collectl/releases"; 118 + license = with lib.licenses; [ 119 + artistic1 120 + gpl1Plus 121 + ]; 122 + maintainers = with lib.maintainers; [ seven_bear ]; 123 + platforms = lib.platforms.linux; 124 + mainProgram = "collectl"; 125 + }; 126 + })
+44
pkgs/by-name/co/collectl/test.nix
··· 1 + { 2 + runCommand, 3 + collectl, 4 + coreutils, 5 + }: 6 + 7 + runCommand "collectl-test" 8 + { 9 + nativeBuildInputs = [ 10 + collectl 11 + coreutils 12 + ]; 13 + meta.timeout = 60; 14 + } 15 + '' 16 + # Test basic functionality - limit to 5 seconds to avoid hanging 17 + timeout 5s collectl -c1 >/dev/null || true 18 + 19 + # Test that explicit config file option still works with original config 20 + timeout 5s collectl --config ${collectl}/etc/collectl.conf -c1 >/dev/null || true 21 + 22 + # Test custom config file path override 23 + custom_config_path=$(mktemp) 24 + cp ${collectl}/etc/collectl.conf "$custom_config_path" 25 + 26 + # Test that collectl uses the custom config file path 27 + config_output=$(timeout 5s collectl --config "$custom_config_path" -c1 -d1 2>&1 | grep -i "Config File Search Path:" | head -1) 28 + expected_output="Config File Search Path: $custom_config_path" 29 + 30 + if [ "$config_output" = "$expected_output" ]; then 31 + echo "✓ Custom config file path test passed" 32 + else 33 + echo "✗ Custom config file path test failed" 34 + echo "Expected: $expected_output" 35 + echo "Got: $config_output" 36 + exit 1 37 + fi 38 + 39 + # Cleanup 40 + rm -f "$custom_config_path" 41 + 42 + # Signal success 43 + touch $out 44 + ''