1
1
/*
2
2
** ATOP - System & Process Monitor
3
3
**
4
- ** The program 'atop' offers the possibility to view the activity of
4
+ ** The program 'atop' offers the possibility to view the activity of
5
5
** the system on system-level as well as process-level.
6
6
**
7
7
** This program converts a raw logfile created by a particular version
11
11
** E-mail: gerlof.langeveld@atoptool.nl
12
12
** Initial: July/August 2018
13
13
** --------------------------------------------------------------------------
14
- ** Copyright (C) 2018-2022 Gerlof Langeveld
14
+ ** Copyright (C) 2018-2024 Gerlof Langeveld
15
15
**
16
16
** This program is free software; you can redistribute it and/or modify it
17
17
** under the terms of the GNU General Public License as published by the
85
85
#include "prev/photosyst_29.h"
86
86
#include "prev/photoproc_29.h"
87
87
88
+ #include "prev/photosyst_210.h"
89
+ #include "prev/photoproc_210.h"
90
+
88
91
89
92
void justcopy (void * , void * , count_t , count_t );
90
93
91
94
void scpu_to_21 (void * , void * , count_t , count_t );
92
95
void sdsk_to_21 (void * , void * , count_t , count_t );
96
+
93
97
void sint_to_22 (void * , void * , count_t , count_t );
98
+
94
99
void scpu_to_27 (void * , void * , count_t , count_t );
95
100
void smem_to_27 (void * , void * , count_t , count_t );
96
101
void sdsk_to_27 (void * , void * , count_t , count_t );
102
+
97
103
void smem_to_28 (void * , void * , count_t , count_t );
98
104
void sdsk_to_28 (void * , void * , count_t , count_t );
99
105
void smnu_to_28 (void * , void * , count_t , count_t );
100
106
void scnu_to_28 (void * , void * , count_t , count_t );
107
+
108
+ void sllc_to_210 (void * , void * , count_t , count_t );
109
+
101
110
void tgen_to_21 (void * , void * , count_t , count_t );
102
111
void tmem_to_21 (void * , void * , count_t , count_t );
112
+
103
113
void tgen_to_22 (void * , void * , count_t , count_t );
114
+
104
115
void tcpu_to_26 (void * , void * , count_t , count_t );
105
116
void tmem_to_26 (void * , void * , count_t , count_t );
117
+
106
118
void tcpu_to_28 (void * , void * , count_t , count_t );
107
119
void tmem_to_28 (void * , void * , count_t , count_t );
108
120
121
+ void tgen_to_210 (void * , void * , count_t , count_t );
122
+
109
123
///////////////////////////////////////////////////////////////
110
124
// Conversion functions
111
125
// --------------------
@@ -190,7 +204,7 @@ sint_to_22(void *old, void *new, count_t oldsize, count_t newsize)
190
204
sizeof (struct perintf_21 ));
191
205
192
206
// correct last members by refilling
193
- //
207
+ //
194
208
i22 -> intf [i ].type = '?' ;
195
209
i22 -> intf [i ].speed = i21 -> intf [i ].speed ;
196
210
i22 -> intf [i ].speedp = i21 -> intf [i ].speed ;
@@ -330,7 +344,7 @@ smnu_to_28(void *old, void *new, count_t oldsize, count_t newsize)
330
344
n28 -> numa [i ].inactive = n27 -> numa [i ].inactive ;
331
345
n28 -> numa [i ].shmem = n27 -> numa [i ].shmem ;
332
346
n28 -> numa [i ].tothp = n27 -> numa [i ].tothp ;
333
- }
347
+ }
334
348
}
335
349
336
350
void
@@ -355,9 +369,26 @@ scnu_to_28(void *old, void *new, count_t oldsize, count_t newsize)
355
369
n28 -> numa [i ].Stime = n27 -> numa [i ].Stime ;
356
370
n28 -> numa [i ].steal = n27 -> numa [i ].steal ;
357
371
n28 -> numa [i ].guest = n27 -> numa [i ].guest ;
358
- }
372
+ }
359
373
}
360
374
375
+ void
376
+ sllc_to_210 (void * old , void * new , count_t oldsize , count_t newsize )
377
+ {
378
+ struct llcstat_29 * l29 = old ;
379
+ struct llcstat_210 * l210 = new ;
380
+ int i ;
381
+
382
+ l210 -> nrllcs = l29 -> nrllcs ;
383
+
384
+ for (i = 0 ; i < l210 -> nrllcs ; i ++ )
385
+ {
386
+ l210 -> perllc [i ].id = l29 -> perllc [i ].id ;
387
+ l210 -> perllc [i ].occupancy = l29 -> perllc [i ].occupancy ;
388
+ l210 -> perllc [i ].mbm_local = l29 -> perllc [i ].mbm_local ;
389
+ l210 -> perllc [i ].mbm_total = l29 -> perllc [i ].mbm_total ;
390
+ }
391
+ }
361
392
362
393
// /////////////////////////////////////////////////////////////////
363
394
// Specific functions that convert an old tstat sub-structure to
@@ -482,6 +513,25 @@ tmem_to_28(void *old, void *new, count_t oldsize, count_t newsize)
482
513
memset (m28 -> cfuture , 0 , sizeof m28 -> cfuture );
483
514
}
484
515
516
+ void
517
+ tgen_to_210 (void * old , void * new , count_t oldsize , count_t newsize )
518
+ {
519
+ // member 'nthridle' inserted, everything from member 'ctid' must shift
520
+ //
521
+ struct gen_29 * g29 = old ;
522
+ struct gen_210 * g210 = new ;
523
+
524
+ memcpy (g210 , g29 , (char * )& g29 -> ctid - (char * )g29 ); // copy base values
525
+
526
+ g210 -> nthridle = 0 ;
527
+ g210 -> ctid = g29 -> ctid ;
528
+ g210 -> vpid = g29 -> vpid ;
529
+ g210 -> wasinactive = g29 -> wasinactive ;
530
+
531
+ memcpy (g210 -> utsname , g29 -> container , sizeof (g210 -> utsname ));
532
+ memcpy (g210 -> cgpath , g29 -> cgpath , sizeof (g210 -> cgpath ));
533
+ }
534
+
485
535
///////////////////////////////////////////////////////////////
486
536
// conversion definition for various structs in sstat and tstat
487
537
//
@@ -510,6 +560,7 @@ struct sstat_26 sstat_26;
510
560
struct sstat_27 sstat_27 ;
511
561
struct sstat_28 sstat_28 ;
512
562
struct sstat_29 sstat_29 ;
563
+ struct sstat_210 sstat_210 ;
513
564
struct sstat sstat ;
514
565
515
566
struct tstat_20 tstat_20 ;
@@ -522,6 +573,7 @@ struct tstat_26 tstat_26;
522
573
struct tstat_27 tstat_27 ;
523
574
struct tstat_28 tstat_28 ;
524
575
struct tstat_29 tstat_29 ;
576
+ struct tstat_210 tstat_210 ;
525
577
struct tstat tstat ;
526
578
527
579
struct convertall {
@@ -556,7 +608,7 @@ struct convertall {
556
608
struct tconvstruct tmem ;
557
609
struct tconvstruct tnet ;
558
610
struct tconvstruct tgpu ;
559
- } convs [] =
611
+ } convs [] =
560
612
{
561
613
{SETVERSION (2 ,0 ),
562
614
sizeof (struct sstat_20 ), & sstat_20 ,
@@ -577,11 +629,11 @@ struct convertall {
577
629
{0 , NULL , NULL },
578
630
{0 , NULL , NULL },
579
631
580
- {sizeof (struct gen_20 ),
632
+ {sizeof (struct gen_20 ),
581
633
STROFFSET (& tstat_20 .gen , & tstat_20 ), NULL },
582
634
{sizeof (struct cpu_20 ),
583
635
STROFFSET (& tstat_20 .cpu , & tstat_20 ), NULL },
584
- {sizeof (struct dsk_20 ),
636
+ {sizeof (struct dsk_20 ),
585
637
STROFFSET (& tstat_20 .dsk , & tstat_20 ), NULL },
586
638
{sizeof (struct mem_20 ),
587
639
STROFFSET (& tstat_20 .mem , & tstat_20 ), NULL },
@@ -613,7 +665,7 @@ struct convertall {
613
665
STROFFSET (& tstat_21 .gen , & tstat_21 ), tgen_to_21 },
614
666
{sizeof (struct cpu_21 ),
615
667
STROFFSET (& tstat_21 .cpu , & tstat_21 ), justcopy },
616
- {sizeof (struct dsk_21 ),
668
+ {sizeof (struct dsk_21 ),
617
669
STROFFSET (& tstat_21 .dsk , & tstat_21 ), justcopy },
618
670
{sizeof (struct mem_21 ),
619
671
STROFFSET (& tstat_21 .mem , & tstat_21 ), tmem_to_21 },
@@ -641,7 +693,7 @@ struct convertall {
641
693
{0 , NULL , NULL },
642
694
{0 , NULL , NULL },
643
695
644
- {sizeof (struct gen_22 ),
696
+ {sizeof (struct gen_22 ),
645
697
STROFFSET (& tstat_22 .gen , & tstat_22 ), tgen_to_22 },
646
698
{sizeof (struct cpu_22 ),
647
699
STROFFSET (& tstat_22 .cpu , & tstat_22 ), justcopy },
@@ -679,7 +731,7 @@ struct convertall {
679
731
STROFFSET (& tstat_23 .cpu , & tstat_23 ), justcopy },
680
732
{sizeof (struct dsk_23 ),
681
733
STROFFSET (& tstat_23 .dsk , & tstat_23 ), justcopy },
682
- {sizeof (struct mem_23 ),
734
+ {sizeof (struct mem_23 ),
683
735
STROFFSET (& tstat_23 .mem , & tstat_23 ), justcopy },
684
736
{sizeof (struct net_23 ),
685
737
STROFFSET (& tstat_23 .net , & tstat_23 ), justcopy },
@@ -883,6 +935,39 @@ struct convertall {
883
935
{sizeof (struct gpu_29 ),
884
936
STROFFSET (& tstat_29 .gpu , & tstat_29 ), justcopy },
885
937
},
938
+
939
+ {SETVERSION (2 ,10 ), // 2.9 --> 2.10
940
+ sizeof (struct sstat_210 ), & sstat_210 ,
941
+ sizeof (struct tstat_210 ), NULL ,
942
+
943
+ {sizeof (struct cpustat_210 ), & sstat_210 .cpu , justcopy },
944
+ {sizeof (struct memstat_210 ), & sstat_210 .mem , justcopy },
945
+ {sizeof (struct netstat_210 ), & sstat_210 .net , justcopy },
946
+ {sizeof (struct intfstat_210 ), & sstat_210 .intf , justcopy },
947
+ {sizeof (struct dskstat_210 ), & sstat_210 .dsk , justcopy },
948
+ {sizeof (struct nfsstat_210 ), & sstat_210 .nfs , justcopy },
949
+ {sizeof (struct contstat_210 ), & sstat_210 .cfs , justcopy },
950
+ {sizeof (struct wwwstat_210 ), & sstat_210 .www , justcopy },
951
+ {sizeof (struct pressure_210 ), & sstat_210 .psi , justcopy },
952
+ {sizeof (struct gpustat_210 ), & sstat_210 .gpu , justcopy },
953
+ {sizeof (struct ifbstat_210 ), & sstat_210 .ifb , justcopy },
954
+ {sizeof (struct memnuma_210 ), & sstat_210 .memnuma , justcopy },
955
+ {sizeof (struct cpunuma_210 ), & sstat_210 .cpunuma , justcopy },
956
+ {sizeof (struct llcstat_210 ), & sstat_210 .llc , sllc_to_210 },
957
+
958
+ {sizeof (struct gen_210 ),
959
+ STROFFSET (& tstat_210 .gen , & tstat_210 ), tgen_to_210 },
960
+ {sizeof (struct cpu_210 ),
961
+ STROFFSET (& tstat_210 .cpu , & tstat_210 ), justcopy },
962
+ {sizeof (struct dsk_210 ),
963
+ STROFFSET (& tstat_210 .dsk , & tstat_210 ), justcopy },
964
+ {sizeof (struct mem_210 ),
965
+ STROFFSET (& tstat_210 .mem , & tstat_210 ), justcopy },
966
+ {sizeof (struct net_210 ),
967
+ STROFFSET (& tstat_210 .net , & tstat_210 ), justcopy },
968
+ {sizeof (struct gpu_210 ),
969
+ STROFFSET (& tstat_210 .gpu , & tstat_210 ), justcopy },
970
+ },
886
971
};
887
972
888
973
int numconvs = sizeof convs / sizeof (struct convertall );
@@ -1046,7 +1131,7 @@ main(int argc, char *argv[])
1046
1131
exit (11 );
1047
1132
}
1048
1133
1049
- // handle the output file
1134
+ // handle the output file
1050
1135
//
1051
1136
if (optind >= argc )
1052
1137
exit (0 );
@@ -1060,7 +1145,7 @@ main(int argc, char *argv[])
1060
1145
exit (12 );
1061
1146
}
1062
1147
1063
- // open the output file
1148
+ // open the output file
1064
1149
//
1065
1150
if ( (ofd = openout (outfile )) == -1 )
1066
1151
{
@@ -1076,6 +1161,9 @@ main(int argc, char *argv[])
1076
1161
orh .sstatlen = convs [targetix ].sstatlen ;
1077
1162
orh .tstatlen = convs [targetix ].tstatlen ;
1078
1163
1164
+ if (orh .pidwidth == 0 ) // no pid width know in old raw log?
1165
+ orh .pidwidth = getpidwidth ();
1166
+
1079
1167
writeout (ofd , & orh , sizeof orh );
1080
1168
1081
1169
printf ("Version of %s: %d.%d\n" , outfile ,
@@ -1127,7 +1215,7 @@ convert_samples(int ifd, int ofd, struct rawheader *irh, int ivix, int ovix)
1127
1215
exit (7 );
1128
1216
1129
1217
// STEP-BY-STEP CONVERSION FROM OLD VERSION TO NEW VERSION
1130
- //
1218
+ //
1131
1219
for (i = ivix ; i < ovix ; i ++ )
1132
1220
{
1133
1221
// convert system-level statistics to newer version
@@ -1161,32 +1249,32 @@ convert_samples(int ifd, int ofd, struct rawheader *irh, int ivix, int ovix)
1161
1249
for (t = 0 ; t < irr .ndeviat ; t ++ ) // for every task
1162
1250
{
1163
1251
do_tconvert (
1164
- convs [i ].tstat + (t * convs [i ].tstatlen ),
1252
+ convs [i ].tstat + (t * convs [i ].tstatlen ),
1165
1253
convs [i + 1 ].tstat + (t * convs [i + 1 ].tstatlen ),
1166
1254
& (convs [i ].tgen ), & (convs [i + 1 ].tgen ));
1167
1255
1168
1256
do_tconvert (
1169
- convs [i ].tstat + (t * convs [i ].tstatlen ),
1257
+ convs [i ].tstat + (t * convs [i ].tstatlen ),
1170
1258
convs [i + 1 ].tstat + (t * convs [i + 1 ].tstatlen ),
1171
1259
& (convs [i ].tcpu ), & (convs [i + 1 ].tcpu ));
1172
1260
1173
1261
do_tconvert (
1174
- convs [i ].tstat + (t * convs [i ].tstatlen ),
1262
+ convs [i ].tstat + (t * convs [i ].tstatlen ),
1175
1263
convs [i + 1 ].tstat + (t * convs [i + 1 ].tstatlen ),
1176
1264
& (convs [i ].tdsk ), & (convs [i + 1 ].tdsk ));
1177
1265
1178
1266
do_tconvert (
1179
- convs [i ].tstat + (t * convs [i ].tstatlen ),
1267
+ convs [i ].tstat + (t * convs [i ].tstatlen ),
1180
1268
convs [i + 1 ].tstat + (t * convs [i + 1 ].tstatlen ),
1181
1269
& (convs [i ].tmem ), & (convs [i + 1 ].tmem ));
1182
1270
1183
1271
do_tconvert (
1184
- convs [i ].tstat + (t * convs [i ].tstatlen ),
1272
+ convs [i ].tstat + (t * convs [i ].tstatlen ),
1185
1273
convs [i + 1 ].tstat + (t * convs [i + 1 ].tstatlen ),
1186
1274
& (convs [i ].tnet ), & (convs [i + 1 ].tnet ));
1187
1275
1188
1276
do_tconvert (
1189
- convs [i ].tstat + (t * convs [i ].tstatlen ),
1277
+ convs [i ].tstat + (t * convs [i ].tstatlen ),
1190
1278
convs [i + 1 ].tstat + (t * convs [i + 1 ].tstatlen ),
1191
1279
& (convs [i ].tgpu ), & (convs [i + 1 ].tgpu ));
1192
1280
}
@@ -1203,7 +1291,7 @@ convert_samples(int ifd, int ofd, struct rawheader *irh, int ivix, int ovix)
1203
1291
irr .ndeviat );
1204
1292
1205
1293
// cleanup
1206
- //
1294
+ //
1207
1295
free (convs [ovix ].tstat );
1208
1296
}
1209
1297
@@ -1524,7 +1612,7 @@ testcompval(int rv, char *func)
1524
1612
exit (7 );
1525
1613
1526
1614
case Z_DATA_ERROR :
1527
- fprintf (stderr ,
1615
+ fprintf (stderr ,
1528
1616
"%s: failed due to corrupted/incomplete data\n" , func );
1529
1617
exit (7 );
1530
1618
@@ -1551,3 +1639,28 @@ ptrverify(const void *ptr, const char *errormsg, ...)
1551
1639
exit (13 );
1552
1640
}
1553
1641
}
1642
+
1643
+
1644
+ /*
1645
+ ** return maximum number of digits for PID/TID
1646
+ ** from the current system
1647
+ */
1648
+ int
1649
+ getpidwidth (void )
1650
+ {
1651
+ FILE * fp ;
1652
+ char linebuf [64 ];
1653
+ int numdigits = 5 ;
1654
+
1655
+ if ( (fp = fopen ("/proc/sys/kernel/pid_max" , "r" )) != NULL )
1656
+ {
1657
+ if ( fgets (linebuf , sizeof (linebuf ), fp ) != NULL )
1658
+ {
1659
+ numdigits = strlen (linebuf ) - 1 ;
1660
+ }
1661
+
1662
+ fclose (fp );
1663
+ }
1664
+
1665
+ return numdigits ;
1666
+ }
0 commit comments