Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


HP Color LaserJet 2600N - Toner percent / Left|Printed pages
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Wed Nov 07, 2007 3:12 pm    Post subject: HP Color LaserJet 2600N - Toner percent / Left|Printed pages Reply with quote

Hi Guys,

this script is a workaround to get the following values over HTML Code from Webpanel which are not inside of SNMP MIB:

- Toner Catridge left
- Estimated Pages Remaining
- Pages printed with this supply

The script get the webpage with wget and grep´ to requested values.
You have to change the language on top of script.

Requirements: Linux, wget, cat, grep, php (command line)

Command: ./get_data.php
Output: rest_toner_black:99 rest_toner_magenta:99 rest_toner_cyan:99 rest_toner_yellow:99 left_pages_black:2483 left_pages_magenta:1989 left_pages_cyan:1989 left_pages_yellow:1989 printed_pages_black:17 printed_pages_magenta:11 printed_pages_cyan:11 printed_pages_yellow:11

You have to create a new "Data Input Method"

Name: "HP Color LaserJet 2600n"
Input Type: "Script/Command"
Input String: "/path/to/get_data.php"

with following output fields:

rest_toner_black
rest_toner_magenta
rest_toner_cyan
rest_toner_yellow
left_pages_black
left_pages_magenta
left_pages_cyan
left_pages_yellow
printed_pages_black
printed_pages_magenta
printed_pages_cyan
printed_pages_yellow

It's not comfortable and not beautiful but it's a good workaround

regards



get_data.php.txt
 Description:
PHP Script

Download
 Filename:  get_data.php.txt
 Filesize:  2.89 KB
 Downloaded:  397 Time(s)



Last edited by tkempken on Wed Nov 07, 2007 4:58 pm; edited 1 time in total
Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Wed Nov 07, 2007 3:17 pm    Post subject: Additional Config for German Interface Reply with quote

Additional Config for German Interface

and a screenshot



sample_graphs.jpg
 Description:
Screenshot of usage
 Filesize:  125.13 KB
 Viewed:  4565 Time(s)

sample_graphs.jpg



Additional Config for German Interface.txt
 Description:
Additional Config for German Interface

Download
 Filename:  Additional Config for German Interface.txt
 Filesize:  469 Bytes
 Downloaded:  178 Time(s)

Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Thu Nov 08, 2007 10:34 am    Post subject: Reply with quote

jweinraub wrote:
I suspect you are from Germany?

Well... my first try failed because I never bothered to read the instructions. I did ./script.php my_ip_addr

As for my second try, ... nicht schlecht!

[jweinraub@intranet ~]$ ./get_data.php
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pgsql.so' - /usr/lib/php/modules/pgsql.so: cannot open shared object file: No such file or directory in Unknown on line 0
rest_toner_black:59 rest_toner_magenta:43 rest_toner_cyan:43 rest_toner_yellow:43 left_pages_black:2518 left_pages_magenta:1324 left_pages_cyan:1324 left_pages_yellow:1324 printed_pages_black:1750 printed_pages_magenta:1756 printed_pages_cyan:1756 printed_pages_yellow:1756

I don't know why I get this warning. I don't know if this is due to your script or my PHP configuration since I recently upgraded to PHP5, compiled from source since RHEL 4 does not support PHP5 just yet .

I have several of these printers. So I wonder if it is possible to make this work with them all. Do I need to use a variable for $ip?

Or do i need several instances when I graph these. Another thing I use here is nagios. I wonder if it is easy to make this into a nagios plugin so i can get warnings when the ink is low.

Thanks! Danke schön!


Try this script with: ./script.php my_ip_addr

This script download a temporary webpage with name status_192.168.1.2.htm for each printer...
So we won't get in any problems regarding "parallel polling"...
My concept was only for my single printer at home
After running it also remove the temp page...

I hope u understand my thoughts...

@PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pgsql.so'

I think you have define some libs of postgresql inside of /etc/php.ini or so
If you don't need it you also can remove package php-pgsql

Otherwise add
Code:
error_reporting(0);

after
Code:

#/usr/bin/php -q

<?php


Sometimes it's better to close the eyes


regards



get_data_with_ip_as_parameter.php.txt
 Description:

Download
 Filename:  get_data_with_ip_as_parameter.php.txt
 Filesize:  3.3 KB
 Downloaded:  188 Time(s)

Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Thu Nov 08, 2007 10:41 am    Post subject: Reply with quote

What are the steps needed to start polling this? I added the script and descriptions into cacti, but how do i add the host?
Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Thu Nov 08, 2007 11:22 am    Post subject: Reply with quote

I think it depends what you want to do...
If you have got more printers I would suggest to create a data and graph template.

For my single printer it would be a kind of 'oversized'...

I written down my steps and create a smart word document...
It was fast and not the best english but i hope you understand it...



cacti.doc
 Description:

Download
 Filename:  cacti.doc
 Filesize:  401 KB
 Downloaded:  164 Time(s)

Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Thu Nov 08, 2007 11:59 am    Post subject: Reply with quote

script for nagios

I think you can implement it like this:

Copy it to your directory where check_plugins are located...

define command{
command_name check_hpcl2600n
command_line $USER1$/check_hpcl2600n.php $ARG1$ $ARG2$ $ARG3$
}

arg1 = ip
arg2 = warn level (percent)
arg3 = crit level (percent)


Code:

./get_data.nagios.php 192.168.2.100 80 43
TONER OK B:99 M:99 C:99 Y:99


TONER WARNING B:99 M:99 C:99 Y:99
TONER CRITICAL B:99 M:99 C:99 Y:99

maybe it works for you



check_hpcl2600n.php.txt
 Description:
Same Script but for Nagios :)

Download
 Filename:  check_hpcl2600n.php.txt
 Filesize:  1.93 KB
 Downloaded:  171 Time(s)

Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Fri Nov 09, 2007 2:57 pm    Post subject: Reply with quote

great thanks! i forgot to make notification on this so i forgot to check. i will work on this now. i will let you know my results. your english is very good, i am sure much better than my german!
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Fri Nov 09, 2007 5:18 pm    Post subject: Reply with quote

reinstalling pgsql fixed that problem!

[root@intranet libexec]# ./check_hpcl2600n.php 10.1.3.6 80 43
TONER WARNING B:54 M:43 C:43 Y:43

as for the warning/critical, shouldn't it be the other way around?

100% is when it is full, so

[root@intranet libexec]# ./check_hpcl2600n.php 10.1.3.6 40 20

I think might be more appropriate in my case, but thanks for the advice!
Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Fri Nov 09, 2007 5:26 pm    Post subject: Reply with quote

hi

if toner level of any catridge is less than 80 so it set the status to warning.
but if it's less!!! than 43 then it's critical?

i think it's working fine?

what do you mean?
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Fri Nov 09, 2007 5:30 pm    Post subject: Reply with quote

it shows percentage remaining. so if it is less than 40% remaining it is a warning, meaning i will check inventory to be sure i have toner in stock.

if it is 20% it is time to examine for print quality and be prepared to replace the toner.

80% remaining is still brand new to me, so it will flag error too soon.
Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Fri Nov 09, 2007 5:33 pm    Post subject: Reply with quote

oh lol... sorry
i understand... that was only a nasty example by me...

i tested it with some values

that's the reason why you can define your own warn and crit level for each printer or globally inside of commands-file

what's about cacti? does it works for you?
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Fri Nov 09, 2007 5:36 pm    Post subject: Reply with quote

i have not tried. i been very busy today actually. though the fact nagios should be running smoothly now so that is main concern.

cacti i use to gather statistics on toner use, mainly to determine or justify the need for a more expensive printer.

As you can see here, I go through a lot of ink on this one particular printer.

i will get back to you monday when i finish cacti (and rest of nagios for the remaining printers).

thanks!



eng-printer.png
 Description:
 Filesize:  24.42 KB
 Viewed:  4426 Time(s)

eng-printer.png


Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Fri Nov 09, 2007 5:41 pm    Post subject: Reply with quote

oh... that's really frequently...

but this is another printer, or?

okay... have a nice weekend
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Fri Nov 09, 2007 5:41 pm    Post subject: Reply with quote

hmm

this is odd on nagios page:

TONER CRITICAL B: M: C: Y:

---

[root@intranet libexec]# ./check_hp2600n.php 10.1.3.6 40 20
TONER OK B:54 M:43 C:43 Y:43


--

Code:
# check_hp2600n
define command{
   command_name         check_hp2600n
   command_line         $USER1$/check_hp2600n.php $HOSTADDRESS$ 40 20
}


--

Code:
# Service definition
define service{
        use                             generic-service         ; Name of service template to use

        host_name                       BoardProdColor
        service_description             Toner Status
        is_volatile                     0
        check_period                    workhours
        max_check_attempts              4
        normal_check_interval           5
        retry_check_interval            1
        contact_groups                  printer-admins
        notification_interval           960
        notification_period             workhours
        notification_options            c,r
        check_command                   check_hp2600n
        }



--

Code:
# 'Board Production Colour LaserJet' host definition
define host{
        use                     generic-host            ; Name of host template to use

        host_name               BoardProdColor
        alias                   HP Color LaserJet 2600n
        address                 10.1.3.6
        check_command           check-host-alive
        max_check_attempts      10
        check_period            24x7
        notification_interval   480
        notification_period     24x7
        contact_groups          printer-admins
        }


--
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Fri Nov 09, 2007 5:43 pm    Post subject: Reply with quote

tkempken wrote:
oh... that's really frequently...

but this is another printer, or?

okay... have a nice weekend



Yes, this is HP 1320n, general use printer.

Danke, Haben Sie eine gute Wochenende auch!

(i hope my grammar was good)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 



Powered by phpBB © 2001, 2005 phpBB Group