# Mailgraph problem



## xy16644 (Jan 6, 2013)

This morning I unplugged my server to move it and when I powered it back on and tested everything I noticed that my mail statistics that are generated by mail/mailgraph are not being updated anymore. When I try to start the service it doesn't help and I can't seem to see any errors in the /var/log/messages logfile.

The only thing I can think of is I upgraded Perl a week or so ago to the latest version in the ports tree (5.16.2). I did recompile all dependant ports.

Any ideas please?


----------



## xy16644 (Jan 8, 2013)

I am still getting no graphs with mailgraph. I have checked the logs (/var/log/messages and /var/log/maillog) but I can't seem to find what is wrong.

Could upgrading to a newer version of perl caused the graphs to stop working? The graphs were updating after I upgraded perl but it was only after rebooting the server that they stopped updating.

Any help will be much appreciated!


----------



## xy16644 (Jan 13, 2013)

If I run:

```
alpha# /usr/local/sbin/mailgraph.pl
```

I get the following error:

```
Error opening /var/log/syslog: No such file or directory at /usr/local/sbin/mailgraph.pl line 470.
```

When I look in /var/log I have no syslog file. 

Where did it go and how do I get it back?


----------



## quintessence (Jan 16, 2013)

Hello,

In /etc/rc.conf place after mailgraph_enable="YES":


```
mailgraph_flags="--logfile /var/log/maillog"
```

and then restart mailgraph.


----------



## xy16644 (Jan 16, 2013)

Thanks for the help. I tried that and now my mailgraph graphs have updated themselves but the service still doesn't (fully) start...it says its starting the service and then it just sits there until I do a Ctrl C to exit.

When I run:

```
/usr/local/sbin/mailgraph.pl
```

I still get the following:

```
Error opening /var/log/syslog: No such file or directory at /usr/local/sbin/mailgraph.pl line 470.
```

and:

```
alpha# /usr/local/etc/rc.d/mailgraph status
mailgraph is not running.
```


----------



## Anonymous (Jan 17, 2013)

You need to change the mode of your maillog to 644


----------



## xy16644 (Jan 17, 2013)

garyjh512 said:
			
		

> You need to change the mode of your maillog to 644



Its already running as that:

```
-rw-r--r--  1 root  wheel  698766 Jan 17 17:50 maillog
```


----------



## quintessence (Jan 18, 2013)

Hello,

Kill the process, paste your /etc/rc.conf - only part related to mailgraph.

By default when you install it from ports, there is a default flag that starts mailgraph as daemon, it is in /usr/local/etc/rc.d/mailgraph and there is no need to Ctrl+C to stop the process.

Also paste the output from
`$ ps aux | grep mailgraph`


----------



## xy16644 (Jan 18, 2013)

Contents of /etc/rc.conf

```
mailgraph_enable="YES"
mailgraph_flags="--logfile /var/log/postfix/maillog"
```

`ps aux | grep mailgraph`
root     90884   0.0  0.0   9636   1696  0  S+    5:21PM     0:00.00 grep mailgraph

What I'm battling to understand is that this has been working for years and it only stopped working when I shutdown the server for a couple hours and then powered it back on??


----------



## quintessence (Jan 20, 2013)

Hello,

And after killing the process and when you start mailgraph by executing `# /usr/local/etc/rc.d/mailgraph start`, what returns `$ ps aux | grep mailgraph`?

If it returns nothing check /usr/ports/UPDATING, section related to upgrading Perl.


----------



## xy16644 (Jan 20, 2013)

quintessence said:
			
		

> Hello,
> 
> And after killing the process and when you start mailgraph by executing `# /usr/local/etc/rc.d/mailgraph start`, what returns `$ ps aux | grep mailgraph`?
> 
> If it returns nothing check /usr/ports/UPDATING, section related to upgrading Perl.



When I try to start the service it just kind of hangs there (as though its trying to do something) and the only way I can get back to the command line is by doing a Ctrl C. I then get:

```
/usr/local/etc/rc.d/mailgraph: WARNING: failed to start mailgraph
```

I can't see mailgraph listed in `# top` so I can't kill any process.

I have had a read through /usr/ports/UPDATING and there is a section in there regarding the new version of perl. It just says you need to recompile all ports that depend on perl (which I have done).

I can only think the syslog error I am getting has something to do with it.

Thanks for your help.


----------



## quintessence (Jan 20, 2013)

Hello,

What is the output from:

`$ ls -l /var/db/pkg/mailgraph*`
and
`$ ls -l /usr/local/etc/rc.d/mailgraph`
?


----------



## xy16644 (Jan 20, 2013)

Here we go:

```
alpha# ls -l /var/db/pkg/mailgraph*
total 23
-rw-r--r--  1 root  wheel     42 Jan 13 09:11 +COMMENT
-rw-r--r--  1 root  wheel   3420 Jan 13 09:11 +CONTENTS
-rw-r--r--  1 root  wheel    209 Jan 13 09:11 +DESC
-rw-r--r--  1 root  wheel    318 Jan 13 09:11 +DISPLAY
-rw-r--r--  1 root  wheel  17553 Jan 13 09:11 +MTREE_DIRS
alpha# ls -l /usr/local/etc/rc.d/mailgraph
-r-xr-xr-x  1 root  wheel  829 Jan 18 17:19 /usr/local/etc/rc.d/mailgraph*
```


----------



## quintessence (Jan 20, 2013)

Hello,

Try to modify direct /usr/local/etc/rc.d/mailgraph in flags section with the name of your logfile.


```
: ${mailgraph_flags="--logfile /var/log/postfix/maillog --daemon-rrd=/var/db/mailgraph --ignore-localhost --daemon --daemon-pid=${mailgraph_pidfile}"}
```

And restart mailgraph


----------



## xy16644 (Jan 20, 2013)

I had high hopes for that one but it still won't start the service! Why is it trying to open /var/log/syslog?


----------



## quintessence (Jan 20, 2013)

Hello,

Because by default tries to open /var/log/syslog.

First option for fixing is to modify direct /usr/local/etc/rc.d/mailgraph with name of your logfile instead of the default.
Second option is to copy/paste all flags from the file and insert it in /etc/rc.conf:

Example:

```
mailgraph_enable="YES"
mailgraph_flags="--daemon-rrd=/var/db/mailgraph --ignore-localhost --daemon --logfile /var/log/maillog"
```


----------



## xy16644 (Jan 20, 2013)

In /etc/rc.conf I added:

```
mailgraph_flags="--daemon-rrd=/var/db/mailgraph --ignore-localhost --daemon --logfile /var/log/postfix/maillog"
```

Now when I try to start the service it comes back straigh away (rather than hanging) saying:

```
/usr/local/etc/rc.d/mailgraph: WARNING: failed to start mailgraph
```


----------



## quintessence (Jan 20, 2013)

Hello, 

Place --daemon-log option to mailgraph and paste the content of the log.


----------



## xy16644 (Jan 20, 2013)

I seem to be battling with this, where (and how) do I place this option? In /etc/rc.conf as a flag?


----------



## xy16644 (Jan 20, 2013)

I installed FreeBSD 9.1 with Postfix and Mailgraph on a test machine and I'm still getting the same error. I just don't get it. The only thing that is unique here is that I have changed the location of my maillog logfiles to /var/log/postfix/maillog


----------



## quintessence (Jan 23, 2013)

Hello,

`$ mailgraph.pl -h`


----------



## dbaio (Feb 8, 2013)

Check if rrdtool was built with PERL_MODULE. I had the same problem.

*B*efore*:*


```
pkg_info -L rrdtool-1.4.7_2 | grep -i pm
/usr/local/share/rrdtool/examples/rrdcached/RRDCached.pm
```

*A*fter*:*


```
pkg_info -L rrdtool-1.4.7_2 | grep -i pm
/usr/local/lib/perl5/site_perl/5.16.2/mach/RRDs.pm
/usr/local/lib/perl5/site_perl/5.16.2/[B]RRDp.pm[/B]
/usr/local/share/rrdtool/examples/rrdcached/RRDCached.pm
```


----------



## time4e (Jun 7, 2013)

I was fighting with this for about three hours and the below command did the trick*:*


```
chgrp www /var/log/maillog
/usr/local/etc/rc.d/mailgraph start
```

Hope this help*s*!

-Tim


----------



## xy16644 (Jun 7, 2014)

So I rebooted my server today to apply the latest security updates and now Mailgraph won't start...again! I have the following in /etc/rc.conf:


```
mailgraph_enable="YES"
mailgraph_flags="--logfile /var/log/postfix/maillog --daemon-rrd=/var/db/mailgraph --ignore-localhost --daemon --daemon-pid=/var/db/mailgraph/mailgraph.pid"
```

NB: Yes, that is the path to my maillog.

I have had a look in the logs but theres absolutely nothing indicating why this service won't start (deja vu?).

Can anyone assist please?


----------



## wblock@ (Jun 7, 2014)

Install sysutils/bsdadminscripts.  Run `pkg_libchk -qo`.  If it produces any output, rebuild those ports with ports-mgmt/portmaster.


----------



## xy16644 (Jun 7, 2014)

wblock@ said:
			
		

> Install sysutils/bsdadminscripts.  Run `pkg_libchk -qo`.  If it produces any output, rebuild those ports with ports-mgmt/portmaster.



Thanks @wblock@.

I ran  `pkg_libchk -qo` but there was no output after it finished running.

Any other ideas? Is there a way to get more details info as to WHY mailgraph won't start?


----------



## wblock@ (Jun 7, 2014)

Many programs offer a verbose mode, or a flag to keep a daemon running in the foreground so the output is visible.  I don't know about that specific one, though.


----------



## xy16644 (Jun 7, 2014)

wblock@ said:
			
		

> Many programs offer a verbose mode, or a flag to keep a daemon running in the foreground so the output is visible.  I don't know about that specific one, though.



Ok, so I tried running `/usr/local/sbin/mailgraph.pl` and it gives me the following output:


```
Error opening /var/log/syslog: No such file or directory at /usr/local/sbin/mailgraph.pl line 470
```

If I change /var/log/syslog to /var/log/postfix/maillog then when I run mailgraph.pl again it doesn't appear to do anything.

I've tried also running it in verbose mode as follows:


```
/usr/local/sbin/mailgraph.pl --verbose
```

but it doesn't appear to do anything. I also tried adding --verbose to the startup flags in /etc/rc.conf but all it (still) says is:


```
Starting mailgraph.
/usr/local/etc/rc.d/mailgraph: WARNING: failed to start mailgraph
```

Any other ideas? I am stumped!


----------



## xy16644 (Jun 7, 2014)

I think its working! I added the following to /etc/rc.conf:


```
mailgraph_user="root"
mailgraph_group="wheel"
```

The permissions haven't changed on my /var/log/postfix/maillog so I have no idea why this is needed now! The service is now running:



> sudo service mailgraph status
> mailgraph is running as pid 41654.



and the graphs are updating  :e 

Thanks for the help @wblock@.


----------



## wblock@ (Jun 7, 2014)

Make sure that is how it is supposed to work.  In other words, don't run things as root just because they work, find out how it should be set up and do that.  Otherwise, it's a security risk.


----------



## johnea (Feb 17, 2015)

I had this exact symptom in a mailgraph failure this week.

mailgraph had been running smoothly for over a year, suddenly without reboot or any software installation, the graphs stopped updating.

Setting: `mailgraph_user="root"` in rc.conf and restarting mailgraph restarted the updates.

Starting mailgraph manually led to the same error: "Error opening /var/log/syslog", in spite of parameters setting the log to maillog.

The rc.conf entries:
	
	



```
mailgraph_enable="YES"
mailgraph_user="root"
mailgraph_group="www"
mailgraph_flags="--rbl-is-spam --logfile /var/log/maillog --daemon-rrd=/var/db/mailgraph --ignore-localhost --daemon --daemon-pid=\"/var/db/mailgraph/mailgraph.pid\""
```
The most unsettling thing about this issue, is how it occurred without any known change to the running system.

I searched my www logs and confirmed that no other IP's other than internal ones, had accessed the mailgraph page.

I know this is a fairly old thread, but it is still a relevant issue with the mailgraph port.

Thanks for any insight!


----------



## johnea (Feb 23, 2015)

Just to follow up, after the mailgraph service had been started and running a few days, with the mailgraph_user=root, as noted above.

I stopped the service, edited mailgraph_user back to the previous user setting (in rc.conf), then restarted the service.

After this, mailgraph started and continued to run without the mailgraph_user set to root.


----------

