@@ -1797,8 +1797,17 @@ static int status_set_callback(char *tgt, size_t tgtsize, const char *token)
17971797 }
17981798
17991799 if (!strcasecmp (token , "ALARM" )) {
1800+ /* Drivers should not do this anymore, but we continue
1801+ * to support it. The upsmon notifiers do not care where
1802+ * alarm tokens get set and legacy drivers may still use
1803+ * this older method. The only real limitations are that ups.alarm
1804+ * does not get published, alarm notifications may show "n/a" instead.
1805+ * We ignore the token here to prepend it to other tokens later within
1806+ * the status_commit() function. For more information, see in discussion:
1807+ * https://github.com/networkupstools/nut/pull/2931#issuecomment-2841705269
1808+ */
18001809 alarm_legacy_status = 1 ;
1801- return 0 ;
1810+ return 0 ; /* ignore it */
18021811 }
18031812
18041813 /* Proceed adding the token */
@@ -1842,7 +1851,11 @@ void status_commit(void)
18421851 }
18431852
18441853 if (alarm_active || alarm_legacy_status ) {
1845- dstate_setinfo ("ups.status" , "ALARM %s" , status_buf );
1854+ if (* status_buf != '\0' ) {
1855+ dstate_setinfo ("ups.status" , "ALARM %s" , status_buf );
1856+ } else {
1857+ dstate_setinfo ("ups.status" , "ALARM" );
1858+ }
18461859 } else {
18471860 dstate_setinfo ("ups.status" , "%s" , status_buf );
18481861 alarm_legacy_status = 0 ; /* just to be sure */
0 commit comments