Bitcoin Forum
November 06, 2024, 12:28:49 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 »  All
  Print  
Author Topic: Simple Cgminer Remote Monitoring Script - now with email alerts  (Read 31893 times)
p4xil (OP)
Full Member
***
Offline Offline

Activity: 214
Merit: 100


View Profile
June 01, 2013, 01:22:44 PM
Last edit: January 02, 2014, 01:53:13 PM by p4xil
 #1

SIMPLE CGMINER REMOTE MONITORING SCRIPT NOW WITH ALERTS



I made this script so I can check status for my rigs from anywhere not just my local computer.
I know there is ANUBIS but it is too heavy for me. I just needed a simple status script.

You will need:
- Webserver / webhosting with PHP (with socket support enabled)
- Crontab access for Alerts
- Postfix or Sendmail for sending Email Alerts
- Miners using Cgminer

1. CONFIGURING CGMINER

Enable API support with adding this to the cgminer.conf:
Code:
"api-port" : "4001",
"api-listen" : true,
"api-allow" : "YOUR_WEBSERVER_IP",

or cgminer command line:
Code:
--api-port 4001 --api-listen --api-allow "YOUR_WEBSERVER_IP"

Change YOUR_WEBSERVER_IP to your webserver REMOTE IP.
With --api-allow only webserver remote IP has the read only access to the cgminer API. This has to be set for security reasons.
Each rig needs its own api-port! Ports numbers can be ANYTHING you want as long the are not already taken. For example you can set port 4001 for Rig #1, 4002 for Rig #2, 4003 for Rig #3, etc.

2. OPEN PORTS ON ROUTER / FIREWALL



If you have a router or a firewall you will need to open ports you have chosen for your rigs. In my example you will need to open ports 4001, 4002, 4003.
To do this you will have to know your rigs local IPs and set the port forwarding on router to these IPs.
You get the rig's local IP number with:

on windows open command prompt and run:
Code:
ipconfig

Look at "IPv4 Address" of your network adapter.


on linux run command:
Code:
ifconfig

Look at "inet addr:"  of your network adapter.


3. SETUP MONITORING PHP SCRIPTS

Download files from here:
https://github.com/Paxxil/cgminer_remote_monitoring

Open functions.inc.php in your text editor.
Follow the instructions inside and add your miner rigs settings there.
After you made the changes, FTP to your webserver, navigate to your public www directory, create subdirectory "monitoring" and upload the files to it.

If you set everything right you should get the monitoring stats when you navigate to http://your_webserver_ip/monitoring/ (or if you have a domain http://wwww.your_domain.com/monitoring/)

4. CONFIGURING ALERTS
Open functions.php.inc in your text editor.
Edit the settings (email, alert configs) in the # SETUP ALERTS # Section.

Next you will have to make the file email.lock writable by the script.
In linux you do it with command:
Code:
chmod 666 email.lock

Now open crontab editor:
Code:
crontab -e

And put ABSULUTE path to the monitoring_cron.php script
Code:
*/2 * * * *     php /path/to/your/monitoring_cron.php >/dev/null 2>&1
This will execute monitoring_cron.php every 2 minutes.
If you want to check the server less frequently change */2 * * * * part.
Some examples:
Code:
* * * * *   => every minute
*/5 * * * * => every 5 minutes
0 * * * *   => every hour
0 0 * * *   => once a day at midnight server time

Save the file and shut down one cgminer to test the script. If you receive the email then everything works.

If you can not get it to work just PM me and I will help you.

If you like it please support it with donating:
LTC : LdQ1UHiRy24Tvmm8NHbhAdHL3Qf3JqrUbG
BTC : 1EA8UrpifP9hi7LZHjJphCJQ6Hh45mb5pP

Good Luck!
--p4xil

EDIT
2014-01-02 : v2.1.1 Fixed some bugs
2013-12-29 : v2.1 Added ASC and PGA support
2013-06-13 : Fixed some bugs
2013-06-04 : v2.0 Added Email Alerts


Nothing! Nothing! Nothing! Selling Nothing for only 1.99 ICN
3ham3
Full Member
***
Offline Offline

Activity: 137
Merit: 100



View Profile
June 02, 2013, 04:55:32 AM
Last edit: June 02, 2013, 11:53:01 AM by 3ham3
 #2

Getting an error from the index file, fails to operate at all.
01BTC10
VIP
Hero Member
*
Offline Offline

Activity: 756
Merit: 503



View Profile
June 02, 2013, 05:38:49 AM
 #3

File is suspicious.

Quote
SHA256:   33bfc4e9478de38255b307ae725dd5a7a940d3a2bb47bf9028f57a5493e55598
File name:   monitoring.rar.exe
Detection ratio:    4 / 47
Analysis date:    2013-06-02 05:38:24 UTC ( 0 minut ago )
https://www.virustotal.com/cs/file/33bfc4e9478de38255b307ae725dd5a7a940d3a2bb47bf9028f57a5493e55598/analysis/1370151504/
p4xil (OP)
Full Member
***
Offline Offline

Activity: 214
Merit: 100


View Profile
June 02, 2013, 07:54:32 AM
 #4

Getting an error from the index file, fails to operate at all. You Sir, are you trying to steal my coins?

Follow the tutorial and you should get it working.
I posted project to github now so you can check the files.

post it on github.  Your link is asking me to download exe which I'd never do without seeing the source code.

Looks nice.

I'd like to try it.  Post your script on github.

I posted project to github now.


File is suspicious.

Quote
SHA256:   33bfc4e9478de38255b307ae725dd5a7a940d3a2bb47bf9028f57a5493e55598
File name:   monitoring.rar.exe
Detection ratio:    4 / 47
Analysis date:    2013-06-02 05:38:24 UTC ( 0 minut ago )
https://www.virustotal.com/cs/file/33bfc4e9478de38255b307ae725dd5a7a940d3a2bb47bf9028f57a5493e55598/analysis/1370151504/

I don't know where did you find EXE, but well it is on github now so do not worry about it anymore.

Nothing! Nothing! Nothing! Selling Nothing for only 1.99 ICN
Jazkal
Sr. Member
****
Offline Offline

Activity: 319
Merit: 250



View Profile
June 02, 2013, 05:21:39 PM
 #5

Any chance this can be modified to use the default port of 4028 for all miners?
p4xil (OP)
Full Member
***
Offline Offline

Activity: 214
Merit: 100


View Profile
June 02, 2013, 06:13:06 PM
 #6

you can change port to default in port section, but it won't work if you set same port for all miners.

Nothing! Nothing! Nothing! Selling Nothing for only 1.99 ICN
p4xil (OP)
Full Member
***
Offline Offline

Activity: 214
Merit: 100


View Profile
June 04, 2013, 09:17:21 AM
 #7

I have added EMAIL ALERTS support.

Nothing! Nothing! Nothing! Selling Nothing for only 1.99 ICN
af_newbie
Legendary
*
Offline Offline

Activity: 2702
Merit: 1468



View Profile WWW
June 04, 2013, 07:20:52 PM
 #8

I have added EMAIL ALERTS support.

The emails will be sent out by whatever mail server you configure in php.ini, right?
Have you tried this on Windows under IIS?

p4xil (OP)
Full Member
***
Offline Offline

Activity: 214
Merit: 100


View Profile
June 04, 2013, 07:28:46 PM
 #9

I have added EMAIL ALERTS support.

The emails will be sent out by whatever mail server you configure in php.ini, right?
Have you tried this on Windows under IIS?

yes... you need postfix or sendmail installed on the server where webserver is.
I haven't tried with IIS.... but I am sure it can be done.

Nothing! Nothing! Nothing! Selling Nothing for only 1.99 ICN
christov84
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
June 08, 2013, 08:21:40 AM
 #10

Nice work
servicelabs
Legendary
*
Offline Offline

Activity: 1064
Merit: 1001


itkylin.com


View Profile WWW
June 16, 2013, 09:30:41 AM
 #11

monitoring_cron.php on line 48
postdrop: warning: unable to look up public/pickup: No such file or directory

servicelabs
Legendary
*
Offline Offline

Activity: 1064
Merit: 1001


itkylin.com


View Profile WWW
June 16, 2013, 10:08:54 AM
Last edit: June 16, 2013, 10:34:04 AM by servicelabs
 #12

I have done according to your guide, Thanks!
http://www.service-labs.com/miner_monitoring/

PSL
Member
**
Offline Offline

Activity: 166
Merit: 10


View Profile
July 06, 2013, 12:35:53 AM
Last edit: July 06, 2013, 12:51:30 AM by PSL
 #13

This patch adds these features to monitoring script 2.0:

- fix temperature when card is hot (cosmetic).
- display correct active pool (bug)
- display user (new)

Code:
$ git diff -p
diff --git a/index.php b/index.php
index 7587ad7..b5c8145 100644
--- a/index.php
+++ b/index.php
@@ -148,12 +148,13 @@ for ($i=0; $i<$nr_rigs; $i++)
 <?php
 
for ($i=0$i<$nr_rigs$i++)
 {
+        
$pool_priority 999;
        foreach (
$r[$i]['pools'] as $pool)
        {
-               if (
$pool['Stratum Active'] == 'true')
+               if ((
$pool['Status'] == 'Alive') and ($pool['Priority'] < $pool_priority))
                {
-                       
$pool_active '<span style="font-weight:normal">Pool ' $pool['POOL'] . ' - ' $pool['URL'] . '</span>';
-                       break;
+                        
$pool_priority $pool['Priority'];
+                       
$pool_active '<span style="font-weight:normal">Pool ' $pool['POOL'] . ' - ' $pool['URL'] . ', user - ' $pool['User'] . '</span>';
                }
        }
        
?>

@@ -187,7 +188,7 @@ for ($i=0; $i<$nr_rigs; $i++)
                                        <tr>
                                                <td style="text-align:center"><?php echo $gpu['GPU'?></td>
                                                <td style="text-align:center"><?php echo $gpu['Status'] == 'Alive' '<span class="ok">' $gpu['Status'] . '</span>' '<span class="error">' $gpu['Status'] . '</span>' ?></td>
-                                               <td style="text-align:center"><?php echo $gpu['Temperature'] > ALERT_TEMP '<span class="error">' round($gpu['Temperature']) . '°C</span>' round($gpu['Temperature']) ?>°C</td>
+                                               <td style="text-align:center"><?php echo $gpu['Temperature'] > ALERT_TEMP '<span class="error">' round($gpu['Temperature']) . '°C</span>' round($gpu['Temperature']) . '°C' ?></td>
                                                <td style="text-align:center"><?php echo $gpu['Fan Percent']?>%</td>
                                                <td style="text-align:center">
                                                        <?php
p4xil (OP)
Full Member
***
Offline Offline

Activity: 214
Merit: 100


View Profile
July 17, 2013, 07:22:09 AM
 #14

Thanks!
I've commited the changes.

Nothing! Nothing! Nothing! Selling Nothing for only 1.99 ICN
grobbes
Member
**
Offline Offline

Activity: 60
Merit: 10


View Profile
July 18, 2013, 02:17:57 PM
 #15

For some reason the degrees symbol wasn't registering right for me so I swapped it out with &deg; but was most likely due to my editor Smiley
p4xil (OP)
Full Member
***
Offline Offline

Activity: 214
Merit: 100


View Profile
July 18, 2013, 02:32:08 PM
 #16

Yes probably.
You should save the files using UTF8 without BOM encoding.

Nothing! Nothing! Nothing! Selling Nothing for only 1.99 ICN
tuckertz1992
Full Member
***
Offline Offline

Activity: 155
Merit: 100



View Profile
July 22, 2013, 07:01:42 PM
 #17

I really can not get this to work....

http://tomsmining.yzi.me/test

New Bitcoin Miner - If i've helped you, please donate: 15G6Zm6rAJu6ME5BQqX9GXGwGLgzC9Mboc
PSL
Member
**
Offline Offline

Activity: 166
Merit: 10


View Profile
July 26, 2013, 10:25:29 AM
 #18

I post a patch, that address an issue that wrong pool and user is displayed for miner that is offline:

Code:
$ git diff -p
diff --git a/index.php b/index.php
index 4ca2063..b4a031f 100644
--- a/index.php
+++ b/index.php
@@ -149,6 +149,7 @@ for ($i=0; $i<$nr_rigs; $i++)
 for ($i=0; $i<$nr_rigs; $i++)
 {
        $pool_priority = 999;
+       $pool_active = '';
        foreach ($r[$i]['pools'] as $pool)
        {
                if (($pool['Status'] == 'Alive') && ($pool['Priority'] < $pool_priority))
forum2005
Full Member
***
Offline Offline

Activity: 127
Merit: 100


View Profile
August 13, 2013, 05:10:13 PM
 #19

only GPU support ? and Icarus boards ?

gjpminingco
Sr. Member
****
Offline Offline

Activity: 350
Merit: 250


Co-Owner Of DCMCo-Op Mining Farm at 3.5 th/s


View Profile WWW
September 18, 2013, 02:49:15 AM
 #20

I am getting this Error

under the USB section

Warning: Division by zero in /home/a1628273/public_html/index.php on line 181

0 Alive 54°C 100% 0.00 | 0.00 0 0 0 0% 2013-09-17 22:36:28 Alive 0°C % 335.61 | 335.03 1 1 2 100% 2013-09-17 22:46:11

Pages: [1] 2 3 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!