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 Previous  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: Fri Nov 09, 2007 6:11 pm    Post subject: Reply with quote

okay

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...



check_nagios_v2.php.txt
 Description:

Download
 Filename:  check_nagios_v2.php.txt
 Filesize:  2.23 KB
 Downloaded:  85 Time(s)

Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Mon Nov 12, 2007 9:13 am    Post subject: Reply with quote

hmm

this is what is being reported: TONER CRITICAL B:
Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Mon Nov 12, 2007 9:14 am    Post subject: Reply with quote

do you have corrected language strings in php file?
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Mon Nov 12, 2007 9:45 am    Post subject: Reply with quote

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
Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Mon Nov 12, 2007 9:52 am    Post subject: Reply with quote

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

#!/usr/bin/php -q
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Mon Nov 12, 2007 9:54 am    Post subject: Reply with quote

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";
Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Mon Nov 12, 2007 9:59 am    Post subject: Reply with quote

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...
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Mon Nov 12, 2007 10:03 am    Post subject: Reply with quote

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.
Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Mon Nov 12, 2007 10:12 am    Post subject: Reply with quote

okay but then there is another wrong whitespace...
permission denied is no permission problem in this case...
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Mon Nov 12, 2007 10:27 am    Post subject: Reply with quote

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.
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Tue Nov 13, 2007 11:23 am    Post subject: Reply with quote

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!
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Tue Nov 13, 2007 12:22 pm    Post subject: Reply with quote

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.
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Tue Nov 13, 2007 1:02 pm    Post subject: Reply with quote

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?
Back to top
jweinraub



Joined: 13 Apr 2007
Posts: 32

PostPosted: Fri Nov 16, 2007 10:41 am    Post subject: Reply with quote

code modified, it works not bad now.


HP2600.php.txt
 Description:
Updated code so nagios works with it

Download
 Filename:  HP2600.php.txt
 Filesize:  3.93 KB
 Downloaded:  104 Time(s)

Back to top
tkempken



Joined: 07 Nov 2007
Posts: 18

PostPosted: Fri Nov 16, 2007 10:51 am    Post subject: Reply with quote

nice work...

thanks...
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 Previous  1, 2, 3  Next
Page 2 of 3

 



Powered by phpBB © 2001, 2005 phpBB Group