Commit 6b8ae122 authored by Claes Sjofors's avatar Claes Sjofors

Post and report server modifications

parent 591dc493
......@@ -296,7 +296,7 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP)
post->format_email_text( MsgP, text, sizeof(text));
post->format_cmd( cmd, post->conf->EmailCmd, address, text);
if ( post->conf->Log)
if ( post->conf->Options & pwr_mPostOptionsMask_Log)
errh_Info( "Email: %s", cmd);
system( cmd);
......@@ -313,7 +313,7 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP)
post->format_sms_text( MsgP, text, sizeof(text));
post->format_cmd( cmd, post->conf->SMS_Cmd, sms, text);
if ( post->conf->Log)
if ( post->conf->Options & pwr_mPostOptionsMask_Log)
errh_Info( "SMS: %s", cmd);
system( cmd);
......@@ -332,7 +332,7 @@ pwr_tStatus rt_post::mh_cancel_bc( mh_sReturn *MsgP)
}
pwr_tStatus rt_post::mh_info_bc( mh_sMessage *MsgP)
{
return 1;
return mh_alarm_bc( MsgP);
}
pwr_tStatus rt_post::mh_clear_alarmlist_bc( pwr_tNodeIndex nix)
{
......@@ -365,8 +365,12 @@ void rt_post::format_sms_text( mh_sMessage *MsgP, char *text, unsigned int size)
strcpy( prio, "?");
}
snprintf( text, size, "Proview %s Prio %s,\n%s,\n%s", nodename, prio, event->Msg.EventText,
event->Msg.EventName);
if ( conf->Options & pwr_mPostOptionsMask_SingleLineSMS)
snprintf( text, size, "Proview %s Prio %s, %s, %s", nodename, prio, event->Msg.EventText,
event->Msg.EventName);
else
snprintf( text, size, "Proview %s Prio %s,\n%s,\n%s", nodename, prio, event->Msg.EventText,
event->Msg.EventName);
}
void rt_post::format_email_text( mh_sMessage *MsgP, char *text, unsigned int size)
......@@ -508,7 +512,7 @@ int rt_post::email_check( mh_sEventId *id)
if ( i == sent_email_endidx)
break;
if ( memcmp( &sent_email[i], id, sizeof(*id)))
if ( memcmp( &sent_email[i], id, sizeof(*id)) == 0)
return 1;
}
......
......@@ -380,8 +380,8 @@ void rt_report::create_report( pwr_sClass_Report *o)
format_cmd( cmd, sizeof(cmd), conf_cmd, address, text, subject,
cnvfile, 0);
// if ( conf->Log)
// errh_Info( "Email: %s", cmd);
if (conf->Options & pwr_mPostOptionsMask_Log)
errh_Info( "Email: %s", cmd);
system( cmd);
conf->SentEmail++;
......@@ -480,8 +480,16 @@ void rt_report::create_report( pwr_sClass_Report *o)
format_cmd( cmd, sizeof(cmd), conf_cmd, address, subject, text,
cnvfile, 0);
// if ( conf->Log)
// errh_Info( "SMS: %s", cmd);
if (conf->Options & pwr_mPostOptionsMask_Log)
errh_Info( "SMS: %s", cmd);
if ( conf->Options & pwr_mPostOptionsMask_SingleLineSMS) {
for ( char *s = cmd; *s; s++) {
// Replace LF with space
if ( *s == 10)
*s = ' ';
}
}
system( cmd);
conf->SentSMS++;
......@@ -507,6 +515,9 @@ void rt_report::create_report( pwr_sClass_Report *o)
format_cmd( cmd, sizeof(cmd), conf_cmd, 0, 0, 0,
cnvfile, 0);
if (conf->Options & pwr_mPostOptionsMask_Log)
errh_Info( "Print: %s", cmd);
system( cmd);
sprintf( cmd, "rm %s", tmpfile);
......@@ -563,6 +574,10 @@ void rt_report::create_report( pwr_sClass_Report *o)
system( cmd);
}
sprintf( cmd, "rm %s", tmpfile);
if (conf->Options & pwr_mPostOptionsMask_Log)
errh_Info( "File: %s", cmd);
system( cmd);
}
}
......
......@@ -144,6 +144,14 @@ SObject pwrb:Class
EndBody
EndObject
!/**
! Options.
!*/
Object Options $Attribute 11
Body SysBody
Attr TypeRef = "pwrb:Type-PostOptionsMask"
EndBody
EndObject
!/**
! Server status.
!*/
Object Status $Attribute 5
......@@ -182,14 +190,6 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Print posted commands to console log.
!*/
Object Log $Attribute 9
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
EndObject
Object Template PostConfig
Body RtBody
......
......@@ -168,6 +168,14 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Options.
!*/
Object Options $Attribute 10
Body SysBody
Attr TypeRef = "pwrb:Type-PostOptionsMask"
EndBody
EndObject
EndObject
Object Template ReportConfig
Body RtBody
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment