@@ -1230,6 +1230,8 @@ int main(int argc, char *argv[])
12301230 }
12311231#endif /* HAVE_PTHREAD && ( HAVE_PTHREAD_TRYJOIN || HAVE_SEMAPHORE_UNNAMED || HAVE_SEMAPHORE_NAMED ) && HAVE_SYS_RESOURCE_H */
12321232
1233+ setproctag (progname );
1234+
12331235 memset (& snmp_sec , 0 , sizeof (snmp_sec ));
12341236 memset (& ipmi_sec , 0 , sizeof (ipmi_sec ));
12351237 memset (& xml_sec , 0 , sizeof (xml_sec ));
@@ -1724,6 +1726,7 @@ int main(int argc, char *argv[])
17241726 * during build also serve as a fallback for pthread failure at runtime?
17251727 */
17261728 if (allow_usb && nutscan_avail_usb ) {
1729+ setproctag ("usb" );
17271730 upsdebugx (quiet , "Scanning USB bus." );
17281731#ifdef HAVE_PTHREAD
17291732 if (pthread_create (& thread [TYPE_USB ], NULL , run_usb , & cli_link_detail_level )) {
@@ -1744,6 +1747,7 @@ int main(int argc, char *argv[])
17441747 nutscan_avail_snmp = 0 ;
17451748 }
17461749 else {
1750+ setproctag ("snmp" );
17471751 upsdebugx (quiet , "Scanning SNMP bus." );
17481752#ifdef HAVE_PTHREAD
17491753 upsdebugx (1 , "SNMP SCAN: starting pthread_create with run_snmp..." );
@@ -1767,6 +1771,7 @@ int main(int argc, char *argv[])
17671771 * so it just runs (if requested and
17681772 * supported).
17691773 */
1774+ setproctag ("netxml" );
17701775 upsdebugx (quiet , "Scanning XML/HTTP bus." );
17711776 xml_sec .usec_timeout = timeout ;
17721777#ifdef HAVE_PTHREAD
@@ -1790,6 +1795,7 @@ int main(int argc, char *argv[])
17901795 nutscan_avail_nut = 0 ;
17911796 }
17921797 else {
1798+ setproctag ("oldnut" );
17931799 upsdebugx (quiet , "Scanning NUT bus (old libupsclient connect method)." );
17941800#ifdef HAVE_PTHREAD
17951801 upsdebugx (1 , "NUT bus (old) SCAN: starting pthread_create with run_nut_old..." );
@@ -1808,6 +1814,7 @@ int main(int argc, char *argv[])
18081814 }
18091815
18101816 if (allow_nut_simulation && nutscan_avail_nut_simulation ) {
1817+ setproctag ("nut_simulation" );
18111818 upsdebugx (quiet , "Scanning NUT simulation devices." );
18121819#ifdef HAVE_PTHREAD
18131820 upsdebugx (1 , "NUT simulation devices SCAN: starting pthread_create with run_nut_simulation..." );
@@ -1825,6 +1832,7 @@ int main(int argc, char *argv[])
18251832 }
18261833
18271834 if (allow_avahi && nutscan_avail_avahi ) {
1835+ setproctag ("avahi" );
18281836 upsdebugx (quiet , "Scanning NUT bus (avahi method)." );
18291837#ifdef HAVE_PTHREAD
18301838 upsdebugx (1 , "NUT bus (avahi) SCAN: starting pthread_create with run_avahi..." );
@@ -1847,6 +1855,7 @@ int main(int argc, char *argv[])
18471855 * so it just runs (if requested and
18481856 * supported).
18491857 */
1858+ setproctag ("ipmi" );
18501859 upsdebugx (quiet , "Scanning IPMI bus." );
18511860#ifdef HAVE_PTHREAD
18521861 upsdebugx (1 , "IPMI SCAN: starting pthread_create with run_ipmi..." );
@@ -1864,6 +1873,7 @@ int main(int argc, char *argv[])
18641873 }
18651874
18661875 if (allow_upower && nutscan_avail_upower ) {
1876+ setproctag ("upower" );
18671877 upsdebugx (quiet , "Scanning UPower bus." );
18681878#ifdef HAVE_PTHREAD
18691879 upsdebugx (1 , "UPOWER SCAN: starting pthread_create with run_upower..." );
@@ -1881,6 +1891,7 @@ int main(int argc, char *argv[])
18811891
18821892 /* Eaton serial scan */
18831893 if (allow_eaton_serial ) {
1894+ setproctag ("serial" );
18841895 upsdebugx (quiet , "Scanning serial bus for Eaton devices." );
18851896#ifdef HAVE_PTHREAD
18861897 upsdebugx (1 , "SERIAL SCAN: starting pthread_create with run_eaton_serial (return not checked!)..." );
@@ -1897,6 +1908,8 @@ int main(int argc, char *argv[])
18971908 upsdebugx (1 , "SERIAL SCAN: not requested or supported, SKIPPED" );
18981909 }
18991910
1911+ setproctag ("post-processing" );
1912+
19001913#ifdef HAVE_PTHREAD
19011914 if (allow_usb && nutscan_avail_usb && thread [TYPE_USB ]) {
19021915 upsdebugx (1 , "USB SCAN: join back the pthread" );
0 commit comments