summaryrefslogtreecommitdiffstats
path: root/web/attachments/216171-check_hpjd_jetreadysupport.patch
blob: f33c934ea0b01538003972bbbce02611cabaa98d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
diff -Naur nagios-plugins-1.4.5-orig/plugins/check_hpjd.c nagios-plugins-1.4.5/plugins/check_hpjd.c
--- nagios-plugins-1.4.5-orig/plugins/check_hpjd.c	2006-10-18 20:25:16.000000000 -0400
+++ nagios-plugins-1.4.5/plugins/check_hpjd.c	2007-02-15 12:31:34.000000000 -0500
@@ -64,6 +64,11 @@
 
 #define ONLINE		0
 #define OFFLINE		1
+#define JAONLINE		1
+#define JAOFFLINE		0
+
+#define JETDIRECT	0
+#define JETREADY	1
 
 int process_arguments (int, char **);
 int validate_arguments (void);
@@ -71,6 +76,7 @@
 void print_usage (void);
 
 char *community = NULL;
+char *jd_type = JETDIRECT;		// default to JetDirect type
 char *address = NULL;
 
 int
@@ -245,8 +251,8 @@
 			result = STATE_WARNING;
 			strcpy (errmsg, _("Out of Paper"));
 		}
-		else if (line_status == OFFLINE) {
-			if (strcmp (errmsg, "POWERSAVE ON") != 0) {
+		else if ((line_status == OFFLINE && jd_type == JETDIRECT) || (line_status == JAOFFLINE && jd_type == JETREADY)) {
+			if ((strcmp (errmsg, "POWERSAVE ON") != 0) || (strcmp (errmsg, "Sleep mode on") != 0)) {
 				result = STATE_WARNING;
 				strcpy (errmsg, _("Printer Offline"));
 			}
@@ -317,6 +323,7 @@
 /*  		{"critical",       required_argument,0,'c'}, */
 /*  		{"warning",        required_argument,0,'w'}, */
 /*  		{"port",           required_argument,0,'P'}, */
+		{"jetready", no_argument, 0, 'A'},
 		{"version", no_argument, 0, 'V'},
 		{"help", no_argument, 0, 'h'},
 		{0, 0, 0, 0}
@@ -327,7 +334,7 @@
 
 	
 	while (1) {
-		c = getopt_long (argc, argv, "+hVH:C:", longopts, &option);
+		c = getopt_long (argc, argv, "+hVAH:C:", longopts, &option);
 
 		if (c == -1 || c == EOF || c == 1)
 			break;
@@ -344,6 +351,9 @@
 		case 'C':									/* community */
 			community = strscpy (community, optarg);
 			break;
+		case 'A':									/* change jd type */
+			jd_type = JETREADY;
+			break;
 		case 'V':									/* version */
 			print_revision (progname, revision);
 			exit (STATE_OK);
@@ -400,6 +410,8 @@
 
 	printf (_(UT_HELP_VRSN));
 
+	printf (" %s\n", "-A, --jetready");
+  printf ("    %s", _("Change logic from assuming JetDirect to JetReady support"));
 	printf (" %s\n", "-C, --community=STRING");
   printf ("    %s", _("The SNMP community name "));
   printf (_("(default=%s)"), DEFAULT_COMMUNITY);
@@ -413,5 +425,5 @@
 print_usage (void)
 {
   printf (_("Usage:"));
-	printf ("%s -H host [-C community]\n", progname);
+	printf ("%s -H host [-a] [-C community]\n", progname);
 }