0

I have a script that uses CUPS lpstat -h command. However, the remote server I am trying to get a response from asks for a password. But I need to execute this script from within Nagios, so I have two questions I am hoping someone can shed some light on.

First, does anyone know of a way to include the password when sending the lpstat command? Example would be: lpstat -h 192.168.1.106 -p PO1 the address is my remote server, PO1 is the name of the printer on that server. It seems cups left out a way to add a password to that command, so it comes up as a prompt.

Second, if I have a script that uses that lpstat command integrally, is there a way to execute the script AND send the password from one command? I tried to echo it but the prompt doesn't accept that. I don't see a prompt when executing the script, it just hangs until I enter my password and press enter, then it completes and outputs the result I need.

I tried using expect scripts, but since there is nothing to expect (if running the script that uses lpstat, I don't get an actual prompt), so I just sent "send" commands, which seems to execute the script but didn't pass on the output.

I'm stuck here, all the scripts I have found for remotely checking the status of a CUPS printer require user input, and unless I can find a way to do it in one line and output a result, I can't use it in Nagios.

  • 1
    Instead of executing lpstat locally pointed at the remote host, you could use nrpe to run it on the cups server which will not require a password if the user is in the lp group. – jordanm Feb 20 '15 at 21:55
  • Hmm, I think that might work. I modified the script to remove the -h and tested it on the server and it ran just fine, so I will add it to my nrpe config, enable the arguments through nrpe, and set it up on the nagios server and see if it returns the right info. Thanks! – Dave Feb 20 '15 at 22:17
0

Although I didn't find the answer to the title, jordanm's response led me in the direction I needed. I was able to use nrpe to execute the script on the print server and therefore didn't need to enter a password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.