Monitor print queues with NRPE

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Monitor print queues with NRPE

Postby jkinning » Tue Aug 07, 2018 12:40 pm

I am trying to figure out how I can monitor Windows Server print queues. I have an application called intellscribe that kicks off print jobs to a Solimar system. We had an issue where the Solimar unit wasn't listening to port 515, Nagios alerted of this problem, but there was nothing the the users waiting for output was aware of. So, I am trying to add monitoring to monitor the print queues. I have read a few article from Google searches that indicate using Performance Monitors; however, I don't see anything listed for this. The other snag I have encountered is the application writes it's log to a dated CSV file. I was going to try and use NRPE to monitor the log file for a "disconnect" message and then send an alert.

Is it possible to monitor a dated csv file and Nagios looks at the latest file all the time for specific content?
Any other way to monitor local or remote print queue?
jkinning
 
Posts: 731
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor print queues with NRPE

Postby lmiltchev » Tue Aug 07, 2018 3:52 pm

You could try searching for a pattern in your csv file, e.g. "disconnect", using the check_log3.exe plugin and check_nrpe, and nsclient++.

https://github.com/pmcaulay/nagios-plugins

Example:

In nsclient.ini
Code: Select all
check_print_queue = scripts\check_log3.exe -l "c:\printqueue.csv" -p "disconnect"


Testing from the CLI
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H <ip address> -c check_print_queue
OK: Found 0 lines (limit=1/0): No matches found.|'lines'=0

/usr/local/nagios/libexec/check_nrpe -H <ip address> -c check_print_queue
WARNING: Found 1 lines (limit=1/0): disconnect|'lines'=1


There could be more (better) plugins out there. This is just an example. You could call this plugin via check_nrpe and NSClient++ or via check_ncpa.py if you wish. You could also use NCPA or check_nrpe with NSClient++ to call a custom script, that can monitor the print queues locally.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
QA Manager
 
Posts: 10506
Joined: Mon May 23, 2011 12:15 pm

Re: Monitor print queues with NRPE

Postby jkinning » Wed Aug 15, 2018 9:49 am

I believe I am almost there. This could work but the application creates dated csv files. I am not sure how I can have Nagios look for the recent csv file and scan that since it changes daily.

Any thoughts? I might have to look for another option if not.
jkinning
 
Posts: 731
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor print queues with NRPE

Postby lmiltchev » Wed Aug 15, 2018 4:06 pm

This could work but the application creates dated csv files.

Maybe check_log3.exe is not the best plugin to be used in this case. Maybe you will need to use some kind of custom PS script. Can you give us an example of the name of one of the csv files?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
QA Manager
 
Posts: 10506
Joined: Mon May 23, 2011 12:15 pm

Re: Monitor print queues with NRPE

Postby jkinning » Thu Aug 16, 2018 8:12 am

The application creates the logs in the directory like this.
20180816.CSV
20180815.CSV
20180814.CSV
20180813.CSV

Start of each new day a new dated .CSV file is created which the application logs to.

Here is a sample of data from the logs. The issue I am trying to get monitored occurred again between 1:35AM-1:42AM. There is a socket error which prevents the print job from getting sent to the printer.

Code: Select all
'Timestamp   Severity   Type   Name   Id   Message
'01:23:39.959   Info   JobManager.JobManager   JobManager   1   Print job 'D:\ESP\Data\ESPIA_xPub\output\ESPIA_XPUB.ps:33351' received from ISendfile
'01:23:40.100   Info   JobManager.JobManager   JobManager   1   Print job 'D:\ESP\Data\ESPIA_xPub\output\ESPIA_XPUB_14_DAY.ps:33352' received from ISendfile
'01:23:43.953   Info   PrintCmd   JobExec   29   Job 'pr23staple00008245.tmp:33351' successfully printed to destination pr23staple:solimar:pr23staple
'01:23:47.806   Info   PrintCmd   JobExec   30   Job 'pr23staple00008246.tmp:33352' successfully printed to destination pr23staple:solimar:pr23staple
'01:30:10.824   Info   JobManager.JobManager   JobManager   1   Print job 'D:\ESP\DATA\IFS\polprint\ADMNPOLICY\OUTPUT\IFS_ADMND421.ps:33353' received from ISendfile
'01:35:11.004   Info   PrintCmd   JobExec   31   Connection timed out after 300 seconds
'01:35:11.004   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression00008247.tmp' on destination 'xPression:solimar:xPression'
'01:35:46.744   Info   JobManager.JobManager   JobManager   1   Print job 'D:\ESP\Data\EnterpriseIndexDocuments\OptionRenewal\Owner\Output\OPTION_RENEWAL_NOTICE_INSERT.ps:33354' received from ISendfile
'01:35:47.790   Error   protocol   Lpd.Print   33   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:35:47.790   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008248.tmp' on destination 'xPublish:solimar:xPublish'
'01:35:54.825   Error   protocol   Lpd.Print   34   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:35:54.825   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008248.tmp' on destination 'xPublish:solimar:xPublish'
'01:36:03.858   Error   protocol   Lpd.Print   35   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:36:03.858   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008248.tmp' on destination 'xPublish:solimar:xPublish'
'01:36:15.964   Error   protocol   Lpd.Print   36   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:36:15.964   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008248.tmp' on destination 'xPublish:solimar:xPublish'
'01:36:28.569   Info   JobManager.JobManager   JobManager   1   Print job 'D:\ESP\Data\EnterpriseIndexDocuments\OptionRenewal\Agent\Output\OPTION_RENEWAL_NOTICE_INSERT.ps:33355' received from ISendfile
'01:36:30.051   Error   protocol   Lpd.Print   37   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:36:30.051   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008248.tmp' on destination 'xPublish:solimar:xPublish'
'01:36:47.086   Error   protocol   Lpd.Print   38   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:36:47.086   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008248.tmp' on destination 'xPublish:solimar:xPublish'
'01:36:47.086   Error   Retries   RetryManager   1   Job  'xPublish00008248.tmp'  retried  '5' times
'01:36:47.086   Info   PrintCmd   JobExec   32   Handling destination failure for 'xPublish:solimar:xPublish'
'01:36:47.102   Error   PrintCmd   JobExec   32   Destination failure: no more destinations for queue 'xPublish'
'01:36:48.131   Error   protocol   Lpd.Print   39   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:36:48.131   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008249.tmp' on destination 'xPublish:solimar:xPublish'
'01:36:55.167   Error   protocol   Lpd.Print   40   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:36:55.167   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008249.tmp' on destination 'xPublish:solimar:xPublish'
'01:37:04.200   Error   protocol   Lpd.Print   41   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:37:04.200   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008249.tmp' on destination 'xPublish:solimar:xPublish'
'01:37:16.212   Error   protocol   Lpd.Print   42   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:37:16.212   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008249.tmp' on destination 'xPublish:solimar:xPublish'
'01:37:30.237   Error   protocol   Lpd.Print   43   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:37:30.237   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008249.tmp' on destination 'xPublish:solimar:xPublish'
'01:37:47.272   Error   protocol   Lpd.Print   44   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:37:47.272   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPublish00008249.tmp' on destination 'xPublish:solimar:xPublish'
'01:37:47.272   Error   Retries   RetryManager   1   Job  'xPublish00008249.tmp'  retried  '5' times
'01:37:47.272   Info   PrintCmd   JobExec   33   Handling destination failure for 'xPublish:solimar:xPublish'
'01:37:47.272   Error   PrintCmd   JobExec   33   Destination failure: no more destinations for queue 'xPublish'
'01:40:18.002   Info   PrintCmd   JobExec   31   Connection timed out after 300 seconds
'01:40:18.002   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression00008247.tmp' on destination 'xPression:solimar:xPression'
'01:40:27.034   Error   protocol   Lpd.Print   45   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:40:27.034   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression00008247.tmp' on destination 'xPression:solimar:xPression'
'01:40:39.078   Error   protocol   Lpd.Print   46   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:40:39.078   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression00008247.tmp' on destination 'xPression:solimar:xPression'
'01:40:53.102   Error   protocol   Lpd.Print   47   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:40:53.102   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression00008247.tmp' on destination 'xPression:solimar:xPression'
'01:41:10.138   Error   protocol   Lpd.Print   48   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:41:10.138   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression00008247.tmp' on destination 'xPression:solimar:xPression'
'01:41:10.138   Error   Retries   RetryManager   1   Job  'xPression00008247.tmp'  retried  '5' times
'01:41:10.138   Info   PrintCmd   JobExec   31   Handling destination failure for 'xPression:solimar:xPression'
'01:41:10.138   Error   PrintCmd   JobExec   31   Destination failure: no more destinations for queue 'xPression'
'01:41:11.402   Info   JobManager.JobManager   JobManager   1   Print job 'D:\ESP\DATA\WesternSouthern\polprint\WSD4A\OUTPUT\WS_COINSD4A.ps:33356' received from ISendfile
'01:41:12.556   Error   protocol   Lpd.Print   49   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:41:12.556   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression0000824A.tmp' on destination 'xPression:solimar:xPression'
'01:41:19.592   Error   protocol   Lpd.Print   50   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:41:19.592   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression0000824A.tmp' on destination 'xPression:solimar:xPression'
'01:41:28.624   Error   protocol   Lpd.Print   51   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:41:28.624   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression0000824A.tmp' on destination 'xPression:solimar:xPression'
'01:41:40.637   Error   protocol   Lpd.Print   52   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:41:40.637   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression0000824A.tmp' on destination 'xPression:solimar:xPression'
'01:41:54.708   Error   protocol   Lpd.Print   53   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:41:54.708   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression0000824A.tmp' on destination 'xPression:solimar:xPression'
'01:42:12.461   Error   protocol   Lpd.Print   54   Socket error (10061): No connection could be made because the target machine actively refused it.
'01:42:12.461   Info   IScheduler   IScribeScheduler   1   Will retry job 'xPression0000824A.tmp' on destination 'xPression:solimar:xPression'
'01:42:12.461   Error   Retries   RetryManager   1   Job  'xPression0000824A.tmp'  retried  '5' times
'01:42:12.461   Info   PrintCmd   JobExec   34   Handling destination failure for 'xPression:solimar:xPression'
'01:42:12.461   Error   PrintCmd   JobExec   34   Destination failure: no more destinations for queue 'xPression'
'01:45:39.165   Info   JobManager.JobManager   JobManager   1   Print job 'D:\ESP\Data\FinancialCorrespondence\DSLetters\Output\DSLETTERS_PRINT_INSERT_DSLETTERS.ps:33357' received from ISendfile
'01:45:41.442   Info   PrintCmd   JobExec   35   Job 'xPublish0000824B.tmp:33357' successfully printed to destination xPublish:solimar:xPublish
'01:45:50.397   Info   JobManager.JobManager   JobManager   1   Print job 'D:\ESP\Data\FinancialCorrespondence\DSLetters\Output\DSLETTERS_PRINT_INSERT_DSLETTERS.ps:33358' received from ISendfile
'01:45:54.016   Info   PrintCmd   JobExec   36   Job 'xPublish0000824C.tmp:33358' successfully printed to destination xPublish:solimar:xPublish
'01:46:01.816   Info   JobManager.JobManager   JobManager   1   Print job 'D:\ESP\Data\FinancialCorrespondence\DSLetters\Output\DSLETTERS_PRINT_INSERT_DSLETTERS.ps:33359' received from ISendfile
'01:46:05.295   Info   PrintCmd   JobExec   37   Job 'xPublish0000824D.tmp:33359' successfully printed to destination xPublish:solimar:xPublish
jkinning
 
Posts: 731
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor print queues with NRPE

Postby lmiltchev » Thu Aug 16, 2018 12:33 pm

You can try using nsclient++ with a powershell script.

Example script (check_pattern.ps1)
Code: Select all
$dir = "c:\temp"
$latest = Get-ChildItem -Path $dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
$file = $latest.name
$keyword = "Socket error"
$pattern =(Select-String -Path "$dir\$file" -pattern $keyword) -split ','

if ($pattern -ne $null) {
  echo "Critical: String '$keyword' found in $file."
  exit 2
} else {
  echo "OK: String '$keyword' NOT found in $file."
  exit 0
}


Example entry in the nsclient.ini
Code: Select all
check_pattern = cmd /c echo scripts\check_pattern.ps1; exit $LastExitCode | powershell.exe -command -


Example command from the CLI, run on the Nagios machine:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_pattern
Critical: String 'Socket error' found in 20180816.CSV.

echo $?
2
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
QA Manager
 
Posts: 10506
Joined: Mon May 23, 2011 12:15 pm

Re: Monitor print queues with NRPE

Postby jkinning » Fri Aug 17, 2018 6:18 am

This is working! I greatly appreciate your assistance!

Next step is configuring a custom timeperiod so this only runs three times a day. Once at 11:57PM to check the log before the date rolls on the filename. Then run it again at 6:00AM before people get in at 6:30AM, and once again at 3:30PM before they leave for the day around 4:00PM?

I can't think of a way to check this so once it sees the "Socket errror" it ignores that instance and only reports on new occurrences. So creating a custom time period to have the current day log checked 3 times a day should hopefully be sufficient.
jkinning
 
Posts: 731
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor print queues with NRPE

Postby scottwilkerson » Fri Aug 17, 2018 1:20 pm

something like this should work

Code: Select all
   sunday         06:30-06:35,15:30-15:35,23:57-24:00
   monday         06:30-06:35,15:30-15:35,23:57-24:00
   tuesday        06:30-06:35,15:30-15:35,23:57-24:00
   wednesday      06:30-06:35,15:30-15:35,23:57-24:00
   thursday       06:30-06:35,15:30-15:35,23:57-24:00
   friday         06:30-06:35,15:30-15:35,23:57-24:00
   saturday       06:30-06:35,15:30-15:35,23:57-24:00
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 11144
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 18 guests