[monit-dev] Unable to read magic

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[monit-dev] Unable to read magic

Sergey B Kirpichev
At the first startup of monit (just installed) users see:
[EDT Jun 24 21:26:20] error : State file '/var/lib/monit/state': Unable to read magic

Example:
https://bugs.launchpad.net/ubuntu/+source/monit/+bug/1017327

That's normal?  Is there any way to prevent this "confusing" message
for this case?

_______________________________________________
monit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/monit-dev
Reply | Threaded
Open this post in threaded view
|

Re: [monit-dev] Unable to read magic

martinp@tildeslash.com
Hi Sergey,

the magic is used to differentiate old state file format (which started with number of services) from the new extensible state file format (starts with 0, which is the "magic" - older monit versions will always start with number > 0).

It seems that the user's statefile is probably empty, hence the error is returned.

The solution is simple:

1.) stop monit
2.) remove the state file: rm -f /var/lib/monit/state
3.) start monit (will create new state file)

Regards,
Martin



On Feb 4, 2013, at 8:05 PM, Sergey B Kirpichev <[hidden email]> wrote:

> At the first startup of monit (just installed) users see:
> [EDT Jun 24 21:26:20] error : State file '/var/lib/monit/state': Unable to read magic
>
> Example:
> https://bugs.launchpad.net/ubuntu/+source/monit/+bug/1017327
>
> That's normal?  Is there any way to prevent this "confusing" message
> for this case?
>
> _______________________________________________
> monit-dev mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/monit-dev


_______________________________________________
monit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/monit-dev
Reply | Threaded
Open this post in threaded view
|

Re: [monit-dev] Unable to read magic

martinp@tildeslash.com
Hi,

yet one note - the error is logged also when monit starts for the first time (this is minor bug, we'll fix) ... the error can be ignored, monit works normally even if the state wasn't read.

Regards,
Martin


On Feb 4, 2013, at 9:40 PM, Martin Pala <[hidden email]> wrote:

> Hi Sergey,
>
> the magic is used to differentiate old state file format (which started with number of services) from the new extensible state file format (starts with 0, which is the "magic" - older monit versions will always start with number > 0).
>
> It seems that the user's statefile is probably empty, hence the error is returned.
>
> The solution is simple:
>
> 1.) stop monit
> 2.) remove the state file: rm -f /var/lib/monit/state
> 3.) start monit (will create new state file)
>
> Regards,
> Martin
>
>
>
> On Feb 4, 2013, at 8:05 PM, Sergey B Kirpichev <[hidden email]> wrote:
>
>> At the first startup of monit (just installed) users see:
>> [EDT Jun 24 21:26:20] error : State file '/var/lib/monit/state': Unable to read magic
>>
>> Example:
>> https://bugs.launchpad.net/ubuntu/+source/monit/+bug/1017327
>>
>> That's normal?  Is there any way to prevent this "confusing" message
>> for this case?
>>
>> _______________________________________________
>> monit-dev mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/monit-dev
>


_______________________________________________
monit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/monit-dev
Reply | Threaded
Open this post in threaded view
|

Re: [monit-dev] Unable to read magic

martinp@tildeslash.com
The fix:

Index: src/state.c
===================================================================
--- src/state.c (revision 5699)
+++ src/state.c (revision 5700)
@@ -239,6 +239,9 @@
 
 
 void State_update() {
+        /* Ignore empty state file */
+        if ((lseek(file, 0L, SEEK_END) == 0))
+             return;
         TRY
         {
                 if (lseek(file, 0L, SEEK_SET) == -1)


On Feb 4, 2013, at 10:58 PM, Martin Pala <[hidden email]> wrote:

> Hi,
>
> yet one note - the error is logged also when monit starts for the first time (this is minor bug, we'll fix) ... the error can be ignored, monit works normally even if the state wasn't read.
>
> Regards,
> Martin
>
>
> On Feb 4, 2013, at 9:40 PM, Martin Pala <[hidden email]> wrote:
>
>> Hi Sergey,
>>
>> the magic is used to differentiate old state file format (which started with number of services) from the new extensible state file format (starts with 0, which is the "magic" - older monit versions will always start with number > 0).
>>
>> It seems that the user's statefile is probably empty, hence the error is returned.
>>
>> The solution is simple:
>>
>> 1.) stop monit
>> 2.) remove the state file: rm -f /var/lib/monit/state
>> 3.) start monit (will create new state file)
>>
>> Regards,
>> Martin
>>
>>
>>
>> On Feb 4, 2013, at 8:05 PM, Sergey B Kirpichev <[hidden email]> wrote:
>>
>>> At the first startup of monit (just installed) users see:
>>> [EDT Jun 24 21:26:20] error : State file '/var/lib/monit/state': Unable to read magic
>>>
>>> Example:
>>> https://bugs.launchpad.net/ubuntu/+source/monit/+bug/1017327
>>>
>>> That's normal?  Is there any way to prevent this "confusing" message
>>> for this case?
>>>
>>> _______________________________________________
>>> monit-dev mailing list
>>> [hidden email]
>>> https://lists.nongnu.org/mailman/listinfo/monit-dev
>>
>
>
> _______________________________________________
> monit-dev mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/monit-dev


_______________________________________________
monit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/monit-dev
Reply | Threaded
Open this post in threaded view
|

Re: [monit-dev] Unable to read magic

Sergey B Kirpichev
In reply to this post by martinp@tildeslash.com
On Mon, Feb 04, 2013 at 10:58:05PM +0100, Martin Pala wrote:
> yet one note - the error is logged also when monit starts for the first time (this is minor bug, we'll fix) ... the error can be ignored, monit works normally even if the state wasn't read.

Yes, I mean exactly this case.  But I'm just not sure if it's really
safe to ignore this file with empty content (as does your patch).

May be we can emit a warning?

_______________________________________________
monit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/monit-dev
Reply | Threaded
Open this post in threaded view
|

Re: [monit-dev] Unable to read magic

martinp@tildeslash.com
It's safe to ignore the empty statefile file - monit overwrites it with valid data.

Regards,
Martin


On Feb 5, 2013, at 10:20 AM, Sergey B Kirpichev <[hidden email]> wrote:

> On Mon, Feb 04, 2013 at 10:58:05PM +0100, Martin Pala wrote:
>> yet one note - the error is logged also when monit starts for the first time (this is minor bug, we'll fix) ... the error can be ignored, monit works normally even if the state wasn't read.
>
> Yes, I mean exactly this case.  But I'm just not sure if it's really
> safe to ignore this file with empty content (as does your patch).
>
> May be we can emit a warning?
>
> _______________________________________________
> monit-dev mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/monit-dev


_______________________________________________
monit-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/monit-dev