HP Color LaserJet 2600N - Toner percent / Left|Printed pages

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

tkempken
Posts: 24
Joined: Wed Nov 07, 2007 12:12 pm
Contact:

Post by tkempken »

okay :lol:

so please see attached corrected version...
problem was that nagios want to store the temp file, but user nagios is not allowed to write to root (/)...

now you have to define temp directory inside of php script...
your nagios config is correct...
Attachments
check_nagios_v2.php.txt
(2.23 KiB) Downloaded 463 times
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

hmm

this is what is being reported: TONER CRITICAL B:
tkempken
Posts: 24
Joined: Wed Nov 07, 2007 12:12 pm
Contact:

Post by tkempken »

do you have corrected language strings in php file?
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

yeah i think so.

i get this from prompt:

[root@intranet libexec]# ./check_hp2600n.php 10.1.3.6 40 20
sh: line 1: --output-document=/tmp/status_10.1.3.6.htm: No such file or directory
sh: line 2: http://10.1.3.6/SSI/supply_status_info.htm: No such file or directory
tkempken
Posts: 24
Joined: Wed Nov 07, 2007 12:12 pm
Contact:

Post by tkempken »

hmm sounds like forgot to copy the first line of my script ;-)

#!/usr/bin/php -q
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

it's there:

[root@intranet libexec]# head check_hp2600n.php
#!/usr/bin/php -q
<?php

// You have to change these values with your configured language inside of webpanel (http://your.ip.address/):
$string_catridge_black = "Black Print Cartridge";
$string_catridge_magenta = "Magenta Print Cartridge";
$string_catridge_cyan = "Cyan Print Cartridge";
$string_catridge_yellow = "Yellow Print Cartridge";

$string_left_pages = "Estimated Pages Remaining";
tkempken
Posts: 24
Joined: Wed Nov 07, 2007 12:12 pm
Contact:

Post by tkempken »

the problem is that the php file is not interpreted as php...
it seems to be interpreted like bash/sh...

don't know... maybe a failure during copy?
try to copy it again from my file to yours... there are no big changes which could occure such problems...
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

okay. i get someplace now.

[root@intranet libexec]# ./check_hp2600n.php 10.1.3.6 40 20
sh: line 1: /tmp/status_10.1.3.6.htm: Permission denied
TONER OK B:53 M:40 C:40 Y:40


it seemed when i copied i used nano editor. i normally use vim, but vim i use syntax highlighting and autotab. when i paste code, it doesn't paste well, so nano tends to do better. nano seems though to paste newline char incorrectly so it puts it on a newline and the whitespace gets misinterpreted.
tkempken
Posts: 24
Joined: Wed Nov 07, 2007 12:12 pm
Contact:

Post by tkempken »

okay but then there is another wrong whitespace...
permission denied is no permission problem in this case...
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

nagios is reporting everything properly now it seems.
though for permission it is possible that when running it from console i am logged in as root so root created the file. if webserver runs script, it is then owned by apache.

though running it as root shouldn't give me error.

i will keep it as is for now, and now work on cacti portion.

thanks again for all your help.
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

I had some free time yesterday to attempt to do it, but I failed. I forgot to add the host, but even after that, I got stuck. Your instructions were fine to follow but some parts I got stuck. Feel free to use German in your help notes if you wish (it will help me learn the language more, and maybe easier for you to explain it to me where I am stuck).

I could not figure out how to define the graphs and colours and what to poll.

The screen grabs helped a lot by the way, thank you for the time and effort you are putting in this to assist me on this!
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

Another thing about permission. I forgot script is run by nagios.

[root@intranet libexec]# ./check_hp2600n.php 10.1.3.11 40 20
sh: line 1: /tmp/status_10.1.3.11.htm: Permission denied
TONER WARNING B:30 M:52 C:52 Y:52

[root@intranet libexec]# ls -l /tmp/status_10.1.3.11.htm
-rw-r--r-- 1 nagios nagios 25942 Nov 13 12:19 /tmp/status_10.1.3.11.htm


Therefore I believe apache is attempting to do something hence the error with permission. Will this permission problem be problematic?

Even if I delete the file, run it as root, I still get the same error. Root owns the file, by default it is 644 permission so I don't see why it won't work then as well.
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

One more thing.
Even though it shows warning in status, it is not flagged warning in nagios. It is not yellow. Do I need to return a flag of some sorts?
jweinraub
Cacti User
Posts: 61
Joined: Fri Apr 13, 2007 9:21 am

Post by jweinraub »

code modified, it works not bad now.
Attachments
HP2600.php.txt
Updated code so nagios works with it
(3.93 KiB) Downloaded 581 times
tkempken
Posts: 24
Joined: Wed Nov 07, 2007 12:12 pm
Contact:

Post by tkempken »

nice work...

thanks...
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests