Add an option to display the status of plugins in zmu

This commit is contained in:
manupap1 2014-11-12 00:11:41 +01:00
parent f4bdee108f
commit 2a3068cfa7
3 changed files with 56 additions and 4 deletions

View File

@ -4413,3 +4413,36 @@ void Monitor::SingleImageZip( int scale)
fprintf( stdout, "Content-Type: image/x-rgbz\r\n\r\n" ); fprintf( stdout, "Content-Type: image/x-rgbz\r\n\r\n" );
fwrite( img_buffer, img_buffer_size, 1, stdout ); fwrite( img_buffer, img_buffer_size, 1, stdout );
} }
#if ZM_PLUGINS_ON
void Monitor::DumpPluginStatus()
{
map<string,pGenConf> mapPluginGenConf;
unsigned int nNumPlugins = ThePluginManager.getPluginsGenConf(mapPluginGenConf);
bool bDoNativeDet = !config.turnoff_native_analysis && iDoNativeMotDet;
if ( nNumPlugins == 0)
{
printf("No plugin found\n");
return;
}
printf("%79sNATIVE DETECTION\n", " ");
printf("PLUGIN NAME%*sREGISTERED CONFIGURED ZONE ENABLED ACTIVE REQUIRE INCLUDE REINIT\n", 19, " ");
for (map<string,pGenConf>::iterator it = mapPluginGenConf.begin() ; it != mapPluginGenConf.end(); ++it)
{
PluginZoneConf mapPluginZoneConf;
ThePluginManager.getPluginZoneConf( it->first, mapPluginZoneConf );
int padLen = 34 - it->first.length();
if(padLen < 0) padLen = 0;
printf("%s%*s%d%*s%d%*s", it->first.c_str(), padLen, " ", it->second.Registered, 10, " ", it->second.Configured, 8, " ");
for (PluginZoneConf::iterator it2 = mapPluginZoneConf.begin() ; it2 != mapPluginZoneConf.end(); ++it2)
{
if (it2 != mapPluginZoneConf.begin())
printf("%*s", 54, " ");
bool bIsActive = it2->second.Enabled && ( !it2->second.RequireNatDet || ( it2->second.RequireNatDet && bDoNativeDet ) );
printf("%d%*s%d%*s%d%*s%d%*s%d%*s%d\n", it2->first, 7, " ", it2->second.Enabled, 7, " ", bIsActive, 8, " ", it2->second.RequireNatDet, 7, " ", it2->second.IncludeNatDet, 6, " ", it2->second.ReInitNatDet);
}
}
ThePluginManager.getImageAnalyser().cleanupPlugins();
}
#endif // ZM_PLUGINS_ON

View File

@ -410,6 +410,8 @@ public:
bool DumpSettings( char *output, bool verbose ); bool DumpSettings( char *output, bool verbose );
void DumpZoneImage( const char *zone_string=0 ); void DumpZoneImage( const char *zone_string=0 );
void DumpPluginStatus();
#if ZM_HAS_V4L #if ZM_HAS_V4L
static int LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose ); static int LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose );
#endif // ZM_HAS_V4L #endif // ZM_HAS_V4L

View File

@ -68,7 +68,9 @@ void Usage( int status=-1 )
fprintf( stderr, " -U, --username <username> : When running in authenticated mode the username and\n" ); fprintf( stderr, " -U, --username <username> : When running in authenticated mode the username and\n" );
fprintf( stderr, " -P, --password <password> : password combination of the given user\n" ); fprintf( stderr, " -P, --password <password> : password combination of the given user\n" );
fprintf( stderr, " -A, --auth <authentication> : Pass authentication hash string instead of user details\n" ); fprintf( stderr, " -A, --auth <authentication> : Pass authentication hash string instead of user details\n" );
#if ZM_PLUGINS_ON
fprintf( stderr, " -p, --plugin-status : Display the status of detected plugins\n" );
#endif // ZM_PLUGINS_ON
exit( status ); exit( status );
} }
@ -96,6 +98,7 @@ typedef enum {
ZMU_SUSPEND = 0x00400000, ZMU_SUSPEND = 0x00400000,
ZMU_RESUME = 0x00800000, ZMU_RESUME = 0x00800000,
ZMU_LIST = 0x10000000, ZMU_LIST = 0x10000000,
ZMU_LIST_PLUG = 0x20000000
} Function; } Function;
bool ValidateAccess( User *user, int mon_id, int function ) bool ValidateAccess( User *user, int mon_id, int function )
@ -111,7 +114,7 @@ bool ValidateAccess( User *user, int mon_id, int function )
if ( user->getEvents() < User::PERM_VIEW ) if ( user->getEvents() < User::PERM_VIEW )
allowed = false; allowed = false;
} }
if ( function & (ZMU_ZONES|ZMU_QUERY|ZMU_LIST) ) if ( function & (ZMU_ZONES|ZMU_QUERY|ZMU_LIST|ZMU_LIST_PLUG) )
{ {
if ( user->getMonitors() < User::PERM_VIEW ) if ( user->getMonitors() < User::PERM_VIEW )
allowed = false; allowed = false;
@ -174,6 +177,9 @@ int main( int argc, char *argv[] )
{"version", 1, 0, 'V'}, {"version", 1, 0, 'V'},
{"help", 0, 0, 'h'}, {"help", 0, 0, 'h'},
{"list", 0, 0, 'l'}, {"list", 0, 0, 'l'},
#if ZM_PLUGINS_ON
{"list_plugins", 0, 0, 'p'},
#endif // ZM_PLUGINS_ON
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@ -203,7 +209,7 @@ int main( int argc, char *argv[] )
{ {
int option_index = 0; int option_index = 0;
int c = getopt_long (argc, argv, "d:m:vsEDLurwei::S:t::fz::ancqhlB::C::H::O::U:P:A:V:", long_options, &option_index); int c = getopt_long (argc, argv, "d:m:vsEDLurwei::S:t::fz::ancqhlpB::C::H::O::U:P:A:V:", long_options, &option_index);
if (c == -1) if (c == -1)
{ {
break; break;
@ -321,6 +327,11 @@ int main( int argc, char *argv[] )
case 'l': case 'l':
function |= ZMU_LIST; function |= ZMU_LIST;
break; break;
#if ZM_PLUGINS_ON
case 'p':
function |= ZMU_LIST_PLUG;
break;
#endif // ZM_PLUGINS_ON
case '?': case '?':
Usage(); Usage();
break; break;
@ -409,7 +420,7 @@ int main( int argc, char *argv[] )
if ( mon_id > 0 ) if ( mon_id > 0 )
{ {
Monitor *monitor = Monitor::Load( mon_id, function&(ZMU_QUERY|ZMU_ZONES), Monitor::QUERY ); Monitor *monitor = Monitor::Load( mon_id, function&(ZMU_QUERY|ZMU_ZONES|ZMU_LIST_PLUG), Monitor::QUERY );
if ( monitor ) if ( monitor )
{ {
if ( verbose ) if ( verbose )
@ -649,6 +660,12 @@ int main( int argc, char *argv[] )
have_output = true; have_output = true;
} }
} }
#if ZM_PLUGINS_ON
if ( function & ZMU_LIST_PLUG )
{
monitor->DumpPluginStatus();
}
#endif // ZM_PLUGINS_ON
if ( have_output ) if ( have_output )
{ {
printf( "\n" ); printf( "\n" );