hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
package HotSaNICmod::OSdep;
use RRDs;
sub version {
($VERSION = '$Revision: 1.8 $') =~ s/.*(\d+\.\d+).*/$1/;
return "$^O.pm $VERSION";
}
sub sample {
my %args=@_;
if ($args{KERNEL} eq "2.4") {
# disk_io: (8,0):(985065,41330,436455,943735,13075448) (8,1):(12563,6363,333604,6200,167608) (8,2):(11194,11012,90140,182,3160)
open FILE,"/proc/stat";
while (<FILE>) { (undef,@stats)=split if /disk_io/; }
close FILE;
foreach my $entry (@stats) {
$entry=~ s/[()]//g;
$entry=~ s/:/,/g;
my ($num1,$num2,undef,$racc,$rblk,$wacc,$wblk)=split /,/,$entry;
$num=$num1."_".$num2;
store_values($args{MODNAME},$num,$racc,$wacc,$rblk,$wblk,512);
}
}
elsif ($args{KERNEL} eq "2.2") {
# disk 1494755 377215 221577 144318
# disk_rio 564538 286941 151189 77490
# disk_wio 930217 90274 70388 66828
# disk_rblk 1129538 573882 302378 154980
# disk_wblk 1860536 180548 140776 133656
open FILE,"/proc/stat";
while (<FILE>) {
(undef,@readacc)=split if /disk_rio/;
(undef,@writeacc)=split if /disk_wio/;
(undef,@readblk)=split if /disk_rblk/;
(undef,@writeblk)=split if /disk_wblk/;
}
close FILE;
$num=0;
while (@readacc) {
$racc=shift @readacc;
$wacc=shift @writeacc;
$rblk=shift @readblk;
$wblk=shift @writeblk;
store_values($args{MODNAME},$num,$racc,$wacc,$rblk,$wblk,512);
$num++;
}
}
}
sub store_values {
my ($MODNAME,$drive,$racc,$wacc,$rblk,$wblk,$blksize)=@_;
if ( ! -e "rrd/$drive.rrd" ) { system("./makerrd","$drive","U") }
RRDs::update "rrd/$drive.rrd",time.":$racc:".($rblk*$blksize).":$wacc:".($wblk*$blksize);
if ($ERROR = RRDs::error) { print time," ","$MODNAME: unable to update `$drive.rrd': $ERROR\n"; }
}
1;
# TODO:
# adapt module to use new kernel structure
#
# ($major,$minor,$blocks,$name,$rio;$rmerge,$rsect,$wio;$wmerge,$wsect,$wuse,$running,$aveq) = split / +/,$line;
#
# cat /proc/partitions
# major minor #blocks name rio rmerge rsect ruse wio wmerge wsect wuse running use aveq
#
# 104 0 35561280 cciss/c0d0 68909 724405 6336824 419050 6956600 6890686 111366402 19464860 0 1497410 19883670
# 104 1 24464 cciss/c0d0p1 27 607 1268 80 7 2 18 20 0 80 100
# 104 2 1052640 cciss/c0d0p2 5 6 64 30 265 1049 10984 14060 0 2210 14090
# 104 3 4198320 cciss/c0d0p3 9254 5869 120470 60170 2145618 2006052 33214056 1824850 0 283200 1885000
# 104 4 1 cciss/c0d0p4 1 0 2 0 0 0 0 0 0 0 0
# 104 5 19926704 cciss/c0d0p5 58885 714532 6187162 342490 3319747 3243011 52953792 15151870 0 736060 15494290
# 104 6 10359104 cciss/c0d0p6 714 2582 26194 10440 1490963 1640572 25187552 2474060 0 610740 2484240
# 104 16 71126640 cciss/c0d1 46332 383183 3435874 228520 20929 467855 3910272 2863240 0 215380 3091720
# 104 17 71126624 cciss/c0d1p1 46329 383174 3435850 228500 20929 467855 3910272 2863240 0 215360 3091700
# major minor #blocks name rio rmerge rsect ruse wio wmerge wsect wuse running use aveq
#
# 8 0 4233600 sda 87022 52087 1111906 12118020 6330547 2877522 73886304 37324609 0 15697687 6495886
# 8 1 1 sda1 0 0 0 0 0 0 0 0 0 0 0
# 8 5 149625 sda5 104 29 890 1280 115 52 1336 1270 0 1940 2550
# 8 6 303502 sda6 0 0 0 0 0 0 0 0 0 0 0
# 8 7 1534270 sda7 41 25 354 1020 1 0 8 0 0 350 1020
# 8 8 511402 sda8 21 25 194 240 1 0 8 0 0 160 240
# 8 9 715144 sda9 90 50 946 2800 530 254 6272 5850 0 5720 8650
# 8 10 1018678 sda10 86759 51937 1109466 12112590 6329900 2877216 73878680 37317489 0 15690877 6483336
# 8 16 8958120 sdb 285 6274 52274 17480 9 3 96 0 0 2750 17480
# 8 17 8956206 sdb1 284 6271 52266 17470 9 3 96 0 0 2740 17470
# 3 0 8257032 hda 193726 71233 2119314 2107820 5636704 4987727 85732672 18207224 0 22854840 20323274
# 3 1 1 hda1 0 0 0 0 0 0 0 0 0 0 0
# 3 5 253953 hda5 12835 9600 178994 190470 1957032 1611062 28545064 12216960 0 3050380 12407430
# 3 6 407200 hda6 2898 10253 105216 97710 2766 11599 117920 77040 0 61740 174800
# 3 7 4092448 hda7 169697 33591 1626610 1580600 2343809 2626912 40498424 31892627 0 13772780 33480437
# 3 8 1020064 hda8 3100 9909 104066 169050 741238 469447 9686144 15820540 0 5594140 15990550
# 3 9 508000 hda9 586 7568 65226 13620 1586 1336 23376 22700 0 24530 36320
# 3 10 1971616 hda10 4603 291 39146 56290 590273 267371 6861744 1127030 0 852560 1183330
# major minor #blocks name rio rmerge rsect ruse wio wmerge wsect wuse running use aveq
#
# 34 0 80043264 ide/host2/bus1/target0/lun0/disc 2368478 1209106 28620666 20372050 2689313 9234680 95391960 22393060 0 26560040 42765110
# 34 1 80043232 ide/host2/bus1/target0/lun0/part1 2368478 1209106 28620666 20372050 2689313 9234680 95391960 22393060 0 26560040 42765110
# 33 0 78156288 ide/host2/bus0/target0/lun0/disc 1416844 466054 15063178 5984550 2219955 4829244 56393656 13350050 0 11109670 19334600
# 33 1 78156256 ide/host2/bus0/target0/lun0/part1 1416844 466054 15063178 5984550 2219955 4829244 56393656 13350050 0 11109670 19334600
# 22 0 80043264 ide/host0/bus1/target0/lun0/disc 9745143 12845870 180728098 9097001 21289780 13295910 276702960 30294484 0 12317751 39394056
# 22 1 80043232 ide/host0/bus1/target0/lun0/part1 9745143 12845870 180728098 9097001 21289780 13295910 276702960 30294484 0 12317751 39394056
# 22 64 80043264 ide/host0/bus1/target1/lun0/disc 1984750 1957415 31537290 22959400 9764772 6543617 130479784 39073688 0 31500000 19091765
# 22 65 80043232 ide/host0/bus1/target1/lun0/part1 1984749 1957412 31537282 22959400 9764772 6543617 130479784 39073688 0 31500000 19091765
# 3 0 15007608 ide/host0/bus0/target0/lun0/disc 6632275 5644782 98028258 22654492 70997906 80414575 1213797554 23639842 0 30358495 4784751
# 3 1 16033 ide/host0/bus0/target0/lun0/part1 1682 29794 62952 19840 651 1699 4712 29320 0 24940 49160
# 3 2 409657 ide/host0/bus0/target0/lun0/part2 18469 37372 446736 635280 11045 38713 405728 985320 0 520850 1621540
# 3 3 14578987 ide/host0/bus0/target0/lun0/part3 6612122 5577610 97518554 21998862 70986209 80374163 1213387112 22625202 0 30200585 3113541